django-cfg 1.4.10__py3-none-any.whl → 1.4.11__py3-none-any.whl

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 (181) hide show
  1. django_cfg/apps/agents/management/commands/create_agent.py +1 -1
  2. django_cfg/apps/agents/management/commands/orchestrator_status.py +3 -3
  3. django_cfg/apps/newsletter/serializers.py +40 -3
  4. django_cfg/apps/newsletter/views/campaigns.py +12 -3
  5. django_cfg/apps/newsletter/views/emails.py +14 -3
  6. django_cfg/apps/newsletter/views/subscriptions.py +12 -2
  7. django_cfg/apps/payments/views/api/currencies.py +49 -6
  8. django_cfg/apps/payments/views/api/webhooks.py +72 -7
  9. django_cfg/apps/payments/views/overview/serializers.py +34 -1
  10. django_cfg/apps/payments/views/overview/views.py +2 -1
  11. django_cfg/apps/payments/views/serializers/payments.py +6 -6
  12. django_cfg/apps/urls.py +106 -45
  13. django_cfg/core/base/config_model.py +2 -2
  14. django_cfg/core/constants.py +1 -1
  15. django_cfg/core/generation/integration_generators/__init__.py +1 -1
  16. django_cfg/core/generation/integration_generators/api.py +72 -49
  17. django_cfg/core/integration/display/startup.py +30 -22
  18. django_cfg/core/integration/url_integration.py +15 -16
  19. django_cfg/dashboard/sections/documentation.py +391 -0
  20. django_cfg/management/commands/check_endpoints.py +11 -160
  21. django_cfg/management/commands/check_settings.py +13 -348
  22. django_cfg/management/commands/clear_constance.py +13 -201
  23. django_cfg/management/commands/create_token.py +13 -321
  24. django_cfg/management/commands/generate_clients.py +23 -0
  25. django_cfg/management/commands/list_urls.py +13 -306
  26. django_cfg/management/commands/migrate_all.py +13 -126
  27. django_cfg/management/commands/migrator.py +13 -396
  28. django_cfg/management/commands/rundramatiq.py +15 -247
  29. django_cfg/management/commands/rundramatiq_simulator.py +12 -429
  30. django_cfg/management/commands/runserver_ngrok.py +15 -160
  31. django_cfg/management/commands/script.py +12 -488
  32. django_cfg/management/commands/show_config.py +12 -215
  33. django_cfg/management/commands/show_urls.py +12 -342
  34. django_cfg/management/commands/superuser.py +15 -295
  35. django_cfg/management/commands/task_clear.py +14 -217
  36. django_cfg/management/commands/task_status.py +13 -248
  37. django_cfg/management/commands/test_email.py +15 -86
  38. django_cfg/management/commands/test_telegram.py +14 -61
  39. django_cfg/management/commands/test_twilio.py +15 -105
  40. django_cfg/management/commands/tree.py +13 -383
  41. django_cfg/management/commands/validate_openapi.py +10 -0
  42. django_cfg/middleware/README.md +1 -1
  43. django_cfg/middleware/user_activity.py +3 -3
  44. django_cfg/models/__init__.py +2 -2
  45. django_cfg/models/api/drf/spectacular.py +6 -6
  46. django_cfg/models/django/__init__.py +2 -2
  47. django_cfg/models/django/openapi.py +238 -0
  48. django_cfg/modules/django_admin/management/__init__.py +0 -0
  49. django_cfg/modules/django_admin/management/commands/__init__.py +0 -0
  50. django_cfg/modules/django_admin/management/commands/check_endpoints.py +169 -0
  51. django_cfg/modules/django_admin/management/commands/check_settings.py +355 -0
  52. django_cfg/modules/django_admin/management/commands/clear_constance.py +208 -0
  53. django_cfg/modules/django_admin/management/commands/create_token.py +328 -0
  54. django_cfg/modules/django_admin/management/commands/list_urls.py +313 -0
  55. django_cfg/modules/django_admin/management/commands/migrate_all.py +133 -0
  56. django_cfg/modules/django_admin/management/commands/migrator.py +403 -0
  57. django_cfg/modules/django_admin/management/commands/script.py +496 -0
  58. django_cfg/modules/django_admin/management/commands/show_config.py +225 -0
  59. django_cfg/modules/django_admin/management/commands/show_urls.py +361 -0
  60. django_cfg/modules/django_admin/management/commands/superuser.py +302 -0
  61. django_cfg/modules/django_admin/management/commands/tree.py +390 -0
  62. django_cfg/modules/django_client/__init__.py +20 -0
  63. django_cfg/modules/django_client/apps.py +35 -0
  64. django_cfg/modules/django_client/core/__init__.py +56 -0
  65. django_cfg/modules/django_client/core/archive/__init__.py +11 -0
  66. django_cfg/modules/django_client/core/archive/manager.py +134 -0
  67. django_cfg/modules/django_client/core/cli/__init__.py +12 -0
  68. django_cfg/modules/django_client/core/cli/main.py +235 -0
  69. django_cfg/modules/django_client/core/config/__init__.py +18 -0
  70. django_cfg/modules/django_client/core/config/config.py +188 -0
  71. django_cfg/modules/django_client/core/config/group.py +101 -0
  72. django_cfg/modules/django_client/core/config/service.py +209 -0
  73. django_cfg/modules/django_client/core/generator/__init__.py +115 -0
  74. django_cfg/modules/django_client/core/generator/base.py +767 -0
  75. django_cfg/modules/django_client/core/generator/python.py +751 -0
  76. django_cfg/modules/django_client/core/generator/templates/python/__init__.py.jinja +9 -0
  77. django_cfg/modules/django_client/core/generator/templates/python/api_wrapper.py.jinja +130 -0
  78. django_cfg/modules/django_client/core/generator/templates/python/app_init.py.jinja +6 -0
  79. django_cfg/modules/django_client/core/generator/templates/python/client/app_client.py.jinja +18 -0
  80. django_cfg/modules/django_client/core/generator/templates/python/client/flat_client.py.jinja +38 -0
  81. django_cfg/modules/django_client/core/generator/templates/python/client/main_client.py.jinja +50 -0
  82. django_cfg/modules/django_client/core/generator/templates/python/client/main_client_file.py.jinja +13 -0
  83. django_cfg/modules/django_client/core/generator/templates/python/client/operation_method.py.jinja +7 -0
  84. django_cfg/modules/django_client/core/generator/templates/python/client/sub_client.py.jinja +11 -0
  85. django_cfg/modules/django_client/core/generator/templates/python/client_file.py.jinja +13 -0
  86. django_cfg/modules/django_client/core/generator/templates/python/main_init.py.jinja +50 -0
  87. django_cfg/modules/django_client/core/generator/templates/python/models/app_models.py.jinja +17 -0
  88. django_cfg/modules/django_client/core/generator/templates/python/models/enum_class.py.jinja +15 -0
  89. django_cfg/modules/django_client/core/generator/templates/python/models/enums.py.jinja +8 -0
  90. django_cfg/modules/django_client/core/generator/templates/python/models/models.py.jinja +17 -0
  91. django_cfg/modules/django_client/core/generator/templates/python/models/schema_class.py.jinja +19 -0
  92. django_cfg/modules/django_client/core/generator/templates/python/utils/logger.py.jinja +255 -0
  93. django_cfg/modules/django_client/core/generator/templates/python/utils/schema.py.jinja +12 -0
  94. django_cfg/modules/django_client/core/generator/templates/typescript/app_index.ts.jinja +2 -0
  95. django_cfg/modules/django_client/core/generator/templates/typescript/client/app_client.ts.jinja +18 -0
  96. django_cfg/modules/django_client/core/generator/templates/typescript/client/client.ts.jinja +327 -0
  97. django_cfg/modules/django_client/core/generator/templates/typescript/client/flat_client.ts.jinja +109 -0
  98. django_cfg/modules/django_client/core/generator/templates/typescript/client/main_client_file.ts.jinja +9 -0
  99. django_cfg/modules/django_client/core/generator/templates/typescript/client/operation.ts.jinja +61 -0
  100. django_cfg/modules/django_client/core/generator/templates/typescript/client/sub_client.ts.jinja +15 -0
  101. django_cfg/modules/django_client/core/generator/templates/typescript/client_file.ts.jinja +9 -0
  102. django_cfg/modules/django_client/core/generator/templates/typescript/index.ts.jinja +5 -0
  103. django_cfg/modules/django_client/core/generator/templates/typescript/main_index.ts.jinja +206 -0
  104. django_cfg/modules/django_client/core/generator/templates/typescript/models/app_models.ts.jinja +8 -0
  105. django_cfg/modules/django_client/core/generator/templates/typescript/models/enums.ts.jinja +4 -0
  106. django_cfg/modules/django_client/core/generator/templates/typescript/models/models.ts.jinja +8 -0
  107. django_cfg/modules/django_client/core/generator/templates/typescript/utils/errors.ts.jinja +114 -0
  108. django_cfg/modules/django_client/core/generator/templates/typescript/utils/http.ts.jinja +98 -0
  109. django_cfg/modules/django_client/core/generator/templates/typescript/utils/logger.ts.jinja +251 -0
  110. django_cfg/modules/django_client/core/generator/templates/typescript/utils/schema.ts.jinja +7 -0
  111. django_cfg/modules/django_client/core/generator/templates/typescript/utils/storage.ts.jinja +114 -0
  112. django_cfg/modules/django_client/core/generator/typescript.py +872 -0
  113. django_cfg/modules/django_client/core/groups/__init__.py +13 -0
  114. django_cfg/modules/django_client/core/groups/detector.py +178 -0
  115. django_cfg/modules/django_client/core/groups/manager.py +314 -0
  116. django_cfg/modules/django_client/core/ir/__init__.py +57 -0
  117. django_cfg/modules/django_client/core/ir/context.py +387 -0
  118. django_cfg/modules/django_client/core/ir/operation.py +518 -0
  119. django_cfg/modules/django_client/core/ir/schema.py +353 -0
  120. django_cfg/modules/django_client/core/parser/__init__.py +74 -0
  121. django_cfg/modules/django_client/core/parser/base.py +648 -0
  122. django_cfg/modules/django_client/core/parser/models/__init__.py +74 -0
  123. django_cfg/modules/django_client/core/parser/models/base.py +212 -0
  124. django_cfg/modules/django_client/core/parser/models/components.py +160 -0
  125. django_cfg/modules/django_client/core/parser/models/openapi.py +203 -0
  126. django_cfg/modules/django_client/core/parser/models/operation.py +207 -0
  127. django_cfg/modules/django_client/core/parser/models/schema.py +266 -0
  128. django_cfg/modules/django_client/core/parser/openapi30.py +56 -0
  129. django_cfg/modules/django_client/core/parser/openapi31.py +64 -0
  130. django_cfg/modules/django_client/core/validation/__init__.py +22 -0
  131. django_cfg/modules/django_client/core/validation/checker.py +134 -0
  132. django_cfg/modules/django_client/core/validation/fixer.py +216 -0
  133. django_cfg/modules/django_client/core/validation/reporter.py +480 -0
  134. django_cfg/modules/django_client/core/validation/rules/__init__.py +11 -0
  135. django_cfg/modules/django_client/core/validation/rules/base.py +96 -0
  136. django_cfg/modules/django_client/core/validation/rules/type_hints.py +288 -0
  137. django_cfg/modules/django_client/core/validation/safety.py +266 -0
  138. django_cfg/modules/django_client/management/__init__.py +3 -0
  139. django_cfg/modules/django_client/management/commands/__init__.py +3 -0
  140. django_cfg/modules/django_client/management/commands/generate_client.py +422 -0
  141. django_cfg/modules/django_client/management/commands/validate_openapi.py +343 -0
  142. django_cfg/modules/django_client/spectacular/__init__.py +9 -0
  143. django_cfg/modules/django_client/spectacular/enum_naming.py +192 -0
  144. django_cfg/modules/django_client/urls.py +72 -0
  145. django_cfg/modules/django_email/management/__init__.py +0 -0
  146. django_cfg/modules/django_email/management/commands/__init__.py +0 -0
  147. django_cfg/modules/django_email/management/commands/test_email.py +93 -0
  148. django_cfg/modules/django_logging/django_logger.py +6 -6
  149. django_cfg/modules/django_ngrok/management/__init__.py +0 -0
  150. django_cfg/modules/django_ngrok/management/commands/__init__.py +0 -0
  151. django_cfg/modules/django_ngrok/management/commands/runserver_ngrok.py +167 -0
  152. django_cfg/modules/django_tasks/management/__init__.py +0 -0
  153. django_cfg/modules/django_tasks/management/commands/__init__.py +0 -0
  154. django_cfg/modules/django_tasks/management/commands/rundramatiq.py +254 -0
  155. django_cfg/modules/django_tasks/management/commands/rundramatiq_simulator.py +437 -0
  156. django_cfg/modules/django_tasks/management/commands/task_clear.py +226 -0
  157. django_cfg/modules/django_tasks/management/commands/task_status.py +257 -0
  158. django_cfg/modules/django_telegram/management/__init__.py +0 -0
  159. django_cfg/modules/django_telegram/management/commands/__init__.py +0 -0
  160. django_cfg/modules/django_telegram/management/commands/test_telegram.py +68 -0
  161. django_cfg/modules/django_twilio/management/__init__.py +0 -0
  162. django_cfg/modules/django_twilio/management/commands/__init__.py +0 -0
  163. django_cfg/modules/django_twilio/management/commands/test_twilio.py +112 -0
  164. django_cfg/modules/django_unfold/callbacks/main.py +16 -5
  165. django_cfg/modules/django_unfold/callbacks/revolution.py +41 -36
  166. django_cfg/pyproject.toml +2 -6
  167. django_cfg/registry/third_party.py +5 -7
  168. django_cfg/routing/callbacks.py +1 -1
  169. django_cfg/static/admin/css/prose-unfold.css +666 -0
  170. django_cfg/templates/admin/index.html +8 -0
  171. django_cfg/templates/admin/index_new.html +13 -0
  172. django_cfg/templates/admin/layouts/dashboard_with_tabs.html +15 -3
  173. django_cfg/templates/admin/sections/documentation_section.html +172 -0
  174. django_cfg/templates/admin/snippets/tabs/documentation_tab.html +231 -0
  175. {django_cfg-1.4.10.dist-info → django_cfg-1.4.11.dist-info}/METADATA +2 -2
  176. {django_cfg-1.4.10.dist-info → django_cfg-1.4.11.dist-info}/RECORD +180 -59
  177. django_cfg/management/commands/generate.py +0 -107
  178. /django_cfg/models/django/{revolution.py → revolution_legacy.py} +0 -0
  179. {django_cfg-1.4.10.dist-info → django_cfg-1.4.11.dist-info}/WHEEL +0 -0
  180. {django_cfg-1.4.10.dist-info → django_cfg-1.4.11.dist-info}/entry_points.txt +0 -0
  181. {django_cfg-1.4.10.dist-info → django_cfg-1.4.11.dist-info}/licenses/LICENSE +0 -0
django_cfg/apps/urls.py CHANGED
@@ -5,67 +5,128 @@ Built-in API endpoints for django_cfg functionality.
5
5
  """
6
6
 
7
7
  from django.urls import path, include
8
- from typing import List
8
+ from typing import List, Dict
9
9
  from django.urls import URLPattern
10
10
 
11
11
 
12
+ def _register_group_urls(patterns: List[URLPattern], groups: Dict) -> None:
13
+ """
14
+ Auto-register URLs from OpenAPI groups using convention.
15
+
16
+ Convention: cfg_{app} → /cfg/{app}/
17
+
18
+ Args:
19
+ patterns: URL patterns list to append to
20
+ groups: OpenAPI groups dict
21
+ """
22
+ for group_name in groups.keys():
23
+ # Only django-cfg apps (convention: cfg_*)
24
+ if not group_name.startswith('cfg_'):
25
+ continue
26
+
27
+ # Extract app name: cfg_payments → payments
28
+ app_name = group_name[4:]
29
+
30
+ # Register main URLs: /cfg/{app}/
31
+ try:
32
+ patterns.append(
33
+ path(f'cfg/{app_name}/', include(f'django_cfg.apps.{app_name}.urls'))
34
+ )
35
+ except ImportError:
36
+ pass # URL module doesn't exist
37
+
38
+ # Register admin URLs: /cfg/{app}/admin/ (if exists)
39
+ try:
40
+ patterns.append(
41
+ path(f'cfg/{app_name}/admin/', include(f'django_cfg.apps.{app_name}.urls_admin'))
42
+ )
43
+ except ImportError:
44
+ pass # Admin URL module doesn't exist
45
+
46
+
47
+ def _register_apps_fallback(patterns: List[URLPattern]) -> None:
48
+ """
49
+ Fallback: Register apps when OpenAPI is disabled.
50
+
51
+ Uses BaseCfgModule checks to determine which apps are enabled.
52
+
53
+ Args:
54
+ patterns: URL patterns list to append to
55
+ """
56
+ from django_cfg.modules.base import BaseCfgModule
57
+ base_module = BaseCfgModule()
58
+
59
+ # Business logic apps
60
+ if base_module.is_support_enabled():
61
+ patterns.append(path('cfg/support/', include('django_cfg.apps.support.urls')))
62
+
63
+ if base_module.is_accounts_enabled():
64
+ patterns.append(path('cfg/accounts/', include('django_cfg.apps.accounts.urls')))
65
+
66
+ if base_module.is_newsletter_enabled():
67
+ patterns.append(path('cfg/newsletter/', include('django_cfg.apps.newsletter.urls')))
68
+
69
+ if base_module.is_leads_enabled():
70
+ patterns.append(path('cfg/leads/', include('django_cfg.apps.leads.urls')))
71
+
72
+ if base_module.is_knowbase_enabled():
73
+ patterns.append(path('cfg/knowbase/', include('django_cfg.apps.knowbase.urls')))
74
+
75
+ if base_module.is_agents_enabled():
76
+ patterns.append(path('cfg/agents/', include('django_cfg.apps.agents.urls')))
77
+
78
+ if base_module.should_enable_tasks():
79
+ patterns.append(path('cfg/tasks/', include('django_cfg.apps.tasks.urls')))
80
+ patterns.append(path('cfg/tasks/admin/', include('django_cfg.apps.tasks.urls_admin')))
81
+
82
+ if base_module.is_payments_enabled():
83
+ patterns.append(path('cfg/payments/', include('django_cfg.apps.payments.urls')))
84
+ patterns.append(path('cfg/payments/admin/', include('django_cfg.apps.payments.urls_admin')))
85
+
86
+ # Standalone apps
87
+ if base_module.is_maintenance_enabled():
88
+ patterns.append(
89
+ path('admin/django_cfg_maintenance/', include('django_cfg.apps.maintenance.urls_admin'))
90
+ )
91
+
92
+ if base_module.is_rpc_enabled():
93
+ patterns.append(path('rpc/', include('django_cfg.modules.django_ipc_client.dashboard.urls')))
94
+ patterns.append(path('admin/rpc/', include('django_cfg.modules.django_ipc_client.dashboard.urls_admin')))
95
+
96
+
12
97
  def get_django_cfg_urlpatterns() -> List[URLPattern]:
13
98
  """
14
- Get Django CFG URL patterns based on enabled applications.
15
-
99
+ Get Django CFG URL patterns based on OpenAPI groups.
100
+
16
101
  Returns:
17
- List of URL patterns for enabled django_cfg applications
102
+ List of URL patterns for django_cfg
18
103
  """
19
- from django_cfg.modules.base import BaseCfgModule
20
-
21
104
  patterns = [
22
105
  # Core APIs (always enabled)
23
106
  path('health/', include('django_cfg.apps.api.health.urls')),
24
107
  path('endpoints/', include('django_cfg.apps.api.endpoints.urls')),
25
108
  path('commands/', include('django_cfg.apps.api.commands.urls')),
26
-
109
+
110
+ # OpenAPI schemas (if enabled)
111
+ # Provides /openapi/{group}/schema/
112
+ path('openapi/', include('django_cfg.modules.django_client.urls')),
27
113
  ]
28
-
114
+
29
115
  try:
30
- # Use BaseModule to check enabled applications
31
- base_module = BaseCfgModule()
32
-
33
- # All business logic apps are handled by Django Revolution zones
34
- # to maintain consistency and enable client generation
35
- # if base_module.is_support_enabled():
36
- # patterns.append(path('support/', include('django_cfg.apps.support.urls')))
37
- #
38
- # if base_module.is_accounts_enabled():
39
- # patterns.append(path('accounts/', include('django_cfg.apps.accounts.urls')))
40
-
41
- # Newsletter and Leads are handled by Django Revolution zones
42
- # to avoid URL namespace conflicts and enable client generation
43
- # if base_module.is_newsletter_enabled():
44
- # patterns.append(path('newsletter/', include('django_cfg.apps.newsletter.urls')))
45
- #
46
- # if base_module.is_leads_enabled():
47
- # patterns.append(path('leads/', include('django_cfg.apps.leads.urls')))
48
-
49
- # Tasks app - enabled when knowbase or agents are enabled
50
- if base_module.should_enable_tasks():
51
- patterns.append(path('admin/django_cfg_tasks/admin/', include('django_cfg.apps.tasks.urls_admin')))
52
-
53
- # Maintenance app - multi-site maintenance mode with Cloudflare
54
- # if base_module.is_maintenance_enabled():
55
- # patterns.append(path('admin/django_cfg_maintenance/', include('django_cfg.apps.maintenance.urls_admin')))
56
-
57
- if base_module.is_payments_enabled():
58
- patterns.append(path('admin/django_cfg_payments/admin/', include('django_cfg.apps.payments.urls_admin')))
59
-
60
- # RPC Dashboard - WebSocket & RPC activity monitoring
61
- if base_module.is_rpc_enabled():
62
- patterns.append(path('admin/rpc/', include('django_cfg.modules.django_ipc_client.dashboard.urls_admin')))
116
+ # Auto-register from OpenAPI groups (preferred)
117
+ from django_cfg.modules.django_client.core import get_openapi_service
118
+ service = get_openapi_service()
119
+
120
+ if service and service.is_enabled():
121
+ _register_group_urls(patterns, service.get_groups())
122
+ else:
123
+ # Fallback: Use BaseCfgModule when OpenAPI disabled
124
+ _register_apps_fallback(patterns)
63
125
 
64
126
  except Exception:
65
- # Fallback: include all URLs if config is not available
66
- # Note: This fallback should not be needed in production
67
- pass
68
-
127
+ # Last resort fallback
128
+ _register_apps_fallback(patterns)
129
+
69
130
  return patterns
70
131
 
71
132
 
@@ -313,12 +313,12 @@ class DjangoConfig(BaseModel):
313
313
  # === API Configuration ===
314
314
  drf: Optional[DRFConfig] = Field(
315
315
  default=None,
316
- description="Extended Django REST Framework configuration (supplements Revolution)",
316
+ description="Extended Django REST Framework configuration (supplements OpenAPI Client)",
317
317
  )
318
318
 
319
319
  spectacular: Optional[SpectacularConfig] = Field(
320
320
  default=None,
321
- description="Extended DRF Spectacular configuration (supplements Revolution)",
321
+ description="Extended DRF Spectacular configuration (supplements OpenAPI Client)",
322
322
  )
323
323
 
324
324
  # === Limits Configuration ===
@@ -42,7 +42,7 @@ DEFAULT_APPS: List[str] = [
42
42
  "constance.backends.database",
43
43
  # Django CFG Core
44
44
  "django_cfg",
45
- "django_revolution",
45
+ "django_cfg.modules.django_client",
46
46
  ]
47
47
 
48
48
  # Default middleware stack
@@ -4,7 +4,7 @@ Integration generators module.
4
4
  Contains generators for third-party integrations and frameworks:
5
5
  - Session configuration
6
6
  - External services (Telegram, Unfold, Constance)
7
- - API frameworks (JWT, DRF, Spectacular, Revolution)
7
+ - API frameworks (JWT, DRF, Spectacular, OpenAPI Client)
8
8
  - Background tasks (Dramatiq)
9
9
  """
10
10
 
@@ -1,7 +1,7 @@
1
1
  """
2
2
  API frameworks generator.
3
3
 
4
- Handles JWT, DRF, Spectacular, and Django Revolution configuration.
4
+ Handles JWT, DRF, Spectacular, and Django Client (OpenAPI) configuration.
5
5
  Size: ~250 lines (focused on API frameworks)
6
6
  """
7
7
 
@@ -20,7 +20,7 @@ class APIFrameworksGenerator:
20
20
 
21
21
  Responsibilities:
22
22
  - JWT authentication configuration
23
- - Django Revolution framework
23
+ - Django Client (OpenAPI) framework
24
24
  - Django REST Framework (DRF)
25
25
  - DRF Spectacular (OpenAPI/Swagger)
26
26
  - Auto-configuration and extensions
@@ -56,7 +56,7 @@ class APIFrameworksGenerator:
56
56
 
57
57
  # Generate settings for each API framework
58
58
  settings.update(self._generate_jwt_settings())
59
- settings.update(self._generate_revolution_settings())
59
+ settings.update(self._generate_openapi_client_settings())
60
60
  settings.update(self._apply_drf_spectacular_extensions())
61
61
 
62
62
  return settings
@@ -74,81 +74,104 @@ class APIFrameworksGenerator:
74
74
  jwt_settings = self.config.jwt.to_django_settings(self.config.secret_key)
75
75
  return jwt_settings
76
76
 
77
- def _generate_revolution_settings(self) -> Dict[str, Any]:
77
+ def _generate_openapi_client_settings(self) -> Dict[str, Any]:
78
78
  """
79
- Generate Django Revolution framework settings.
79
+ Generate Django Client (OpenAPI) framework settings.
80
80
 
81
81
  Returns:
82
- Dictionary with Revolution and auto-generated DRF configuration
82
+ Dictionary with OpenAPI configuration and auto-generated DRF configuration
83
83
  """
84
- if not hasattr(self.config, "revolution") or not self.config.revolution:
84
+ if not hasattr(self.config, "openapi_client") or not self.config.openapi_client:
85
85
  return {}
86
86
 
87
87
  settings = {}
88
88
 
89
- # Revolution configuration
90
- revolution_settings = {
91
- "DJANGO_REVOLUTION": {
92
- "api_prefix": self.config.revolution.api_prefix,
93
- "debug": getattr(self.config.revolution, "debug", self.config.debug),
94
- "auto_install_deps": getattr(self.config.revolution, "auto_install_deps", True),
95
- "zones": {
96
- zone_name: zone_config.model_dump()
97
- for zone_name, zone_config in self.config.revolution.get_zones_with_defaults().items()
98
- },
99
- }
89
+ # OpenAPI Client configuration
90
+ openapi_settings = {
91
+ "OPENAPI_CLIENT": self.config.openapi_client.model_dump(),
100
92
  }
101
- settings.update(revolution_settings)
93
+ settings.update(openapi_settings)
102
94
 
103
- # Auto-generate DRF configuration using Revolution's core_config
104
- drf_settings = self._generate_drf_from_revolution()
95
+ # Auto-generate DRF configuration from OpenAPIClientConfig
96
+ drf_settings = self._generate_drf_from_openapi()
105
97
  if drf_settings:
106
98
  settings.update(drf_settings)
107
99
 
108
100
  return settings
109
101
 
110
- def _generate_drf_from_revolution(self) -> Dict[str, Any]:
102
+ def _generate_drf_from_openapi(self) -> Dict[str, Any]:
111
103
  """
112
- Generate DRF + Spectacular settings from Revolution config.
104
+ Generate DRF + Spectacular settings from OpenAPIClientConfig.
113
105
 
114
106
  Returns:
115
107
  Dictionary with DRF and Spectacular configuration
116
108
  """
117
109
  try:
118
- from django_revolution import create_drf_spectacular_config
119
-
120
- # Extract DRF parameters from RevolutionConfig
121
- drf_kwargs = {
122
- "title": getattr(self.config.revolution, "drf_title", "API"),
123
- "description": getattr(self.config.revolution, "drf_description", "RESTful API"),
124
- "version": getattr(self.config.revolution, "drf_version", "1.0.0"),
125
- "schema_path_prefix": f"/{self.config.revolution.api_prefix}/",
126
- "enable_browsable_api": getattr(self.config.revolution, "drf_enable_browsable_api", True),
127
- "enable_throttling": getattr(self.config.revolution, "drf_enable_throttling", False),
128
-
129
- # Django-CFG specific settings
130
- "REST_FRAMEWORK_DEFAULT_PAGINATION_CLASS": "django_cfg.middleware.pagination.DefaultPagination",
131
- "REST_FRAMEWORK_PAGE_SIZE": 100,
132
- "REST_FRAMEWORK_DEFAULT_RENDERER_CLASSES": [
110
+ # Extract DRF parameters from OpenAPIClientConfig
111
+ openapi_config = self.config.openapi_client
112
+
113
+ # Build REST_FRAMEWORK settings
114
+ rest_framework = {
115
+ "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
116
+ "DEFAULT_PAGINATION_CLASS": "django_cfg.middleware.pagination.DefaultPagination",
117
+ "PAGE_SIZE": 100,
118
+ "DEFAULT_RENDERER_CLASSES": [
133
119
  "rest_framework.renderers.JSONRenderer",
134
120
  "django_cfg.modules.django_drf_theme.renderers.TailwindBrowsableAPIRenderer",
135
121
  ],
136
122
  }
137
123
 
138
- # Create DRF + Spectacular config with Revolution's comprehensive settings
139
- drf_settings = create_drf_spectacular_config(**drf_kwargs)
124
+ # Add authentication classes if not browsable
125
+ if not openapi_config.drf_enable_browsable_api:
126
+ rest_framework["DEFAULT_RENDERER_CLASSES"] = [
127
+ "rest_framework.renderers.JSONRenderer",
128
+ ]
129
+
130
+ # Add throttling if enabled
131
+ if openapi_config.drf_enable_throttling:
132
+ rest_framework["DEFAULT_THROTTLE_CLASSES"] = [
133
+ "rest_framework.throttling.AnonRateThrottle",
134
+ "rest_framework.throttling.UserRateThrottle",
135
+ ]
136
+ rest_framework["DEFAULT_THROTTLE_RATES"] = {
137
+ "anon": "100/day",
138
+ "user": "1000/day",
139
+ }
140
+
141
+ # Build SPECTACULAR_SETTINGS
142
+ spectacular_settings = {
143
+ "TITLE": openapi_config.drf_title,
144
+ "DESCRIPTION": openapi_config.drf_description,
145
+ "VERSION": openapi_config.drf_version,
146
+ "SERVE_INCLUDE_SCHEMA": openapi_config.drf_serve_include_schema,
147
+ "SCHEMA_PATH_PREFIX": openapi_config.get_drf_schema_path_prefix(),
148
+ "SWAGGER_UI_SETTINGS": {
149
+ "deepLinking": True,
150
+ "persistAuthorization": True,
151
+ "displayOperationId": True,
152
+ },
153
+ "COMPONENT_SPLIT_REQUEST": True,
154
+ "COMPONENT_SPLIT_PATCH": True,
155
+ # Auto-fix enum naming collisions
156
+ "POSTPROCESSING_HOOKS": [
157
+ "django_cfg.modules.django_client.spectacular.auto_fix_enum_names",
158
+ ],
159
+ }
160
+
161
+ drf_settings = {
162
+ "REST_FRAMEWORK": rest_framework,
163
+ "SPECTACULAR_SETTINGS": spectacular_settings,
164
+ }
140
165
 
141
- logger.info("🚀 Generated DRF + Spectacular settings using Revolution's create_drf_spectacular_config")
166
+ logger.info("🚀 Generated DRF + Spectacular settings from OpenAPIClientConfig")
142
167
  logger.info(" - Pagination: django_cfg.middleware.pagination.DefaultPagination")
143
168
  logger.info(" - Renderer: TailwindBrowsableAPIRenderer")
169
+ logger.info(f" - API: {openapi_config.drf_title} v{openapi_config.drf_version}")
144
170
 
145
171
  return drf_settings
146
172
 
147
- except ImportError as e:
148
- logger.warning(f"Could not import django_revolution.create_drf_spectacular_config: {e}")
149
- return {}
150
173
  except Exception as e:
151
- logger.warning(f"Could not generate DRF config from Revolution: {e}")
174
+ logger.warning(f"Could not generate DRF config from OpenAPIClientConfig: {e}")
152
175
  return {}
153
176
 
154
177
  def _apply_drf_spectacular_extensions(self) -> Dict[str, Any]:
@@ -185,7 +208,7 @@ class APIFrameworksGenerator:
185
208
  Returns:
186
209
  Dictionary with Spectacular settings
187
210
  """
188
- # Check if Spectacular settings exist (from Revolution or elsewhere)
211
+ # Check if Spectacular settings exist (from OpenAPI Client or elsewhere)
189
212
  if not hasattr(self, '_has_spectacular_settings'):
190
213
  return {}
191
214
 
@@ -221,9 +244,9 @@ class APIFrameworksGenerator:
221
244
  Returns:
222
245
  Dictionary with DRF settings
223
246
  """
224
- # Don't override if Revolution already created full DRF config
225
- if self.config.revolution:
226
- logger.info("🔧 DRF settings already configured by Revolution, skipping django-cfg extensions")
247
+ # Don't override if OpenAPIClientConfig already created full DRF config
248
+ if hasattr(self.config, 'openapi_client') and self.config.openapi_client:
249
+ logger.info("🔧 DRF settings already configured by OpenAPIClientConfig, skipping django-cfg extensions")
227
250
  return {}
228
251
 
229
252
  settings = {}
@@ -160,8 +160,8 @@ class StartupDisplayManager(BaseDisplayManager):
160
160
  # App-specific configuration panels
161
161
  self._display_config_panels()
162
162
 
163
- # Revolution info
164
- self._display_revolution_info()
163
+ # OpenAPI Client info
164
+ self._display_openapi_client_info()
165
165
 
166
166
  # Management commands
167
167
  self._display_commands_info()
@@ -661,30 +661,38 @@ class StartupDisplayManager(BaseDisplayManager):
661
661
  print(f"❌ ERROR in _display_constance_summary: {e}")
662
662
  traceback.print_exc()
663
663
 
664
- def _display_revolution_info(self):
665
- """Display Django Revolution information."""
664
+ def _display_openapi_client_info(self):
665
+ """Display Django Client (OpenAPI) information."""
666
666
  try:
667
- from django_revolution import get_revolution_info
668
- revolution_info = get_revolution_info()
669
-
670
- revolution_table = self.create_table()
671
- revolution_table.add_column("Setting", style="cyan", width=30)
672
- revolution_table.add_column("Value", style="white")
673
-
674
- revolution_table.add_row("📦 Version", revolution_info.get('version', 'unknown'))
675
- revolution_table.add_row("📊 Zones", str(revolution_info.get('zones_count', 0)))
676
- revolution_table.add_row("📱 Apps", str(revolution_info.get('apps_count', 0)))
677
- revolution_table.add_row("🔗 API Prefix", revolution_info.get('api_prefix', '/api/'))
678
-
679
- revolution_panel = self.create_panel(
680
- revolution_table,
681
- title="🚀 Django Revolution",
667
+ from django_cfg.modules.django_client.core.config.service import DjangoOpenAPI
668
+
669
+ service = DjangoOpenAPI.instance()
670
+ if not service.config or not service.config.enabled:
671
+ return
672
+
673
+ openapi_table = self.create_table()
674
+ openapi_table.add_column("Setting", style="cyan", width=30)
675
+ openapi_table.add_column("Value", style="white")
676
+
677
+ openapi_table.add_row("📦 Status", "[green]Enabled[/green]")
678
+ openapi_table.add_row("📊 Groups", str(len(service.config.groups)))
679
+ openapi_table.add_row("🔗 API Prefix", f"/{service.config.api_prefix}/")
680
+ openapi_table.add_row("📁 Output Dir", str(service.config.output_dir))
681
+
682
+ # List groups
683
+ group_names = [g.name for g in service.config.groups]
684
+ if group_names:
685
+ openapi_table.add_row("🏷️ Groups", ", ".join(group_names[:3]) + ("..." if len(group_names) > 3 else ""))
686
+
687
+ openapi_panel = self.create_panel(
688
+ openapi_table,
689
+ title="🚀 Django Client (OpenAPI)",
682
690
  border_style="blue"
683
691
  )
684
-
685
- self.console.print(revolution_panel)
692
+
693
+ self.console.print(openapi_panel)
686
694
  except ImportError:
687
- # Django Revolution not available
695
+ # Django Client not available
688
696
  pass
689
697
  except Exception:
690
698
  pass
@@ -16,7 +16,7 @@ def add_django_cfg_urls(urlpatterns: List[URLPattern], cfg_prefix: str = "cfg/")
16
16
 
17
17
  This function adds:
18
18
  - Django CFG management URLs (cfg/)
19
- - Django Revolution URLs (if available)
19
+ - Django Client URLs (if available)
20
20
  - Startup information display (based on config)
21
21
 
22
22
  Args:
@@ -37,22 +37,16 @@ def add_django_cfg_urls(urlpatterns: List[URLPattern], cfg_prefix: str = "cfg/")
37
37
 
38
38
  # Automatically adds:
39
39
  # - path("cfg/", include("django_cfg.apps.urls"))
40
- # - Django Revolution URLs (if available)
40
+ # - Django Client URLs (if available)
41
41
  # - Startup info display (based on config.startup_info_mode)
42
42
  urlpatterns = add_django_cfg_urls(urlpatterns)
43
43
  """
44
44
  # Add django_cfg API URLs
45
+ # Note: Django Client URLs are included in django_cfg.apps.urls
46
+ # at /cfg/openapi/{group}/schema/ to avoid conflicts
45
47
  new_patterns = urlpatterns + [
46
48
  path(cfg_prefix, include("django_cfg.apps.urls")),
47
49
  ]
48
-
49
- # Try to add Django Revolution URLs if available
50
- try:
51
- from django_revolution import add_revolution_urls
52
- new_patterns = add_revolution_urls(new_patterns)
53
- except ImportError:
54
- # Django Revolution not available - skip
55
- pass
56
50
 
57
51
  # Add django-browser-reload URLs in development (if installed)
58
52
  if settings.DEBUG:
@@ -122,13 +116,18 @@ def get_django_cfg_urls_info() -> dict:
122
116
  }
123
117
  }
124
118
 
125
- # Add Django Revolution info if available
119
+ # Add Django Client info if available
126
120
  try:
127
- from django_revolution import get_revolution_urls_info
128
- revolution_info = get_revolution_urls_info()
129
- if revolution_info:
130
- info["django_revolution"] = revolution_info
121
+ from django_cfg.modules.django_client.core.config.service import DjangoOpenAPI
122
+ service = DjangoOpenAPI.instance()
123
+ if service.config and service.config.enabled:
124
+ info["django_client"] = {
125
+ "enabled": True,
126
+ "groups": len(service.config.groups),
127
+ "base_url": service.config.base_url,
128
+ "output_dir": service.config.output_dir,
129
+ }
131
130
  except ImportError:
132
131
  pass
133
-
132
+
134
133
  return info