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

+11 -14
View File
@@ -7,6 +7,7 @@ import {
lintJavaScriptCode,
lintMvelCode,
executeJavaScriptSandbox,
executeMvelSandbox,
} from "../../../domains/platform/services.js";
import { stringOption, booleanOption } from "../../parser.js";
import { printJson, printKeyValue } from "../../printer.js";
@@ -196,6 +197,8 @@ export async function handleWorkflowEvalScript(
const codeInline = stringOption(parsed.options, ["code"]);
const timeoutStr = stringOption(parsed.options, ["timeout"]);
const timeoutMs = timeoutStr ? parseInt(timeoutStr, 10) : 3000;
const explicitType = (stringOption(parsed.options, ["type"]) || "").toLowerCase();
const isMvel = explicitType === "code" || explicitType === "mvel" || (filePath ? filePath.endsWith(".mvel") : false);
// 1. 获取输入参数 inputs
let inputs: Record<string, unknown> = {};
@@ -245,7 +248,9 @@ export async function handleWorkflowEvalScript(
code = fs.readFileSync(filePath, "utf-8");
}
const evalResult = await executeJavaScriptSandbox(code, inputs, { timeoutMs });
const evalResult = isMvel
? await executeMvelSandbox(code, inputs, { timeoutMs })
: await executeJavaScriptSandbox(code, inputs, { timeoutMs });
if (isJson) {
return { stdout: printJson(evalResult, runtime.outputOptions), stderr: "", exitCode: evalResult.success ? 0 : 1 };
@@ -296,18 +301,7 @@ export async function handleWorkflowEvalScript(
}
const task = located.task;
if (task.type !== "code-js2") {
if (task.type === "code") {
return {
stdout: "",
stderr: [
`节点 [${task.name}] 是 MVEL (code) 节点。`,
"当前本地离线沙箱仅支持 JavaScript (code-js2) 运行时仿真。",
"提示: 您可以使用 hose-use workflow lint-script 检查其括号与上游引用,或使用 hose-use workflow test 进行全链路调试。",
].join("\n") + "\n",
exitCode: 1,
};
}
if (task.type !== "code-js2" && task.type !== "code") {
return {
stdout: "",
stderr: `节点 [${task.name}] 不是代码节点,类型为: ${task.type}\n`,
@@ -316,6 +310,7 @@ export async function handleWorkflowEvalScript(
}
const code: string = (task as any).code || "";
const isNodeMvel = task.type === "code";
// 如果没有显式传 input,尝试提取工作流样本数据
if (Object.keys(inputs).length === 0) {
@@ -352,7 +347,9 @@ export async function handleWorkflowEvalScript(
}
}
const evalResult = await executeJavaScriptSandbox(code, inputs, { timeoutMs });
const evalResult = isNodeMvel
? await executeMvelSandbox(code, inputs, { timeoutMs })
: await executeJavaScriptSandbox(code, inputs, { timeoutMs });
if (isJson) {
return { stdout: printJson(evalResult, runtime.outputOptions), stderr: "", exitCode: evalResult.success ? 0 : 1 };