django-cfg 1.4.108__py3-none-any.whl → 1.4.110__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.
- django_cfg/__init__.py +1 -1
- django_cfg/modules/django_admin/__init__.py +6 -0
- django_cfg/modules/django_admin/base/pydantic_admin.py +91 -0
- django_cfg/modules/django_admin/config/__init__.py +5 -0
- django_cfg/modules/django_admin/config/admin_config.py +7 -0
- django_cfg/modules/django_admin/config/documentation_config.py +406 -0
- django_cfg/modules/django_admin/config/field_config.py +87 -0
- django_cfg/modules/django_admin/templates/django_admin/change_form_docs.html +23 -0
- django_cfg/modules/django_admin/templates/django_admin/change_list_docs.html +23 -0
- django_cfg/modules/django_admin/templates/django_admin/documentation_block.html +297 -0
- django_cfg/modules/django_admin/templates/django_admin/markdown_docs_block.html +37 -0
- django_cfg/modules/django_admin/utils/__init__.py +3 -0
- django_cfg/modules/django_admin/utils/html_builder.py +94 -1
- django_cfg/modules/django_admin/utils/markdown_renderer.py +344 -0
- django_cfg/pyproject.toml +2 -2
- django_cfg/static/frontend/admin.zip +0 -0
- {django_cfg-1.4.108.dist-info → django_cfg-1.4.110.dist-info}/METADATA +2 -1
- {django_cfg-1.4.108.dist-info → django_cfg-1.4.110.dist-info}/RECORD +21 -28
- django_cfg/modules/django_admin/CHANGELOG_CODE_METHODS.md +0 -153
- django_cfg/modules/django_admin/IMPORT_EXPORT_FIX.md +0 -72
- django_cfg/modules/django_admin/RESOURCE_CONFIG_ENHANCEMENT.md +0 -350
- django_cfg/modules/django_client/system/__init__.py +0 -24
- django_cfg/modules/django_client/system/base_generator.py +0 -123
- django_cfg/modules/django_client/system/generate_mjs_clients.py +0 -176
- django_cfg/modules/django_client/system/mjs_generator.py +0 -219
- django_cfg/modules/django_client/system/schema_parser.py +0 -199
- django_cfg/modules/django_client/system/templates/api_client.js.j2 +0 -87
- django_cfg/modules/django_client/system/templates/app_index.js.j2 +0 -13
- django_cfg/modules/django_client/system/templates/base_client.js.j2 +0 -166
- django_cfg/modules/django_client/system/templates/main_index.js.j2 +0 -80
- django_cfg/modules/django_client/system/templates/types.js.j2 +0 -24
- {django_cfg-1.4.108.dist-info → django_cfg-1.4.110.dist-info}/WHEEL +0 -0
- {django_cfg-1.4.108.dist-info → django_cfg-1.4.110.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.4.108.dist-info → django_cfg-1.4.110.dist-info}/licenses/LICENSE +0 -0
|
@@ -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 {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|