mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 21:49:36 +02:00
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* Execution graph: step nodes connected by edges. The graph supports cycles
|
|
* via back-edges (loop iteration), and is captured in the execution record at
|
|
* start, immutable for the execution's lifetime.
|
|
*/
|
|
|
|
export type StepType = 'trigger' | 'v1-node' | 'wait' | 'subworkflow' | 'batch';
|
|
|
|
/**
|
|
* Per-step configuration. The engine persists it with the graph without
|
|
* inspecting it. Left as `unknown` — a to-be-narrowed union — because it
|
|
* becomes a discriminated union of concrete per-`StepType` configs as those
|
|
* step types land, rather than an arbitrary JSON blob.
|
|
*/
|
|
export type StepConfig = unknown;
|
|
|
|
export interface GraphNode {
|
|
/** Deterministic from the source workflow, so re-converting yields the same graph. */
|
|
id: string;
|
|
/** Human-readable name (the v1 node name, for v1 workflows). */
|
|
name: string;
|
|
type: StepType;
|
|
/** Step-type-specific configuration; some step types (e.g. trigger) carry none. */
|
|
config?: StepConfig;
|
|
}
|
|
|
|
export interface GraphEdge {
|
|
/** Source node id. */
|
|
from: string;
|
|
/** Target node id. */
|
|
to: string;
|
|
/** Which output slot of `from` feeds this edge; `0` unless `from` has several outputs. */
|
|
outputIndex: number;
|
|
/** Which input slot of `to` this edge feeds; `0` unless `to` has several inputs (e.g. Merge). */
|
|
inputIndex: number;
|
|
/**
|
|
* Closes a cycle (loop iteration).
|
|
*
|
|
* TODO(CAT-3854): validate that back-edges really close loops.
|
|
*/
|
|
isBackEdge?: boolean;
|
|
}
|
|
|
|
export interface WorkflowGraph {
|
|
nodes: GraphNode[];
|
|
edges: GraphEdge[];
|
|
}
|