refactor: 整理工作流触发器并校验节点写入版本

集中触发器分类及 Webhook 规则,节点写入前检查远端版本并保留部分保存语义。
This commit is contained in:
gitea committed 2026-10-30 17:38:28 +08:00
1 parent c813498da2
commit 7af7e7db35
13 files changed
+191 -112

No files matched your search

@@ -0,0 +1,18 @@
import type { WorkflowTask } from "../types.js";
/** 复制的工作流需要独立的 Webhook 地址和样本。 */
export function resetCopiedWebhookTrigger(task?: WorkflowTask): void {
if (task?.type !== "webhook") return;
task.urlPath = crypto.randomUUID();
delete task.sampleId;
}
export function ensureWebhookTriggerPath(task: WorkflowTask): void {
if (task.type === "webhook" && !task.urlPath) task.urlPath = crypto.randomUUID();
}
export function webhookTriggerUrl(task: WorkflowTask): string | undefined {
const rawPath = [task.urlPath, task.url, task.path].find((value) => typeof value === "string" && value);
if (typeof rawPath !== "string") return undefined;
return rawPath.startsWith("http") ? rawPath : `https://piper.ekuaibao.com/api/webhook/${rawPath.replace(/^\/+/, "")}`;
}