using MAF1.Decisions; namespace MAF1.Web; /// 浏览器 POST /api/run 的图:节点 + 连线。和前端 state.nodes / state.edges 一一对应。 public sealed class WorkflowGraph { public List Nodes { get; set; } = []; public List Edges { get; set; } = []; } /// 画布节点。Config 里可写 filePath、credentialId、decisionTimeoutSeconds 等固定输入。 public sealed class WorkflowNode { public string Id { get; set; } = ""; public string Type { get; set; } = ""; public string Title { get; set; } = ""; public double X { get; set; } public double Y { get; set; } public Dictionary Config { get; set; } = new(StringComparer.OrdinalIgnoreCase); } /// /// 一条边:FromPort → ToPort 传数据。When 是运行条件(hasValidCities / !hasValidCities / 空=始终)。 /// public sealed class WorkflowEdge { public string Id { get; set; } = ""; public string From { get; set; } = ""; public string To { get; set; } = ""; public string FromPort { get; set; } = ""; public string ToPort { get; set; } = ""; public string? When { get; set; } } /// 一次运行的状态机:completed / needsDecision / failed。 public static class WorkflowRunStatus { public const string Completed = "completed"; public const string NeedsDecision = "needsDecision"; public const string Failed = "failed"; } /// 返回给前端的运行快照。暂停时带 Decision,方便弹出确认框。 public sealed class WorkflowRunResult { public bool Ok { get; set; } public string Status { get; set; } = WorkflowRunStatus.Completed; public string? RunId { get; set; } public string? Error { get; set; } public DecisionRequest? Decision { get; set; } public DecisionAnswer? AppliedDecision { get; set; } public List Steps { get; set; } = []; } /// 单个节点的执行日志,显示在页面底部「运行结果」。 public sealed class NodeRunLog { public string NodeId { get; set; } = ""; public string Type { get; set; } = ""; public string Title { get; set; } = ""; public bool Skipped { get; set; } public string? Message { get; set; } public Dictionary Inputs { get; set; } = []; public Dictionary Outputs { get; set; } = []; }