merge(main): 合入 main (v0.8.22) 解决 catalog 灰度开通网关冲突

- 解决 src/domains/platform/workflow/transport/catalog/api.ts 中的冲突,
  合并 innerData 解析与 interpretGatewayOutcome 判定逻辑;
- 执行 bun install 补齐 qrcode-terminal 依赖;
- 全部 1021 个单测通过,tsc --noEmit 校验通过。
This commit is contained in:
gitea committed 2026-11-03 17:53:57 +08:00
commit c3e39fe77a
53 files changed
+20116 -640

No files matched your search

+83 -39
View File
@@ -11,7 +11,7 @@ import {
import { isServerManagedDescType } from "../../../domains/platform/workflow/nodes/mutations.js";
import { ValidationError } from "../../../core/errors.js";
import type { WorkflowDetail } from "../../../domains/platform/workflow/types.js";
import { stringOption } from "../../parser.js";
import { stringOption, numberOption } from "../../parser.js";
import { printJson, printTable, printKeyValue } from "../../printer.js";
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
@@ -257,10 +257,12 @@ async function handleAddNode(
stdout: "",
stderr: [
"请指定新增节点类型: --type=<类型>",
"常见类型: code-js2 (JS脚本), code (MVEL代码), http (HTTP请求), stop (终止流程), every (循环遍历), condition (分支条件)",
"常见类型: task-dynamic-delay (延迟等待), code-js2 (JS脚本), code (MVEL代码), http (HTTP请求), stop (终止流程), every (循环遍历), condition (分支条件)",
"",
"常用选项:",
" --type=<type> 节点类型 (如 code-js2 / code)",
" --type=<type> 节点类型 (如 task-dynamic-delay / code-js2 / http)",
" --sleep-time=<秒数> 延迟等待秒数 (针对 task-dynamic-delay,如 5)",
" --set='key=value' 自定义节点属性注入",
" --label=<标题> 节点类型标题",
" --display-name=<名称> 设计器节点标题(displayName,最多 20 字符)",
" --code-file=<脚本路径> (推荐) 从本地文件导入代码,避免终端转义与 Token 浪费",
@@ -269,7 +271,9 @@ async function handleAddNode(
" --after=<前置节点name> 插入指定节点之后",
" --yes 确认追加",
"",
"示例: hose-use workflow node add 896398895352487950 --type=code-js2 --label='数据清洗' --code-file=./clean.js --yes",
"示例:",
" hose-use workflow node add 881196955148578838 --type=task-dynamic-delay --sleep-time=5 --after=action_123 --yes",
" hose-use workflow node add 896398895352487950 --type=code-js2 --label='数据清洗' --code-file=./clean.js --yes",
].join("\n") + "\n",
exitCode: 1,
};
@@ -288,6 +292,33 @@ async function handleAddNode(
code = await fs.readFile(codeFile, "utf-8");
}
const rawSleepTime = numberOption(parsed.options, ["sleep-time", "sleepTime", "seconds"]);
const rawSet = stringOption(parsed.options, ["set", "value"]);
const extra: Record<string, any> = {};
if (rawSleepTime !== undefined) {
extra.sleepTime = rawSleepTime;
}
if (rawSet) {
if (rawSet.startsWith("{") && rawSet.endsWith("}")) {
try {
Object.assign(extra, JSON.parse(rawSet));
} catch {
// fallback
}
} else {
const eqIdx = rawSet.indexOf("=");
if (eqIdx !== -1) {
const k = rawSet.slice(0, eqIdx).trim();
const v = rawSet.slice(eqIdx + 1).trim();
try {
extra[k] = JSON.parse(v);
} catch {
extra[k] = v;
}
}
}
}
requireMutationConfirmation(
parsed,
runtime,
@@ -295,6 +326,17 @@ async function handleAddNode(
`hose-use workflow node add ${pipelineId} --type=${type}${label ? ` --label="${label}"` : ""}${displayName ? ` --display-name="${displayName}"` : ""}${parent ? ` --parent="${parent}"` : ""}${after ? ` --after="${after}"` : ""} --yes`
);
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "追加工作流节点", pipelineId, {
pipelineId,
type,
label: label || "-",
displayName: displayName || "-",
targetLocation: parent ? `容器 [${parent}] 内部` : after ? `节点 [${after}] 之后` : "工作流末尾",
extra: Object.keys(extra).length ? extra : undefined,
});
}
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
const detail = await getWorkflowDetail(client, pipelineId);
@@ -306,20 +348,9 @@ async function handleAddNode(
code,
parent,
after,
extra: Object.keys(extra).length ? extra : undefined,
});
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "追加工作流节点", pipelineId, {
pipelineId,
newNodeName: newTask.name,
type: newTask.type,
label: newTask.label,
displayName: newTask.displayName,
targetLocation: parent ? `容器 [${parent}] 内部` : after ? `节点 [${after}] 之后` : "工作流末尾",
totalTasksCount: updatedWorkflow.tasks?.length || 0,
});
}
const saveResult = await saveNodeChanges(client, detail, updatedWorkflow, platformId);
if (runtime.jsonMode) {
@@ -359,12 +390,13 @@ async function handleEditNode(
"请提供节点标识 (name 或层级序号): hose-use workflow node edit <pipelineId> <nodeNameOrIndex> [选项]",
"",
"常用选项:",
" --sleep-time=<秒数> 更新延迟等待秒数 (针对 task-dynamic-delay,如 5)",
" --set='key=value' 定向修改节点自定义属性 (如 --set='sleepTime=5')",
" --label=<类型标题> 更新节点类型标题(服务端保存时可能重新生成)",
" --display-name=<新名称> 更新设计器节点标题(displayName,最多 20 字符)",
" --code-file=<脚本路径> (推荐) 从本地文件导入最新脚本,避免终端转义与 Token 浪费",
" --code=<行内代码> 直接传入代码片段(短脚本)",
" --desc=<描述> 更新节点描述",
" --set='key=value' 定向修改节点自定义属性",
" --dry-run 只预览变更",
" --yes 确认保存修改",
"",
@@ -388,15 +420,27 @@ async function handleEditNode(
const rawSet = stringOption(parsed.options, ["set", "value"]);
const customSet: Record<string, any> = {};
const rawSleepTime = numberOption(parsed.options, ["sleep-time", "sleepTime", "seconds"]);
if (rawSleepTime !== undefined) {
customSet.sleepTime = rawSleepTime;
}
if (rawSet) {
const eqIdx = rawSet.indexOf("=");
if (eqIdx !== -1) {
const k = rawSet.slice(0, eqIdx).trim();
const v = rawSet.slice(eqIdx + 1).trim();
if (rawSet.startsWith("{") && rawSet.endsWith("}")) {
try {
customSet[k] = JSON.parse(v);
Object.assign(customSet, JSON.parse(rawSet));
} catch {
customSet[k] = v;
// fallback to key=value if json parse fails
}
} else {
const eqIdx = rawSet.indexOf("=");
if (eqIdx !== -1) {
const k = rawSet.slice(0, eqIdx).trim();
const v = rawSet.slice(eqIdx + 1).trim();
try {
customSet[k] = JSON.parse(v);
} catch {
customSet[k] = v;
}
}
}
}
@@ -416,6 +460,22 @@ async function handleEditNode(
`hose-use workflow node edit ${pipelineId} ${nodeTarget}${label ? ` --label="${label}"` : ""}${displayName ? ` --display-name="${displayName}"` : ""} --yes`
);
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "修改工作流节点", `${pipelineId}:${nodeTarget}`, {
pipelineId,
nodeName: nodeTarget,
label: label || "-",
displayName: displayName || "-",
updatedFields: {
...(label ? { label } : {}),
...(displayName !== undefined ? { displayName } : {}),
...(desc ? { desc } : {}),
...(code !== undefined ? { code: `${code.length} 字符${!codeFile && code.length > 300 ? " [TIP: 建议使用 --code-file=<path> 从本地文件载入以规避转义错误并节省 Token]" : ""}` } : {}),
...customSet,
},
});
}
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
const detail = await getWorkflowDetail(client, pipelineId);
@@ -428,22 +488,6 @@ async function handleEditNode(
});
const descManaged = desc !== undefined && isServerManagedDescType(editedTask.type);
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "修改工作流节点", `${pipelineId}:${editedTask.name}`, {
pipelineId,
nodeName: editedTask.name,
label: editedTask.label,
updatedFields: {
...(label ? { label } : {}),
...(displayName !== undefined ? { displayName } : {}),
...(desc && !descManaged ? { desc } : {}),
...(descManaged ? { desc: "服务端托管,已跳过" } : {}),
...(code !== undefined ? { code: `${code.length} 字符${!codeFile && code.length > 300 ? " [TIP: 建议使用 --code-file=<path> 从本地文件载入以规避转义错误并节省 Token]" : ""}` } : {}),
...customSet,
},
});
}
const saveResult = await saveNodeChanges(client, detail, updatedWorkflow, platformId);
if (runtime.jsonMode) {