oxutils 0.1.0__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.
Files changed (43) hide show
  1. oxutils-0.1.0/PKG-INFO +201 -0
  2. oxutils-0.1.0/README.md +159 -0
  3. oxutils-0.1.0/pyproject.toml +100 -0
  4. oxutils-0.1.0/src/oxutils/__init__.py +23 -0
  5. oxutils-0.1.0/src/oxutils/apps.py +14 -0
  6. oxutils-0.1.0/src/oxutils/audit/__init__.py +0 -0
  7. oxutils-0.1.0/src/oxutils/audit/apps.py +12 -0
  8. oxutils-0.1.0/src/oxutils/audit/export.py +229 -0
  9. oxutils-0.1.0/src/oxutils/audit/masks.py +97 -0
  10. oxutils-0.1.0/src/oxutils/audit/models.py +75 -0
  11. oxutils-0.1.0/src/oxutils/audit/settings.py +19 -0
  12. oxutils-0.1.0/src/oxutils/celery/__init__.py +1 -0
  13. oxutils-0.1.0/src/oxutils/celery/base.py +98 -0
  14. oxutils-0.1.0/src/oxutils/celery/settings.py +1 -0
  15. oxutils-0.1.0/src/oxutils/conf.py +12 -0
  16. oxutils-0.1.0/src/oxutils/enums/__init__.py +1 -0
  17. oxutils-0.1.0/src/oxutils/enums/audit.py +8 -0
  18. oxutils-0.1.0/src/oxutils/enums/invoices.py +11 -0
  19. oxutils-0.1.0/src/oxutils/exceptions.py +117 -0
  20. oxutils-0.1.0/src/oxutils/functions.py +99 -0
  21. oxutils-0.1.0/src/oxutils/jwt/__init__.py +0 -0
  22. oxutils-0.1.0/src/oxutils/jwt/auth.py +55 -0
  23. oxutils-0.1.0/src/oxutils/jwt/client.py +123 -0
  24. oxutils-0.1.0/src/oxutils/jwt/constants.py +1 -0
  25. oxutils-0.1.0/src/oxutils/locale/fr/LC_MESSAGES/django.mo +0 -0
  26. oxutils-0.1.0/src/oxutils/locale/fr/LC_MESSAGES/django.po +368 -0
  27. oxutils-0.1.0/src/oxutils/logger/__init__.py +0 -0
  28. oxutils-0.1.0/src/oxutils/logger/receivers.py +18 -0
  29. oxutils-0.1.0/src/oxutils/logger/settings.py +63 -0
  30. oxutils-0.1.0/src/oxutils/mixins/__init__.py +0 -0
  31. oxutils-0.1.0/src/oxutils/mixins/base.py +21 -0
  32. oxutils-0.1.0/src/oxutils/mixins/schemas.py +13 -0
  33. oxutils-0.1.0/src/oxutils/mixins/services.py +146 -0
  34. oxutils-0.1.0/src/oxutils/models/__init__.py +3 -0
  35. oxutils-0.1.0/src/oxutils/models/base.py +116 -0
  36. oxutils-0.1.0/src/oxutils/models/billing.py +140 -0
  37. oxutils-0.1.0/src/oxutils/models/invoice.py +467 -0
  38. oxutils-0.1.0/src/oxutils/py.typed +0 -0
  39. oxutils-0.1.0/src/oxutils/s3/__init__.py +0 -0
  40. oxutils-0.1.0/src/oxutils/s3/settings.py +34 -0
  41. oxutils-0.1.0/src/oxutils/s3/storages.py +130 -0
  42. oxutils-0.1.0/src/oxutils/settings.py +254 -0
  43. oxutils-0.1.0/src/oxutils/types.py +13 -0
oxutils-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.4
2
+ Name: oxutils
3
+ Version: 0.1.0
4
+ Summary: Production-ready utilities for Django applications in the Oxiliere ecosystem
5
+ Keywords: django,utilities,jwt,s3,audit,logging,celery,structlog
6
+ Author: Edimedia Mutoke
7
+ Author-email: Edimedia Mutoke <eddycondor07@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Django :: 5.0
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Internet :: WWW/HTTP
20
+ Requires-Dist: boto3>=1.41.5
21
+ Requires-Dist: celery>=5.5.3
22
+ Requires-Dist: cryptography>=46.0.3
23
+ Requires-Dist: django-auditlog>=3.3.0
24
+ Requires-Dist: django-celery-results>=2.6.0
25
+ Requires-Dist: django-cid>=3.0
26
+ Requires-Dist: django-extensions>=4.1
27
+ Requires-Dist: django-ninja>=1.5.0
28
+ Requires-Dist: django-ninja-extra>=0.30.6
29
+ Requires-Dist: django-storages[s3]>=1.14.6
30
+ Requires-Dist: django-structlog[celery]>=10.0.0
31
+ Requires-Dist: jwcrypto>=1.5.6
32
+ Requires-Dist: pydantic-settings>=2.12.0
33
+ Requires-Dist: pyjwt>=2.10.1
34
+ Requires-Dist: requests>=2.32.5
35
+ Requires-Python: >=3.11
36
+ Project-URL: Changelog, https://github.com/oxiliere/oxutils/blob/main/CHANGELOG.md
37
+ Project-URL: Documentation, https://github.com/oxiliere/oxutils/tree/main/docs
38
+ Project-URL: Homepage, https://github.com/oxiliere/oxutils
39
+ Project-URL: Issues, https://github.com/oxiliere/oxutils/issues
40
+ Project-URL: Repository, https://github.com/oxiliere/oxutils
41
+ Description-Content-Type: text/markdown
42
+
43
+ # OxUtils
44
+
45
+ **Production-ready utilities for Django applications in the Oxiliere ecosystem.**
46
+
47
+ [![PyPI version](https://img.shields.io/pypi/v/oxutils.svg)](https://pypi.org/project/oxutils/)
48
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)
49
+ [![Django 5.0+](https://img.shields.io/badge/django-5.0+-green.svg)](https://www.djangoproject.com/)
50
+ [![Tests](https://img.shields.io/badge/tests-126%20passed-success.svg)](tests/)
51
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
52
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
53
+
54
+ ## Features
55
+
56
+ - 🔐 **JWT Authentication** - RS256 with JWKS caching
57
+ - 📦 **S3 Storage** - Static, media, private, and log backends
58
+ - 📝 **Structured Logging** - JSON logs with correlation IDs
59
+ - 🔍 **Audit System** - Change tracking with S3 export
60
+ - ⚙️ **Celery Integration** - Pre-configured task processing
61
+ - 🛠️ **Django Mixins** - UUID, timestamps, user tracking
62
+ - ⚡ **Custom Exceptions** - Standardized API errors
63
+
64
+ ---
65
+
66
+ ## Installation
67
+
68
+ ```bash
69
+ pip install oxutils
70
+ ```
71
+
72
+ ```bash
73
+ uv add oxutils
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ ### 1. Configure Django Settings
79
+
80
+ ```python
81
+ # settings.py
82
+ from oxutils.conf import UTILS_APPS, AUDIT_MIDDLEWARE
83
+
84
+ INSTALLED_APPS = [
85
+ *UTILS_APPS, # structlog, auditlog, cid, celery_results
86
+ # your apps...
87
+ ]
88
+
89
+ MIDDLEWARE = [
90
+ *AUDIT_MIDDLEWARE, # CID, Auditlog, RequestMiddleware
91
+ # your middleware...
92
+ ]
93
+ ```
94
+
95
+ ### 2. Environment Variables
96
+
97
+ ```bash
98
+ OXI_SERVICE_NAME=my-service
99
+ OXI_JWT_JWKS_URL=https://auth.example.com/.well-known/jwks.json
100
+ OXI_USE_STATIC_S3=True
101
+ OXI_STATIC_STORAGE_BUCKET_NAME=my-bucket
102
+ ```
103
+
104
+ ### 3. Usage Examples
105
+
106
+ ```python
107
+ # JWT Authentication
108
+ from oxutils.jwt.client import verify_token
109
+ payload = verify_token(token)
110
+
111
+ # Structured Logging
112
+ import structlog
113
+ logger = structlog.get_logger(__name__)
114
+ logger.info("user_action", user_id=user_id)
115
+
116
+ # S3 Storage
117
+ from oxutils.s3.storages import PrivateMediaStorage
118
+ class Document(models.Model):
119
+ file = models.FileField(storage=PrivateMediaStorage())
120
+
121
+ # Model Mixins
122
+ from oxutils.models.base import BaseModelMixin
123
+ class Product(BaseModelMixin): # UUID + timestamps + is_active
124
+ name = models.CharField(max_length=255)
125
+
126
+ # Custom Exceptions
127
+ from oxutils.exceptions import NotFoundException
128
+ raise NotFoundException(detail="User not found")
129
+ ```
130
+
131
+ ## Documentation
132
+
133
+ - **[Settings](docs/settings.md)** - Configuration reference
134
+ - **[JWT](docs/jwt.md)** - Authentication
135
+ - **[S3](docs/s3.md)** - Storage backends
136
+ - **[Audit](docs/audit.md)** - Change tracking
137
+ - **[Logging](docs/logger.md)** - Structured logs
138
+ - **[Mixins](docs/mixins.md)** - Model/service mixins
139
+ - **[Celery](docs/celery.md)** - Task processing
140
+
141
+ ## Requirements
142
+
143
+ - Python 3.11+
144
+ - Django 5.0+
145
+ - PostgreSQL (recommended)
146
+
147
+ ## Development
148
+
149
+ ```bash
150
+ git clone https://github.com/oxiliere/oxutils.git
151
+ cd oxutils
152
+ uv sync
153
+ uv run pytest # 126 tests
154
+ ```
155
+
156
+ ## Advanced Examples
157
+
158
+ ### JWT with Django Ninja
159
+
160
+ ```python
161
+ from ninja import NinjaAPI
162
+ from ninja.security import HttpBearer
163
+ from oxutils.jwt.client import verify_token
164
+
165
+ class JWTAuth(HttpBearer):
166
+ def authenticate(self, request, token):
167
+ try:
168
+ return verify_token(token)
169
+ except:
170
+ return None
171
+
172
+ api = NinjaAPI(auth=JWTAuth())
173
+
174
+ @api.get("/protected")
175
+ def protected(request):
176
+ return {"user_id": request.auth['sub']}
177
+ ```
178
+
179
+ ### Audit Log Export
180
+
181
+ ```python
182
+ from oxutils.audit.export import export_logs_from_date
183
+ from datetime import datetime, timedelta
184
+
185
+ from_date = datetime.now() - timedelta(days=7)
186
+ export = export_logs_from_date(from_date=from_date)
187
+ print(f"Exported to {export.data.url}")
188
+ ```
189
+
190
+ ## License
191
+
192
+ MIT License - see [LICENSE](LICENSE)
193
+
194
+ ## Support
195
+
196
+ - **Issues**: [GitHub Issues](https://github.com/oxiliere/oxutils/issues)
197
+ - **Email**: dev@oxiliere.com
198
+
199
+ ---
200
+
201
+ **Made with ❤️ by Oxiliere**
@@ -0,0 +1,159 @@
1
+ # OxUtils
2
+
3
+ **Production-ready utilities for Django applications in the Oxiliere ecosystem.**
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/oxutils.svg)](https://pypi.org/project/oxutils/)
6
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)
7
+ [![Django 5.0+](https://img.shields.io/badge/django-5.0+-green.svg)](https://www.djangoproject.com/)
8
+ [![Tests](https://img.shields.io/badge/tests-126%20passed-success.svg)](tests/)
9
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
11
+
12
+ ## Features
13
+
14
+ - 🔐 **JWT Authentication** - RS256 with JWKS caching
15
+ - 📦 **S3 Storage** - Static, media, private, and log backends
16
+ - 📝 **Structured Logging** - JSON logs with correlation IDs
17
+ - 🔍 **Audit System** - Change tracking with S3 export
18
+ - ⚙️ **Celery Integration** - Pre-configured task processing
19
+ - 🛠️ **Django Mixins** - UUID, timestamps, user tracking
20
+ - ⚡ **Custom Exceptions** - Standardized API errors
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install oxutils
28
+ ```
29
+
30
+ ```bash
31
+ uv add oxutils
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### 1. Configure Django Settings
37
+
38
+ ```python
39
+ # settings.py
40
+ from oxutils.conf import UTILS_APPS, AUDIT_MIDDLEWARE
41
+
42
+ INSTALLED_APPS = [
43
+ *UTILS_APPS, # structlog, auditlog, cid, celery_results
44
+ # your apps...
45
+ ]
46
+
47
+ MIDDLEWARE = [
48
+ *AUDIT_MIDDLEWARE, # CID, Auditlog, RequestMiddleware
49
+ # your middleware...
50
+ ]
51
+ ```
52
+
53
+ ### 2. Environment Variables
54
+
55
+ ```bash
56
+ OXI_SERVICE_NAME=my-service
57
+ OXI_JWT_JWKS_URL=https://auth.example.com/.well-known/jwks.json
58
+ OXI_USE_STATIC_S3=True
59
+ OXI_STATIC_STORAGE_BUCKET_NAME=my-bucket
60
+ ```
61
+
62
+ ### 3. Usage Examples
63
+
64
+ ```python
65
+ # JWT Authentication
66
+ from oxutils.jwt.client import verify_token
67
+ payload = verify_token(token)
68
+
69
+ # Structured Logging
70
+ import structlog
71
+ logger = structlog.get_logger(__name__)
72
+ logger.info("user_action", user_id=user_id)
73
+
74
+ # S3 Storage
75
+ from oxutils.s3.storages import PrivateMediaStorage
76
+ class Document(models.Model):
77
+ file = models.FileField(storage=PrivateMediaStorage())
78
+
79
+ # Model Mixins
80
+ from oxutils.models.base import BaseModelMixin
81
+ class Product(BaseModelMixin): # UUID + timestamps + is_active
82
+ name = models.CharField(max_length=255)
83
+
84
+ # Custom Exceptions
85
+ from oxutils.exceptions import NotFoundException
86
+ raise NotFoundException(detail="User not found")
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - **[Settings](docs/settings.md)** - Configuration reference
92
+ - **[JWT](docs/jwt.md)** - Authentication
93
+ - **[S3](docs/s3.md)** - Storage backends
94
+ - **[Audit](docs/audit.md)** - Change tracking
95
+ - **[Logging](docs/logger.md)** - Structured logs
96
+ - **[Mixins](docs/mixins.md)** - Model/service mixins
97
+ - **[Celery](docs/celery.md)** - Task processing
98
+
99
+ ## Requirements
100
+
101
+ - Python 3.11+
102
+ - Django 5.0+
103
+ - PostgreSQL (recommended)
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ git clone https://github.com/oxiliere/oxutils.git
109
+ cd oxutils
110
+ uv sync
111
+ uv run pytest # 126 tests
112
+ ```
113
+
114
+ ## Advanced Examples
115
+
116
+ ### JWT with Django Ninja
117
+
118
+ ```python
119
+ from ninja import NinjaAPI
120
+ from ninja.security import HttpBearer
121
+ from oxutils.jwt.client import verify_token
122
+
123
+ class JWTAuth(HttpBearer):
124
+ def authenticate(self, request, token):
125
+ try:
126
+ return verify_token(token)
127
+ except:
128
+ return None
129
+
130
+ api = NinjaAPI(auth=JWTAuth())
131
+
132
+ @api.get("/protected")
133
+ def protected(request):
134
+ return {"user_id": request.auth['sub']}
135
+ ```
136
+
137
+ ### Audit Log Export
138
+
139
+ ```python
140
+ from oxutils.audit.export import export_logs_from_date
141
+ from datetime import datetime, timedelta
142
+
143
+ from_date = datetime.now() - timedelta(days=7)
144
+ export = export_logs_from_date(from_date=from_date)
145
+ print(f"Exported to {export.data.url}")
146
+ ```
147
+
148
+ ## License
149
+
150
+ MIT License - see [LICENSE](LICENSE)
151
+
152
+ ## Support
153
+
154
+ - **Issues**: [GitHub Issues](https://github.com/oxiliere/oxutils/issues)
155
+ - **Email**: dev@oxiliere.com
156
+
157
+ ---
158
+
159
+ **Made with ❤️ by Oxiliere**
@@ -0,0 +1,100 @@
1
+ [project]
2
+ name = "oxutils"
3
+ version = "0.1.0"
4
+ description = "Production-ready utilities for Django applications in the Oxiliere ecosystem"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ authors = [
8
+ { name = "Edimedia Mutoke", email = "eddycondor07@gmail.com" }
9
+ ]
10
+ requires-python = ">=3.11"
11
+ keywords = ["django", "utilities", "jwt", "s3", "audit", "logging", "celery", "structlog"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Framework :: Django",
15
+ "Framework :: Django :: 5.0",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Topic :: Internet :: WWW/HTTP",
24
+ ]
25
+ dependencies = [
26
+ "boto3>=1.41.5",
27
+ "celery>=5.5.3",
28
+ "cryptography>=46.0.3",
29
+ "django-auditlog>=3.3.0",
30
+ "django-celery-results>=2.6.0",
31
+ "django-cid>=3.0",
32
+ "django-extensions>=4.1",
33
+ "django-ninja>=1.5.0",
34
+ "django-ninja-extra>=0.30.6",
35
+ "django-storages[s3]>=1.14.6",
36
+ "django-structlog[celery]>=10.0.0",
37
+ "jwcrypto>=1.5.6",
38
+ "pydantic-settings>=2.12.0",
39
+ "pyjwt>=2.10.1",
40
+ "requests>=2.32.5",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/oxiliere/oxutils"
45
+ Documentation = "https://github.com/oxiliere/oxutils/tree/main/docs"
46
+ Repository = "https://github.com/oxiliere/oxutils"
47
+ Issues = "https://github.com/oxiliere/oxutils/issues"
48
+ Changelog = "https://github.com/oxiliere/oxutils/blob/main/CHANGELOG.md"
49
+
50
+ [build-system]
51
+ requires = ["uv_build>=0.8.13,<0.9.0"]
52
+ build-backend = "uv_build"
53
+
54
+ [tool.uv.workspace]
55
+ members = [
56
+ ".",
57
+ ]
58
+
59
+ [dependency-groups]
60
+ dev = [
61
+ "pytest>=8.0.0",
62
+ "pytest-django>=4.8.0",
63
+ "pytest-cov>=4.1.0",
64
+ "pytest-mock>=3.12.0",
65
+ "coverage>=7.4.0",
66
+ "pillow>=12.0.0",
67
+ "ruff>=0.8.0",
68
+ ]
69
+
70
+ [tool.ruff]
71
+ line-length = 100
72
+ target-version = "py311"
73
+ exclude = [
74
+ ".git",
75
+ ".venv",
76
+ "__pycache__",
77
+ "build",
78
+ "dist",
79
+ ]
80
+
81
+ [tool.ruff.lint]
82
+ select = [
83
+ "E", # pycodestyle errors
84
+ "W", # pycodestyle warnings
85
+ "F", # pyflakes
86
+ "I", # isort
87
+ "B", # flake8-bugbear
88
+ "C4", # flake8-comprehensions
89
+ ]
90
+ ignore = [
91
+ "E501", # line too long (handled by formatter)
92
+ ]
93
+
94
+ [tool.pytest.ini_options]
95
+ pythonpath = [".", "src"]
96
+ python_files = ["test_*.py"]
97
+ python_classes = ["Test*"]
98
+ python_functions = ["test_*"]
99
+ addopts = "-v --tb=short --ds=tests.settings"
100
+ testpaths = ["tests"]
@@ -0,0 +1,23 @@
1
+ """OxUtils - Production-ready utilities for Django applications.
2
+
3
+ This package provides:
4
+ - JWT authentication with JWKS support
5
+ - S3 storage backends (static, media, private, logs)
6
+ - Structured logging with correlation IDs
7
+ - Audit system with S3 export
8
+ - Celery integration
9
+ - Django model mixins
10
+ - Custom exceptions
11
+ """
12
+
13
+ __version__ = "0.1.0"
14
+
15
+ from oxutils.settings import oxi_settings
16
+ from oxutils.conf import UTILS_APPS, AUDIT_MIDDLEWARE
17
+
18
+ __all__ = [
19
+ "oxi_settings",
20
+ "UTILS_APPS",
21
+ "AUDIT_MIDDLEWARE",
22
+ "__version__",
23
+ ]
@@ -0,0 +1,14 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+
6
+ class OxutilsConfig(AppConfig):
7
+ default_auto_field = 'django.db.models.BigAutoField'
8
+ name = 'oxutils'
9
+ verbose_name = _("Oxiliere Utilities")
10
+
11
+ def ready(self):
12
+ import oxutils.logger.receivers
13
+
14
+ return super().ready()
File without changes
@@ -0,0 +1,12 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+
6
+ class OxutilsConfig(AppConfig):
7
+ default_auto_field = 'django.db.models.BigAutoField'
8
+ name = 'oxutils_export'
9
+ verbose_name = _("Oxutils Export")
10
+
11
+ def ready(self):
12
+ return super().ready()