@statezero/core 0.2.22 → 0.2.23
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/dist/actions/backend1/django_app/calculate-hash.d.ts +57 -0
- package/dist/actions/backend1/django_app/calculate-hash.js +80 -0
- package/dist/actions/backend1/django_app/calculate-hash.schema.json +148 -0
- package/dist/actions/backend1/django_app/get-current-username.d.ts +29 -0
- package/dist/actions/backend1/django_app/get-current-username.js +65 -0
- package/dist/actions/backend1/django_app/get-current-username.schema.json +47 -0
- package/dist/actions/backend1/django_app/get-server-status.d.ts +38 -0
- package/dist/actions/backend1/django_app/get-server-status.js +68 -0
- package/dist/actions/backend1/django_app/get-server-status.schema.json +93 -0
- package/dist/actions/backend1/django_app/get-user-info.d.ts +44 -0
- package/dist/actions/backend1/django_app/get-user-info.js +70 -0
- package/dist/actions/backend1/django_app/get-user-info.schema.json +127 -0
- package/dist/actions/backend1/django_app/index.d.ts +1 -0
- package/dist/actions/backend1/django_app/index.js +6 -0
- package/dist/actions/backend1/django_app/process-data.d.ts +51 -0
- package/dist/actions/backend1/django_app/process-data.js +78 -0
- package/dist/actions/backend1/django_app/process-data.schema.json +117 -0
- package/dist/actions/backend1/django_app/send-notification.d.ts +55 -0
- package/dist/actions/backend1/django_app/send-notification.js +81 -0
- package/dist/actions/backend1/django_app/send-notification.schema.json +175 -0
- package/dist/actions/backend1/index.d.ts +1 -0
- package/dist/actions/backend1/index.js +1 -0
- package/dist/actions/default/django_app/calculate-hash.d.ts +57 -0
- package/dist/actions/default/django_app/calculate-hash.js +80 -0
- package/dist/actions/default/django_app/calculate-hash.schema.json +148 -0
- package/dist/actions/default/django_app/get-current-username.d.ts +29 -0
- package/dist/actions/default/django_app/get-current-username.js +65 -0
- package/dist/actions/default/django_app/get-current-username.schema.json +47 -0
- package/dist/actions/default/django_app/get-server-status.d.ts +38 -0
- package/dist/actions/default/django_app/get-server-status.js +68 -0
- package/dist/actions/default/django_app/get-server-status.schema.json +93 -0
- package/dist/actions/default/django_app/get-user-info.d.ts +44 -0
- package/dist/actions/default/django_app/get-user-info.js +70 -0
- package/dist/actions/default/django_app/get-user-info.schema.json +127 -0
- package/dist/actions/default/django_app/index.d.ts +1 -0
- package/dist/actions/default/django_app/index.js +6 -0
- package/dist/actions/default/django_app/process-data.d.ts +51 -0
- package/dist/actions/default/django_app/process-data.js +78 -0
- package/dist/actions/default/django_app/process-data.schema.json +117 -0
- package/dist/actions/default/django_app/send-notification.d.ts +55 -0
- package/dist/actions/default/django_app/send-notification.js +81 -0
- package/dist/actions/default/django_app/send-notification.schema.json +175 -0
- package/dist/actions/default/index.d.ts +1 -0
- package/dist/actions/default/index.js +1 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +5 -0
- package/dist/flavours/django/dates.js +4 -1
- package/dist/flavours/django/serializers.js +8 -4
- package/dist/models/backend1/django_app/comprehensivemodel.d.ts +894 -0
- package/dist/models/backend1/django_app/comprehensivemodel.js +71 -0
- package/dist/models/backend1/django_app/comprehensivemodel.schema.json +870 -0
- package/dist/models/backend1/django_app/custompkmodel.d.ts +92 -0
- package/dist/models/backend1/django_app/custompkmodel.js +69 -0
- package/dist/models/backend1/django_app/custompkmodel.schema.json +71 -0
- package/dist/models/backend1/django_app/dailyrate.d.ts +230 -0
- package/dist/models/backend1/django_app/dailyrate.js +71 -0
- package/dist/models/backend1/django_app/dailyrate.schema.json +212 -0
- package/dist/models/backend1/django_app/deepmodellevel1.d.ts +140 -0
- package/dist/models/backend1/django_app/deepmodellevel1.js +72 -0
- package/dist/models/backend1/django_app/deepmodellevel1.schema.json +114 -0
- package/dist/models/backend1/django_app/deepmodellevel2.d.ts +118 -0
- package/dist/models/backend1/django_app/deepmodellevel2.js +71 -0
- package/dist/models/backend1/django_app/deepmodellevel2.schema.json +92 -0
- package/dist/models/backend1/django_app/deepmodellevel3.d.ts +92 -0
- package/dist/models/backend1/django_app/deepmodellevel3.js +69 -0
- package/dist/models/backend1/django_app/deepmodellevel3.schema.json +69 -0
- package/dist/models/backend1/django_app/dummymodel.d.ts +134 -0
- package/dist/models/backend1/django_app/dummymodel.js +71 -0
- package/dist/models/backend1/django_app/dummymodel.schema.json +109 -0
- package/dist/models/backend1/django_app/dummyrelatedmodel.d.ts +92 -0
- package/dist/models/backend1/django_app/dummyrelatedmodel.js +69 -0
- package/dist/models/backend1/django_app/dummyrelatedmodel.schema.json +69 -0
- package/dist/models/backend1/django_app/filetest.d.ts +140 -0
- package/dist/models/backend1/django_app/filetest.js +69 -0
- package/dist/models/backend1/django_app/filetest.schema.json +111 -0
- package/dist/models/backend1/django_app/index.d.ts +1 -0
- package/dist/models/backend1/django_app/index.js +18 -0
- package/dist/models/backend1/django_app/modelwithcustompkrelation.d.ts +118 -0
- package/dist/models/backend1/django_app/modelwithcustompkrelation.js +71 -0
- package/dist/models/backend1/django_app/modelwithcustompkrelation.schema.json +93 -0
- package/dist/models/backend1/django_app/modelwithrestrictedfields.d.ts +134 -0
- package/dist/models/backend1/django_app/modelwithrestrictedfields.js +71 -0
- package/dist/models/backend1/django_app/modelwithrestrictedfields.schema.json +111 -0
- package/dist/models/backend1/django_app/namefiltercustompkmodel.d.ts +92 -0
- package/dist/models/backend1/django_app/namefiltercustompkmodel.js +69 -0
- package/dist/models/backend1/django_app/namefiltercustompkmodel.schema.json +71 -0
- package/dist/models/backend1/django_app/order.d.ts +220 -0
- package/dist/models/backend1/django_app/order.js +71 -0
- package/dist/models/backend1/django_app/order.schema.json +203 -0
- package/dist/models/backend1/django_app/orderitem.d.ts +172 -0
- package/dist/models/backend1/django_app/orderitem.js +72 -0
- package/dist/models/backend1/django_app/orderitem.schema.json +149 -0
- package/dist/models/backend1/django_app/product.d.ts +254 -0
- package/dist/models/backend1/django_app/product.js +71 -0
- package/dist/models/backend1/django_app/product.schema.json +277 -0
- package/dist/models/backend1/django_app/productcategory.d.ts +92 -0
- package/dist/models/backend1/django_app/productcategory.js +69 -0
- package/dist/models/backend1/django_app/productcategory.schema.json +70 -0
- package/dist/models/backend1/django_app/rateplan.d.ts +92 -0
- package/dist/models/backend1/django_app/rateplan.js +69 -0
- package/dist/models/backend1/django_app/rateplan.schema.json +70 -0
- package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.d.ts +108 -0
- package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.js +69 -0
- package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.schema.json +87 -0
- package/dist/models/backend1/fileobject.d.ts +4 -0
- package/dist/models/backend1/fileobject.js +9 -0
- package/dist/models/backend1/index.d.ts +2 -0
- package/dist/models/backend1/index.js +2 -0
- package/dist/models/default/django_app/comprehensivemodel.d.ts +894 -0
- package/dist/models/default/django_app/comprehensivemodel.js +71 -0
- package/dist/models/default/django_app/comprehensivemodel.schema.json +870 -0
- package/dist/models/default/django_app/custompkmodel.d.ts +92 -0
- package/dist/models/default/django_app/custompkmodel.js +69 -0
- package/dist/models/default/django_app/custompkmodel.schema.json +71 -0
- package/dist/models/default/django_app/dailyrate.d.ts +230 -0
- package/dist/models/default/django_app/dailyrate.js +71 -0
- package/dist/models/default/django_app/dailyrate.schema.json +212 -0
- package/dist/models/default/django_app/deepmodellevel1.d.ts +128 -0
- package/dist/models/default/django_app/deepmodellevel1.js +72 -0
- package/dist/models/default/django_app/deepmodellevel1.schema.json +102 -0
- package/dist/models/default/django_app/deepmodellevel2.d.ts +106 -0
- package/dist/models/default/django_app/deepmodellevel2.js +71 -0
- package/dist/models/default/django_app/deepmodellevel2.schema.json +80 -0
- package/dist/models/default/django_app/deepmodellevel3.d.ts +80 -0
- package/dist/models/default/django_app/deepmodellevel3.js +69 -0
- package/dist/models/default/django_app/deepmodellevel3.schema.json +57 -0
- package/dist/models/default/django_app/dummymodel.d.ts +122 -0
- package/dist/models/default/django_app/dummymodel.js +71 -0
- package/dist/models/default/django_app/dummymodel.schema.json +97 -0
- package/dist/models/default/django_app/dummyrelatedmodel.d.ts +80 -0
- package/dist/models/default/django_app/dummyrelatedmodel.js +69 -0
- package/dist/models/default/django_app/dummyrelatedmodel.schema.json +57 -0
- package/dist/models/default/django_app/filetest.d.ts +128 -0
- package/dist/models/default/django_app/filetest.js +69 -0
- package/dist/models/default/django_app/filetest.schema.json +99 -0
- package/dist/models/default/django_app/index.d.ts +1 -0
- package/dist/models/default/django_app/index.js +18 -0
- package/dist/models/default/django_app/modelwithcustompkrelation.d.ts +118 -0
- package/dist/models/default/django_app/modelwithcustompkrelation.js +71 -0
- package/dist/models/default/django_app/modelwithcustompkrelation.schema.json +93 -0
- package/dist/models/default/django_app/modelwithrestrictedfields.d.ts +134 -0
- package/dist/models/default/django_app/modelwithrestrictedfields.js +71 -0
- package/dist/models/default/django_app/modelwithrestrictedfields.schema.json +111 -0
- package/dist/models/default/django_app/namefiltercustompkmodel.d.ts +92 -0
- package/dist/models/default/django_app/namefiltercustompkmodel.js +69 -0
- package/dist/models/default/django_app/namefiltercustompkmodel.schema.json +71 -0
- package/dist/models/default/django_app/order.d.ts +220 -0
- package/dist/models/default/django_app/order.js +71 -0
- package/dist/models/default/django_app/order.schema.json +203 -0
- package/dist/models/default/django_app/orderitem.d.ts +172 -0
- package/dist/models/default/django_app/orderitem.js +72 -0
- package/dist/models/default/django_app/orderitem.schema.json +149 -0
- package/dist/models/default/django_app/product.d.ts +254 -0
- package/dist/models/default/django_app/product.js +71 -0
- package/dist/models/default/django_app/product.schema.json +277 -0
- package/dist/models/default/django_app/productcategory.d.ts +92 -0
- package/dist/models/default/django_app/productcategory.js +69 -0
- package/dist/models/default/django_app/productcategory.schema.json +70 -0
- package/dist/models/default/django_app/rateplan.d.ts +92 -0
- package/dist/models/default/django_app/rateplan.js +69 -0
- package/dist/models/default/django_app/rateplan.schema.json +70 -0
- package/dist/models/default/django_app/restrictedfieldrelatedmodel.d.ts +108 -0
- package/dist/models/default/django_app/restrictedfieldrelatedmodel.js +69 -0
- package/dist/models/default/django_app/restrictedfieldrelatedmodel.schema.json +87 -0
- package/dist/models/default/fileobject.d.ts +4 -0
- package/dist/models/default/fileobject.js +9 -0
- package/dist/models/default/index.d.ts +2 -0
- package/dist/models/default/index.js +2 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
* Action: Get User Info
|
|
4
|
+
* App: django_app
|
|
5
|
+
*/
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { configInstance, parseStateZeroError, serializeActionPayload } from '../../../../src';
|
|
9
|
+
import actionSchema from './get-user-info.schema.json' assert { type: 'json' };
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for the response of getUserInfo.
|
|
12
|
+
*/
|
|
13
|
+
export const getUserInfoResponseSchema = z.object({ username: z.string(),
|
|
14
|
+
email: z.string().email(),
|
|
15
|
+
is_staff: z.boolean(),
|
|
16
|
+
is_superuser: z.boolean(),
|
|
17
|
+
date_joined: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }),
|
|
18
|
+
last_login: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }).nullable(),
|
|
19
|
+
server_time: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }) });
|
|
20
|
+
/**
|
|
21
|
+
* Get current user information (no serializers - simple action)
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
24
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
25
|
+
*/
|
|
26
|
+
export async function getUserInfo(axiosOverrides = {}) {
|
|
27
|
+
// Construct the data payload from the function arguments
|
|
28
|
+
const rawPayload = {};
|
|
29
|
+
// Serialize payload - handles model instances (extracts PK), files, dates, etc.
|
|
30
|
+
const payload = serializeActionPayload(rawPayload, actionSchema.input_properties);
|
|
31
|
+
const config = configInstance.getConfig();
|
|
32
|
+
const backend = config.backendConfigs['backend1'];
|
|
33
|
+
if (!backend) {
|
|
34
|
+
throw new Error(`No backend configuration found for key: backend1`);
|
|
35
|
+
}
|
|
36
|
+
const baseUrl = backend.API_URL.replace(/\/+$/, '');
|
|
37
|
+
const actionUrl = `${baseUrl}/actions/get_user_info/`;
|
|
38
|
+
const headers = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
|
|
39
|
+
try {
|
|
40
|
+
const response = await axios.post(actionUrl, payload, {
|
|
41
|
+
headers: { 'Content-Type': 'application/json', ...headers },
|
|
42
|
+
...axiosOverrides,
|
|
43
|
+
});
|
|
44
|
+
return getUserInfoResponseSchema.parse(response.data);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof z.ZodError) {
|
|
48
|
+
throw new Error(`Get User Info failed: Invalid response from server. Details: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
if (error.response && error.response.data) {
|
|
51
|
+
const parsedError = parseStateZeroError(error.response.data);
|
|
52
|
+
if (Error.captureStackTrace) {
|
|
53
|
+
Error.captureStackTrace(parsedError, getUserInfo);
|
|
54
|
+
}
|
|
55
|
+
throw parsedError;
|
|
56
|
+
}
|
|
57
|
+
else if (error.request) {
|
|
58
|
+
throw new Error(`Get User Info failed: No response received from server.`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error(`Get User Info failed: ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export default getUserInfo;
|
|
66
|
+
getUserInfo.actionName = 'get_user_info';
|
|
67
|
+
getUserInfo.title = 'Get User Info';
|
|
68
|
+
getUserInfo.app = 'django_app';
|
|
69
|
+
getUserInfo.permissions = ['IsAuthenticated'];
|
|
70
|
+
getUserInfo.configKey = 'backend1';
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action_name": "get_user_info",
|
|
3
|
+
"app": "django_app",
|
|
4
|
+
"title": "Get User Info",
|
|
5
|
+
"docstring": "Get current user information (no serializers - simple action)",
|
|
6
|
+
"class_name": "GetUserInfo",
|
|
7
|
+
"input_properties": {},
|
|
8
|
+
"response_properties": {
|
|
9
|
+
"username": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"title": "Username",
|
|
12
|
+
"required": true,
|
|
13
|
+
"description": null,
|
|
14
|
+
"nullable": false,
|
|
15
|
+
"format": null,
|
|
16
|
+
"max_length": null,
|
|
17
|
+
"choices": null,
|
|
18
|
+
"default": null,
|
|
19
|
+
"validators": [],
|
|
20
|
+
"max_digits": null,
|
|
21
|
+
"decimal_places": null,
|
|
22
|
+
"read_only": false,
|
|
23
|
+
"ref": null
|
|
24
|
+
},
|
|
25
|
+
"email": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"title": "Email",
|
|
28
|
+
"required": true,
|
|
29
|
+
"description": null,
|
|
30
|
+
"nullable": false,
|
|
31
|
+
"format": "email",
|
|
32
|
+
"max_length": null,
|
|
33
|
+
"choices": null,
|
|
34
|
+
"default": null,
|
|
35
|
+
"validators": [],
|
|
36
|
+
"max_digits": null,
|
|
37
|
+
"decimal_places": null,
|
|
38
|
+
"read_only": false,
|
|
39
|
+
"ref": null
|
|
40
|
+
},
|
|
41
|
+
"is_staff": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"title": "Is staff",
|
|
44
|
+
"required": true,
|
|
45
|
+
"description": null,
|
|
46
|
+
"nullable": false,
|
|
47
|
+
"format": null,
|
|
48
|
+
"max_length": null,
|
|
49
|
+
"choices": null,
|
|
50
|
+
"default": null,
|
|
51
|
+
"validators": [],
|
|
52
|
+
"max_digits": null,
|
|
53
|
+
"decimal_places": null,
|
|
54
|
+
"read_only": false,
|
|
55
|
+
"ref": null
|
|
56
|
+
},
|
|
57
|
+
"is_superuser": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"title": "Is superuser",
|
|
60
|
+
"required": true,
|
|
61
|
+
"description": null,
|
|
62
|
+
"nullable": false,
|
|
63
|
+
"format": null,
|
|
64
|
+
"max_length": null,
|
|
65
|
+
"choices": null,
|
|
66
|
+
"default": null,
|
|
67
|
+
"validators": [],
|
|
68
|
+
"max_digits": null,
|
|
69
|
+
"decimal_places": null,
|
|
70
|
+
"read_only": false,
|
|
71
|
+
"ref": null
|
|
72
|
+
},
|
|
73
|
+
"date_joined": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"title": "Date joined",
|
|
76
|
+
"required": true,
|
|
77
|
+
"description": null,
|
|
78
|
+
"nullable": false,
|
|
79
|
+
"format": "date-time",
|
|
80
|
+
"max_length": null,
|
|
81
|
+
"choices": null,
|
|
82
|
+
"default": null,
|
|
83
|
+
"validators": [],
|
|
84
|
+
"max_digits": null,
|
|
85
|
+
"decimal_places": null,
|
|
86
|
+
"read_only": false,
|
|
87
|
+
"ref": null
|
|
88
|
+
},
|
|
89
|
+
"last_login": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"title": "Last login",
|
|
92
|
+
"required": true,
|
|
93
|
+
"description": null,
|
|
94
|
+
"nullable": true,
|
|
95
|
+
"format": "date-time",
|
|
96
|
+
"max_length": null,
|
|
97
|
+
"choices": null,
|
|
98
|
+
"default": null,
|
|
99
|
+
"validators": [],
|
|
100
|
+
"max_digits": null,
|
|
101
|
+
"decimal_places": null,
|
|
102
|
+
"read_only": false,
|
|
103
|
+
"ref": null
|
|
104
|
+
},
|
|
105
|
+
"server_time": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"title": "Server time",
|
|
108
|
+
"required": true,
|
|
109
|
+
"description": null,
|
|
110
|
+
"nullable": false,
|
|
111
|
+
"format": "date-time",
|
|
112
|
+
"max_length": null,
|
|
113
|
+
"choices": null,
|
|
114
|
+
"default": null,
|
|
115
|
+
"validators": [],
|
|
116
|
+
"max_digits": null,
|
|
117
|
+
"decimal_places": null,
|
|
118
|
+
"read_only": false,
|
|
119
|
+
"ref": null
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"relationships": {},
|
|
123
|
+
"permissions": [
|
|
124
|
+
"IsAuthenticated"
|
|
125
|
+
],
|
|
126
|
+
"display": null
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process a list of numbers with various mathematical operations
|
|
3
|
+
*
|
|
4
|
+
* @param any[] data - List of numbers to process
|
|
5
|
+
* @param 'sum' | 'avg' | 'max' | 'min' operation - Mathematical operation to perform
|
|
6
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
7
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
8
|
+
*/
|
|
9
|
+
export function processData(data: any, operation: any, axiosOverrides?: Object): Promise<Object>;
|
|
10
|
+
export namespace processData {
|
|
11
|
+
let actionName: string;
|
|
12
|
+
let title: string;
|
|
13
|
+
let app: string;
|
|
14
|
+
let permissions: string[];
|
|
15
|
+
let configKey: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for the input of processData.
|
|
19
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
20
|
+
*/
|
|
21
|
+
export const processDataInputSchema: z.ZodObject<{
|
|
22
|
+
data: z.ZodArray<z.ZodAny, "many">;
|
|
23
|
+
operation: z.ZodEnum<["sum", "avg", "max", "min"]>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
data: any[];
|
|
26
|
+
operation: "min" | "max" | "avg" | "sum";
|
|
27
|
+
}, {
|
|
28
|
+
data: any[];
|
|
29
|
+
operation: "min" | "max" | "avg" | "sum";
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Zod schema for the response of processData.
|
|
33
|
+
*/
|
|
34
|
+
export const processDataResponseSchema: z.ZodObject<{
|
|
35
|
+
operation: z.ZodString;
|
|
36
|
+
result: z.ZodNumber;
|
|
37
|
+
processed_count: z.ZodNumber;
|
|
38
|
+
execution_time_ms: z.ZodNumber;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
operation: string;
|
|
41
|
+
result: number;
|
|
42
|
+
processed_count: number;
|
|
43
|
+
execution_time_ms: number;
|
|
44
|
+
}, {
|
|
45
|
+
operation: string;
|
|
46
|
+
result: number;
|
|
47
|
+
processed_count: number;
|
|
48
|
+
execution_time_ms: number;
|
|
49
|
+
}>;
|
|
50
|
+
export default processData;
|
|
51
|
+
import { z } from 'zod';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
* Action: Process Data
|
|
4
|
+
* App: django_app
|
|
5
|
+
*/
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { configInstance, parseStateZeroError, serializeActionPayload } from '../../../../src';
|
|
9
|
+
import actionSchema from './process-data.schema.json' assert { type: 'json' };
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for the input of processData.
|
|
12
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
13
|
+
*/
|
|
14
|
+
export const processDataInputSchema = z.object({ data: z.array(z.any()),
|
|
15
|
+
operation: z.enum(["sum", "avg", "max", "min"]) });
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema for the response of processData.
|
|
18
|
+
*/
|
|
19
|
+
export const processDataResponseSchema = z.object({ operation: z.string(),
|
|
20
|
+
result: z.number(),
|
|
21
|
+
processed_count: z.number().int(),
|
|
22
|
+
execution_time_ms: z.number().int() });
|
|
23
|
+
/**
|
|
24
|
+
* Process a list of numbers with various mathematical operations
|
|
25
|
+
*
|
|
26
|
+
* @param any[] data - List of numbers to process
|
|
27
|
+
* @param 'sum' | 'avg' | 'max' | 'min' operation - Mathematical operation to perform
|
|
28
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
29
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
30
|
+
*/
|
|
31
|
+
export async function processData(data, operation, axiosOverrides = {}) {
|
|
32
|
+
// Construct the data payload from the function arguments
|
|
33
|
+
const rawPayload = {
|
|
34
|
+
data,
|
|
35
|
+
operation
|
|
36
|
+
};
|
|
37
|
+
// Serialize payload - handles model instances (extracts PK), files, dates, etc.
|
|
38
|
+
const payload = serializeActionPayload(rawPayload, actionSchema.input_properties);
|
|
39
|
+
const config = configInstance.getConfig();
|
|
40
|
+
const backend = config.backendConfigs['backend1'];
|
|
41
|
+
if (!backend) {
|
|
42
|
+
throw new Error(`No backend configuration found for key: backend1`);
|
|
43
|
+
}
|
|
44
|
+
const baseUrl = backend.API_URL.replace(/\/+$/, '');
|
|
45
|
+
const actionUrl = `${baseUrl}/actions/process_data/`;
|
|
46
|
+
const headers = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
|
|
47
|
+
try {
|
|
48
|
+
const response = await axios.post(actionUrl, payload, {
|
|
49
|
+
headers: { 'Content-Type': 'application/json', ...headers },
|
|
50
|
+
...axiosOverrides,
|
|
51
|
+
});
|
|
52
|
+
return processDataResponseSchema.parse(response.data);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof z.ZodError) {
|
|
56
|
+
throw new Error(`Process Data failed: Invalid response from server. Details: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
if (error.response && error.response.data) {
|
|
59
|
+
const parsedError = parseStateZeroError(error.response.data);
|
|
60
|
+
if (Error.captureStackTrace) {
|
|
61
|
+
Error.captureStackTrace(parsedError, processData);
|
|
62
|
+
}
|
|
63
|
+
throw parsedError;
|
|
64
|
+
}
|
|
65
|
+
else if (error.request) {
|
|
66
|
+
throw new Error(`Process Data failed: No response received from server.`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`Process Data failed: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export default processData;
|
|
74
|
+
processData.actionName = 'process_data';
|
|
75
|
+
processData.title = 'Process Data';
|
|
76
|
+
processData.app = 'django_app';
|
|
77
|
+
processData.permissions = ['HasValidApiKey'];
|
|
78
|
+
processData.configKey = 'backend1';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action_name": "process_data",
|
|
3
|
+
"app": "django_app",
|
|
4
|
+
"title": "Process Data",
|
|
5
|
+
"docstring": "Process a list of numbers with various mathematical operations",
|
|
6
|
+
"class_name": "ProcessData",
|
|
7
|
+
"input_properties": {
|
|
8
|
+
"data": {
|
|
9
|
+
"type": "array",
|
|
10
|
+
"title": "Data",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "List of numbers to process",
|
|
13
|
+
"nullable": false,
|
|
14
|
+
"format": null,
|
|
15
|
+
"max_length": null,
|
|
16
|
+
"choices": null,
|
|
17
|
+
"default": null,
|
|
18
|
+
"validators": [],
|
|
19
|
+
"max_digits": null,
|
|
20
|
+
"decimal_places": null,
|
|
21
|
+
"read_only": false,
|
|
22
|
+
"ref": null
|
|
23
|
+
},
|
|
24
|
+
"operation": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"title": "Operation",
|
|
27
|
+
"required": true,
|
|
28
|
+
"description": "Mathematical operation to perform",
|
|
29
|
+
"nullable": false,
|
|
30
|
+
"format": null,
|
|
31
|
+
"max_length": null,
|
|
32
|
+
"choices": {
|
|
33
|
+
"sum": "Sum",
|
|
34
|
+
"avg": "Average",
|
|
35
|
+
"max": "Maximum",
|
|
36
|
+
"min": "Minimum"
|
|
37
|
+
},
|
|
38
|
+
"default": null,
|
|
39
|
+
"validators": [],
|
|
40
|
+
"max_digits": null,
|
|
41
|
+
"decimal_places": null,
|
|
42
|
+
"read_only": false,
|
|
43
|
+
"ref": null
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"response_properties": {
|
|
47
|
+
"operation": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"title": "Operation",
|
|
50
|
+
"required": true,
|
|
51
|
+
"description": null,
|
|
52
|
+
"nullable": false,
|
|
53
|
+
"format": null,
|
|
54
|
+
"max_length": null,
|
|
55
|
+
"choices": null,
|
|
56
|
+
"default": null,
|
|
57
|
+
"validators": [],
|
|
58
|
+
"max_digits": null,
|
|
59
|
+
"decimal_places": null,
|
|
60
|
+
"read_only": false,
|
|
61
|
+
"ref": null
|
|
62
|
+
},
|
|
63
|
+
"result": {
|
|
64
|
+
"type": "number",
|
|
65
|
+
"title": "Result",
|
|
66
|
+
"required": true,
|
|
67
|
+
"description": null,
|
|
68
|
+
"nullable": false,
|
|
69
|
+
"format": null,
|
|
70
|
+
"max_length": null,
|
|
71
|
+
"choices": null,
|
|
72
|
+
"default": null,
|
|
73
|
+
"validators": [],
|
|
74
|
+
"max_digits": null,
|
|
75
|
+
"decimal_places": null,
|
|
76
|
+
"read_only": false,
|
|
77
|
+
"ref": null
|
|
78
|
+
},
|
|
79
|
+
"processed_count": {
|
|
80
|
+
"type": "integer",
|
|
81
|
+
"title": "Processed count",
|
|
82
|
+
"required": true,
|
|
83
|
+
"description": null,
|
|
84
|
+
"nullable": false,
|
|
85
|
+
"format": null,
|
|
86
|
+
"max_length": null,
|
|
87
|
+
"choices": null,
|
|
88
|
+
"default": null,
|
|
89
|
+
"validators": [],
|
|
90
|
+
"max_digits": null,
|
|
91
|
+
"decimal_places": null,
|
|
92
|
+
"read_only": false,
|
|
93
|
+
"ref": null
|
|
94
|
+
},
|
|
95
|
+
"execution_time_ms": {
|
|
96
|
+
"type": "integer",
|
|
97
|
+
"title": "Execution time ms",
|
|
98
|
+
"required": true,
|
|
99
|
+
"description": null,
|
|
100
|
+
"nullable": false,
|
|
101
|
+
"format": null,
|
|
102
|
+
"max_length": null,
|
|
103
|
+
"choices": null,
|
|
104
|
+
"default": null,
|
|
105
|
+
"validators": [],
|
|
106
|
+
"max_digits": null,
|
|
107
|
+
"decimal_places": null,
|
|
108
|
+
"read_only": false,
|
|
109
|
+
"ref": null
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"relationships": {},
|
|
113
|
+
"permissions": [
|
|
114
|
+
"HasValidApiKey"
|
|
115
|
+
],
|
|
116
|
+
"display": null
|
|
117
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send notifications to multiple recipients
|
|
3
|
+
*
|
|
4
|
+
* @param string message - Notification message to send
|
|
5
|
+
* @param any[] recipients - List of email addresses to notify
|
|
6
|
+
* @param 'low' | 'high' priority - Notification priority level
|
|
7
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
8
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
9
|
+
*/
|
|
10
|
+
export function sendNotification(message: any, recipients: any, priority?: string, axiosOverrides?: Object): Promise<Object>;
|
|
11
|
+
export namespace sendNotification {
|
|
12
|
+
let actionName: string;
|
|
13
|
+
let title: string;
|
|
14
|
+
let app: string;
|
|
15
|
+
let permissions: string[];
|
|
16
|
+
let configKey: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Zod schema for the input of sendNotification.
|
|
20
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
21
|
+
*/
|
|
22
|
+
export const sendNotificationInputSchema: z.ZodObject<{
|
|
23
|
+
message: z.ZodString;
|
|
24
|
+
recipients: z.ZodArray<z.ZodAny, "many">;
|
|
25
|
+
priority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["low", "high"]>>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
message: string;
|
|
28
|
+
priority: "low" | "high";
|
|
29
|
+
recipients: any[];
|
|
30
|
+
}, {
|
|
31
|
+
message: string;
|
|
32
|
+
recipients: any[];
|
|
33
|
+
priority?: "low" | "high" | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Zod schema for the response of sendNotification.
|
|
37
|
+
*/
|
|
38
|
+
export const sendNotificationResponseSchema: z.ZodObject<{
|
|
39
|
+
success: z.ZodBoolean;
|
|
40
|
+
message_id: z.ZodString;
|
|
41
|
+
sent_to: z.ZodNumber;
|
|
42
|
+
queued_at: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
success: boolean;
|
|
45
|
+
message_id: string;
|
|
46
|
+
sent_to: number;
|
|
47
|
+
queued_at: string;
|
|
48
|
+
}, {
|
|
49
|
+
success: boolean;
|
|
50
|
+
message_id: string;
|
|
51
|
+
sent_to: number;
|
|
52
|
+
queued_at: string;
|
|
53
|
+
}>;
|
|
54
|
+
export default sendNotification;
|
|
55
|
+
import { z } from 'zod';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
* Action: Send Notification
|
|
4
|
+
* App: django_app
|
|
5
|
+
*/
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { configInstance, parseStateZeroError, serializeActionPayload } from '../../../../src';
|
|
9
|
+
import actionSchema from './send-notification.schema.json' assert { type: 'json' };
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for the input of sendNotification.
|
|
12
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
13
|
+
*/
|
|
14
|
+
export const sendNotificationInputSchema = z.object({ message: z.string().max(500),
|
|
15
|
+
recipients: z.array(z.any()),
|
|
16
|
+
priority: z.enum(["low", "high"]).optional().default("low") });
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for the response of sendNotification.
|
|
19
|
+
*/
|
|
20
|
+
export const sendNotificationResponseSchema = z.object({ success: z.boolean(),
|
|
21
|
+
message_id: z.string(),
|
|
22
|
+
sent_to: z.number().int(),
|
|
23
|
+
queued_at: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }) });
|
|
24
|
+
/**
|
|
25
|
+
* Send notifications to multiple recipients
|
|
26
|
+
*
|
|
27
|
+
* @param string message - Notification message to send
|
|
28
|
+
* @param any[] recipients - List of email addresses to notify
|
|
29
|
+
* @param 'low' | 'high' priority - Notification priority level
|
|
30
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
31
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
32
|
+
*/
|
|
33
|
+
export async function sendNotification(message, recipients, priority = "low", axiosOverrides = {}) {
|
|
34
|
+
// Construct the data payload from the function arguments
|
|
35
|
+
const rawPayload = {
|
|
36
|
+
message,
|
|
37
|
+
recipients,
|
|
38
|
+
priority
|
|
39
|
+
};
|
|
40
|
+
// Serialize payload - handles model instances (extracts PK), files, dates, etc.
|
|
41
|
+
const payload = serializeActionPayload(rawPayload, actionSchema.input_properties);
|
|
42
|
+
const config = configInstance.getConfig();
|
|
43
|
+
const backend = config.backendConfigs['backend1'];
|
|
44
|
+
if (!backend) {
|
|
45
|
+
throw new Error(`No backend configuration found for key: backend1`);
|
|
46
|
+
}
|
|
47
|
+
const baseUrl = backend.API_URL.replace(/\/+$/, '');
|
|
48
|
+
const actionUrl = `${baseUrl}/actions/send_notification/`;
|
|
49
|
+
const headers = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
|
|
50
|
+
try {
|
|
51
|
+
const response = await axios.post(actionUrl, payload, {
|
|
52
|
+
headers: { 'Content-Type': 'application/json', ...headers },
|
|
53
|
+
...axiosOverrides,
|
|
54
|
+
});
|
|
55
|
+
return sendNotificationResponseSchema.parse(response.data);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof z.ZodError) {
|
|
59
|
+
throw new Error(`Send Notification failed: Invalid response from server. Details: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
if (error.response && error.response.data) {
|
|
62
|
+
const parsedError = parseStateZeroError(error.response.data);
|
|
63
|
+
if (Error.captureStackTrace) {
|
|
64
|
+
Error.captureStackTrace(parsedError, sendNotification);
|
|
65
|
+
}
|
|
66
|
+
throw parsedError;
|
|
67
|
+
}
|
|
68
|
+
else if (error.request) {
|
|
69
|
+
throw new Error(`Send Notification failed: No response received from server.`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw new Error(`Send Notification failed: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export default sendNotification;
|
|
77
|
+
sendNotification.actionName = 'send_notification';
|
|
78
|
+
sendNotification.title = 'Send Notification';
|
|
79
|
+
sendNotification.app = 'django_app';
|
|
80
|
+
sendNotification.permissions = ['CanSendNotifications'];
|
|
81
|
+
sendNotification.configKey = 'backend1';
|