@djangocfg/api 1.2.7 → 1.2.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "author": {
5
5
  "name": "DjangoCFG",
6
6
  "url": "https://djangocfg.com"
@@ -68,7 +68,7 @@
68
68
  "@types/node": "^22.15.3",
69
69
  "@types/react": "19.2.2",
70
70
  "@types/react-dom": "19.2.1",
71
- "@djangocfg/typescript-config": "^1.2.7",
71
+ "@djangocfg/typescript-config": "^1.2.8",
72
72
  "react": "^19.1.0",
73
73
  "react-dom": "^19.1.0",
74
74
  "tsup": "^8.5.0",
@@ -29,6 +29,8 @@
29
29
  * const users = await getUsers({ page: 1 }, api)
30
30
  * ```
31
31
  */
32
+ import { CommandExecuteRequestRequestSchema, type CommandExecuteRequestRequest } from '../schemas/CommandExecuteRequestRequest.schema'
33
+ import { CommandHelpResponseSchema, type CommandHelpResponse } from '../schemas/CommandHelpResponse.schema'
32
34
  import { CommandsSummarySchema, type CommandsSummary } from '../schemas/CommandsSummary.schema'
33
35
  import { getAPIInstance } from '../../api-instance'
34
36
 
@@ -46,6 +48,34 @@ export async function getDashboardApiCommandsList( client?: any
46
48
  }
47
49
 
48
50
 
51
+ /**
52
+ * Get command help
53
+ *
54
+ * @method GET
55
+ * @path /cfg/dashboard/api/commands/{id}/help/
56
+ */
57
+ export async function getDashboardApiCommandsHelpRetrieve( id: string, client?: any
58
+ ): Promise<CommandHelpResponse> {
59
+ const api = client || getAPIInstance()
60
+ const response = await api.cfg_dashboard_commands.dashboardApiCommandsHelpRetrieve(id)
61
+ return CommandHelpResponseSchema.parse(response)
62
+ }
63
+
64
+
65
+ /**
66
+ * Execute command
67
+ *
68
+ * @method POST
69
+ * @path /cfg/dashboard/api/commands/execute/
70
+ */
71
+ export async function createDashboardApiCommandsExecuteCreate( data: CommandExecuteRequestRequest, client?: any
72
+ ): Promise<any> {
73
+ const api = client || getAPIInstance()
74
+ const response = await api.cfg_dashboard_commands.dashboardApiCommandsExecuteCreate(data)
75
+ return response
76
+ }
77
+
78
+
49
79
  /**
50
80
  * Get commands summary
51
81
  *
@@ -18,6 +18,8 @@ import useSWR from 'swr'
18
18
  import { useSWRConfig } from 'swr'
19
19
  import * as Fetchers from '../fetchers/cfg__dashboard__dashboard_commands'
20
20
  import type { API } from '../../index'
21
+ import type { CommandExecuteRequestRequest } from '../schemas/CommandExecuteRequestRequest.schema'
22
+ import type { CommandHelpResponse } from '../schemas/CommandHelpResponse.schema'
21
23
  import type { CommandsSummary } from '../schemas/CommandsSummary.schema'
22
24
 
23
25
  /**
@@ -34,6 +36,38 @@ export function useDashboardApiCommandsList(client?: API): ReturnType<typeof use
34
36
  }
35
37
 
36
38
 
39
+ /**
40
+ * Get command help
41
+ *
42
+ * @method GET
43
+ * @path /cfg/dashboard/api/commands/{id}/help/
44
+ */
45
+ export function useDashboardApiCommandsHelpRetrieve(id: string, client?: API): ReturnType<typeof useSWR<CommandHelpResponse>> {
46
+ return useSWR<CommandHelpResponse>(
47
+ ['cfg-dashboard-api-commands-help', id],
48
+ () => Fetchers.getDashboardApiCommandsHelpRetrieve(id, client)
49
+ )
50
+ }
51
+
52
+
53
+ /**
54
+ * Execute command
55
+ *
56
+ * @method POST
57
+ * @path /cfg/dashboard/api/commands/execute/
58
+ */
59
+ export function useCreateDashboardApiCommandsExecuteCreate() {
60
+ const { mutate } = useSWRConfig()
61
+
62
+ return async (data: CommandExecuteRequestRequest, client?: API): Promise<any> => {
63
+ const result = await Fetchers.createDashboardApiCommandsExecuteCreate(data, client)
64
+ // Revalidate related queries
65
+ mutate('cfg-dashboard-api-commands-execute')
66
+ return result
67
+ }
68
+ }
69
+
70
+
37
71
  /**
38
72
  * Get commands summary
39
73
  *
@@ -15,6 +15,8 @@ export const CommandSchema = z.object({
15
15
  help: z.string(),
16
16
  is_core: z.boolean(),
17
17
  is_custom: z.boolean(),
18
+ is_allowed: z.boolean().optional(),
19
+ risk_level: z.string().optional(),
18
20
  })
19
21
 
20
22
  /**
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Zod schema for CommandExecuteRequestRequest
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Request serializer for command execution.
6
+ * */
7
+ import { z } from 'zod'
8
+
9
+ /**
10
+ * Request serializer for command execution.
11
+ */
12
+ export const CommandExecuteRequestRequestSchema = z.object({
13
+ command: z.string().min(1),
14
+ args: z.array(z.string().min(1)).optional(),
15
+ options: z.record(z.string(), z.any()).optional(),
16
+ })
17
+
18
+ /**
19
+ * Infer TypeScript type from Zod schema
20
+ */
21
+ export type CommandExecuteRequestRequest = z.infer<typeof CommandExecuteRequestRequestSchema>
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Zod schema for CommandHelpResponse
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Response serializer for command help.
6
+ * */
7
+ import { z } from 'zod'
8
+
9
+ /**
10
+ * Response serializer for command help.
11
+ */
12
+ export const CommandHelpResponseSchema = z.object({
13
+ status: z.string(),
14
+ command: z.string(),
15
+ app: z.string().optional(),
16
+ help_text: z.string().optional(),
17
+ is_allowed: z.boolean().optional(),
18
+ risk_level: z.string().optional(),
19
+ error: z.string().optional(),
20
+ })
21
+
22
+ /**
23
+ * Infer TypeScript type from Zod schema
24
+ */
25
+ export type CommandHelpResponse = z.infer<typeof CommandHelpResponseSchema>
@@ -74,6 +74,8 @@ export * from './ChatSource.schema'
74
74
  export * from './ChatSourceRequest.schema'
75
75
  export * from './ChunkRevectorizationRequestRequest.schema'
76
76
  export * from './Command.schema'
77
+ export * from './CommandExecuteRequestRequest.schema'
78
+ export * from './CommandHelpResponse.schema'
77
79
  export * from './CommandsSummary.schema'
78
80
  export * from './ConnectionTokenRequestRequest.schema'
79
81
  export * from './ConnectionTokenResponse.schema'
@@ -21,6 +21,27 @@ export class CfgDashboardCommands {
21
21
  return response;
22
22
  }
23
23
 
24
+ /**
25
+ * Get command help
26
+ *
27
+ * Get detailed help text for a specific Django management command
28
+ */
29
+ async dashboardApiCommandsHelpRetrieve(id: string): Promise<Models.CommandHelpResponse> {
30
+ const response = await this.client.request('GET', `/cfg/dashboard/api/commands/${id}/help/`);
31
+ return response;
32
+ }
33
+
34
+ /**
35
+ * Execute command
36
+ *
37
+ * Execute a Django management command and stream output in Server-Sent
38
+ * Events format
39
+ */
40
+ async dashboardApiCommandsExecuteCreate(data: Models.CommandExecuteRequestRequest): Promise<any> {
41
+ const response = await this.client.request('POST', "/cfg/dashboard/api/commands/execute/", { body: data });
42
+ return response;
43
+ }
44
+
24
45
  /**
25
46
  * Get commands summary
26
47
  *
@@ -1,3 +1,32 @@
1
+ /**
2
+ * Response serializer for command help.
3
+ *
4
+ * Response model (includes read-only fields).
5
+ */
6
+ export interface CommandHelpResponse {
7
+ status: string;
8
+ command: string;
9
+ app?: string;
10
+ help_text?: string;
11
+ is_allowed?: boolean;
12
+ risk_level?: string;
13
+ error?: string;
14
+ }
15
+
16
+ /**
17
+ * Request serializer for command execution.
18
+ *
19
+ * Request model (no read-only fields).
20
+ */
21
+ export interface CommandExecuteRequestRequest {
22
+ /** Name of the Django management command */
23
+ command: string;
24
+ /** Positional arguments for the command */
25
+ args?: Array<string>;
26
+ /** Named options for the command (e.g., {'verbosity': '2'}) */
27
+ options?: Record<string, any>;
28
+ }
29
+
1
30
  /**
2
31
  * Commands summary serializer.
3
32
  *
@@ -23,5 +52,7 @@ export interface Command {
23
52
  help: string;
24
53
  is_core: boolean;
25
54
  is_custom: boolean;
55
+ is_allowed?: boolean;
56
+ risk_level?: string;
26
57
  }
27
58
 
@@ -2218,6 +2218,9 @@ export const OPENAPI_SCHEMA = {
2218
2218
  "help": {
2219
2219
  "type": "string"
2220
2220
  },
2221
+ "is_allowed": {
2222
+ "type": "boolean"
2223
+ },
2221
2224
  "is_core": {
2222
2225
  "type": "boolean"
2223
2226
  },
@@ -2226,6 +2229,9 @@ export const OPENAPI_SCHEMA = {
2226
2229
  },
2227
2230
  "name": {
2228
2231
  "type": "string"
2232
+ },
2233
+ "risk_level": {
2234
+ "type": "string"
2229
2235
  }
2230
2236
  },
2231
2237
  "required": [
@@ -2237,6 +2243,64 @@ export const OPENAPI_SCHEMA = {
2237
2243
  ],
2238
2244
  "type": "object"
2239
2245
  },
2246
+ "CommandExecuteRequestRequest": {
2247
+ "description": "Request serializer for command execution.",
2248
+ "properties": {
2249
+ "args": {
2250
+ "description": "Positional arguments for the command",
2251
+ "items": {
2252
+ "minLength": 1,
2253
+ "type": "string"
2254
+ },
2255
+ "type": "array"
2256
+ },
2257
+ "command": {
2258
+ "description": "Name of the Django management command",
2259
+ "minLength": 1,
2260
+ "type": "string"
2261
+ },
2262
+ "options": {
2263
+ "additionalProperties": {},
2264
+ "description": "Named options for the command (e.g., {\u0027verbosity\u0027: \u00272\u0027})",
2265
+ "type": "object"
2266
+ }
2267
+ },
2268
+ "required": [
2269
+ "command"
2270
+ ],
2271
+ "type": "object"
2272
+ },
2273
+ "CommandHelpResponse": {
2274
+ "description": "Response serializer for command help.",
2275
+ "properties": {
2276
+ "app": {
2277
+ "type": "string"
2278
+ },
2279
+ "command": {
2280
+ "type": "string"
2281
+ },
2282
+ "error": {
2283
+ "type": "string"
2284
+ },
2285
+ "help_text": {
2286
+ "type": "string"
2287
+ },
2288
+ "is_allowed": {
2289
+ "type": "boolean"
2290
+ },
2291
+ "risk_level": {
2292
+ "type": "string"
2293
+ },
2294
+ "status": {
2295
+ "type": "string"
2296
+ }
2297
+ },
2298
+ "required": [
2299
+ "command",
2300
+ "status"
2301
+ ],
2302
+ "type": "object"
2303
+ },
2240
2304
  "CommandsSummary": {
2241
2305
  "description": "Commands summary serializer.",
2242
2306
  "properties": {
@@ -9933,6 +9997,9 @@ export const OPENAPI_SCHEMA = {
9933
9997
  }
9934
9998
  },
9935
9999
  "security": [
10000
+ {
10001
+ "jwtAuth": []
10002
+ },
9936
10003
  {
9937
10004
  "cookieAuth": []
9938
10005
  },
@@ -9947,6 +10014,80 @@ export const OPENAPI_SCHEMA = {
9947
10014
  "x-async-capable": false
9948
10015
  }
9949
10016
  },
10017
+ "/cfg/dashboard/api/commands/execute/": {
10018
+ "post": {
10019
+ "description": "Execute a Django management command and stream output in Server-Sent Events format",
10020
+ "operationId": "cfg_dashboard_api_commands_execute_create",
10021
+ "requestBody": {
10022
+ "content": {
10023
+ "application/json": {
10024
+ "schema": {
10025
+ "$ref": "#/components/schemas/CommandExecuteRequestRequest"
10026
+ }
10027
+ },
10028
+ "application/x-www-form-urlencoded": {
10029
+ "schema": {
10030
+ "$ref": "#/components/schemas/CommandExecuteRequestRequest"
10031
+ }
10032
+ },
10033
+ "multipart/form-data": {
10034
+ "schema": {
10035
+ "$ref": "#/components/schemas/CommandExecuteRequestRequest"
10036
+ }
10037
+ }
10038
+ },
10039
+ "required": true
10040
+ },
10041
+ "responses": {
10042
+ "200": {
10043
+ "content": {
10044
+ "application/json": {
10045
+ "schema": {
10046
+ "description": "Command execution started (SSE stream)"
10047
+ }
10048
+ }
10049
+ },
10050
+ "description": ""
10051
+ },
10052
+ "400": {
10053
+ "content": {
10054
+ "application/json": {
10055
+ "schema": {
10056
+ "description": "Invalid request"
10057
+ }
10058
+ }
10059
+ },
10060
+ "description": ""
10061
+ },
10062
+ "403": {
10063
+ "content": {
10064
+ "application/json": {
10065
+ "schema": {
10066
+ "description": "Command not allowed"
10067
+ }
10068
+ }
10069
+ },
10070
+ "description": ""
10071
+ }
10072
+ },
10073
+ "security": [
10074
+ {
10075
+ "jwtAuth": []
10076
+ },
10077
+ {
10078
+ "cookieAuth": []
10079
+ },
10080
+ {
10081
+ "basicAuth": []
10082
+ }
10083
+ ],
10084
+ "summary": "Execute command",
10085
+ "tags": [
10086
+ "Dashboard - Commands"
10087
+ ],
10088
+ "x-async-capable": false
10089
+ }
10090
+ },
9950
10091
  "/cfg/dashboard/api/commands/summary/": {
9951
10092
  "get": {
9952
10093
  "description": "Retrieve commands summary with statistics and categorization",
@@ -9964,6 +10105,9 @@ export const OPENAPI_SCHEMA = {
9964
10105
  }
9965
10106
  },
9966
10107
  "security": [
10108
+ {
10109
+ "jwtAuth": []
10110
+ },
9967
10111
  {
9968
10112
  "cookieAuth": []
9969
10113
  },
@@ -9978,6 +10122,50 @@ export const OPENAPI_SCHEMA = {
9978
10122
  "x-async-capable": false
9979
10123
  }
9980
10124
  },
10125
+ "/cfg/dashboard/api/commands/{id}/help/": {
10126
+ "get": {
10127
+ "description": "Get detailed help text for a specific Django management command",
10128
+ "operationId": "cfg_dashboard_api_commands_help_retrieve",
10129
+ "parameters": [
10130
+ {
10131
+ "in": "path",
10132
+ "name": "id",
10133
+ "required": true,
10134
+ "schema": {
10135
+ "type": "string"
10136
+ }
10137
+ }
10138
+ ],
10139
+ "responses": {
10140
+ "200": {
10141
+ "content": {
10142
+ "application/json": {
10143
+ "schema": {
10144
+ "$ref": "#/components/schemas/CommandHelpResponse"
10145
+ }
10146
+ }
10147
+ },
10148
+ "description": ""
10149
+ }
10150
+ },
10151
+ "security": [
10152
+ {
10153
+ "jwtAuth": []
10154
+ },
10155
+ {
10156
+ "cookieAuth": []
10157
+ },
10158
+ {
10159
+ "basicAuth": []
10160
+ }
10161
+ ],
10162
+ "summary": "Get command help",
10163
+ "tags": [
10164
+ "Dashboard - Commands"
10165
+ ],
10166
+ "x-async-capable": false
10167
+ }
10168
+ },
9981
10169
  "/cfg/dashboard/api/overview/overview/": {
9982
10170
  "get": {
9983
10171
  "description": "Retrieve complete dashboard data including stats, health, actions, and metrics",