waygraph / ComposedBlock
Interface: ComposedBlock<In, Out>
Defined in: src/engine/block/compose.ts:20
A Block guaranteed to have withStepVerify/modStepVerify attached - what composeBlock returns. Extends plain Block, so it drops straight into a flow like any other Block; no special casing needed anywhere that only expects a Block.
Extends
Block<In,Out>
Extended by
Type Parameters
In
In extends Checkpoint<string>
Out
Out extends Checkpoint<string>
Properties
demoPace?
optionaldemoPace?:DemoPace
Defined in: src/engine/block/block.ts:138
Demo pacing for this Block (the { pace } step option). Demo/step only - runGraph ignores. Prefer fastForwardComposeBlock for blitz.
Inherited from
description?
optionaldescription?:string
Defined in: src/engine/block/block.ts:105
A human-readable sentence describing what this Block actually tests or does - "the outsider case: a user outside a request's audience is denied its detail page," not a restatement of the code. Purely additive, optional narration for a human watching a run (demo tooling shows it before the Block runs) - never read by runGraph/connect/anything that decides behavior. A Block with none just shows its name instead.
Inherited from
instruction
instruction:
Instruction<In,Out,unknown>
Defined in: src/engine/block/block.ts:107
The act/observe/resolve/verify pipeline itself. See Instruction.
Inherited from
name
name:
string
Defined in: src/engine/block/block.ts:95
A short, stable label - shows up in every error this Block can produce ("Y: check X didn't pass").
Inherited from
requires?
optionalrequires?: readonlyMemKey<unknown>[]
Defined in: src/engine/block/block.ts:133
MemKeys this Block's act reads from mem and needs already set. Declaring it lets preflight (built into runGraph) catch a missing value before any browser action runs, instead of failing loud deep inside act.
Example
requires: [LoginCreds.key]Inherited from
routes?
optionalroutes?:Readonly<Record<string,string|null>>
Defined in: src/engine/block/block.ts:125
branch()'s routing table as plain, readable data - Checkpoint tag -> target Block's .name (null for a terminal tag) - alongside next itself, which stays the actual runtime dispatch. next is an opaque closure a graph-introspection tool can't read; this is next's own routing decisions exposed as data instead, purely additive and never consulted by runGraph/connect - it exists only for tools like Flow's inspection method (and, eventually, toMermaid) to walk without executing anything. A route back to the Block itself (a self-loop) maps to that same Block's own name, not null.
Inherited from
Methods
instanceOptions()?
optionalinstanceOptions(page):Promise<readonlyWaygraphInstanceOption<unknown>[]>
Defined in: src/engine/block/block.ts:151
Optional. When this Block's real choices depend on the live page (which of several items to add to cart, which of several rows to open) rather than being knowable ahead of time, this returns one option per live choice - waygraph auto lists one menu row per option (via label) instead of a single generic edge, and seeds mem.set(option.key, option.value) before this Block's own act() runs when a row is picked. Purely additive tooling data - runGraph/ connect/anything that decides behavior never consults it; a Block without it behaves exactly as before.
Parameters
page
Page
Returns
Promise<readonly WaygraphInstanceOption<unknown>[]>
Example
instanceOptions: (page) => collectInventoryItems(page).then((items) => items.map((it) => ({ id: it.id, label: `Add "${it.name}" to cart`, key: SelectedItem.key, value: it })))Inherited from
Block.instanceOptions
modStepVerify()
modStepVerify(
step,nameOrIndex,newCheck):ComposedBlock<In,Out>
Defined in: src/engine/block/compose.ts:43
Replaces one Trait inside one step's verify list - same rules as modVerify. Throws if no step matches, or that step has no verify trait at the given name/index.
Parameters
step
string | number | SomeBlock
nameOrIndex
string | number
newCheck
Trait | ((page, mem) => Promise<boolean | TraitResult>)
Function
(page, mem) => Promise<boolean | TraitResult>
Returns
ComposedBlock<In, Out>
Example
GovFormBlock.modStepVerify("step-2-address", "zip-visible", Trait.visible("#zip-confirmed"))modVerify()?
optionalmodVerify(nameOrIndex,newCheck):Block<In,Out>
Defined in: src/engine/block/block.ts:169
Replaces one existing Trait in this Block's verify list, by its name (recommended) or numeric index, leaving every other check untouched - the v1/v2/legacy-app case, where one check needs a different selector but the rest of the Block is identical. Throws loud if the name/index doesn't exist - use Block.withVerify if there's nothing there yet to replace.
Parameters
nameOrIndex
string | number
newCheck
Trait | ((page, mem) => Promise<boolean | TraitResult>)
Function
(page, mem) => Promise<boolean | TraitResult>
Returns
Block<In, Out>
Example
LoginBlock.modVerify("url-matches", urlMatches(/dashboard\.html/))Inherited from
modVerifyAll()?
optionalmodVerifyAll(patches):Block<In,Out>
Defined in: src/engine/block/block.ts:175
Block.modVerify, but for several named checks in one call - a v2 variant that differs in five ways from v1 shouldn't need five nested calls.
Parameters
patches
Record<string, Trait["check"] | Trait>
Returns
Block<In, Out>
Example
LoginBlock.modVerifyAll({ "url-matches": urlMatches(/v2/), "cart-badge": textEquals(".badge-v2", "1") })Inherited from
next()?
optionalnext(checkpoint):SomeBlock|null|undefined
Defined in: src/engine/block/block.ts:113
Routing attached by branch. Unset on a plain or connect()-composed Block, meaning "terminal after one step". Returning the Block itself is a self-loop - see runGraph's maxSteps for the safety net that needs.
Parameters
checkpoint
Out
Returns
SomeBlock | null | undefined
Inherited from
Block.next
steps()
steps(): readonly
BlockInfo[]
Defined in: src/engine/block/compose.ts:27
This composed Block's constituent steps, in order, as plain data - same shape and purpose as Flow.blocks.
Returns
readonly BlockInfo[]
Example
GovFormBlock.steps() // [{ name: "step-1-name" }, { name: "step-2-address" }, ...]withStepVerify()
withStepVerify(
step,verify):ComposedBlock<In,Out>
Defined in: src/engine/block/compose.ts:33
Replaces one step's whole verify list, wherever it sits in this composed Block - same rules as withVerify. Throws if no step matches.
Parameters
step
string | number | SomeBlock
verify
Returns
ComposedBlock<In, Out>
Example
GovFormBlock.withStepVerify("step-2-address", [])withVerify()?
optionalwithVerify(verify):Block<In,Out>
Defined in: src/engine/block/block.ts:160
Replaces this Block's whole verify list - the only way to clear it to empty (the "I only care that I navigated this far" case) or go from no verify to some. For tweaking one existing check without restating the rest, use Block.modVerify instead.
Parameters
verify
Returns
Block<In, Out>
Examples
LoginBlock.withVerify([]) // navigation-only, no DOM confirmationLoginBlock.withVerify([urlMatches(/dashboard/)])