django-mindoff 0.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.
Files changed (70) hide show
  1. django_mindoff-0.1.2/LICENSE +28 -0
  2. django_mindoff-0.1.2/MANIFEST.in +6 -0
  3. django_mindoff-0.1.2/PKG-INFO +230 -0
  4. django_mindoff-0.1.2/README.md +195 -0
  5. django_mindoff-0.1.2/apps/django_mindoff/__init__.py +7 -0
  6. django_mindoff-0.1.2/apps/django_mindoff/apps.py +12 -0
  7. django_mindoff-0.1.2/apps/django_mindoff/checks.py +65 -0
  8. django_mindoff-0.1.2/apps/django_mindoff/cli.py +19 -0
  9. django_mindoff-0.1.2/apps/django_mindoff/components/__init__.py +0 -0
  10. django_mindoff-0.1.2/apps/django_mindoff/components/_api_kit/__init__.py +0 -0
  11. django_mindoff-0.1.2/apps/django_mindoff/components/_api_kit/queue_process.py +202 -0
  12. django_mindoff-0.1.2/apps/django_mindoff/components/_api_kit/redis.py +126 -0
  13. django_mindoff-0.1.2/apps/django_mindoff/components/_crud_kit/__init__.py +0 -0
  14. django_mindoff-0.1.2/apps/django_mindoff/components/_crud_kit/column_validator.py +201 -0
  15. django_mindoff-0.1.2/apps/django_mindoff/components/_crud_kit/crud_processor.py +277 -0
  16. django_mindoff-0.1.2/apps/django_mindoff/components/_crud_kit/foreign_key_validator.py +91 -0
  17. django_mindoff-0.1.2/apps/django_mindoff/components/_crud_kit/row_validator.py +817 -0
  18. django_mindoff-0.1.2/apps/django_mindoff/components/_helper_kit/__init__.py +0 -0
  19. django_mindoff-0.1.2/apps/django_mindoff/components/_helper_kit/file_guardian.py +194 -0
  20. django_mindoff-0.1.2/apps/django_mindoff/components/_helper_kit/validate_schema.py +150 -0
  21. django_mindoff-0.1.2/apps/django_mindoff/components/_polars_kit/__init__.py +0 -0
  22. django_mindoff-0.1.2/apps/django_mindoff/components/_polars_kit/json_to_frame.py +397 -0
  23. django_mindoff-0.1.2/apps/django_mindoff/components/_tdd_kit/__init__.py +0 -0
  24. django_mindoff-0.1.2/apps/django_mindoff/components/_tdd_kit/field_value_generator.py +201 -0
  25. django_mindoff-0.1.2/apps/django_mindoff/components/api_kit.py +508 -0
  26. django_mindoff-0.1.2/apps/django_mindoff/components/crud_kit.py +521 -0
  27. django_mindoff-0.1.2/apps/django_mindoff/components/helper_kit.py +150 -0
  28. django_mindoff-0.1.2/apps/django_mindoff/components/managers/__init__.py +0 -0
  29. django_mindoff-0.1.2/apps/django_mindoff/components/managers/_build.py +88 -0
  30. django_mindoff-0.1.2/apps/django_mindoff/components/managers/_create.py +244 -0
  31. django_mindoff-0.1.2/apps/django_mindoff/components/managers/_delete.py +90 -0
  32. django_mindoff-0.1.2/apps/django_mindoff/components/managers/_organize.py +85 -0
  33. django_mindoff-0.1.2/apps/django_mindoff/components/managers/create_api.py +482 -0
  34. django_mindoff-0.1.2/apps/django_mindoff/components/managers/create_app.py +191 -0
  35. django_mindoff-0.1.2/apps/django_mindoff/components/managers/create_model.py +174 -0
  36. django_mindoff-0.1.2/apps/django_mindoff/components/managers/create_modelfield.py +361 -0
  37. django_mindoff-0.1.2/apps/django_mindoff/components/managers/delete_app.py +119 -0
  38. django_mindoff-0.1.2/apps/django_mindoff/components/managers/init.py +265 -0
  39. django_mindoff-0.1.2/apps/django_mindoff/components/managers/nuke.py +144 -0
  40. django_mindoff-0.1.2/apps/django_mindoff/components/managers/organize_init.py +59 -0
  41. django_mindoff-0.1.2/apps/django_mindoff/components/managers/organize_py_format.py +125 -0
  42. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/__init__.py +1 -0
  43. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/_api_class.py +49 -0
  44. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/_api_router_class.py +30 -0
  45. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/_gitignore.txt +27 -0
  46. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/_test_api_class.py +35 -0
  47. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/_test_api_router_class.py +10 -0
  48. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/html/404.html +0 -0
  49. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/html/__init__.py +1 -0
  50. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/html/index.html +0 -0
  51. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/mindoff.py +26 -0
  52. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/pytest.ini +4 -0
  53. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/responses.csv +17 -0
  54. django_mindoff-0.1.2/apps/django_mindoff/components/managers/resources/tdd_class_formats.py +90 -0
  55. django_mindoff-0.1.2/apps/django_mindoff/components/polars_kit.py +238 -0
  56. django_mindoff-0.1.2/apps/django_mindoff/components/response_kit.py +334 -0
  57. django_mindoff-0.1.2/apps/django_mindoff/components/tdd_kit.py +872 -0
  58. django_mindoff-0.1.2/apps/django_mindoff/components/validation_kit.py +957 -0
  59. django_mindoff-0.1.2/apps/django_mindoff/models.py +68 -0
  60. django_mindoff-0.1.2/apps/django_mindoff/py.typed +0 -0
  61. django_mindoff-0.1.2/apps/django_mindoff/urls.py +15 -0
  62. django_mindoff-0.1.2/apps/django_mindoff/views.py +156 -0
  63. django_mindoff-0.1.2/apps/django_mindoff.egg-info/PKG-INFO +230 -0
  64. django_mindoff-0.1.2/apps/django_mindoff.egg-info/SOURCES.txt +68 -0
  65. django_mindoff-0.1.2/apps/django_mindoff.egg-info/dependency_links.txt +1 -0
  66. django_mindoff-0.1.2/apps/django_mindoff.egg-info/entry_points.txt +2 -0
  67. django_mindoff-0.1.2/apps/django_mindoff.egg-info/requires.txt +3 -0
  68. django_mindoff-0.1.2/apps/django_mindoff.egg-info/top_level.txt +1 -0
  69. django_mindoff-0.1.2/pyproject.toml +81 -0
  70. django_mindoff-0.1.2/setup.cfg +4 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, MindOff
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ graft apps/django_mindoff
4
+ prune apps/django_mindoff/tests
5
+ recursive-exclude * __pycache__
6
+ recursive-exclude * *.py[co]
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-mindoff
3
+ Version: 0.1.2
4
+ Summary: Architectural framework for reliable, scalable Django REST APIs with native Polars.
5
+ Author: Joel Samraj
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/mindoffwork/django-mindoff
8
+ Project-URL: Documentation, https://github.com/mindoffwork/django-mindoff#readme
9
+ Project-URL: Source, https://github.com/mindoffwork/django-mindoff.git
10
+ Project-URL: Issues, https://github.com/mindoffwork/django-mindoff/issues
11
+ Project-URL: Changelog, https://github.com/mindoffwork/django-mindoff/blob/main/CHANGELOG.md
12
+ Keywords: django,django-rest-framework,drf,api,api-development,code-generation,scaffolding,automation,boilerplate,cli
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Environment :: Web Environment
16
+ Classifier: Framework :: Django
17
+ Classifier: Framework :: Django :: 5.0
18
+ Classifier: Framework :: Django :: 5.1
19
+ Classifier: Framework :: Django :: 5.2
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Code Generators
26
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.12
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: django>=5.0
32
+ Requires-Dist: djangorestframework>=3.15.0
33
+ Requires-Dist: polars>=1.0.0
34
+ Dynamic: license-file
35
+
36
+ # django-mindoff
37
+
38
+ `django-mindoff` is an architectural framework designed to eliminate repetitive API setup so developers can focus on business logic instead of infrastructure, scaffolding, and version coordination.
39
+
40
+ It combines project automation, standardized API architecture, structured responses, testing utilities, and Polars-powered workflows into one cohesive system.
41
+
42
+ ## Project Status 🧪
43
+
44
+ `django-mindoff` is currently experimental and in active development. Architecture, philosophy, functionality and structure may evolve. It is designed for fresh Django-Mindoff projects and is not intended for retrofitting into existing Django applications.
45
+
46
+ ## Requirements ⚙️
47
+
48
+ - Python ≥ 3.12
49
+
50
+ All other framework dependencies are managed internally. `django-mindoff` selects compatible versions of Django, DRF, and Polars so you do not have to manage version alignment manually.
51
+
52
+ ## Installation 📦
53
+
54
+ ```bash
55
+ pip install django-mindoff
56
+ ```
57
+
58
+ ## Quick Start 🚀
59
+
60
+ ### 1. Initialize a Project
61
+
62
+ ```bash
63
+ django-mindoff init
64
+ ```
65
+
66
+ Creates a fully structured Django-Mindoff project with:
67
+
68
+ - Virtual environment
69
+ - `.env` configuration
70
+ - Git initialization (if available)
71
+ - Preconfigured architecture
72
+
73
+ ### 2. Create Apps, Models, and APIs
74
+
75
+ ```bash
76
+ python mindoff.py create
77
+ ```
78
+
79
+ Interactive CLI allows you to:
80
+
81
+ - Create apps → `apps/<app_name>/`
82
+ - Create models → `apps/<app_name>/models.py`
83
+ - Create APIs → `apps/<app_name>/apis/<api_name>.py`
84
+ - Auto-register routes
85
+
86
+ ### 3. Add Your Logic
87
+
88
+ Edit your generated API and return structured responses:
89
+
90
+ ```python
91
+ return mo_response_kit.json_response(
92
+ code="SUCCESS",
93
+ category="success",
94
+ data={"message": "Hello World"}
95
+ )
96
+ ```
97
+
98
+ Run the server. Focus on your logic. Repeat.
99
+
100
+ ---
101
+
102
+ ## Response Standard 📄
103
+
104
+ All responses follow a consistent structure:
105
+
106
+ ```json
107
+ {
108
+ "status": "ok",
109
+ "message": {
110
+ "code": "SUCCESS",
111
+ "title": "Success",
112
+ "description": "Operation completed successfully.",
113
+ "category": "success"
114
+ },
115
+ "data": {
116
+ "id": "ec4786f7-3646-4159-a091-7c83ba3addaf",
117
+ "name": "John Doe"
118
+ }
119
+ }
120
+ ```
121
+
122
+ No unstructured exceptions. No inconsistent payloads.
123
+ Umm... One more thing. `django-mindoff` uses uuids for primary keys and foreign keys by design.
124
+
125
+ ## Architecture 🧭
126
+
127
+ ### Versioned Routing
128
+
129
+ ```
130
+ <int:version>/<app_name>
131
+ ```
132
+
133
+ Routers resolve the correct API version automatically.
134
+
135
+ ### Project Structure 📁
136
+
137
+ A freshly generated project follows this layout:
138
+
139
+ ```text
140
+ project_root/
141
+ ├─ manage.py
142
+ ├─ mindoff.py
143
+ ├─ pytest.ini
144
+ ├─ README.md
145
+ ├─ .env
146
+
147
+ ├─ config/
148
+ │ ├─ settings.py
149
+ │ ├─ urls.py
150
+ │ ├─ asgi.py
151
+ │ ├─ wsgi.py
152
+ │ └─ Responses.csv
153
+
154
+ ├─ templates/
155
+ │ ├─ index.html
156
+ │ └─ 404.html
157
+
158
+ └─ apps/
159
+ └─ <app_name>/
160
+ ├─ apps.py
161
+ ├─ models.py
162
+ ├─ serializers.py
163
+ ├─ views.py
164
+ ├─ urls.py
165
+ ├─ apis/
166
+ │ └─ <api_name>.py
167
+ ├─ components/
168
+ │ └─ <component_name>.py
169
+ └─ tests/
170
+ ├─ test_views.py
171
+ └─ test_apis/
172
+ └─ test_<api_name>.py
173
+ ```
174
+
175
+ ## Core Kits 🧰
176
+
177
+ Mindoff is modular. Each kit removes a specific category of friction.
178
+
179
+ **1. Project Management Kit:**
180
+ Prompt-driven CLI for creating and organizing projects, apps, models, and APIs.
181
+
182
+ **2. API Kit:**
183
+ Centralized configuration layer handling validation, security, documentation, and error handling.
184
+
185
+ **3. CRUD Kit:**
186
+ Polars `DataFrame` and `LazyFrame` driven database operations with validation.
187
+
188
+ **4. Polars Kit:**
189
+ High-performance utilities for streaming-safe frame operations.
190
+
191
+ **5. Validation Kit:**
192
+ Single-line validation helpers that reduce conditional complexity.
193
+
194
+ **6. Response Kit:**
195
+ Structured JSON, file, text, and HTML responses.
196
+
197
+ **7. TDD Kit:**
198
+ Testing base classes and helpers for rapid API testing.
199
+
200
+ ## CLI Overview 🛠️
201
+
202
+ ```bash
203
+ django-mindoff init # Create project
204
+ django-mindoff delete # Delete project
205
+ python mindoff.py create # Create app/model/api
206
+ python mindoff.py delete # Delete app
207
+ ```
208
+
209
+ ## Testing ✅
210
+
211
+ `MindoffTestCase` provides:
212
+
213
+ - Pytest integration
214
+ - Mock app and model generation
215
+ - Polars DataFrame and LazyFrame support
216
+ - Assertion helpers
217
+
218
+ ## Configuration ⚙️
219
+
220
+ Optional settings in `settings.py`:
221
+
222
+ ```python
223
+ MINDOFF_LOG_ERRORS_IN_DEBUG = False
224
+ MINDOFF_TRACEBACK_DIRS = ["apps", "config"]
225
+ REDIS_URL = config("REDIS_URL")
226
+ POLARS_VALIDATOR_ERROR_COL = "__error__info"
227
+ MINDOFF_USE_VIEW_CACHE = False
228
+ ```
229
+
230
+ `.env` is auto-generated during initialization.
@@ -0,0 +1,195 @@
1
+ # django-mindoff
2
+
3
+ `django-mindoff` is an architectural framework designed to eliminate repetitive API setup so developers can focus on business logic instead of infrastructure, scaffolding, and version coordination.
4
+
5
+ It combines project automation, standardized API architecture, structured responses, testing utilities, and Polars-powered workflows into one cohesive system.
6
+
7
+ ## Project Status 🧪
8
+
9
+ `django-mindoff` is currently experimental and in active development. Architecture, philosophy, functionality and structure may evolve. It is designed for fresh Django-Mindoff projects and is not intended for retrofitting into existing Django applications.
10
+
11
+ ## Requirements ⚙️
12
+
13
+ - Python ≥ 3.12
14
+
15
+ All other framework dependencies are managed internally. `django-mindoff` selects compatible versions of Django, DRF, and Polars so you do not have to manage version alignment manually.
16
+
17
+ ## Installation 📦
18
+
19
+ ```bash
20
+ pip install django-mindoff
21
+ ```
22
+
23
+ ## Quick Start 🚀
24
+
25
+ ### 1. Initialize a Project
26
+
27
+ ```bash
28
+ django-mindoff init
29
+ ```
30
+
31
+ Creates a fully structured Django-Mindoff project with:
32
+
33
+ - Virtual environment
34
+ - `.env` configuration
35
+ - Git initialization (if available)
36
+ - Preconfigured architecture
37
+
38
+ ### 2. Create Apps, Models, and APIs
39
+
40
+ ```bash
41
+ python mindoff.py create
42
+ ```
43
+
44
+ Interactive CLI allows you to:
45
+
46
+ - Create apps → `apps/<app_name>/`
47
+ - Create models → `apps/<app_name>/models.py`
48
+ - Create APIs → `apps/<app_name>/apis/<api_name>.py`
49
+ - Auto-register routes
50
+
51
+ ### 3. Add Your Logic
52
+
53
+ Edit your generated API and return structured responses:
54
+
55
+ ```python
56
+ return mo_response_kit.json_response(
57
+ code="SUCCESS",
58
+ category="success",
59
+ data={"message": "Hello World"}
60
+ )
61
+ ```
62
+
63
+ Run the server. Focus on your logic. Repeat.
64
+
65
+ ---
66
+
67
+ ## Response Standard 📄
68
+
69
+ All responses follow a consistent structure:
70
+
71
+ ```json
72
+ {
73
+ "status": "ok",
74
+ "message": {
75
+ "code": "SUCCESS",
76
+ "title": "Success",
77
+ "description": "Operation completed successfully.",
78
+ "category": "success"
79
+ },
80
+ "data": {
81
+ "id": "ec4786f7-3646-4159-a091-7c83ba3addaf",
82
+ "name": "John Doe"
83
+ }
84
+ }
85
+ ```
86
+
87
+ No unstructured exceptions. No inconsistent payloads.
88
+ Umm... One more thing. `django-mindoff` uses uuids for primary keys and foreign keys by design.
89
+
90
+ ## Architecture 🧭
91
+
92
+ ### Versioned Routing
93
+
94
+ ```
95
+ <int:version>/<app_name>
96
+ ```
97
+
98
+ Routers resolve the correct API version automatically.
99
+
100
+ ### Project Structure 📁
101
+
102
+ A freshly generated project follows this layout:
103
+
104
+ ```text
105
+ project_root/
106
+ ├─ manage.py
107
+ ├─ mindoff.py
108
+ ├─ pytest.ini
109
+ ├─ README.md
110
+ ├─ .env
111
+
112
+ ├─ config/
113
+ │ ├─ settings.py
114
+ │ ├─ urls.py
115
+ │ ├─ asgi.py
116
+ │ ├─ wsgi.py
117
+ │ └─ Responses.csv
118
+
119
+ ├─ templates/
120
+ │ ├─ index.html
121
+ │ └─ 404.html
122
+
123
+ └─ apps/
124
+ └─ <app_name>/
125
+ ├─ apps.py
126
+ ├─ models.py
127
+ ├─ serializers.py
128
+ ├─ views.py
129
+ ├─ urls.py
130
+ ├─ apis/
131
+ │ └─ <api_name>.py
132
+ ├─ components/
133
+ │ └─ <component_name>.py
134
+ └─ tests/
135
+ ├─ test_views.py
136
+ └─ test_apis/
137
+ └─ test_<api_name>.py
138
+ ```
139
+
140
+ ## Core Kits 🧰
141
+
142
+ Mindoff is modular. Each kit removes a specific category of friction.
143
+
144
+ **1. Project Management Kit:**
145
+ Prompt-driven CLI for creating and organizing projects, apps, models, and APIs.
146
+
147
+ **2. API Kit:**
148
+ Centralized configuration layer handling validation, security, documentation, and error handling.
149
+
150
+ **3. CRUD Kit:**
151
+ Polars `DataFrame` and `LazyFrame` driven database operations with validation.
152
+
153
+ **4. Polars Kit:**
154
+ High-performance utilities for streaming-safe frame operations.
155
+
156
+ **5. Validation Kit:**
157
+ Single-line validation helpers that reduce conditional complexity.
158
+
159
+ **6. Response Kit:**
160
+ Structured JSON, file, text, and HTML responses.
161
+
162
+ **7. TDD Kit:**
163
+ Testing base classes and helpers for rapid API testing.
164
+
165
+ ## CLI Overview 🛠️
166
+
167
+ ```bash
168
+ django-mindoff init # Create project
169
+ django-mindoff delete # Delete project
170
+ python mindoff.py create # Create app/model/api
171
+ python mindoff.py delete # Delete app
172
+ ```
173
+
174
+ ## Testing ✅
175
+
176
+ `MindoffTestCase` provides:
177
+
178
+ - Pytest integration
179
+ - Mock app and model generation
180
+ - Polars DataFrame and LazyFrame support
181
+ - Assertion helpers
182
+
183
+ ## Configuration ⚙️
184
+
185
+ Optional settings in `settings.py`:
186
+
187
+ ```python
188
+ MINDOFF_LOG_ERRORS_IN_DEBUG = False
189
+ MINDOFF_TRACEBACK_DIRS = ["apps", "config"]
190
+ REDIS_URL = config("REDIS_URL")
191
+ POLARS_VALIDATOR_ERROR_COL = "__error__info"
192
+ MINDOFF_USE_VIEW_CACHE = False
193
+ ```
194
+
195
+ `.env` is auto-generated during initialization.
@@ -0,0 +1,7 @@
1
+ default_app_config = "django_mindoff.apps.DjangoMindoffConfig"
2
+ from importlib.metadata import version, PackageNotFoundError
3
+
4
+ try:
5
+ __version__ = version("django-mindoff")
6
+ except PackageNotFoundError:
7
+ __version__ = "unknown"
@@ -0,0 +1,12 @@
1
+ from django.apps import AppConfig
2
+
3
+ from .components.response_kit import load_responses_csv
4
+
5
+
6
+ class DjangoMindoffConfig(AppConfig):
7
+ default_auto_field = "django.db.models.BigAutoField"
8
+ name = __name__.rpartition(".")[0]
9
+
10
+ def ready(self):
11
+ load_responses_csv()
12
+ from . import checks
@@ -0,0 +1,65 @@
1
+ from django.core.checks import Error, register
2
+ from django.urls import get_resolver
3
+ from django.urls.resolvers import URLResolver, URLPattern
4
+ from django.core.exceptions import ImproperlyConfigured
5
+ from django.apps import apps as django_apps
6
+ from inspect import isclass
7
+ import inspect
8
+ import importlib
9
+ import pkgutil
10
+ import sys
11
+
12
+ from .components.api_kit import MindoffAPIMixin
13
+
14
+
15
+ @register()
16
+ def check_mindoff_api_configs(app_configs, **kwargs):
17
+ errors = []
18
+
19
+ for app_config in django_apps.get_app_configs():
20
+ apis_dir = (
21
+ app_config.path and __import__("pathlib").Path(app_config.path) / "apis"
22
+ )
23
+ if not apis_dir or not apis_dir.is_dir():
24
+ continue
25
+
26
+ # Walk every .py file under apis/ and import it fresh
27
+ package_name = f"{app_config.name}.apis"
28
+ for finder, module_name, _ in pkgutil.walk_packages(
29
+ path=[str(apis_dir)],
30
+ prefix=f"{package_name}.",
31
+ onerror=lambda name: None,
32
+ ):
33
+ # Force a fresh import — evict any cached version first
34
+ sys.modules.pop(module_name, None)
35
+ try:
36
+ module = importlib.import_module(module_name)
37
+ except Exception:
38
+ continue
39
+
40
+ for attr_name in dir(module):
41
+ obj = getattr(module, attr_name, None)
42
+ if (
43
+ isclass(obj)
44
+ and issubclass(obj, MindoffAPIMixin)
45
+ and obj is not MindoffAPIMixin
46
+ ):
47
+ _validate_view_class(obj, errors)
48
+
49
+ return errors
50
+
51
+
52
+ def _validate_view_class(view_class, errors):
53
+ try:
54
+ instance = view_class()
55
+ instance.validate_api_configuration()
56
+ except Exception as exc:
57
+ error_code = getattr(exc, "code", "API_CONFIG_ERR")
58
+ errors.append(
59
+ Error(
60
+ f"API Configuration Error in {view_class.__name__}: {str(exc)}",
61
+ hint="Check validate_api_configuration() in your API class.",
62
+ obj=view_class,
63
+ id=f"django_mindoff.{error_code}",
64
+ )
65
+ )
@@ -0,0 +1,19 @@
1
+ import argparse
2
+ import importlib
3
+
4
+
5
+ def main():
6
+ parser = argparse.ArgumentParser(prog="django-mindoff")
7
+ subparsers = parser.add_subparsers(dest="command", required=True)
8
+
9
+ for name in ["init", "nuke"]:
10
+ module = importlib.import_module(f"django_mindoff.components.managers.{name}")
11
+ if hasattr(module, "register_subcommand"):
12
+ module.register_subcommand(subparsers)
13
+
14
+ args = parser.parse_args()
15
+
16
+ if hasattr(args, "handler"):
17
+ args.handler(args)
18
+ else:
19
+ parser.print_help()