The work item being handled
The chain result type
The work item being handled
Behaviors to apply, in declared order
The terminal handler, invoked exactly once when no behaviour short-circuits
The result of the chain: the terminal's result, or the short-circuiting behaviour's return value
Composes behaviours around a terminal handler — the ONE shared composer for the CQRS pipeline and all four non-HTTP ingress chains.
Behaviors are wrapped last-to-first so
behaviors[0]runs first (declared order = execution order). A behaviour short-circuits by returning without callingnext(), which skips the downstream behaviours and the terminal. A behaviour that throws — synchronously or asynchronously — REJECTS the returned promise, propagating to that ingress's existing failure path. An empty array invokes the terminal exactly once.The implementation converts every synchronous throw into a rejected promise: the declared return type is a promise, and a caller writing
.catch(...)— orPromise.allSettledover a batch — must see every failure.