@statezero/core 0.2.48 → 0.2.50
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/core/get-current-user.d.ts +15 -0
- package/dist/actions/backend1/core/get-current-user.js +51 -0
- package/dist/actions/backend1/core/index.d.ts +1 -0
- package/dist/actions/backend1/core/index.js +1 -0
- package/dist/actions/backend1/django_app/auto-create-ticket.d.ts +66 -0
- package/dist/actions/backend1/django_app/auto-create-ticket.js +99 -0
- package/dist/actions/backend1/django_app/auto-create-ticket.schema.json +156 -0
- package/dist/actions/backend1/django_app/auto-update-profile.d.ts +39 -0
- package/dist/actions/backend1/django_app/auto-update-profile.js +78 -0
- package/dist/actions/backend1/django_app/auto-update-profile.schema.json +47 -0
- package/dist/actions/backend1/django_app/get-user-info.d.ts +2 -2
- package/dist/actions/backend1/django_app/index.js +2 -0
- package/dist/actions/backend1/django_app/send-notification.schema.json +1 -0
- package/dist/actions/backend1/index.d.ts +1 -0
- package/dist/actions/backend1/index.js +1 -0
- package/dist/actions/default/core/get-current-user.d.ts +15 -0
- package/dist/actions/default/core/get-current-user.js +51 -0
- package/dist/actions/default/core/index.d.ts +1 -0
- package/dist/actions/default/core/index.js +1 -0
- package/dist/actions/default/django_app/auto-create-ticket.d.ts +66 -0
- package/dist/actions/default/django_app/auto-create-ticket.js +99 -0
- package/dist/actions/default/django_app/auto-create-ticket.schema.json +156 -0
- package/dist/actions/default/django_app/auto-update-profile.d.ts +39 -0
- package/dist/actions/default/django_app/auto-update-profile.js +78 -0
- package/dist/actions/default/django_app/auto-update-profile.schema.json +47 -0
- package/dist/actions/default/django_app/get-user-info.d.ts +2 -2
- package/dist/actions/default/django_app/index.js +2 -0
- package/dist/actions/default/django_app/send-notification.schema.json +1 -0
- package/dist/actions/default/index.d.ts +1 -0
- package/dist/actions/default/index.js +1 -0
- package/dist/adaptors/vue/reactivity.js +3 -0
- package/dist/cli/commands/syncActions.js +145 -0
- package/dist/models/backend1/django_app/comprehensivemodel.schema.json +5 -5
- package/dist/models/backend1/django_app/dailyrate.schema.json +8 -8
- package/dist/models/backend1/django_app/dummymodel.schema.json +2 -2
- package/dist/models/backend1/django_app/m2mdepthtestlevel1.schema.json +2 -2
- package/dist/models/backend1/django_app/m2mdepthtestlevel2.schema.json +2 -2
- package/dist/models/backend1/django_app/m2mdepthtestlevel3.schema.json +5 -5
- package/dist/models/backend1/django_app/modelwithcustompkrelation.schema.json +2 -2
- package/dist/models/backend1/django_app/modelwithrestrictedfields.schema.json +3 -3
- package/dist/models/backend1/django_app/order.schema.json +7 -7
- package/dist/models/backend1/django_app/orderitem.schema.json +1 -1
- package/dist/models/backend1/django_app/product.d.ts +1 -0
- package/dist/models/backend1/django_app/product.schema.json +10 -9
- package/dist/models/backend1/django_app/productcategory.schema.json +2 -2
- package/dist/models/backend1/django_app/rateplan.schema.json +2 -2
- package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.schema.json +2 -2
- package/dist/models/default/django_app/comprehensivemodel.schema.json +5 -5
- package/dist/models/default/django_app/dailyrate.schema.json +8 -8
- package/dist/models/default/django_app/deepmodellevel1.d.ts +13 -1
- package/dist/models/default/django_app/deepmodellevel1.schema.json +13 -1
- package/dist/models/default/django_app/deepmodellevel2.d.ts +13 -1
- package/dist/models/default/django_app/deepmodellevel2.schema.json +13 -1
- package/dist/models/default/django_app/deepmodellevel3.d.ts +13 -1
- package/dist/models/default/django_app/deepmodellevel3.schema.json +13 -1
- package/dist/models/default/django_app/dummymodel.d.ts +13 -1
- package/dist/models/default/django_app/dummymodel.schema.json +15 -3
- package/dist/models/default/django_app/dummyrelatedmodel.d.ts +13 -1
- package/dist/models/default/django_app/dummyrelatedmodel.schema.json +13 -1
- package/dist/models/default/django_app/filetest.d.ts +13 -1
- package/dist/models/default/django_app/filetest.schema.json +13 -1
- package/dist/models/default/django_app/m2mdepthtestlevel1.schema.json +2 -2
- package/dist/models/default/django_app/m2mdepthtestlevel2.schema.json +2 -2
- package/dist/models/default/django_app/m2mdepthtestlevel3.schema.json +5 -5
- package/dist/models/default/django_app/modelwithcustompkrelation.schema.json +2 -2
- package/dist/models/default/django_app/modelwithrestrictedfields.schema.json +3 -3
- package/dist/models/default/django_app/order.schema.json +7 -7
- package/dist/models/default/django_app/orderitem.schema.json +1 -1
- package/dist/models/default/django_app/product.d.ts +1 -0
- package/dist/models/default/django_app/product.schema.json +10 -9
- package/dist/models/default/django_app/productcategory.schema.json +2 -2
- package/dist/models/default/django_app/rateplan.schema.json +2 -2
- package/dist/models/default/django_app/restrictedfieldrelatedmodel.schema.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-current-user';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a ticket from type hints only.
|
|
3
|
+
*
|
|
4
|
+
* Args:
|
|
5
|
+
* title: Ticket title.
|
|
6
|
+
* priority: Priority from 1 to 5.
|
|
7
|
+
* due_at: When the ticket is due.
|
|
8
|
+
* tags: Tags to attach.
|
|
9
|
+
* metadata: Extra JSON metadata.
|
|
10
|
+
* assignee: Primary assignee user.
|
|
11
|
+
* reviewers: Additional reviewer users.
|
|
12
|
+
* is_blocked: Whether the ticket is blocked.
|
|
13
|
+
*
|
|
14
|
+
* @param string title - Ticket title.
|
|
15
|
+
* @param number priority - Priority from 1 to 5.
|
|
16
|
+
* @param string due_at - When the ticket is due.
|
|
17
|
+
* @param any[] tags - Tags to attach.
|
|
18
|
+
* @param Record<string, any> metadata - Extra JSON metadata.
|
|
19
|
+
* @param number assignee - Primary assignee user.
|
|
20
|
+
* @param any[] reviewers - Additional reviewer users.
|
|
21
|
+
* @param boolean is_blocked - Whether the ticket is blocked.
|
|
22
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
23
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
24
|
+
*/
|
|
25
|
+
export function autoCreateTicket(title: any, priority: any, due_at: any, tags: any, metadata: any, assignee: any, reviewers: any, is_blocked?: boolean, axiosOverrides?: Object): Promise<Object>;
|
|
26
|
+
export namespace autoCreateTicket {
|
|
27
|
+
let actionName: string;
|
|
28
|
+
let title: string;
|
|
29
|
+
let app: string;
|
|
30
|
+
let permissions: string[];
|
|
31
|
+
let configKey: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Zod schema for the input of autoCreateTicket.
|
|
35
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
36
|
+
*/
|
|
37
|
+
export const autoCreateTicketInputSchema: z.ZodObject<{
|
|
38
|
+
title: z.ZodString;
|
|
39
|
+
priority: z.ZodNumber;
|
|
40
|
+
due_at: z.ZodString;
|
|
41
|
+
tags: z.ZodArray<z.ZodAny, "many">;
|
|
42
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
43
|
+
assignee: z.ZodNumber;
|
|
44
|
+
reviewers: z.ZodArray<z.ZodAny, "many">;
|
|
45
|
+
is_blocked: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
priority: number;
|
|
48
|
+
metadata: Record<string, any>;
|
|
49
|
+
title: string;
|
|
50
|
+
due_at: string;
|
|
51
|
+
tags: any[];
|
|
52
|
+
assignee: number;
|
|
53
|
+
reviewers: any[];
|
|
54
|
+
is_blocked: boolean;
|
|
55
|
+
}, {
|
|
56
|
+
priority: number;
|
|
57
|
+
metadata: Record<string, any>;
|
|
58
|
+
title: string;
|
|
59
|
+
due_at: string;
|
|
60
|
+
tags: any[];
|
|
61
|
+
assignee: number;
|
|
62
|
+
reviewers: any[];
|
|
63
|
+
is_blocked?: boolean | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
export default autoCreateTicket;
|
|
66
|
+
import { z } from 'zod';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
* Action: Auto Create Ticket
|
|
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 './auto-create-ticket.schema.json' assert { type: 'json' };
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for the input of autoCreateTicket.
|
|
12
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
13
|
+
*/
|
|
14
|
+
export const autoCreateTicketInputSchema = z.object({ title: z.string(),
|
|
15
|
+
priority: z.number().int(),
|
|
16
|
+
due_at: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }),
|
|
17
|
+
tags: z.array(z.any()),
|
|
18
|
+
metadata: z.record(z.any()),
|
|
19
|
+
assignee: z.number().int(),
|
|
20
|
+
reviewers: z.array(z.any()),
|
|
21
|
+
is_blocked: z.boolean().optional().default(false) });
|
|
22
|
+
/**
|
|
23
|
+
* Create a ticket from type hints only.
|
|
24
|
+
*
|
|
25
|
+
* Args:
|
|
26
|
+
* title: Ticket title.
|
|
27
|
+
* priority: Priority from 1 to 5.
|
|
28
|
+
* due_at: When the ticket is due.
|
|
29
|
+
* tags: Tags to attach.
|
|
30
|
+
* metadata: Extra JSON metadata.
|
|
31
|
+
* assignee: Primary assignee user.
|
|
32
|
+
* reviewers: Additional reviewer users.
|
|
33
|
+
* is_blocked: Whether the ticket is blocked.
|
|
34
|
+
*
|
|
35
|
+
* @param string title - Ticket title.
|
|
36
|
+
* @param number priority - Priority from 1 to 5.
|
|
37
|
+
* @param string due_at - When the ticket is due.
|
|
38
|
+
* @param any[] tags - Tags to attach.
|
|
39
|
+
* @param Record<string, any> metadata - Extra JSON metadata.
|
|
40
|
+
* @param number assignee - Primary assignee user.
|
|
41
|
+
* @param any[] reviewers - Additional reviewer users.
|
|
42
|
+
* @param boolean is_blocked - Whether the ticket is blocked.
|
|
43
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
44
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
45
|
+
*/
|
|
46
|
+
export async function autoCreateTicket(title, priority, due_at, tags, metadata, assignee, reviewers, is_blocked = false, axiosOverrides = {}) {
|
|
47
|
+
// Construct the data payload from the function arguments
|
|
48
|
+
const rawPayload = {
|
|
49
|
+
title,
|
|
50
|
+
priority,
|
|
51
|
+
due_at,
|
|
52
|
+
tags,
|
|
53
|
+
metadata,
|
|
54
|
+
assignee,
|
|
55
|
+
reviewers,
|
|
56
|
+
is_blocked
|
|
57
|
+
};
|
|
58
|
+
// Serialize payload - handles model instances (extracts PK), files, dates, etc.
|
|
59
|
+
const payload = serializeActionPayload(rawPayload, actionSchema.input_properties);
|
|
60
|
+
const config = configInstance.getConfig();
|
|
61
|
+
const backend = config.backendConfigs['default'];
|
|
62
|
+
if (!backend) {
|
|
63
|
+
throw new Error(`No backend configuration found for key: default`);
|
|
64
|
+
}
|
|
65
|
+
const baseUrl = backend.API_URL.replace(/\/+$/, '');
|
|
66
|
+
const actionUrl = `${baseUrl}/actions/auto_create_ticket/`;
|
|
67
|
+
const headers = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
|
|
68
|
+
try {
|
|
69
|
+
const response = await axios.post(actionUrl, payload, {
|
|
70
|
+
headers: { 'Content-Type': 'application/json', ...headers },
|
|
71
|
+
...axiosOverrides,
|
|
72
|
+
});
|
|
73
|
+
return response.data;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof z.ZodError) {
|
|
77
|
+
throw new Error(`Auto Create Ticket failed: Invalid response from server. Details: ${error.message}`);
|
|
78
|
+
}
|
|
79
|
+
if (error.response && error.response.data) {
|
|
80
|
+
const parsedError = parseStateZeroError(error.response.data);
|
|
81
|
+
if (Error.captureStackTrace) {
|
|
82
|
+
Error.captureStackTrace(parsedError, autoCreateTicket);
|
|
83
|
+
}
|
|
84
|
+
throw parsedError;
|
|
85
|
+
}
|
|
86
|
+
else if (error.request) {
|
|
87
|
+
throw new Error(`Auto Create Ticket failed: No response received from server.`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw new Error(`Auto Create Ticket failed: ${error.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export default autoCreateTicket;
|
|
95
|
+
autoCreateTicket.actionName = 'auto_create_ticket';
|
|
96
|
+
autoCreateTicket.title = 'Auto Create Ticket';
|
|
97
|
+
autoCreateTicket.app = 'django_app';
|
|
98
|
+
autoCreateTicket.permissions = ['ValidatedIsAuthenticated'];
|
|
99
|
+
autoCreateTicket.configKey = 'default';
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action_name": "auto_create_ticket",
|
|
3
|
+
"app": "django_app",
|
|
4
|
+
"title": "Auto Create Ticket",
|
|
5
|
+
"docstring": "Create a ticket from type hints only.\n\nArgs:\n title: Ticket title.\n priority: Priority from 1 to 5.\n due_at: When the ticket is due.\n tags: Tags to attach.\n metadata: Extra JSON metadata.\n assignee: Primary assignee user.\n reviewers: Additional reviewer users.\n is_blocked: Whether the ticket is blocked.",
|
|
6
|
+
"class_name": "AutoCreateTicket",
|
|
7
|
+
"input_properties": {
|
|
8
|
+
"title": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"title": "Title",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "Ticket title.",
|
|
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
|
+
"priority": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"title": "Priority",
|
|
27
|
+
"required": true,
|
|
28
|
+
"description": "Priority from 1 to 5.",
|
|
29
|
+
"nullable": false,
|
|
30
|
+
"format": null,
|
|
31
|
+
"max_length": null,
|
|
32
|
+
"choices": null,
|
|
33
|
+
"default": null,
|
|
34
|
+
"validators": [],
|
|
35
|
+
"max_digits": null,
|
|
36
|
+
"decimal_places": null,
|
|
37
|
+
"read_only": false,
|
|
38
|
+
"ref": null
|
|
39
|
+
},
|
|
40
|
+
"due_at": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"title": "Due at",
|
|
43
|
+
"required": true,
|
|
44
|
+
"description": "When the ticket is due.",
|
|
45
|
+
"nullable": false,
|
|
46
|
+
"format": "date-time",
|
|
47
|
+
"max_length": null,
|
|
48
|
+
"choices": null,
|
|
49
|
+
"default": null,
|
|
50
|
+
"validators": [],
|
|
51
|
+
"max_digits": null,
|
|
52
|
+
"decimal_places": null,
|
|
53
|
+
"read_only": false,
|
|
54
|
+
"ref": null
|
|
55
|
+
},
|
|
56
|
+
"tags": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"title": "Tags",
|
|
59
|
+
"required": true,
|
|
60
|
+
"description": "Tags to attach.",
|
|
61
|
+
"nullable": false,
|
|
62
|
+
"format": null,
|
|
63
|
+
"max_length": null,
|
|
64
|
+
"choices": null,
|
|
65
|
+
"default": null,
|
|
66
|
+
"validators": [],
|
|
67
|
+
"max_digits": null,
|
|
68
|
+
"decimal_places": null,
|
|
69
|
+
"read_only": false,
|
|
70
|
+
"ref": null
|
|
71
|
+
},
|
|
72
|
+
"metadata": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"title": "Metadata",
|
|
75
|
+
"required": true,
|
|
76
|
+
"description": "Extra JSON metadata.",
|
|
77
|
+
"nullable": false,
|
|
78
|
+
"format": null,
|
|
79
|
+
"max_length": null,
|
|
80
|
+
"choices": null,
|
|
81
|
+
"default": null,
|
|
82
|
+
"validators": [],
|
|
83
|
+
"max_digits": null,
|
|
84
|
+
"decimal_places": null,
|
|
85
|
+
"read_only": false,
|
|
86
|
+
"ref": null
|
|
87
|
+
},
|
|
88
|
+
"assignee": {
|
|
89
|
+
"type": "integer",
|
|
90
|
+
"title": "Assignee",
|
|
91
|
+
"required": true,
|
|
92
|
+
"description": "Primary assignee user.",
|
|
93
|
+
"nullable": false,
|
|
94
|
+
"format": "foreign-key",
|
|
95
|
+
"max_length": null,
|
|
96
|
+
"choices": null,
|
|
97
|
+
"default": null,
|
|
98
|
+
"validators": [],
|
|
99
|
+
"max_digits": null,
|
|
100
|
+
"decimal_places": null,
|
|
101
|
+
"read_only": false,
|
|
102
|
+
"ref": null
|
|
103
|
+
},
|
|
104
|
+
"reviewers": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"title": "Reviewers",
|
|
107
|
+
"required": true,
|
|
108
|
+
"description": "Additional reviewer users.",
|
|
109
|
+
"nullable": false,
|
|
110
|
+
"format": "many-to-many",
|
|
111
|
+
"max_length": null,
|
|
112
|
+
"choices": null,
|
|
113
|
+
"default": null,
|
|
114
|
+
"validators": [],
|
|
115
|
+
"max_digits": null,
|
|
116
|
+
"decimal_places": null,
|
|
117
|
+
"read_only": false,
|
|
118
|
+
"ref": null
|
|
119
|
+
},
|
|
120
|
+
"is_blocked": {
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"title": "Is blocked",
|
|
123
|
+
"required": false,
|
|
124
|
+
"description": "Whether the ticket is blocked.",
|
|
125
|
+
"nullable": false,
|
|
126
|
+
"format": null,
|
|
127
|
+
"max_length": null,
|
|
128
|
+
"choices": null,
|
|
129
|
+
"default": false,
|
|
130
|
+
"validators": [],
|
|
131
|
+
"max_digits": null,
|
|
132
|
+
"decimal_places": null,
|
|
133
|
+
"read_only": false,
|
|
134
|
+
"ref": null
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"response_properties": {},
|
|
138
|
+
"relationships": {
|
|
139
|
+
"assignee": {
|
|
140
|
+
"type": "foreign-key",
|
|
141
|
+
"model": "auth.user",
|
|
142
|
+
"class_name": "User",
|
|
143
|
+
"primary_key_field": "id"
|
|
144
|
+
},
|
|
145
|
+
"reviewers": {
|
|
146
|
+
"type": "many-to-many",
|
|
147
|
+
"model": "auth.user",
|
|
148
|
+
"class_name": "User",
|
|
149
|
+
"primary_key_field": "id"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"permissions": [
|
|
153
|
+
"ValidatedIsAuthenticated"
|
|
154
|
+
],
|
|
155
|
+
"display": null
|
|
156
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update profile fields.
|
|
3
|
+
*
|
|
4
|
+
* Parameters
|
|
5
|
+
* ----------
|
|
6
|
+
* email : str
|
|
7
|
+
* New email address.
|
|
8
|
+
* birthday : datetime
|
|
9
|
+
* User birthday.
|
|
10
|
+
*
|
|
11
|
+
* @param string email - New email address.
|
|
12
|
+
* @param string birthday - User birthday.
|
|
13
|
+
* @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
|
|
14
|
+
* @returns {Promise<Object>} A promise that resolves with the action's result.
|
|
15
|
+
*/
|
|
16
|
+
export function autoUpdateProfile(email: any, birthday: any, axiosOverrides?: Object): Promise<Object>;
|
|
17
|
+
export namespace autoUpdateProfile {
|
|
18
|
+
let actionName: string;
|
|
19
|
+
let title: string;
|
|
20
|
+
let app: string;
|
|
21
|
+
let permissions: string[];
|
|
22
|
+
let configKey: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Zod schema for the input of autoUpdateProfile.
|
|
26
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
27
|
+
*/
|
|
28
|
+
export const autoUpdateProfileInputSchema: z.ZodObject<{
|
|
29
|
+
email: z.ZodString;
|
|
30
|
+
birthday: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
email: string;
|
|
33
|
+
birthday: string;
|
|
34
|
+
}, {
|
|
35
|
+
email: string;
|
|
36
|
+
birthday: string;
|
|
37
|
+
}>;
|
|
38
|
+
export default autoUpdateProfile;
|
|
39
|
+
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: Auto Update Profile
|
|
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 './auto-update-profile.schema.json' assert { type: 'json' };
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for the input of autoUpdateProfile.
|
|
12
|
+
* NOTE: This is an object schema for validating the data payload.
|
|
13
|
+
*/
|
|
14
|
+
export const autoUpdateProfileInputSchema = z.object({ email: z.string(),
|
|
15
|
+
birthday: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }) });
|
|
16
|
+
/**
|
|
17
|
+
* Update profile fields.
|
|
18
|
+
*
|
|
19
|
+
* Parameters
|
|
20
|
+
* ----------
|
|
21
|
+
* email : str
|
|
22
|
+
* New email address.
|
|
23
|
+
* birthday : datetime
|
|
24
|
+
* User birthday.
|
|
25
|
+
*
|
|
26
|
+
* @param string email - New email address.
|
|
27
|
+
* @param string birthday - User birthday.
|
|
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 autoUpdateProfile(email, birthday, axiosOverrides = {}) {
|
|
32
|
+
// Construct the data payload from the function arguments
|
|
33
|
+
const rawPayload = {
|
|
34
|
+
email,
|
|
35
|
+
birthday
|
|
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['default'];
|
|
41
|
+
if (!backend) {
|
|
42
|
+
throw new Error(`No backend configuration found for key: default`);
|
|
43
|
+
}
|
|
44
|
+
const baseUrl = backend.API_URL.replace(/\/+$/, '');
|
|
45
|
+
const actionUrl = `${baseUrl}/actions/auto_update_profile/`;
|
|
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 response.data;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof z.ZodError) {
|
|
56
|
+
throw new Error(`Auto Update Profile 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, autoUpdateProfile);
|
|
62
|
+
}
|
|
63
|
+
throw parsedError;
|
|
64
|
+
}
|
|
65
|
+
else if (error.request) {
|
|
66
|
+
throw new Error(`Auto Update Profile failed: No response received from server.`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`Auto Update Profile failed: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export default autoUpdateProfile;
|
|
74
|
+
autoUpdateProfile.actionName = 'auto_update_profile';
|
|
75
|
+
autoUpdateProfile.title = 'Auto Update Profile';
|
|
76
|
+
autoUpdateProfile.app = 'django_app';
|
|
77
|
+
autoUpdateProfile.permissions = ['ValidatedIsAuthenticated'];
|
|
78
|
+
autoUpdateProfile.configKey = 'default';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action_name": "auto_update_profile",
|
|
3
|
+
"app": "django_app",
|
|
4
|
+
"title": "Auto Update Profile",
|
|
5
|
+
"docstring": "Update profile fields.\n\nParameters\n----------\nemail : str\n New email address.\nbirthday : datetime\n User birthday.",
|
|
6
|
+
"class_name": "AutoUpdateProfile",
|
|
7
|
+
"input_properties": {
|
|
8
|
+
"email": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"title": "Email",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "New email address.",
|
|
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
|
+
"birthday": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"title": "Birthday",
|
|
27
|
+
"required": true,
|
|
28
|
+
"description": "User birthday.",
|
|
29
|
+
"nullable": false,
|
|
30
|
+
"format": "date-time",
|
|
31
|
+
"max_length": null,
|
|
32
|
+
"choices": null,
|
|
33
|
+
"default": null,
|
|
34
|
+
"validators": [],
|
|
35
|
+
"max_digits": null,
|
|
36
|
+
"decimal_places": null,
|
|
37
|
+
"read_only": false,
|
|
38
|
+
"ref": null
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"response_properties": {},
|
|
42
|
+
"relationships": {},
|
|
43
|
+
"permissions": [
|
|
44
|
+
"ValidatedIsAuthenticated"
|
|
45
|
+
],
|
|
46
|
+
"display": null
|
|
47
|
+
}
|
|
@@ -24,16 +24,16 @@ export const getUserInfoResponseSchema: z.ZodObject<{
|
|
|
24
24
|
last_login: z.ZodNullable<z.ZodString>;
|
|
25
25
|
server_time: z.ZodString;
|
|
26
26
|
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
username: string;
|
|
28
27
|
email: string;
|
|
28
|
+
username: string;
|
|
29
29
|
is_staff: boolean;
|
|
30
30
|
is_superuser: boolean;
|
|
31
31
|
date_joined: string;
|
|
32
32
|
last_login: string | null;
|
|
33
33
|
server_time: string;
|
|
34
34
|
}, {
|
|
35
|
-
username: string;
|
|
36
35
|
email: string;
|
|
36
|
+
username: string;
|
|
37
37
|
is_staff: boolean;
|
|
38
38
|
is_superuser: boolean;
|
|
39
39
|
date_joined: string;
|
|
@@ -83,6 +83,7 @@ export function ModelAdaptor(modelInstance, reactivityFn = reactive) {
|
|
|
83
83
|
const modelPk = model[pkField];
|
|
84
84
|
// Check if this model's pk is in the event's pks array
|
|
85
85
|
if (eventData.pks && eventData.pks.includes(modelPk)) {
|
|
86
|
+
console.log(`[sz] model update: ${modelName} pk=${modelPk}`);
|
|
86
87
|
if (isRef) {
|
|
87
88
|
wrapper.value.touch();
|
|
88
89
|
}
|
|
@@ -124,6 +125,7 @@ export function QuerySetAdaptor(liveQuerySet, reactivityFn = reactive) {
|
|
|
124
125
|
// Handler bumps version to trigger Vue reactivity when this queryset updates
|
|
125
126
|
const renderHandler = (eventData) => {
|
|
126
127
|
if (eventData && eventData.ast && isEqual(querysetAst, eventData.ast)) {
|
|
128
|
+
console.log(`[sz] queryset update: ${modelName}`, { count: liveQuerySet.length, version: wrapper.__version + 1 });
|
|
127
129
|
if (reactivityFn === ref) {
|
|
128
130
|
wrapper.value = [...liveQuerySet];
|
|
129
131
|
}
|
|
@@ -170,6 +172,7 @@ export function MetricAdaptor(metric) {
|
|
|
170
172
|
eventData.field === metric.field &&
|
|
171
173
|
eventData.ast === hash(querysetAst) &&
|
|
172
174
|
eventData.valueChanged === true) {
|
|
175
|
+
console.log(`[sz] metric update: ${modelName}.${metric.field} (${metric.metricType}) =`, metric.value);
|
|
173
176
|
// Update the wrapper value with the latest metric value
|
|
174
177
|
wrapper.value = metric.value;
|
|
175
178
|
}
|