merge: integrate review-20-trigger-removal-guard

This commit is contained in:
gitea committed 2026-10-20 23:04:05 +08:00
commit 2e5e3c208c
4 files changed
+18 -2

No files matched your search

@@ -149,3 +149,5 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
监听结果区分完成、超时、快照和取消:只有到达终态才发送 `job_completed`;超时发送 `timeout` 并设置 `timedOut`,取消设置 `cancelled`。CLI 超时或取消返回非零退出码;`--once` 的运行中快照仍可成功返回,且不冒充完成。持续监听的总超时预算覆盖正在跟踪的 Job。
公式诊断仅对完整公式表达式且具有明确数值/日期字段类型的映射执行硬阻断;类型未知降为软建议,明确文本类型及备注中的公式样式词语不构成阻断。
节点删除命令始终保护工作流首个触发器,包括仅包含触发器的新建草稿;移除普通动作节点不受影响。触发器结构变更仍通过完整草稿保存或设计器进行。
@@ -284,7 +284,6 @@ export function removeWorkflowTask(
if (
target.parentTasks === cloned.tasks &&
target.arrayIndex === 0 &&
cloned.tasks.length > 1 &&
(target.task.groupName === "trigger" || target.task.type.includes("trigger") || target.task.type === "webhook" || target.task.type === "clock")
) {
throw new ValidationError(
@@ -0,0 +1,15 @@
import { expect, test } from "bun:test";
import { removeWorkflowTask } from "./mutations.js";
for (const type of ["webhook", "clock", "ekuaibao-datalink-create-trigger"]) {
test(`protects the only ${type} trigger from removal`, () => {
const workflow = { tasks: [{ name: "trigger", type }] } as any;
expect(() => removeWorkflowTask(workflow, "trigger")).toThrow("触发源节点");
expect(workflow.tasks).toHaveLength(1);
});
}
test("ordinary action removal remains supported while the last trigger stays protected", () => {
const workflow = { tasks: [{ name: "trigger", type: "webhook" }, { name: "action", type: "http" }] } as any;
const result = removeWorkflowTask(workflow, "action");
expect(result.workflow.tasks.map(t => t.name)).toEqual(["trigger"]);
expect(() => removeWorkflowTask(result.workflow, "trigger")).toThrow("触发源节点");
});