tools2fast-fastapi 0.2.1__tar.gz → 0.3.10__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.2.1/src/tools2fast_fastapi.egg-info → tools2fast_fastapi-0.3.10}/PKG-INFO +1 -1
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/pyproject.toml +1 -1
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/__init__.py +2 -1
- tools2fast_fastapi-0.3.10/src/tools2fast_fastapi/__version__.py +1 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/models/mixins.py +53 -2
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10/src/tools2fast_fastapi.egg-info}/PKG-INFO +1 -1
- tools2fast_fastapi-0.2.1/src/tools2fast_fastapi/__version__.py +0 -1
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/LICENSE +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/MANIFEST.in +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/README.md +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/docs/guide.md +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/examples/example.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/setup.cfg +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/models/__init__.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/schemas/__init__.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/schemas/mixins.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/schemas/response_schema.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/__init__.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/document_simple_revision_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/document_with_items_revision_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/number_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/revision_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/services/transaction_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/utils/__init__.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/utils/routing.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/SOURCES.txt +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/dependency_links.txt +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/requires.txt +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/top_level.txt +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/tests/test_initial.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/tests/test_response_schema.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/tests/test_revision_service.py +0 -0
- {tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/tests/test_schemas.py +0 -0
{tools2fast_fastapi-0.2.1/src/tools2fast_fastapi.egg-info → tools2fast_fastapi-0.3.10}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tools2fast-fastapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.10
|
|
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.
|
|
7
|
+
version = "0.3.10"
|
|
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,4 +1,4 @@
|
|
|
1
|
-
from .models.mixins import AuditMixin, IdMixin, TimestampMixin, NumberUniqueMixin, RevisionMixin, NumberMixin
|
|
1
|
+
from .models.mixins import AuditMixin, AuditTimestampMixin, IdMixin, TimestampMixin, NumberUniqueMixin, RevisionMixin, NumberMixin
|
|
2
2
|
from .services import DocumentSimpleRevisionService, DocumentWithItemsRevisionService, TransactionService
|
|
3
3
|
from .schemas import (
|
|
4
4
|
APIResponse,
|
|
@@ -18,6 +18,7 @@ from .__version__ import __version__
|
|
|
18
18
|
|
|
19
19
|
__all__ = [
|
|
20
20
|
# Model mixins
|
|
21
|
+
"AuditTimestampMixin",
|
|
21
22
|
"IdMixin",
|
|
22
23
|
"TimestampMixin",
|
|
23
24
|
"AuditMixin",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0"
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/models/mixins.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from datetime import datetime, timezone
|
|
2
2
|
|
|
3
|
-
from sqlalchemy import DateTime, func
|
|
3
|
+
from sqlalchemy import DateTime, func, event
|
|
4
4
|
from sqlmodel import BigInteger, Field
|
|
5
5
|
|
|
6
6
|
|
|
@@ -83,4 +83,55 @@ class RevisionMixin(NumberMixin):
|
|
|
83
83
|
...
|
|
84
84
|
"""
|
|
85
85
|
|
|
86
|
-
revision: int = Field(default=1, ge=1, index=True)
|
|
86
|
+
revision: int = Field(default=1, ge=1, index=True)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class AuditTimestampMixin(AuditMixin, TimestampMixin):
|
|
90
|
+
"""
|
|
91
|
+
Combines AuditMixin (created_by, updated_by) + TimestampMixin (created_at, updated_at)
|
|
92
|
+
with SQLAlchemy events that auto-populate audit fields.
|
|
93
|
+
|
|
94
|
+
Events read from tenant2fast_fastapi's user context to set
|
|
95
|
+
created_by/updated_by automatically on inserts and updates.
|
|
96
|
+
|
|
97
|
+
Usage:
|
|
98
|
+
class MyModel(AuditTimestampMixin, IdTenantModel, table=True):
|
|
99
|
+
__abstract__ = True
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
__abstract__ = True
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@event.listens_for(AuditTimestampMixin, "before_insert", propagate=True)
|
|
106
|
+
def _audit_before_insert(mapper, connection, target):
|
|
107
|
+
"""Auto-populate created_by from user context on insert."""
|
|
108
|
+
# Lazy import to avoid circular dependency with tenant2fast_fastapi
|
|
109
|
+
try:
|
|
110
|
+
from tenant2fast_fastapi.dependencies import get_user_context
|
|
111
|
+
user = get_user_context()
|
|
112
|
+
if user is not None:
|
|
113
|
+
user_id = getattr(user, 'id', None)
|
|
114
|
+
if user_id is not None and getattr(target, 'created_by', None) is None:
|
|
115
|
+
target.created_by = user_id
|
|
116
|
+
except (ImportError, AttributeError):
|
|
117
|
+
# tenant2fast_fastapi not available or user has no 'id' attribute, skip auto-population
|
|
118
|
+
pass
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@event.listens_for(AuditTimestampMixin, "before_update", propagate=True)
|
|
122
|
+
def _audit_before_update(mapper, connection, target):
|
|
123
|
+
"""Auto-populate updated_by and updated_at from user context on update."""
|
|
124
|
+
# Lazy import to avoid circular dependency with tenant2fast_fastapi
|
|
125
|
+
try:
|
|
126
|
+
from tenant2fast_fastapi.dependencies import get_user_context
|
|
127
|
+
user = get_user_context()
|
|
128
|
+
if user is not None:
|
|
129
|
+
user_id = getattr(user, 'id', None)
|
|
130
|
+
if user_id is not None:
|
|
131
|
+
target.updated_by = user_id
|
|
132
|
+
except (ImportError, AttributeError):
|
|
133
|
+
# tenant2fast_fastapi not available or user has no 'id' attribute, skip auto-population
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
# Always update updated_at when entity has changes
|
|
137
|
+
target.updated_at = datetime.now(timezone.utc)
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10/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.
|
|
3
|
+
Version: 0.3.10
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/models/__init__.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/schemas/__init__.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/schemas/mixins.py
RENAMED
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/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
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/utils/__init__.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi/utils/routing.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/requires.txt
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.2.1 → tools2fast_fastapi-0.3.10}/src/tools2fast_fastapi.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|