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:
1 parent
1739daacf2
commit
ad771e92e0
18 files changed
+591
-29
No files matched your search
@@ -122,3 +122,90 @@ export async function handleImports(parsed: CliParsedArgs, runtime: CliRuntime):
|
||||
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
|
||||
return { stdout: `====== 导入任务: ${resolved.platform.name} / ${resolved.entity.name} ======\n${printTable(["#", "任务"], jobs.map((job, i) => [i + 1, cell(job)]))}\n`, stderr: "", exitCode: 0 };
|
||||
}
|
||||
|
||||
export async function handleGenProps(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
|
||||
const resolved = await resolveAppAndEntity(parsed, runtime);
|
||||
if (!resolved.entity) {
|
||||
throw new Error("请提供业务对象 ID、编码或名称: hose-use platform gen-props <应用> <业务对象> [--lang=mvel|js]");
|
||||
}
|
||||
|
||||
const lang = (stringOption(parsed.options, ["lang", "language"]) || "mvel").toLowerCase();
|
||||
const entity = resolved.entity;
|
||||
const entityId = entity.id;
|
||||
const entityName = entity.name;
|
||||
const prefix = entityId ? `${entityId}_` : "";
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson(
|
||||
{
|
||||
platform: resolved.platform,
|
||||
entity: {
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
code: entity.code,
|
||||
prefix,
|
||||
fields: entity.fields.map((f) => ({
|
||||
fieldKey: f.name,
|
||||
label: f.label,
|
||||
type: f.type,
|
||||
suffix: f.name.startsWith(prefix) ? f.name.slice(prefix.length) : f.name,
|
||||
})),
|
||||
},
|
||||
},
|
||||
runtime.outputOptions
|
||||
),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
if (lang === "js" || lang === "javascript") {
|
||||
lines.push(`// ====== 自建应用实体代码模板 [${entityName}] (JS / QuickJS) ======`);
|
||||
lines.push(`const ENTITY_ID = "${entityId}";`);
|
||||
lines.push(`const FIELD_PREFIX = "${prefix}";`);
|
||||
lines.push("");
|
||||
lines.push("// ── 字段物理键定义 ──");
|
||||
lines.push("const FIELDS = {");
|
||||
for (const f of entity.fields) {
|
||||
const suffix = f.name.startsWith(prefix) ? f.name.slice(prefix.length) : f.name;
|
||||
const safeLabel = f.label.replace(/"/g, '\\"');
|
||||
lines.push(` "${safeLabel}": FIELD_PREFIX + "${suffix}", // ${f.type || "text"}${f.optional === false ? " [必填]" : ""}`);
|
||||
}
|
||||
lines.push("};");
|
||||
lines.push("");
|
||||
lines.push("// ── 写入数据对象示例 ──");
|
||||
lines.push("const recordData = {");
|
||||
for (const f of entity.fields) {
|
||||
const safeLabel = f.label.replace(/"/g, '\\"');
|
||||
lines.push(` [FIELDS["${safeLabel}"]]: "", // ${f.label}`);
|
||||
}
|
||||
lines.push("};");
|
||||
} else {
|
||||
// 默认 MVEL 模板
|
||||
lines.push(`// ====== 自建应用实体代码模板 [${entityName}] (MVEL) ======`);
|
||||
lines.push(`String TARGET_ENTITY_ID = "${entityId}";`);
|
||||
lines.push(`String FIELD_PREFIX = "${prefix}";`);
|
||||
lines.push("");
|
||||
lines.push("// ── 物理字段键常量 ──");
|
||||
for (const f of entity.fields) {
|
||||
const suffix = f.name.startsWith(prefix) ? f.name.slice(prefix.length) : f.name;
|
||||
const constName = `FIELD_${f.label.replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g, "_")}`;
|
||||
lines.push(`String ${constName} = FIELD_PREFIX + "${suffix}"; // ${f.label} (${f.type || "text"})${f.optional === false ? " [必填]" : ""}`);
|
||||
}
|
||||
lines.push("");
|
||||
lines.push("// ── DataLink 行构建模板 (row.put) ──");
|
||||
lines.push("Map row = new HashMap();");
|
||||
for (const f of entity.fields) {
|
||||
const constName = `FIELD_${f.label.replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g, "_")}`;
|
||||
lines.push(`row.put(${constName}, ""); // ${f.label}`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: `${lines.join("\n")}\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { booleanOption } from "../../parser.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
import { handleList, handleGet, handleEntities, handleSchema, handlePermissions, handleImports } from "./app-info.js";
|
||||
import { handleList, handleGet, handleEntities, handleSchema, handlePermissions, handleImports, handleGenProps } from "./app-info.js";
|
||||
import { handleRecords, handleAudit } from "./records.js";
|
||||
import { handleRecordAction } from "./record-actions.js";
|
||||
|
||||
@@ -47,9 +47,12 @@ export async function handlePlatformCommand(parsed: CliParsedArgs, runtime: CliR
|
||||
case "permissions":
|
||||
case "permission":
|
||||
case "auth": return handlePermissions(parsed, runtime);
|
||||
case "gen-props":
|
||||
case "gen-mvel-props":
|
||||
case "props": return handleGenProps(parsed, runtime);
|
||||
case "imports":
|
||||
case "import-jobs": return handleImports(parsed, runtime);
|
||||
default:
|
||||
return { stdout: "", stderr: `未知 platform 子命令: ${action}。支持: list, get, entities, schema, records, audit, record, permissions, imports\n`, exitCode: 1 };
|
||||
return { stdout: "", stderr: `未知 platform 子命令: ${action}。支持: list, get, entities, schema, records, audit, record, gen-props, permissions, imports\n`, exitCode: 1 };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user