Write a Dynamic View
Write a Dynamic View, one scenario as numbered Steps, so readers can follow a flow such as “a customer signs in” as a sequence chart.
Before you start
Section titled “Before you start”- Every call in the scenario is a Relationship in the Model. See Connect Services. Views says why a Step must follow one.
1. Trace the scenario
Section titled “1. Trace the scenario”Start from who or what begins it, and follow the Relationships. In the viewer, the Element panel lists each Element’s Relationships, and the Connect to… Lens shows the paths between two Elements. Where a call happens but the Model has no Relationship for it, add the Relationship first.
2. Write the Steps
Section titled “2. Write the Steps”Add the View under views › dynamic in a Project’s views.yaml. Each Step is a call, a reply with return: true, or an event from a Publisher to a Subscriber:
sign-in: title: Customer signs in steps: - from: customer to: spa description: Enters username and password - from: spa to: sign-in-controller description: POST /api/sign-in - from: sign-in-controller to: security-component description: Checks the session - from: security-component to: identity:auth-service description: Validates the token - from: identity:auth-service to: security-component return: true description: Token valid - from: sign-in-controller to: spa return: true description: Session cookieAn event is drawn the way it travels, from the Publisher, though its Relationship points the other way. To fix the order of the lifelines, list them in participants. Every field of a Step is in the Saved Views reference.
3. Check the Workspace
Section titled “3. Check the Workspace”archidocs check0 errors, 0 warningsCheck it worked
Section titled “Check it worked”In the viewer, open the View from the Views tree. It opens as a sequence chart, with its Steps listed beside it:
Select a Step to follow it.
If it didn’t
Section titled “If it didn’t”A Step needs a Relationship to follow. A reply written as a call has none:
views: dynamic: place-order: title: Place an order steps: - from: web to: api description: POST /orders - from: api to: web description: Order placedarchidocs/shop/views.yaml:9:11 error missing-step No Relationship from "shop:api" to "shop:web", nor a `via` subscription of "shop:web" to it
1 error, 0 warnings
Rule docs: missing-step https://archidocs.dev/docs/reference/rules/missing-step/That is missing-step. The second Step is the reply to the first, so add return: true to it.
check reports ambiguous-step when two Relationships connect the same pair. Name one with relationship: <id>.
With an agent
Section titled “With an agent”upsert_view writes a Dynamic View when its definition has steps. find_paths helps trace one.
Related
Section titled “Related”- Views
- Saved Views reference
- Kitchen sink, whose Dynamic View has a call, a derived edge, an event and a reply
Documents Archidocs v1.4.0, the latest release.