django-cfg 1.4.107__py3-none-any.whl → 1.4.109__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.

Potentially problematic release.


This version of django-cfg might be problematic. Click here for more details.

Files changed (140) hide show
  1. django_cfg/__init__.py +1 -1
  2. django_cfg/apps/accounts/views/profile.py +19 -9
  3. django_cfg/apps/centrifugo/views/admin_api.py +4 -7
  4. django_cfg/apps/centrifugo/views/monitoring.py +3 -6
  5. django_cfg/apps/centrifugo/views/testing_api.py +3 -6
  6. django_cfg/apps/dashboard/services/system_health_service.py +16 -11
  7. django_cfg/apps/dashboard/views/activity_views.py +3 -5
  8. django_cfg/apps/dashboard/views/apizones_views.py +4 -5
  9. django_cfg/apps/dashboard/views/charts_views.py +4 -5
  10. django_cfg/apps/dashboard/views/overview_views.py +4 -5
  11. django_cfg/apps/dashboard/views/statistics_views.py +4 -5
  12. django_cfg/apps/dashboard/views/system_views.py +4 -5
  13. django_cfg/apps/knowbase/__init__.py +2 -2
  14. django_cfg/apps/knowbase/apps.py +2 -8
  15. django_cfg/apps/knowbase/views/base.py +9 -4
  16. django_cfg/apps/support/views/api.py +16 -7
  17. django_cfg/apps/tasks/__init__.py +61 -2
  18. django_cfg/apps/tasks/admin/__init__.py +3 -10
  19. django_cfg/apps/tasks/admin/config.py +98 -0
  20. django_cfg/apps/tasks/admin/task_log.py +265 -0
  21. django_cfg/apps/tasks/apps.py +7 -9
  22. django_cfg/apps/tasks/filters/__init__.py +10 -0
  23. django_cfg/apps/tasks/filters/task_log.py +121 -0
  24. django_cfg/apps/tasks/migrations/0001_initial.py +196 -0
  25. django_cfg/apps/tasks/models/__init__.py +4 -0
  26. django_cfg/apps/tasks/models/task_log.py +246 -0
  27. django_cfg/apps/tasks/serializers/__init__.py +28 -0
  28. django_cfg/apps/tasks/serializers/task_log.py +249 -0
  29. django_cfg/apps/tasks/services/__init__.py +10 -0
  30. django_cfg/apps/tasks/services/client/__init__.py +7 -0
  31. django_cfg/apps/tasks/services/client/client.py +234 -0
  32. django_cfg/apps/tasks/services/config_helper.py +63 -0
  33. django_cfg/apps/tasks/services/sync.py +204 -0
  34. django_cfg/apps/tasks/urls.py +7 -13
  35. django_cfg/apps/tasks/views/__init__.py +4 -10
  36. django_cfg/apps/tasks/views/task_log.py +41 -0
  37. django_cfg/apps/tasks/views/task_log_base.py +41 -0
  38. django_cfg/apps/tasks/views/task_log_overview.py +100 -0
  39. django_cfg/apps/tasks/views/task_log_related.py +41 -0
  40. django_cfg/apps/tasks/views/task_log_stats.py +91 -0
  41. django_cfg/apps/tasks/views/task_log_timeline.py +81 -0
  42. django_cfg/apps/urls.py +0 -1
  43. django_cfg/cli/commands/info.py +1 -1
  44. django_cfg/cli/utils.py +1 -1
  45. django_cfg/core/base/config_model.py +1 -1
  46. django_cfg/core/builders/apps_builder.py +1 -1
  47. django_cfg/core/generation/integration_generators/__init__.py +1 -1
  48. django_cfg/core/generation/integration_generators/tasks.py +14 -18
  49. django_cfg/core/generation/security_generators/crypto_fields.py +2 -1
  50. django_cfg/core/integration/display/startup.py +1 -1
  51. django_cfg/mixins/__init__.py +12 -0
  52. django_cfg/mixins/admin_api.py +37 -0
  53. django_cfg/mixins/client_api.py +39 -0
  54. django_cfg/models/django/constance.py +2 -8
  55. django_cfg/models/django/crypto_fields.py +13 -48
  56. django_cfg/models/tasks/__init__.py +8 -10
  57. django_cfg/models/tasks/backends.py +76 -207
  58. django_cfg/models/tasks/config.py +20 -127
  59. django_cfg/models/tasks/utils.py +17 -29
  60. django_cfg/modules/django_client/management/commands/generate_client.py +13 -1
  61. django_cfg/modules/django_unfold/navigation.py +121 -22
  62. django_cfg/pyproject.toml +2 -2
  63. django_cfg/registry/core.py +1 -1
  64. django_cfg/static/frontend/admin.zip +0 -0
  65. {django_cfg-1.4.107.dist-info → django_cfg-1.4.109.dist-info}/METADATA +3 -3
  66. {django_cfg-1.4.107.dist-info → django_cfg-1.4.109.dist-info}/RECORD +70 -117
  67. django_cfg/apps/tasks/admin/actions.py +0 -29
  68. django_cfg/apps/tasks/admin/tasks_admin.py +0 -154
  69. django_cfg/apps/tasks/api/serializers.py +0 -82
  70. django_cfg/apps/tasks/api/views.py +0 -571
  71. django_cfg/apps/tasks/serializers.py +0 -82
  72. django_cfg/apps/tasks/static/tasks/css/dashboard-alpine.css +0 -299
  73. django_cfg/apps/tasks/static/tasks/css/dashboard.css +0 -120
  74. django_cfg/apps/tasks/static/tasks/js/alpine/README.md +0 -47
  75. django_cfg/apps/tasks/static/tasks/js/alpine/actions/index.js +0 -8
  76. django_cfg/apps/tasks/static/tasks/js/alpine/actions/management.js +0 -123
  77. django_cfg/apps/tasks/static/tasks/js/alpine/actions/pagination.js +0 -21
  78. django_cfg/apps/tasks/static/tasks/js/alpine/actions/tasks.js +0 -101
  79. django_cfg/apps/tasks/static/tasks/js/alpine/actions/workers.js +0 -59
  80. django_cfg/apps/tasks/static/tasks/js/alpine/computed.js +0 -35
  81. django_cfg/apps/tasks/static/tasks/js/alpine/index.js +0 -148
  82. django_cfg/apps/tasks/static/tasks/js/alpine/loaders/index.js +0 -36
  83. django_cfg/apps/tasks/static/tasks/js/alpine/loaders/overview.js +0 -37
  84. django_cfg/apps/tasks/static/tasks/js/alpine/loaders/queues.js +0 -27
  85. django_cfg/apps/tasks/static/tasks/js/alpine/loaders/tasks.js +0 -32
  86. django_cfg/apps/tasks/static/tasks/js/alpine/loaders/workers.js +0 -21
  87. django_cfg/apps/tasks/static/tasks/js/alpine/state.js +0 -36
  88. django_cfg/apps/tasks/static/tasks/js/alpine/utils/formatters.js +0 -42
  89. django_cfg/apps/tasks/static/tasks/js/alpine/utils/helpers.js +0 -68
  90. django_cfg/apps/tasks/static/tasks/js/dashboard-alpine.js +0 -725
  91. django_cfg/apps/tasks/tasks/__init__.py +0 -10
  92. django_cfg/apps/tasks/tasks/demo_tasks.py +0 -127
  93. django_cfg/apps/tasks/templates/tasks/components/management_actions.html +0 -71
  94. django_cfg/apps/tasks/templates/tasks/components/overview_content.html +0 -94
  95. django_cfg/apps/tasks/templates/tasks/components/queues_content.html +0 -44
  96. django_cfg/apps/tasks/templates/tasks/components/tab_navigation.html +0 -45
  97. django_cfg/apps/tasks/templates/tasks/components/task_details_modal.html +0 -151
  98. django_cfg/apps/tasks/templates/tasks/components/tasks_content.html +0 -61
  99. django_cfg/apps/tasks/templates/tasks/components/tasks_mjs_integration.html +0 -269
  100. django_cfg/apps/tasks/templates/tasks/components/workers_content.html +0 -60
  101. django_cfg/apps/tasks/templates/tasks/layout/base.html +0 -20
  102. django_cfg/apps/tasks/templates/tasks/pages/dashboard-improved.html +0 -168
  103. django_cfg/apps/tasks/templates/tasks/pages/dashboard.html +0 -77
  104. django_cfg/apps/tasks/templates/tasks/partials/task_row_template.html +0 -40
  105. django_cfg/apps/tasks/templates/tasks/widgets/task_filters.html +0 -40
  106. django_cfg/apps/tasks/templates/tasks/widgets/task_footer.html +0 -86
  107. django_cfg/apps/tasks/templates/tasks/widgets/task_table.html +0 -90
  108. django_cfg/apps/tasks/urls_admin.py +0 -15
  109. django_cfg/apps/tasks/utils/__init__.py +0 -1
  110. django_cfg/apps/tasks/utils/simulator.py +0 -353
  111. django_cfg/apps/tasks/views/api.py +0 -571
  112. django_cfg/apps/tasks/views/dashboard.py +0 -89
  113. django_cfg/management/commands/rundramatiq.py +0 -24
  114. django_cfg/management/commands/rundramatiq_simulator.py +0 -22
  115. django_cfg/management/commands/task_clear.py +0 -25
  116. django_cfg/management/commands/task_status.py +0 -24
  117. django_cfg/modules/django_client/system/__init__.py +0 -24
  118. django_cfg/modules/django_client/system/base_generator.py +0 -123
  119. django_cfg/modules/django_client/system/generate_mjs_clients.py +0 -176
  120. django_cfg/modules/django_client/system/mjs_generator.py +0 -219
  121. django_cfg/modules/django_client/system/schema_parser.py +0 -199
  122. django_cfg/modules/django_client/system/templates/api_client.js.j2 +0 -87
  123. django_cfg/modules/django_client/system/templates/app_index.js.j2 +0 -13
  124. django_cfg/modules/django_client/system/templates/base_client.js.j2 +0 -166
  125. django_cfg/modules/django_client/system/templates/main_index.js.j2 +0 -80
  126. django_cfg/modules/django_client/system/templates/types.js.j2 +0 -24
  127. django_cfg/modules/django_tasks/__init__.py +0 -29
  128. django_cfg/modules/django_tasks/dramatiq_setup.py +0 -20
  129. django_cfg/modules/django_tasks/factory.py +0 -127
  130. django_cfg/modules/django_tasks/management/commands/__init__.py +0 -0
  131. django_cfg/modules/django_tasks/management/commands/rundramatiq.py +0 -253
  132. django_cfg/modules/django_tasks/management/commands/rundramatiq_simulator.py +0 -436
  133. django_cfg/modules/django_tasks/management/commands/task_clear.py +0 -226
  134. django_cfg/modules/django_tasks/management/commands/task_status.py +0 -257
  135. django_cfg/modules/django_tasks/service.py +0 -281
  136. django_cfg/modules/django_tasks/settings.py +0 -107
  137. /django_cfg/{modules/django_tasks/management → apps/tasks/migrations}/__init__.py +0 -0
  138. {django_cfg-1.4.107.dist-info → django_cfg-1.4.109.dist-info}/WHEEL +0 -0
  139. {django_cfg-1.4.107.dist-info → django_cfg-1.4.109.dist-info}/entry_points.txt +0 -0
  140. {django_cfg-1.4.107.dist-info → django_cfg-1.4.109.dist-info}/licenses/LICENSE +0 -0
@@ -1,199 +0,0 @@
1
- """
2
- OpenAPI schema parser for extracting operation and type information.
3
- """
4
-
5
- import re
6
- from typing import Any, Dict, List, Optional
7
-
8
-
9
- class SchemaParser:
10
- """Parse OpenAPI schema to extract operation and type information."""
11
-
12
- def __init__(self, schema: Dict[str, Any]):
13
- """Initialize with OpenAPI schema."""
14
- self.schema = schema
15
- self.components = schema.get('components', {})
16
- self.schemas = self.components.get('schemas', {})
17
-
18
- def extract_app_from_path(self, path: str) -> str:
19
- """Extract app name from API path."""
20
- # Pattern: /cfg/{app_name}/...
21
- match = re.match(r'/cfg/([^/]+)/', path)
22
- if match:
23
- return match.group(1)
24
- return 'core' # Default for paths without clear app
25
-
26
- def extract_method_name(self, operation_id: str) -> str:
27
- """Extract clean method name from operation ID."""
28
- # Remove common prefixes
29
- for prefix in ['cfg__', 'api_', 'cfg_']:
30
- if operation_id.startswith(prefix):
31
- operation_id = operation_id[len(prefix):]
32
-
33
- # Handle double underscores
34
- operation_id = operation_id.replace('__', '_')
35
-
36
- return operation_id
37
-
38
- def group_operations_by_app(self) -> Dict[str, List[Dict]]:
39
- """Group API operations by Django app based on path patterns."""
40
- grouped = {}
41
-
42
- for path, path_item in self.schema.get('paths', {}).items():
43
- for method, operation in path_item.items():
44
- if method in ['get', 'post', 'put', 'patch', 'delete']:
45
- # Extract app name from path
46
- app_name = self.extract_app_from_path(path)
47
-
48
- # Add operation info
49
- op_info = {
50
- 'path': path,
51
- 'method': method,
52
- 'operationId': operation.get('operationId', ''),
53
- 'summary': operation.get('summary', ''),
54
- 'description': operation.get('description', ''),
55
- 'parameters': operation.get('parameters', []),
56
- 'requestBody': operation.get('requestBody'),
57
- 'responses': operation.get('responses', {}),
58
- 'tags': operation.get('tags', [])
59
- }
60
-
61
- if app_name not in grouped:
62
- grouped[app_name] = []
63
- grouped[app_name].append(op_info)
64
-
65
- return grouped
66
-
67
- def extract_parameter_info(self, parameter: Dict[str, Any]) -> Dict[str, Any]:
68
- """Extract detailed parameter information."""
69
- param_info = {
70
- 'name': parameter.get('name'),
71
- 'in': parameter.get('in'),
72
- 'required': parameter.get('required', False),
73
- 'description': parameter.get('description', ''),
74
- 'schema': parameter.get('schema', {})
75
- }
76
-
77
- # Extract type information
78
- schema = parameter.get('schema', {})
79
- param_info['type'] = self.get_js_type(schema)
80
- param_info['format'] = schema.get('format')
81
-
82
- return param_info
83
-
84
- def extract_request_body_info(self, request_body: Dict[str, Any]) -> Optional[Dict[str, Any]]:
85
- """Extract request body information."""
86
- if not request_body:
87
- return None
88
-
89
- content = request_body.get('content', {})
90
- json_content = content.get('application/json', {})
91
- schema = json_content.get('schema', {})
92
-
93
- return {
94
- 'required': request_body.get('required', False),
95
- 'description': request_body.get('description', ''),
96
- 'schema': schema,
97
- 'type': self.get_js_type(schema)
98
- }
99
-
100
- def get_js_type(self, schema: Dict[str, Any]) -> str:
101
- """Convert OpenAPI schema to JavaScript/TypeScript type."""
102
- if not schema:
103
- return 'any'
104
-
105
- # Handle references
106
- if '$ref' in schema:
107
- ref_name = schema['$ref'].split('/')[-1]
108
- return ref_name
109
-
110
- # Handle arrays
111
- if schema.get('type') == 'array':
112
- items_type = self.get_js_type(schema.get('items', {}))
113
- return f'{items_type}[]'
114
-
115
- # Handle objects
116
- if schema.get('type') == 'object':
117
- # Check if it has specific properties
118
- if 'properties' in schema:
119
- # Could generate an interface here
120
- return 'Object'
121
- # Check for additionalProperties (dictionary-like)
122
- if 'additionalProperties' in schema:
123
- additional = schema['additionalProperties']
124
- # additionalProperties can be bool or schema object
125
- if isinstance(additional, bool):
126
- return 'Record<string, any>' if additional else 'Object'
127
- value_type = self.get_js_type(additional)
128
- return f'Record<string, {value_type}>'
129
- return 'Object'
130
-
131
- # Handle enums
132
- if 'enum' in schema:
133
- # Create a union type from enum values
134
- values = schema['enum']
135
- if all(isinstance(v, str) for v in values):
136
- return ' | '.join(f'"{v}"' for v in values)
137
- return 'string'
138
-
139
- # Handle primitive types
140
- type_mapping = {
141
- 'string': 'string',
142
- 'integer': 'number',
143
- 'number': 'number',
144
- 'boolean': 'boolean',
145
- 'null': 'null'
146
- }
147
-
148
- openapi_type = schema.get('type', 'any')
149
-
150
- # Handle special formats
151
- format_type = schema.get('format')
152
- if openapi_type == 'string' and format_type:
153
- format_mapping = {
154
- 'date': 'string', # Could be Date
155
- 'date-time': 'string', # Could be Date
156
- 'uuid': 'string',
157
- 'email': 'string',
158
- 'uri': 'string',
159
- 'binary': 'Blob',
160
- 'byte': 'string'
161
- }
162
- return format_mapping.get(format_type, 'string')
163
-
164
- return type_mapping.get(openapi_type, 'any')
165
-
166
- def get_response_type(self, responses: Dict[str, Any]) -> str:
167
- """Extract the response type from operation responses."""
168
- # Look for successful response (200, 201, etc.)
169
- for status in ['200', '201', '202']:
170
- if status in responses:
171
- response = responses[status]
172
- content = response.get('content', {})
173
-
174
- if 'application/json' in content:
175
- schema = content['application/json'].get('schema', {})
176
- return self.get_js_type(schema)
177
-
178
- # Check for 204 No Content
179
- if '204' in responses:
180
- return 'void'
181
-
182
- # Default to any
183
- return 'any'
184
-
185
- def resolve_ref(self, ref: str) -> Optional[Dict[str, Any]]:
186
- """Resolve a $ref to its schema definition."""
187
- if not ref.startswith('#/'):
188
- return None
189
-
190
- parts = ref[2:].split('/')
191
- current = self.schema
192
-
193
- for part in parts:
194
- if isinstance(current, dict) and part in current:
195
- current = current[part]
196
- else:
197
- return None
198
-
199
- return current
@@ -1,87 +0,0 @@
1
- import { BaseAPIClient } from '../base.mjs';
2
-
3
- /**
4
- * {{ app_name.replace('_', ' ').title() }} API Client
5
- * Auto-generated from OpenAPI schema
6
- * @module {{ app_name }}
7
- * @extends BaseAPIClient
8
- */
9
- export class {{ class_name }} extends BaseAPIClient {
10
- /**
11
- * Initialize {{ app_name }} API client
12
- * @param {string} [baseURL] - Optional base URL
13
- */
14
- constructor(baseURL) {
15
- super(baseURL);
16
- }
17
-
18
- {% for method in methods %}
19
- /**
20
- * {{ method.summary or method.name }}
21
- {%- if method.description %}
22
- * {{ method.description }}
23
- {%- endif %}
24
- {%- for param in method.path_params %}
25
- * @param {{ '{' }}{{ param.type }}{{ '}' }} {{ param.name }}{% if param.description %} - {{ param.description }}{% endif %}
26
- {%- endfor %}
27
- {%- if method.request_body %}
28
- * @param {{ '{' }}{{ method.request_body.type }}{{ '}' }} data - Request body{% if method.request_body.description %} - {{ method.request_body.description }}{% endif %}
29
- {%- endif %}
30
- {%- if method.query_params %}
31
- * @param {{ '{Object}' }} [params={}] - Query parameters
32
- {%- for param in method.query_params %}
33
- * @param {{ '{' }}{{ param.type }}{{ '}' }} [params.{{ param.name }}]{% if param.description %} - {{ param.description }}{% endif %}
34
- {%- endfor %}
35
- {%- endif %}
36
- * @returns {{ '{Promise<' }}{{ method.response_type }}{{ '>}' }} {{ 'Response data' if method.response_type != 'void' else 'No content' }}
37
- */
38
- async {{ method.name }}(
39
- {%- set params = [] %}
40
- {%- for param in method.path_params %}
41
- {%- set _ = params.append(param.name) %}
42
- {%- endfor %}
43
- {%- if method.request_body %}
44
- {%- set _ = params.append('data') %}
45
- {%- endif %}
46
- {%- if method.query_params %}
47
- {%- set _ = params.append('params = {}') %}
48
- {%- endif %}
49
- {{- params | join(', ') -}}
50
- ) {
51
- const path = `{{ method.path }}`;
52
- {%- if method.http_method == 'GET' %}
53
- {%- if method.query_params %}
54
- return this.get(path, params);
55
- {%- else %}
56
- return this.get(path);
57
- {%- endif %}
58
- {%- elif method.http_method == 'POST' %}
59
- {%- if method.request_body %}
60
- return this.post(path, data);
61
- {%- else %}
62
- return this.post(path, {});
63
- {%- endif %}
64
- {%- elif method.http_method == 'PUT' %}
65
- {%- if method.request_body %}
66
- return this.put(path, data);
67
- {%- else %}
68
- return this.put(path, {});
69
- {%- endif %}
70
- {%- elif method.http_method == 'PATCH' %}
71
- {%- if method.request_body %}
72
- return this.patch(path, data);
73
- {%- else %}
74
- return this.patch(path, {});
75
- {%- endif %}
76
- {%- elif method.http_method == 'DELETE' %}
77
- return this.delete(path);
78
- {%- endif %}
79
- }
80
- {% endfor %}
81
- }
82
-
83
- // Default instance for convenience
84
- export const {{ instance_name }} = new {{ class_name }}();
85
-
86
- // Default export
87
- export default {{ class_name }};
@@ -1,13 +0,0 @@
1
- /**
2
- * {{ app_name.replace('_', ' ').title() }} API Module
3
- * Re-exports the API client for convenient importing
4
- * @module {{ app_name }}
5
- */
6
-
7
- import { {{ class_name }}, {{ instance_name }} } from './client.mjs';
8
-
9
- // Re-export the class and instance
10
- export { {{ class_name }}, {{ instance_name }} };
11
-
12
- // Default export is the instance for convenience
13
- export default {{ instance_name }};
@@ -1,166 +0,0 @@
1
- /**
2
- * Base API Client for django-cfg
3
- * Lightweight ES Module with JSDoc type annotations
4
- * @module base
5
- */
6
-
7
- /**
8
- * Custom error class for API errors
9
- * @class APIError
10
- * @extends Error
11
- */
12
- class APIError extends Error {
13
- /**
14
- * @param {string} message - Error message
15
- * @param {number} status - HTTP status code
16
- * @param {any} data - Additional error data
17
- */
18
- constructor(message, status, data) {
19
- super(message);
20
- this.name = 'APIError';
21
- this.status = status;
22
- this.data = data;
23
- }
24
- }
25
-
26
- /**
27
- * Get Django CSRF token from cookies
28
- * @returns {string} CSRF token value
29
- */
30
- function getCsrfToken() {
31
- const cookie = document.cookie.split('; ')
32
- .find(row => row.startsWith('csrftoken='));
33
- return cookie ? cookie.split('=')[1] : '';
34
- }
35
-
36
- /**
37
- * @typedef {Object} RequestOptions
38
- * @property {string} [method='GET'] - HTTP method
39
- * @property {Object} [headers={}] - Request headers
40
- * @property {any} [body] - Request body
41
- * @property {string} [credentials='same-origin'] - Credentials mode
42
- */
43
-
44
- /**
45
- * Base API client class with built-in Django CSRF support
46
- * @class BaseAPIClient
47
- */
48
- export class BaseAPIClient {
49
- /**
50
- * Initialize the API client
51
- * @param {string} [baseURL=''] - Base URL for API requests (defaults to current origin)
52
- */
53
- constructor(baseURL = '') {
54
- this.baseURL = baseURL || window.location.origin;
55
- }
56
-
57
- /**
58
- * Make an API request
59
- * @param {string} path - API endpoint path
60
- * @param {RequestOptions} [options={}] - Request options
61
- * @returns {Promise<any>} Response data
62
- * @throws {APIError} When request fails
63
- */
64
- async request(path, options = {}) {
65
- const url = `${this.baseURL}${path}`;
66
-
67
- // Default headers with CSRF token
68
- const headers = {
69
- 'Content-Type': 'application/json',
70
- 'X-CSRFToken': getCsrfToken(),
71
- ...options.headers
72
- };
73
-
74
- try {
75
- const response = await fetch(url, {
76
- ...options,
77
- headers,
78
- credentials: 'same-origin'
79
- });
80
-
81
- if (!response.ok) {
82
- const error = await response.json().catch(() => ({}));
83
- throw new APIError(
84
- error.detail || `HTTP ${response.status}`,
85
- response.status,
86
- error
87
- );
88
- }
89
-
90
- // Handle empty responses
91
- if (response.status === 204) {
92
- return null;
93
- }
94
-
95
- return await response.json();
96
- } catch (error) {
97
- if (error instanceof APIError) {
98
- throw error;
99
- }
100
- throw new APIError(error.message, 0, null);
101
- }
102
- }
103
-
104
- /**
105
- * Make a GET request
106
- * @param {string} path - API endpoint path
107
- * @param {Object} [params={}] - Query parameters
108
- * @returns {Promise<any>} Response data
109
- */
110
- async get(path, params = {}) {
111
- const queryString = new URLSearchParams(params).toString();
112
- const fullPath = queryString ? `${path}?${queryString}` : path;
113
- return this.request(fullPath, { method: 'GET' });
114
- }
115
-
116
- /**
117
- * Make a POST request
118
- * @param {string} path - API endpoint path
119
- * @param {any} [data={}] - Request body data
120
- * @returns {Promise<any>} Response data
121
- */
122
- async post(path, data = {}) {
123
- return this.request(path, {
124
- method: 'POST',
125
- body: JSON.stringify(data)
126
- });
127
- }
128
-
129
- /**
130
- * Make a PUT request
131
- * @param {string} path - API endpoint path
132
- * @param {any} [data={}] - Request body data
133
- * @returns {Promise<any>} Response data
134
- */
135
- async put(path, data = {}) {
136
- return this.request(path, {
137
- method: 'PUT',
138
- body: JSON.stringify(data)
139
- });
140
- }
141
-
142
- /**
143
- * Make a PATCH request
144
- * @param {string} path - API endpoint path
145
- * @param {any} [data={}] - Request body data
146
- * @returns {Promise<any>} Response data
147
- */
148
- async patch(path, data = {}) {
149
- return this.request(path, {
150
- method: 'PATCH',
151
- body: JSON.stringify(data)
152
- });
153
- }
154
-
155
- /**
156
- * Make a DELETE request
157
- * @param {string} path - API endpoint path
158
- * @returns {Promise<any>} Response data
159
- */
160
- async delete(path) {
161
- return this.request(path, { method: 'DELETE' });
162
- }
163
- }
164
-
165
- // Export the error class as well
166
- export { APIError };
@@ -1,80 +0,0 @@
1
- /**
2
- * Django CFG API Clients
3
- * Lightweight ES Modules with JSDoc type annotations
4
- * Organized by Django apps
5
- *
6
- * @module django-cfg-api
7
- *
8
- * @example
9
- * // Import specific app API
10
- * import { tasksAPI } from '/static/api/tasks/index.mjs';
11
- * const stats = await tasksAPI.cfgTasksApiTasksStatsRetrieve();
12
- *
13
- * @example
14
- * // Import multiple APIs from main index
15
- * import { tasksAPI, paymentsAPI } from '/static/api/index.mjs';
16
- *
17
- * @example
18
- * // Import with custom base URL
19
- * import { TasksAPI } from '/static/api/tasks/index.mjs';
20
- * const api = new TasksAPI('https://api.example.com');
21
- */
22
-
23
- import { BaseAPIClient } from './base.mjs';
24
- {% for app in apps %}
25
- import { {{ app.class_name }}, {{ app.instance_name }} } from './{{ app.app_name }}/index.mjs';
26
- {% endfor %}
27
-
28
- /**
29
- * Export all API classes for custom instantiation
30
- * @exports
31
- */
32
- export {
33
- BaseAPIClient,
34
- {% for app in apps %}
35
- {{ app.class_name }},
36
- {% endfor %}
37
- };
38
-
39
- /**
40
- * Export all default instances for convenience
41
- * These instances use the current origin as base URL
42
- * @exports
43
- */
44
- export {
45
- {% for app in apps %}
46
- {{ app.instance_name }},
47
- {% endfor %}
48
- };
49
-
50
- /**
51
- * Grouped exports by functionality
52
- * Access APIs by app name: apis.tasks, apis.payments, etc.
53
- * @type {Object.<string, BaseAPIClient>}
54
- */
55
- export const apis = {
56
- {% for app in apps %}
57
- {{ app.app_name }}: {{ app.instance_name }},
58
- {% endfor %}
59
- };
60
-
61
- /**
62
- * Helper function to get API by app name
63
- * @param {string} appName - Name of the Django app
64
- * @returns {BaseAPIClient|undefined} API instance for the app
65
- * @example
66
- * const tasksAPI = getAPI('tasks');
67
- */
68
- export function getAPI(appName) {
69
- return apis[appName];
70
- }
71
-
72
- /**
73
- * List of all available apps
74
- * @type {string[]}
75
- */
76
- export const availableApps = [
77
- {% for app in apps %}
78
- '{{ app.app_name }}',
79
- {% endfor %}
80
- ];
@@ -1,24 +0,0 @@
1
- /**
2
- * Type definitions for django-cfg API
3
- * Auto-generated from OpenAPI schema
4
- * @module types
5
- */
6
-
7
- // This file contains JSDoc type definitions generated from the OpenAPI schema
8
- // These types can be used for better IDE support and documentation
9
-
10
- {% for typedef in typedefs %}
11
- /**
12
- * @typedef {{ '{Object}' }} {{ typedef.name }}
13
- {%- if typedef.description %}
14
- * @description {{ typedef.description }}
15
- {%- endif %}
16
- {%- for prop in typedef.properties %}
17
- * @property {{ '{' }}{{ prop.type }}{{ '}' }} {% if not prop.required %}[{% endif %}{{ prop.name }}{% if not prop.required %}]{% endif %}{% if prop.description %} - {{ prop.description }}{% endif %}
18
- {%- endfor %}
19
- */
20
-
21
- {% endfor %}
22
-
23
- // Export empty object to make this a module
24
- export {};
@@ -1,29 +0,0 @@
1
- """
2
- Django-CFG Task Service Module.
3
-
4
- Simplified task service for Dramatiq integration with essential functionality.
5
- """
6
-
7
- from .factory import (
8
- get_task_health,
9
- get_task_service,
10
- initialize_task_system,
11
- is_task_system_available,
12
- reset_task_service,
13
- )
14
- from .service import DjangoTasks
15
- from .settings import (
16
- extend_constance_config_with_tasks,
17
- generate_dramatiq_settings_from_config,
18
- )
19
-
20
- __all__ = [
21
- "DjangoTasks",
22
- "get_task_service",
23
- "reset_task_service",
24
- "is_task_system_available",
25
- "get_task_health",
26
- "generate_dramatiq_settings_from_config",
27
- "extend_constance_config_with_tasks",
28
- "initialize_task_system",
29
- ]
@@ -1,20 +0,0 @@
1
- """
2
- Dramatiq broker module for django-cfg CLI integration.
3
-
4
- This module provides the broker instance required by Dramatiq CLI.
5
- It's a thin wrapper around django_dramatiq.setup with broker export.
6
-
7
- Usage:
8
- dramatiq django_cfg.modules.dramatiq_setup [task_modules...]
9
- """
10
-
11
- # CRITICAL: Initialize Django BEFORE any model imports in worker processes
12
- import django
13
-
14
- # Initialize Django app registry (DJANGO_SETTINGS_MODULE must be set by caller)
15
- django.setup()
16
-
17
- # Re-export the broker for Dramatiq CLI
18
- import dramatiq
19
-
20
- broker = dramatiq.get_broker()