Journey Definition Resolver
Source file: packages/core/src/journey-machine/resolve-journey-definition.ts
This file turns authored transition shapes into the one runtime shape the machine actually executes: an ordered array of transitions.
How It Works
Section titled “How It Works”- If
journey.transitionsis missing, the resolver returns the journey with an empty transition list. - If transitions were authored as an array, the file treats that as a linear journey declaration. It validates
that every entry is a known step id, checks that the first item matches
journey.initial, and expands the array into implicitgoToNextStepedges. - If transitions were authored as an object graph, the file validates each
from -> event -> edges[]layer and flattens it into ordered transition objects. - Every named step branch is resolved first and keeps its step id. The
globalbranch is resolved last and rewritten tofrom: "*", so it behaves as a fallback bucket after step-local transitions for the same event. - The original journey object is returned with
transitionsreplaced by that normalized array.
The important guarantee is ordering. send.ts scans transitions in order, so the resolver preserves author intent
while still giving the runtime one deterministic structure to evaluate.
Recommended Reading
Section titled “Recommended Reading”- Read Send Pipeline to see how the ordered transition list is consumed.
- Read Transitions Syntax for the public authoring shapes this file accepts.
- Read Quickstart if you want to compare the normalized behavior with authored examples.