@yiyi_zhang/reactflow-ui 0.2.0 → 0.3.0

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.
@@ -3,8 +3,14 @@
3
3
  "status": "COMPLETED",
4
4
  "startTime": 1704546000000,
5
5
  "endTime": 1704546090000,
6
- "input": { "userType": "premium", "requestId": "req_555" },
7
- "output": { "processed": true, "tier": "premium" },
6
+ "input": {
7
+ "userType": "premium",
8
+ "requestId": "req_555"
9
+ },
10
+ "output": {
11
+ "processed": true,
12
+ "tier": "premium"
13
+ },
8
14
  "workflowDefinition": {
9
15
  "name": "user_tier_workflow",
10
16
  "description": "SWITCH 分支演示:根据用户类型走不同处理路径(premium 分支执行)",
@@ -34,13 +40,18 @@
34
40
  "name": "premium_processing",
35
41
  "taskReferenceName": "premium_proc_ref",
36
42
  "type": "SIMPLE",
37
- "inputParameters": { "priority": "high", "sla": "1h" }
43
+ "inputParameters": {
44
+ "priority": "high",
45
+ "sla": "1h"
46
+ }
38
47
  },
39
48
  {
40
49
  "name": "premium_notify",
41
50
  "taskReferenceName": "premium_notify_ref",
42
51
  "type": "EVENT",
43
- "inputParameters": { "sink": "sqs:premium-events" }
52
+ "inputParameters": {
53
+ "sink": "sqs:premium-events"
54
+ }
44
55
  }
45
56
  ],
46
57
  "standard": [
@@ -48,7 +59,10 @@
48
59
  "name": "standard_processing",
49
60
  "taskReferenceName": "standard_proc_ref",
50
61
  "type": "SIMPLE",
51
- "inputParameters": { "priority": "normal", "sla": "24h" }
62
+ "inputParameters": {
63
+ "priority": "normal",
64
+ "sla": "24h"
65
+ }
52
66
  }
53
67
  ],
54
68
  "free": [
@@ -56,7 +70,9 @@
56
70
  "name": "queue_request",
57
71
  "taskReferenceName": "queue_ref",
58
72
  "type": "SET_VARIABLE",
59
- "inputParameters": { "queuePosition": "${workflow.input.requestId}" }
73
+ "inputParameters": {
74
+ "queuePosition": "${workflow.input.requestId}"
75
+ }
60
76
  }
61
77
  ]
62
78
  },
@@ -81,7 +97,8 @@
81
97
  }
82
98
  }
83
99
  ],
84
- "schemaVersion": 2
100
+ "schemaVersion": 2,
101
+ "restartable": true
85
102
  },
86
103
  "tasks": [
87
104
  {
@@ -91,8 +108,14 @@
91
108
  "taskType": "HTTP",
92
109
  "startTime": 1704546000000,
93
110
  "endTime": 1704546005000,
94
- "inputData": { "uri": "https://api.example.com/users/req_555" },
95
- "outputData": { "userId": "usr_999", "tier": "premium", "email": "user@example.com" }
111
+ "inputData": {
112
+ "uri": "https://api.example.com/users/req_555"
113
+ },
114
+ "outputData": {
115
+ "userId": "usr_999",
116
+ "tier": "premium",
117
+ "email": "user@example.com"
118
+ }
96
119
  },
97
120
  {
98
121
  "taskId": "task_switch_001",
@@ -101,8 +124,12 @@
101
124
  "taskType": "SWITCH",
102
125
  "startTime": 1704546006000,
103
126
  "endTime": 1704546006500,
104
- "inputData": { "switchCaseValue": "premium" },
105
- "outputData": { "caseOutput": "premium" }
127
+ "inputData": {
128
+ "switchCaseValue": "premium"
129
+ },
130
+ "outputData": {
131
+ "caseOutput": "premium"
132
+ }
106
133
  },
107
134
  {
108
135
  "taskId": "task_premium_proc_001",
@@ -111,8 +138,14 @@
111
138
  "taskType": "SIMPLE",
112
139
  "startTime": 1704546007000,
113
140
  "endTime": 1704546040000,
114
- "inputData": { "priority": "high", "sla": "1h" },
115
- "outputData": { "jobId": "job_premium_789", "estimatedTime": "45m" }
141
+ "inputData": {
142
+ "priority": "high",
143
+ "sla": "1h"
144
+ },
145
+ "outputData": {
146
+ "jobId": "job_premium_789",
147
+ "estimatedTime": "45m"
148
+ }
116
149
  },
117
150
  {
118
151
  "taskId": "task_premium_notify_001",
@@ -121,7 +154,9 @@
121
154
  "taskType": "EVENT",
122
155
  "startTime": 1704546041000,
123
156
  "endTime": 1704546043000,
124
- "outputData": { "eventId": "evt_premium_sent" }
157
+ "outputData": {
158
+ "eventId": "evt_premium_sent"
159
+ }
125
160
  },
126
161
  {
127
162
  "taskId": "task_log_001",
@@ -130,7 +165,9 @@
130
165
  "taskType": "INLINE",
131
166
  "startTime": 1704546044000,
132
167
  "endTime": 1704546046000,
133
- "outputData": { "result": "logged" }
168
+ "outputData": {
169
+ "result": "logged"
170
+ }
134
171
  }
135
172
  ]
136
- }
173
+ }
@@ -1,5 +1,70 @@
1
1
  import { Node, Edge, Position } from 'reactflow';
2
2
  import { WorkflowDef, TaskDef, WorkflowInstance, TaskInstance } from './conductor';
3
+ /**
4
+ * 视图详情级别(独立于编辑模式)
5
+ * - `business`:仅展示核心业务节点,控制/数据节点折叠为边标签
6
+ * - `standard`:业务 + 控制流节点
7
+ * - `developer`:全部节点(含数据转换等)
8
+ */
9
+ export type ViewMode = 'business' | 'standard' | 'developer';
10
+ export interface WorkflowDiffRow {
11
+ kind: 'add' | 'mod' | 'del';
12
+ desc: string;
13
+ }
14
+ export type WorkflowPatchOp = {
15
+ op: 'patchTask';
16
+ ref: string;
17
+ set: Partial<TaskDef>;
18
+ } | {
19
+ op: 'insertAfter';
20
+ after: string;
21
+ edgeTo: string;
22
+ task: TaskDef;
23
+ } | {
24
+ op: 'insertBefore';
25
+ before: string;
26
+ task: TaskDef;
27
+ } | {
28
+ op: 'addTask';
29
+ task: TaskDef;
30
+ extraEdges?: Array<{
31
+ from: string;
32
+ to: string;
33
+ label?: string;
34
+ }>;
35
+ removeEdges?: Array<{
36
+ from: string;
37
+ to: string;
38
+ }>;
39
+ } | {
40
+ op: 'removeTask';
41
+ ref: string;
42
+ } | {
43
+ op: 'addEdge';
44
+ from: string;
45
+ to: string;
46
+ label?: string;
47
+ } | {
48
+ op: 'removeEdge';
49
+ from: string;
50
+ to: string;
51
+ };
52
+ export interface WorkflowDiff {
53
+ kind: 'add' | 'mod' | 'del' | 'replace';
54
+ summary: string;
55
+ rows: WorkflowDiffRow[];
56
+ patch?: WorkflowPatchOp[];
57
+ payload?: WorkflowDef;
58
+ }
59
+ export interface AIChatMessage {
60
+ id: string;
61
+ role: 'user' | 'ai';
62
+ content?: string;
63
+ thinking?: boolean;
64
+ diff?: WorkflowDiff;
65
+ applied?: boolean;
66
+ inverse?: WorkflowDiff;
67
+ }
3
68
  /**
4
69
  * 布局方向
5
70
  */
@@ -74,6 +139,10 @@ export interface WorkflowNodeData {
74
139
  parentRef?: string;
75
140
  edgeData?: Record<string, any>;
76
141
  isDynamicRuntime?: boolean;
142
+ simRunning?: boolean;
143
+ simDone?: boolean;
144
+ _layoutWidth?: number;
145
+ _layoutHeight?: number;
77
146
  }
78
147
  /**
79
148
  * 强类型节点
@@ -96,6 +165,7 @@ export type ThemeColor = 'blue' | 'orange';
96
165
  */
97
166
  export interface WorkflowState {
98
167
  mode: EditorMode;
168
+ viewMode: ViewMode;
99
169
  workflowDef: WorkflowDef | null;
100
170
  workflowInstance: WorkflowInstance | null;
101
171
  nodes: WorkflowNode[];
@@ -113,6 +183,10 @@ export interface WorkflowState {
113
183
  nodesLocked: boolean;
114
184
  copiedTask: TaskDef | null;
115
185
  isDetailPanelOpen: boolean;
186
+ simState: Record<string, 'idle' | 'running' | 'done'>;
187
+ isSimRunning: boolean;
188
+ /** 每次 setWorkflow() 调用时递增,用于触发 WorkflowDesigner 的 fitView */
189
+ workflowLoadKey: number;
116
190
  }
117
191
  /**
118
192
  * 工作流操作接口
@@ -139,6 +213,7 @@ export interface WorkflowActions {
139
213
  removeLoopTask: (loopRef: string, taskRef: string) => void;
140
214
  addDecisionBranch: (taskRef: string, caseName: string) => void;
141
215
  removeDecisionBranch: (taskRef: string, caseName: string) => void;
216
+ renameDecisionBranch: (taskRef: string, oldName: string, newName: string) => void;
142
217
  addForkBranch: (taskRef: string) => void;
143
218
  copyTask: (task: TaskDef) => void;
144
219
  pasteTask: (task: TaskDef) => void;
@@ -150,18 +225,67 @@ export interface WorkflowActions {
150
225
  applyAIGeneratedWorkflow: (workflowJson: any) => void;
151
226
  setIsDetailPanelOpen: (isOpen: boolean) => void;
152
227
  selectTaskAction: (task: TaskDef | null, openPanel?: boolean) => void;
228
+ setViewMode: (viewMode: ViewMode) => void;
229
+ startSimulation: () => void;
230
+ stopSimulation: () => void;
231
+ }
232
+ /**
233
+ * 重启选项
234
+ * - `useLatestDef: true` 使用当前最新工作流定义版本重启
235
+ * - `useLatestDef: false` 使用本次执行时的定义版本重启(默认)
236
+ */
237
+ export interface RestartOptions {
238
+ useLatestDef?: boolean;
153
239
  }
154
240
  /**
155
241
  * 运行态操作回调
156
- * 集成方通过此接口注入工作流执行操作(暂停/恢复/停止/重试/重启)的回调函数。
157
- * 未传入的回调对应的按钮不会渲染。
242
+ * 集成方通过此接口注入工作流执行操作的回调函数;未传入的回调对应的按钮不会渲染。
243
+ *
244
+ * 工作流级别操作:暂停、继续、终止、重试、重新运行(支持版本选择)
245
+ * 任务级别操作:从指定任务重新运行、跳过任务
158
246
  */
159
247
  export interface ExecutionActions {
160
- onRestart?: (workflowId: string) => void;
248
+ /**
249
+ * 是否允许操作。
250
+ * - `true`(默认):所有操作按钮正常可用。
251
+ * - `false`:所有操作按钮置灰并提示"操作权限受限"。
252
+ * @default true
253
+ */
254
+ allowOperations?: boolean;
255
+ /** 暂停工作流(RUNNING → PAUSED) */
161
256
  onPause?: (workflowId: string) => void;
257
+ /** 继续执行暂停中的工作流(PAUSED → RUNNING) */
162
258
  onResume?: (workflowId: string) => void;
259
+ /** 终止工作流(RUNNING/PAUSED → TERMINATED) */
163
260
  onTerminate?: (workflowId: string) => void;
261
+ /** 重试失败的工作流(FAILED/TIMED_OUT/TERMINATED) */
164
262
  onRetry?: (workflowId: string) => void;
263
+ /**
264
+ * 重新运行工作流(需要 workflowDef.restartable = true)
265
+ * @param options.useLatestDef true=使用最新定义版本;false=使用执行时的版本(默认)
266
+ */
267
+ onRestart?: (workflowId: string, options?: RestartOptions) => void;
268
+ /**
269
+ * 从指定任务重新运行(工作流须处于终态:FAILED/TERMINATED/COMPLETED)
270
+ *
271
+ * 对应 Conductor OSS API:POST /workflow/{workflowId}/rerun
272
+ * - body: { reRunFromTaskId: taskId, taskInput: {} }
273
+ *
274
+ * @param workflowId 工作流实例 ID
275
+ * @param taskReferenceName 目标任务的引用名(taskReferenceName)
276
+ * @param taskId 目标任务实例 ID(对应 Conductor API 的 reRunFromTaskId)
277
+ */
278
+ onRerunFromTask?: (workflowId: string, taskReferenceName: string, taskId?: string) => void;
279
+ /**
280
+ * 跳过指定任务(任务须处于 SCHEDULED 或 IN_PROGRESS 状态)
281
+ *
282
+ * 对应 Conductor OSS API:PUT /workflow/{workflowId}/skiptask/{taskReferenceName}
283
+ *
284
+ * @param workflowId 工作流实例 ID
285
+ * @param taskReferenceName 目标任务的引用名(URL path 参数)
286
+ * @param taskId 目标任务实例 ID(可用于请求体附加校验)
287
+ */
288
+ onSkipTask?: (workflowId: string, taskReferenceName: string, taskId?: string) => void;
165
289
  }
166
290
  /**
167
291
  * 组合 Store 类型
@@ -0,0 +1,11 @@
1
+ import { ViewMode, WorkflowNodeData } from '../types/workflow';
2
+ declare function truncate(s: string, max: number): string;
3
+ /**
4
+ * Returns the meta subtitle for a node based on the current viewMode.
5
+ * - business: task.description (fallback to label)
6
+ * - standard: unchanged (returns fallback)
7
+ * - developer: key config field for the task type
8
+ */
9
+ export declare function getNodeMeta(taskType: string, data: WorkflowNodeData, viewMode: ViewMode, fallback: string): string;
10
+ /** Truncate helper exported for use in node components (e.g. DecisionNode). */
11
+ export { truncate };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 对工作流任务进行拓扑排序,返回按并行波浪分组的执行顺序。
3
+ * 每一波内的任务可以并行执行,波与波之间有依赖关系。
4
+ */
5
+ export declare function buildExecutionWaves(taskRefs: string[], edges: Array<{
6
+ source: string;
7
+ target: string;
8
+ }>): string[][];
@@ -0,0 +1,15 @@
1
+ import { WorkflowDef } from '../types/conductor';
2
+ import { WorkflowDiff } from '../types/workflow';
3
+ /**
4
+ * 将 WorkflowDiff 应用到 WorkflowDef,返回新的 def 以及用于撤销的逆操作 diff。
5
+ * 不修改入参(深拷贝)。
6
+ */
7
+ export declare function applyWorkflowDiff(def: WorkflowDef, diff: WorkflowDiff): {
8
+ next: WorkflowDef;
9
+ inverse: WorkflowDiff;
10
+ };
11
+ /**
12
+ * 从 AI 响应文本中提取 ```diff-json ... ``` 块并解析为 WorkflowDiff。
13
+ * 找不到或解析失败时返回 null。
14
+ */
15
+ export declare function parseDiffFromAIResponse(text: string): WorkflowDiff | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiyi_zhang/reactflow-ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Conductor Workflow IDE — a visual workflow designer built with React 19, ReactFlow and Zustand for editing, validating and monitoring Netflix Conductor workflows.",
5
5
  "keywords": [
6
6
  "conductor",
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "scripts": {
38
38
  "dev": "vite",
39
- "build": "tsc && vite build && tsc -p tsconfig.build.json",
39
+ "build": "vite build && tsc -p tsconfig.build.json",
40
40
  "lint": "eslint .",
41
41
  "preview": "vite preview"
42
42
  },