openxiangda 1.0.29 → 1.0.31

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.
@@ -9,52 +9,147 @@ Automations have two files:
9
9
 
10
10
  Automation can run from form events, workflow events, fixed cron schedules, or a form date field reaching a configured time. Pair these triggers with JS_CODE when the action must execute on the backend and cannot be handled reliably by a frontend page.
11
11
 
12
+ AI-authored automations must use `trigger_v2`. The CLI passes this JSON through unchanged and only fills the root `appType` and `formUuid` when they are missing and can be resolved from the active workspace/profile.
13
+
12
14
  Form submit trigger:
13
15
 
14
16
  ```json
15
17
  {
16
- "type": "form_data_submitted",
18
+ "version": "trigger_v2",
19
+ "mode": "event",
20
+ "appType": "APP_XXX",
21
+ "formUuid": "FORM_XXX",
22
+ "enabled": true,
23
+ "event": {
24
+ "source": "form_data",
25
+ "action": "submitted"
26
+ },
27
+ "filters": {
28
+ "conditions": []
29
+ }
30
+ }
31
+ ```
32
+
33
+ Form update/delete triggers use the same shape with `event.action` set to `updated` or `deleted`. Update events expose `ctx.formData.current`, `ctx.formData.previous`, `ctx.formData.changes`, and `ctx.triggerEvent.data.metadata.changeRecords`.
34
+
35
+ Form field change trigger:
36
+
37
+ ```json
38
+ {
39
+ "version": "trigger_v2",
40
+ "mode": "event",
41
+ "appType": "APP_XXX",
42
+ "formUuid": "FORM_XXX",
43
+ "enabled": true,
44
+ "event": {
45
+ "source": "form_field",
46
+ "action": "changed"
47
+ },
48
+ "filters": {
49
+ "fieldChange": {
50
+ "fieldId": "status",
51
+ "changeType": "to_value",
52
+ "toValue": "approved"
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ `fieldChange.changeType` can be `any`, `from_to`, `to_value`, or `from_value`.
59
+
60
+ Workflow task trigger:
61
+
62
+ ```json
63
+ {
64
+ "version": "trigger_v2",
65
+ "mode": "event",
17
66
  "appType": "APP_XXX",
18
67
  "formUuid": "FORM_XXX",
19
- "enabled": true
68
+ "enabled": true,
69
+ "event": {
70
+ "source": "workflow_task",
71
+ "action": "approved"
72
+ },
73
+ "filters": {
74
+ "workflow": {
75
+ "processDefinitionId": "workflow-id",
76
+ "nodeId": "approval-node-id",
77
+ "operatorId": "",
78
+ "assigneeId": "",
79
+ "previousAssigneeId": ""
80
+ }
81
+ }
20
82
  }
21
83
  ```
22
84
 
23
- Form update trigger:
85
+ Workflow task actions are `approved`, `rejected`, `returned`, `transferred`, and `cancelled`. Returned task events include `ctx.workflowData.targetNodeId` and `ctx.workflowData.targetNodeName` when the platform can resolve the target node.
86
+
87
+ Workflow process trigger:
24
88
 
25
89
  ```json
26
90
  {
27
- "type": "form_data_updated",
91
+ "version": "trigger_v2",
92
+ "mode": "event",
28
93
  "appType": "APP_XXX",
29
94
  "formUuid": "FORM_XXX",
30
- "enabled": true
95
+ "enabled": true,
96
+ "event": {
97
+ "source": "workflow_process",
98
+ "action": "rejected"
99
+ },
100
+ "filters": {
101
+ "workflow": {
102
+ "processDefinitionId": "workflow-id",
103
+ "finalResult": "rejected"
104
+ }
105
+ }
31
106
  }
32
107
  ```
33
108
 
34
- Scheduled trigger:
109
+ Workflow process actions are `started`, `approved`, `rejected`, `terminated`, and `withdrawn`. Final approval is backed by `workflow_process_completed`; final rejection is backed by `workflow_process_terminated` with `finalResult: "rejected"`; manual termination uses `finalResult: "terminated"`.
110
+
111
+ Fixed-time scheduled trigger:
35
112
 
36
113
  ```json
37
114
  {
38
- "type": "scheduled",
115
+ "version": "trigger_v2",
116
+ "mode": "scheduled",
39
117
  "appType": "APP_XXX",
40
118
  "enabled": true,
41
- "scheduleType": "fixed_time",
42
- "fixedTime": {
43
- "startTime": "2026-05-21T09:00:00+08:00",
44
- "cronExpression": "0 0 9 * * *"
119
+ "schedule": {
120
+ "type": "fixed_time",
121
+ "fixedTime": {
122
+ "startTime": "2026-05-21T09:00:00+08:00",
123
+ "cronExpression": "0 0 9 * * *",
124
+ "maxExecutions": 1
125
+ }
45
126
  }
46
127
  }
47
128
  ```
48
129
 
49
- Workflow trigger:
130
+ Form date-field scheduled trigger:
50
131
 
51
132
  ```json
52
133
  {
53
- "type": "workflow_process_completed",
134
+ "version": "trigger_v2",
135
+ "mode": "scheduled",
54
136
  "appType": "APP_XXX",
55
137
  "formUuid": "FORM_XXX",
56
- "processDefinitionId": "workflow-id",
57
- "enabled": true
138
+ "enabled": true,
139
+ "schedule": {
140
+ "type": "form_date_field",
141
+ "formDateField": {
142
+ "fieldId": "dueAt",
143
+ "startOffset": {
144
+ "type": "before",
145
+ "days": 1,
146
+ "time": "09:00:00"
147
+ },
148
+ "endFieldId": "",
149
+ "cronExpression": "0 0 9 * * *",
150
+ "maxExecutions": 1
151
+ }
152
+ }
58
153
  }
59
154
  ```
60
155
 
@@ -102,7 +197,18 @@ Resource manifest shape:
102
197
  {
103
198
  "code": "daily_ticket_digest",
104
199
  "name": "每日工单摘要",
105
- "triggerConfig": { "type": "scheduled", "enabled": true },
200
+ "triggerConfig": {
201
+ "version": "trigger_v2",
202
+ "mode": "scheduled",
203
+ "enabled": true,
204
+ "schedule": {
205
+ "type": "fixed_time",
206
+ "fixedTime": {
207
+ "startTime": "2026-05-21T09:00:00+08:00",
208
+ "cronExpression": "0 0 9 * * *"
209
+ }
210
+ }
211
+ },
106
212
  "definitionFile": "definition.code.json",
107
213
  "previewFile": "preview.json",
108
214
  "publish": true,
@@ -92,6 +92,18 @@ Inside the TypeScript script, prefer `export default async function (ctx) {}` or
92
92
 
93
93
  ## Automation Flow
94
94
 
95
+ New automation triggers must use `trigger_v2`.
96
+
97
+ Use these v2 event sources and actions:
98
+
99
+ - Form data: `event.source: "form_data"` with `submitted`, `updated`, or `deleted`.
100
+ - Form field: `event.source: "form_field"`, `event.action: "changed"`, and `filters.fieldChange` with `fieldId` plus `changeType: "any" | "from_to" | "to_value" | "from_value"`.
101
+ - Workflow task: `event.source: "workflow_task"` with `approved`, `rejected`, `returned`, `transferred`, or `cancelled`; use `filters.workflow.nodeId`, `operatorId`, `assigneeId`, and `previousAssigneeId` when needed.
102
+ - Workflow process: `event.source: "workflow_process"` with `started`, `approved`, `rejected`, `terminated`, or `withdrawn`; set `filters.workflow.finalResult` for final outcomes.
103
+ - Scheduled: `mode: "scheduled"` with `schedule.type: "fixed_time"` or `"form_date_field"`.
104
+
105
+ The CLI passes `trigger_v2` through unchanged and fills root `appType`/`formUuid` from the active profile when omitted and resolvable, for example with `--form-code customer`. Do not put profile-specific IDs into reusable examples unless they are resolved from local workspace state.
106
+
95
107
  1. Create a trigger JSON and automation v3 definition JSON locally.
96
108
  2. Validate:
97
109
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {
@@ -109,8 +109,8 @@
109
109
  "vite": "^6.0.0"
110
110
  },
111
111
  "peerDependencies": {
112
- "react": ">=18",
113
- "react-dom": ">=18"
112
+ "react": ">=18 <19",
113
+ "react-dom": ">=18 <19"
114
114
  },
115
115
  "devDependencies": {
116
116
  "@testing-library/jest-dom": "^6.9.1",