namespace w4c_workflows.Models; // --------------------------------------------------------------------------- // YAML shape (authoritative source of truth, stored in git under workflows/). // Field names are camelCase in YAML; YamlDotNet maps them via CamelCaseNaming. // --------------------------------------------------------------------------- public class WorkflowDefinition { public string? Name { get; set; } public string? Description { get; set; } public string? Version { get; set; } // user-facing build/version, e.g. "1.0.1" public string? Mode { get; set; } // function | durable | handler public string? Language { get; set; } // shell | javascript | typescript | csharp | python public string? Target { get; set; } // execution host (default: "default") /// Managed-server id (or alias) that task code should run on. A task-level /// server overrides this header default; when set, the worker executes the task /// on that server via SSH instead of a local subprocess. public string? Server { get; set; } public TriggerDefinition? Trigger { get; set; } public EntryDefinition? Entry { get; set; } public Dictionary? Env { get; set; } public List? Tasks { get; set; } /// /// Workflow-level connections between node tasks. Task-local edges take /// precedence for their own from; when both are present they are merged. /// next/onError stay valid sugar (main[0] and the error port). /// public List? Edges { get; set; } } /// /// One step of a workflow. A step is either a script task (legacy: language /// + entry) or a node task ( + ). /// The two modes are mutually exclusive. /// public class TaskDefinition { public string? Id { get; set; } public string? Parent { get; set; } // "root" | another task id (organizational) public string? Next { get; set; } // success flow → lowers to main[0] public string? OnError { get; set; } // failure flow (compensation) → lowers to the error port public string? Language { get; set; } // inherits workflow language when omitted public string? Mode { get; set; } // inherits workflow mode when omitted /// Target managed server for this task. Overrides the workflow header server. public string? Server { get; set; } public EntryDefinition? Entry { get; set; } public Dictionary? Env { get; set; } // ---- node-mode fields (n8n-style integration steps) -------------------- /// Catalog blueprint this step runs. Requires . public NodeTaskDefinition? Node { get; set; } /// /// Node parameters. Values may be literals or expressions (see the parameter /// interpolation rules); nested mappings/sequences are supported. /// public Dictionary? Parameters { get; set; } /// /// Credentials this node needs, keyed by the blueprint's credential alias; /// the value is the vault credential id or its unique name. Resolved to /// decrypted data at run time. /// public Dictionary? Credentials { get; set; } /// Explicit outgoing connections owned by this step (from = this id). public List? Edges { get; set; } /// Per-node retry policy. public TaskRetryDefinition? Retry { get; set; } /// Route failures to the error port instead of failing the run. public bool? ContinueOnFail { get; set; } /// Overrides the blueprint run mode: eachItem | allItems. public string? RunMode { get; set; } } /// Reference to a node type in the catalog, with an optional pinned version. public class NodeTaskDefinition { public string? Type { get; set; } /// Pinned blueprint version; null/absent means "use the default (highest)". public double? Version { get; set; } } /// /// A directed connection between two steps. defaults to the /// owning task for task-local edges; a global edge must set it. /// public class TaskEdgeDefinition { /// Source task id (defaults to the owning task). public string? From { get; set; } /// Source output port index; defaults to 0 (main). public int? Output { get; set; } /// Target task id. public string? To { get; set; } /// Target input port index; defaults to 0 (main). public int? Input { get; set; } } /// Retry policy for a node task. public class TaskRetryDefinition { /// Total attempts (1 = no retry). public int? MaxTries { get; set; } /// Initial delay between attempts, e.g. "2s" or "500ms". public string? WaitBetweenTries { get; set; } /// Multiplier applied to the delay after each failed attempt. public double? BackoffFactor { get; set; } /// HTTP status codes that are retried before the policy gives up. public List? RetryOnStatus { get; set; } } public class TriggerDefinition { public string? Type { get; set; } // queue | cron | interval | webhook | event public string? Stream { get; set; } // queue: stream/topic (default wf:{tenant}:events) public string? Cron { get; set; } // cron: "0 */6 * * *" public string? Interval { get; set; } // interval: "30m", "2h", "45s" public string? WebhookPath { get; set; } // webhook: "/h/orders" } public class EntryDefinition { public string? File { get; set; } public string? Function { get; set; } }