feat(workflow): add action enums, EKB_ENUM resolver, and condition dead-filter lint

This commit is contained in:
gitea committed 2026-10-16 13:27:32 +08:00
1 parent 627e17e0f2
commit 1876e8a8f2
10 files changed
+484 -9

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
import {
resolveWorkflowEnumOptions,
SYSTEM_WORKFLOW_ACTION_ENUMS,
} from "../../../domains/platform/services.js";
import { stringOption } from "../../parser.js";
import { printJson, printTable, printKeyValue } from "../../printer.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
import { createJobPiperClient } from "./shared.js";
export async function handleWorkflowEnum(
parsed: CliParsedArgs,
runtime: CliRuntime
): Promise<CliResult> {
const thirdId =
parsed.args[0] ||
stringOption(parsed.options, ["third-id", "thirdId", "id", "type"]) ||
"action";
let client: any = undefined;
if (runtime.selectedCorp) {
try {
client = await createJobPiperClient(parsed, runtime);
} catch {
// 离线或创建客户端失败时走本地内置 Fallback
}
}
const platformId = stringOption(parsed.options, ["platform-id", "platformId", "app-id", "appId"]);
const items = await resolveWorkflowEnumOptions(client, thirdId, platformId);
if (runtime.jsonMode) {
return {
stdout: printJson(items, runtime.outputOptions),
stderr: "",
exitCode: 0,
};
}
if (items.length === 0) {
return {
stdout: "",
stderr: `未查询到字典/枚举 [${thirdId}] 的可用选项(可能无网络、无自建应用权限或该 thirdId 不存在)。\n`,
exitCode: 1,
};
}
const isAction = thirdId.toLowerCase() === "action";
const rows = items.map((item) => [
item.code,
item.label,
item.description ||
(isAction
? SYSTEM_WORKFLOW_ACTION_ENUMS.find((s) => s.code === item.code)?.description || "-"
: "-"),
]);
const output = [
`====== 工作流枚举字典: ${thirdId} (共 ${items.length} 项) ======`,
printKeyValue({
"字典类别 (thirdId)": thirdId,
"总项数": items.length,
"数据来源": client ? "在线获取 (含内置兼容)" : "系统内置静态字典 (离线/默认)",
}),
"",
printTable(["Code (底层真实值)", "名称 (界面展示)", "说明 / 适用场景"], rows),
"",
isAction
? "💡 提示:在配置工作流条件节点时,务必选择 [通知类型] (action) 并从下拉列表中选中上述枚举,切勿选择 [审批状态] 匹配汉字!"
: "",
]
.filter(Boolean)
.join("\n");
return {
stdout: output + "\n",
stderr: "",
exitCode: 0,
};
}