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

+3 -11
View File
@@ -1,6 +1,6 @@
import { existsSync, readFileSync } from "node:fs";
import ky from "ky";
import { getWorkflowDetail } from "../../../domains/platform/workflow/services.js";
import { getWorkflowDetail, webhookTriggerUrl } from "../../../domains/platform/workflow/services.js";
import { getBillByCodeOrId } from "../../../domains/bill/tools.js";
import { stringOption } from "../../parser.js";
import { printJson, printKeyValue } from "../../printer.js";
@@ -60,13 +60,9 @@ export async function handleWebhookCommand(
};
}
const rawNode = triggerNode as Record<string, unknown>;
const rawPath =
(typeof rawNode.urlPath === "string" && rawNode.urlPath) ||
(typeof rawNode.url === "string" && rawNode.url) ||
(typeof rawNode.path === "string" && rawNode.path);
const webhookUrl = triggerNode && webhookTriggerUrl(triggerNode);
if (!rawPath) {
if (!webhookUrl) {
return {
stdout: "",
stderr: `❌ 未能在 Webhook 触发器节点 [${triggerNode?.name || "-"}] 中找到有效的调用路径 (urlPath)。\n`,
@@ -74,10 +70,6 @@ export async function handleWebhookCommand(
};
}
const webhookUrl = rawPath.startsWith("http")
? rawPath
: `https://piper.ekuaibao.com/api/webhook/${rawPath.replace(/^\/+/, "")}`;
let payload: Record<string, unknown> = {};
const rawBody = stringOption(parsed.options, ["body", "data", "payload"]);
const filePath = stringOption(parsed.options, ["file", "path"]);