feat(workflow): implement trigger-aware debug path branching for clock, webhook, datalink and flowform
This commit is contained in:
1 parent
c74fdda7da
commit
c8d9e409c6
6 files changed
+523
-57
No files matched your search
@@ -22,10 +22,22 @@ hose-use workflow logs <pipelineId> [--has-error] [--state=FAILED]
|
||||
hose-use workflow job <jobId> [--failed] [--node=<name|id>] [--verbose]
|
||||
hose-use workflow diff <snapshotId1> <snapshotId2> [--pipelineId=<id>]
|
||||
hose-use workflow diff-job <jobId1> <jobId2> [--json]
|
||||
hose-use workflow test <pipelineId> --flow=<单号|单据ID> [--auto-publish]
|
||||
hose-use workflow test <pipelineId> [--flow=<单号>] [--record=<ID>] [--body='{...}']
|
||||
hose-use workflow debug <pipelineId> --flow=<单号>
|
||||
```
|
||||
|
||||
## 触发器分类与调测路径分支 (Path Branching)
|
||||
|
||||
合思 EASO/Piper 调度引擎下不同首节点(Trigger)底层的调试协议存在显著差异,`hose-use workflow test` 会自动自适应路由:
|
||||
|
||||
| 触发器分类 (`category`) | 常见触发器类型 (`type`) | 调测协议与入参 | CLI 命令与交互行为 |
|
||||
|---|---|---|---|
|
||||
| **`SCHEDULE`** (定时调度) | `clock` | 服务端无 `debugSource`,`inputs: { id: "" }` | **自动模拟触发**:无需 `--flow`,直接秒级派发并抓取执行树 |
|
||||
| **`WEBHOOK`** (外部集成) | `webhook`, `hab-trigger-task` | 服务端无 `debugSource`,`inputs: { data: { ... } }` | **Payload 注入**:支持 `--body='{...}'` / `--file=event.json` / `--empty` |
|
||||
| **`DATALINK`** (业务对象台账) | `ekuaibao-datalink-*-trigger` | 服务端返回 `fields` 动态列定义与台账记录 | **动态列展示**:按实体结构动态打表,支持 `--record=<ID>` 或 `--flow=<编码>` |
|
||||
| **`FLOW_FORM`** (单据流转) | `ekuaibao-flowform-trigger`, `ekuaibao-ebot-trigger` | 服务端返回单据列表与表单定义 | **单据列表与筛选**:支持 `--flow=<单号>`,未提供时拉取候选单据表供挑选 |
|
||||
|
||||
|
||||
## 生产环境调试缺陷与安全防线(合思平台缺陷记录)
|
||||
|
||||
> [!WARNING] **合思后端架构缺陷:前端置灰防御,后端裸奔无防**
|
||||
|
||||
@@ -346,13 +346,14 @@ export async function getWorkflowDebugSource(
|
||||
export async function triggerWorkflowDebug(
|
||||
client: KyInstance,
|
||||
pipelineId: string,
|
||||
options: { entityId: string; autoPublish?: boolean; dataLimit?: number }
|
||||
options: { entityId?: string; data?: Record<string, any>; autoPublish?: boolean; dataLimit?: number } = {}
|
||||
): Promise<string> {
|
||||
const response = await client.post("api/easo/jobs", {
|
||||
json: {
|
||||
pipelineId,
|
||||
inputs: {
|
||||
id: options.entityId,
|
||||
id: options.entityId ?? "",
|
||||
...(options.data !== undefined ? { data: options.data } : {}),
|
||||
$autoPublish: options.autoPublish ?? false,
|
||||
},
|
||||
dataLimit: options.dataLimit ?? 20,
|
||||
|
||||
@@ -658,23 +658,28 @@ export async function runWorkflowDebugTest(
|
||||
client: import("ky").KyInstance,
|
||||
pipelineId: string,
|
||||
options: {
|
||||
flowCodeOrId: string;
|
||||
flowCodeOrId?: string;
|
||||
data?: Record<string, any>;
|
||||
triggerCategory?: import("./types.js").WorkflowTriggerCategory;
|
||||
triggerType?: string;
|
||||
triggerLabel?: string;
|
||||
autoPublish?: boolean;
|
||||
timeoutMs?: number;
|
||||
pollIntervalMs?: number;
|
||||
}
|
||||
} = {}
|
||||
): Promise<import("./types.js").WorkflowTestReport> {
|
||||
let targetEntityId = options.flowCodeOrId;
|
||||
const isDirectCode = options.flowCodeOrId.includes("-") || options.flowCodeOrId.startsWith("ID01");
|
||||
if (!isDirectCode) {
|
||||
let targetEntityId = options.flowCodeOrId ?? "";
|
||||
const code = options.flowCodeOrId;
|
||||
const isDirectCode = !code || code.includes("-") || code.startsWith("ID01");
|
||||
if (code && !isDirectCode) {
|
||||
try {
|
||||
const source = await api.getWorkflowDebugSource(client, pipelineId, {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keywords: options.flowCodeOrId,
|
||||
keywords: code,
|
||||
});
|
||||
const matched = source.items.find(
|
||||
(item) => item.id === options.flowCodeOrId || item.title.includes(options.flowCodeOrId)
|
||||
(item) => item.id === code || (item as any).code === code || item.title?.includes(code) || (item as any).name?.includes(code)
|
||||
);
|
||||
if (matched) {
|
||||
targetEntityId = matched.id;
|
||||
@@ -685,7 +690,8 @@ export async function runWorkflowDebugTest(
|
||||
}
|
||||
|
||||
const jobId = await api.triggerWorkflowDebug(client, pipelineId, {
|
||||
entityId: targetEntityId,
|
||||
entityId: targetEntityId || undefined,
|
||||
data: options.data,
|
||||
autoPublish: options.autoPublish ?? false,
|
||||
});
|
||||
|
||||
@@ -734,6 +740,9 @@ export async function runWorkflowDebugTest(
|
||||
runType: finalJob.runType || "DEBUG",
|
||||
durationTime: typeof (finalJob as any).durationTime === "number" ? (finalJob as any).durationTime : undefined,
|
||||
targetEntityId,
|
||||
triggerCategory: options.triggerCategory,
|
||||
triggerType: options.triggerType,
|
||||
triggerLabel: options.triggerLabel,
|
||||
executionTree: tree,
|
||||
failedExecutions: rawFailed,
|
||||
conditionDiagnoses,
|
||||
@@ -746,3 +755,8 @@ export {
|
||||
type ConditionRuleExplanation,
|
||||
} from "./workflow-branch.js";
|
||||
|
||||
export {
|
||||
classifyWorkflowTrigger,
|
||||
type WorkflowTriggerCategory,
|
||||
} from "./types.js";
|
||||
|
||||
@@ -191,14 +191,14 @@ export const FlowCreateTaskSchema = BaseTaskSchema.extend({
|
||||
// 兜底节点:遇到未收录类型时仍保留全部字段
|
||||
export const UnknownTaskSchema = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
name: z.string().default("task"),
|
||||
type: z.string(),
|
||||
label: z.string().optional(),
|
||||
desc: z.string().optional(),
|
||||
groupName: z.string(),
|
||||
orderIndex: z.number(),
|
||||
levelIndex: z.array(z.number()),
|
||||
status: z.string(),
|
||||
groupName: z.string().default("trigger"),
|
||||
orderIndex: z.number().default(0),
|
||||
levelIndex: z.array(z.number()).default([0]),
|
||||
status: z.string().default("active"),
|
||||
displayName: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
@@ -634,9 +634,40 @@ export interface WorkflowTestReport {
|
||||
runType: string;
|
||||
durationTime?: number;
|
||||
targetEntityId: string;
|
||||
triggerCategory?: WorkflowTriggerCategory;
|
||||
triggerType?: string;
|
||||
triggerLabel?: string;
|
||||
executionTree: WorkflowTaskExecution[];
|
||||
failedExecutions: WorkflowTaskExecution[];
|
||||
conditionDiagnoses: import("./workflow-branch.js").ConditionBranchExplanation[];
|
||||
}
|
||||
|
||||
// ── 触发器元类型分类与智能路径路由 ───────────────────────────────────────────────
|
||||
|
||||
export type WorkflowTriggerCategory =
|
||||
| "FLOW_FORM" // 单据审批流转类 (ekuaibao-flowform-trigger, ekuaibao-ebot-trigger, other-event-trigger)
|
||||
| "DATALINK" // 业务对象/台账变更类 (ekuaibao-datalink-create-trigger, ekuaibao-datalink-change-trigger, ekuaibao-datalink-time-trigger, datalink-button-trigger, ekuaibao-tmc-datalink-change-trigger)
|
||||
| "SCHEDULE" // 定时调度类 (clock)
|
||||
| "WEBHOOK" // 外部调用/网关集成类 (webhook, hab-trigger-task)
|
||||
| "CUSTOM"; // 其他自定义触发器
|
||||
|
||||
export function classifyWorkflowTrigger(triggerType?: string): WorkflowTriggerCategory {
|
||||
if (!triggerType) return "CUSTOM";
|
||||
const t = triggerType.toLowerCase();
|
||||
if (t === "clock" || t.includes("timer") || t.includes("schedule")) {
|
||||
return "SCHEDULE";
|
||||
}
|
||||
if (t.includes("flowform") || t.includes("ebot") || t.includes("flow-") || t === "other-event-trigger") {
|
||||
return "FLOW_FORM";
|
||||
}
|
||||
if (t.includes("datalink") || t.includes("entity")) {
|
||||
return "DATALINK";
|
||||
}
|
||||
if (t.includes("webhook") || t.includes("hab-trigger")) {
|
||||
return "WEBHOOK";
|
||||
}
|
||||
return "CUSTOM";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user