建立 applications 的应用模型和查询出口,保留基础及详情投影差异。 下沉 DataLink,将工作流模型、API、编排及执行上下文归回 workflow。 同步 CLI、SDK、生成脚本、测试和活跃文档引用,公开命令与 SDK 名称保持兼容。 验证:943 项测试、类型和版本检查通过;三份生成规范字节一致,README 审计通过。
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import { deleteWorkflow, getWorkflowDetail } from "../../../domains/platform/workflow/services.js";
|
|
import { stringOption } from "../../parser.js";
|
|
import { printJson } from "../../printer.js";
|
|
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
|
|
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
|
import { createWorkflowDetailClient } from "./shared.js";
|
|
|
|
export async function handleDelete(
|
|
parsed: CliParsedArgs,
|
|
runtime: CliRuntime
|
|
): Promise<CliResult> {
|
|
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipelineId"]);
|
|
|
|
if (!pipelineId) {
|
|
return {
|
|
stdout: "",
|
|
stderr: [
|
|
"用法: hose-use workflow delete <pipelineId> [选项]",
|
|
"",
|
|
"选项:",
|
|
" --dry-run 预览删除操作,不实际删除",
|
|
" --yes 确认执行删除",
|
|
"",
|
|
"别名: rm, remove",
|
|
"示例: hose-use workflow delete 898588496146063385 --yes",
|
|
].join("\n") + "\n",
|
|
exitCode: 1,
|
|
};
|
|
}
|
|
|
|
requireMutationConfirmation(
|
|
parsed,
|
|
runtime,
|
|
"删除工作流",
|
|
`hose-use workflow delete ${pipelineId} --yes`
|
|
);
|
|
|
|
const { client } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
|
|
|
if (isDryRun(parsed, runtime)) {
|
|
const detail = await getWorkflowDetail(client, pipelineId).catch(() => null);
|
|
return mutationPreview(parsed, runtime, "删除工作流", pipelineId, {
|
|
pipelineId,
|
|
name: detail?.label || "未知流程",
|
|
state: detail?.state === 1 ? "🟢 启用中" : "⚪ 停用中",
|
|
});
|
|
}
|
|
|
|
await deleteWorkflow(client, pipelineId);
|
|
|
|
if (runtime.jsonMode) {
|
|
return {
|
|
stdout: printJson({ success: true, pipelineId }, runtime.outputOptions),
|
|
stderr: "",
|
|
exitCode: 0,
|
|
};
|
|
}
|
|
|
|
return {
|
|
stdout: `🗑️ 工作流 [${pipelineId}] 已成功删除。\n`,
|
|
stderr: "",
|
|
exitCode: 0,
|
|
};
|
|
}
|