Day 2: Multi-role approval
Day 1 had one approver. Day 2 has several, in a defined order, and the interesting question becomes: who is allowed to answer which one, and when?
Same project, same prepared identity data. Nothing here needs a customer identity service or a second runtime.
Gate G4 — required implementation. The walkthrough is executable only when the supplied starter and its pinned dependencies pass their own checks.
The exact install, workflow, and test code is in Testing Workflows.
Before you change anything: restore the starter revision from yesterday, check PostgreSQL and the prepared data are up, and re-run the Day 1 test. Save that result.
This takes two minutes and saves an hour. When something breaks after your change, you want to be certain it was your change.
Follow one request through its approvals. For each one, find five things: what goes in, who gets asked, where it waits, what comes back, and which events mark the transition.
The order lives in the workflow definition — it is code, not a convention the UI happens to follow. That’s the whole point of writing processes this way.
Where several approvals are independent, the workflow uses plain
Promise.allSettled. There is nothing IdentityFlow-specific about it: the
standard method does what you expect. Read the
Promise composition contract
before you change that part, because there is one subtlety — a rejection is a
business outcome you handle, while the engine pausing the workflow is control
flow and never shows up as a settled result.
Change one stage at a time, then re-run the test and check which person can see and complete which pending step.
Two things to keep straight when you do:
- Refer to people by provider and principal, never by a bare string. The same text under a different provider is a different person as far as the engine is concerned.
- Say explicitly who a step is for. Don’t let it be implied by ordering.
Keep the change small enough that you can still explain the resulting event list to someone else.
The 0.2.0 release teaches this example as it is. There is no helper API for declaring ordered stages — it was considered and dropped from this release — so don’t go looking for one or present one as available.
When a step’s recipient has to come from an external system instead of being known up front, that’s a different mechanism; see Assignee Sources. This page stays on the prepared data.