feat(workflow & platform): optimize complex workflow orchestration, code node debug summary, MVEL simulation and entity/feetype helpers

- feat(feetype): add --subtree and --ids-only flags to listFeeTypes for direct array export
- feat(platform): add platform gen-props command to generate MVEL/JS entity field constants and templates
- feat(workflow): show code node return value summaries in workflow test and job first screen
- feat(workflow): add workflow node map sub-command and --mapping-file for deep declarative field mutations
- feat(workflow): add executeMvelSandbox for local offline simulation of MVEL code nodes
- test: add comprehensive test cases across feetype, platform gen-props, node map, and MVEL sandbox

Closes #140
This commit is contained in:
gitea committed 2026-10-23 13:06:32 +08:00
1 parent 1739daacf2
commit ad771e92e0
18 files changed
+591 -29

No files matched your search

@@ -310,3 +310,45 @@ export function removeWorkflowTask(
reindexTasks(cloned.tasks);
return { workflow: cloned, removedTask };
}
export type MappingContent = Array<Record<string, any>> | Record<string, any>;
/**
* 批量映射节点字段配置 (支持数组格式替换 fields,或对象格式深度设置属性)
*/
export function applyNodeMapping(
workflow: WorkflowDetail,
targetKey: string | number,
mapping: MappingContent
): { workflow: WorkflowDetail; editedTask: WorkflowTask; changedKeys: string[] } {
const cloned = JSON.parse(JSON.stringify(workflow)) as WorkflowDetail;
if (!cloned.tasks) cloned.tasks = [];
const target = findWorkflowTask(cloned.tasks, targetKey);
if (!target) {
throw new NotFoundError(`未找到目标工作流任务节点: ${targetKey}`);
}
const { task } = target;
const changedKeys: string[] = [];
if (Array.isArray(mapping)) {
// 数组格式直接更新/替换 fields 数组
(task as any).fields = mapping;
changedKeys.push(`fields (${mapping.length} 项)`);
} else if (mapping && typeof mapping === "object") {
// 对象格式:合并/设置每个顶层键
for (const [key, value] of Object.entries(mapping)) {
(task as any)[key] = value;
if (Array.isArray(value)) {
changedKeys.push(`${key} (${value.length} 项)`);
} else {
changedKeys.push(key);
}
}
} else {
throw new ValidationError("映射内容必须为 JSON 数组或 JSON 对象");
}
return { workflow: cloned, editedTask: task, changedKeys };
}