- 在 `domains/platform/workflow/transport/outbound/` 接入合思 `api/outbound/v1/message` 与 `api/outbound/v1/message/messageLog` 接口; - 在 `domains/platform/workflow/services.ts` 暴露 `getOutboundMessages` 与 `queryOutboundMessageLogs` 服务门面; - 新增 `hose-use workflow outbound (list|logs)` 命令与别名支持; - 在 `command-metadata.ts` 补齐对应子命令与 `--sn`、`--message-type`、`--start`、`--offset` 等参数校验契约; - 补齐单元测试并通过全量单测与类型检查。
144 lines
4.4 KiB
TypeScript
144 lines
4.4 KiB
TypeScript
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
|
import { handleList, handleGet, handleFind } from "./list.js";
|
|
import { handleToggle, handlePublish } from "./lifecycle.js";
|
|
import { handlePatch, handleSave, handleRefreshChooses } from "./draft.js";
|
|
import { handleHistory, handleLogs } from "./history.js";
|
|
import { handleJob } from "./job.js";
|
|
import { handleCheck } from "./check.js";
|
|
import { handleAnalyze } from "./analyze.js";
|
|
import { handleWorkflowDiff, handleWorkflowDiffJob } from "./diff.js";
|
|
import { handleWorkflowTest } from "./test.js";
|
|
import { handleCopy } from "./copy.js";
|
|
import { handleDelete } from "./delete.js";
|
|
import { handleCreate } from "./create.js";
|
|
import { handleNodeCommand } from "./node.js";
|
|
import { handleWorkflowTailCommand } from "./tail.js";
|
|
import { handleWorkflowLintScript, handleWorkflowEvalScript } from "./script.js";
|
|
import { handleWorkflowEnum } from "./enum.js";
|
|
import { handleWebhookCommand } from "./webhook.js";
|
|
import { handleWorkflowLink } from "./link.js";
|
|
import { handleOutboundCommand } from "./outbound.js";
|
|
|
|
|
|
export async function handleWorkflowCommand(
|
|
parsed: CliParsedArgs,
|
|
runtime: CliRuntime
|
|
): Promise<CliResult> {
|
|
const currentCorp = runtime.selectedCorp;
|
|
if (!currentCorp) {
|
|
return {
|
|
stdout: "",
|
|
stderr: "未选中企业,请先通过 hose-use corps switch 或 --corp 指定企业\n",
|
|
exitCode: 1,
|
|
};
|
|
}
|
|
|
|
const action = parsed.action || "list";
|
|
|
|
switch (action) {
|
|
case "list":
|
|
case "list-all":
|
|
case "ls":
|
|
return handleList(parsed, runtime);
|
|
case "get":
|
|
case "detail":
|
|
case "info":
|
|
return handleGet(parsed, runtime);
|
|
case "find":
|
|
case "search":
|
|
return handleFind(parsed, runtime);
|
|
case "toggle":
|
|
return handleToggle(parsed, runtime);
|
|
case "publish":
|
|
case "enable":
|
|
return handlePublish(parsed, runtime);
|
|
case "save":
|
|
case "update":
|
|
return handleSave(parsed, runtime);
|
|
case "refresh-chooses":
|
|
return handleRefreshChooses(parsed, runtime);
|
|
case "patch":
|
|
return handlePatch(parsed, runtime);
|
|
case "history":
|
|
case "snapshots":
|
|
return handleHistory(parsed, runtime);
|
|
case "logs":
|
|
case "log":
|
|
return handleLogs(parsed, runtime);
|
|
case "job":
|
|
case "execution":
|
|
return handleJob(parsed, runtime);
|
|
case "check":
|
|
case "health":
|
|
return handleCheck(parsed, runtime);
|
|
case "analyze":
|
|
case "analyse":
|
|
return handleAnalyze(parsed, runtime);
|
|
case "diff":
|
|
case "diff-snapshot":
|
|
case "diff-snapshots":
|
|
case "compare":
|
|
return handleWorkflowDiff(parsed, runtime);
|
|
case "diff-job":
|
|
case "diff-jobs":
|
|
case "compare-job":
|
|
return handleWorkflowDiffJob(parsed, runtime);
|
|
case "test":
|
|
case "debug":
|
|
case "run-test":
|
|
return handleWorkflowTest(parsed, runtime);
|
|
case "copy":
|
|
case "cp":
|
|
case "clone":
|
|
return handleCopy(parsed, runtime);
|
|
case "delete":
|
|
case "rm":
|
|
case "remove":
|
|
return handleDelete(parsed, runtime);
|
|
case "create":
|
|
case "new":
|
|
case "add":
|
|
return handleCreate(parsed, runtime);
|
|
case "node":
|
|
case "nodes":
|
|
return handleNodeCommand(parsed, runtime);
|
|
case "tail":
|
|
case "watch":
|
|
case "follow":
|
|
return handleWorkflowTailCommand(parsed, runtime);
|
|
case "lint-script":
|
|
case "lint":
|
|
case "lint-code":
|
|
return handleWorkflowLintScript(parsed, runtime);
|
|
case "eval-script":
|
|
case "eval":
|
|
case "eval-code":
|
|
case "run-script":
|
|
return handleWorkflowEvalScript(parsed, runtime);
|
|
case "enum":
|
|
case "enums":
|
|
case "dictionary":
|
|
case "dict":
|
|
return handleWorkflowEnum(parsed, runtime);
|
|
case "webhook":
|
|
case "webhook-send":
|
|
case "webhooks":
|
|
return handleWebhookCommand(parsed, runtime);
|
|
case "link":
|
|
case "url":
|
|
case "web":
|
|
return handleWorkflowLink(parsed, runtime);
|
|
case "outbound":
|
|
case "outbounds":
|
|
case "outbound-message":
|
|
return handleOutboundCommand(parsed, runtime);
|
|
default:
|
|
return {
|
|
stdout: "",
|
|
stderr: `未知 workflow 子命令: ${action}。支持: list, get, find, analyze, toggle, publish, patch, save, refresh-chooses, history, logs, job, diff, diff-job, check, test, copy, create, delete, node, tail, lint-script, eval-script, enum, webhook, link, outbound\n`,
|
|
exitCode: 1,
|
|
};
|
|
|
|
}
|
|
}
|