waygraph / ApiBlockOptions
Interface: ApiBlockOptions<In, Out>
Defined in: src/engine/block/kinds/api.ts:29
Options for defineApiBlock: the HTTP call, how its result maps to a Checkpoint, and the demo network panel.
Type Parameters
In
In extends Checkpoint<string>
Out
Out extends Checkpoint<string>
Properties
call
call: (
ctx) =>Promise<APIResponse<any>>
Defined in: src/engine/block/kinds/api.ts:37
Make the request - request is Playwright's own page.request (same cookies/origin as the browser context, so an authenticated UI session carries over to the API call for free).
Parameters
ctx
mem
request
APIRequestContext
Returns
Promise<APIResponse<any>>
Example
call: ({ request }) => request.get("/api/orders/1")description?
optionaldescription?:string
Defined in: src/engine/block/kinds/api.ts:31
expect?
optionalexpect?:ExpectList<Out>
Defined in: src/engine/block/kinds/api.ts:59
What this Block promises wherever it's used, checked after its verify: Expect Blocks, Traits, Key.is(...). A Block that can land in several places lists them per outcome. Read-only and run together; a step can drop them ({ expect: false }) or add its own.
Example
expect: [ExpectArchivedToastBlock] · expect: { EquipmentDetail: [ExpectSavedBlock], EquipmentAdd: [ExpectNameRequiredBlock] }from?
optionalfrom?:In| readonlyIn[]
Defined in: src/engine/block/kinds/api.ts:47
Where it runs: one Checkpoint value or a list; leave it out for "from anywhere".
method?
optionalmethod?:string
Defined in: src/engine/block/kinds/api.ts:45
HTTP method shown in the network-tab overlay (GET/POST/PATCH/...) - APIResponse (unlike a page's own Response) carries no back-reference to the request that produced it, so this can't be read back automatically; defaults to "GET" if omitted. Purely cosmetic - never affects the actual request call makes.
Example
method: "POST"name
name:
string
Defined in: src/engine/block/kinds/api.ts:30
requires?
optionalrequires?: readonlyMemKey<unknown>[]
Defined in: src/engine/block/kinds/api.ts:60
resolve?
optionalresolve?: (result) =>Out
Defined in: src/engine/block/kinds/api.ts:51
Pure, like every other Block's resolve - picks the Checkpoint from the response. Optional when to is one Checkpoint.
Parameters
result
Returns
Out
to
to:
Out| readonlyOut[]
Defined in: src/engine/block/kinds/api.ts:49
Where it lands: one Checkpoint value (then resolve may be left out) or a list.
undo?
optionalundo?: (ctx) =>Promise<APIResponse<any>>
Defined in: src/engine/block/kinds/api.ts:67
What puts the world back after this Block made something (delete what call created). When the Block is a flow's given (a precondition), it runs after the flow, pass or fail, in the reverse order of the givens; its failure is reported and never decides the flow. Read mem for the id call stored.
Parameters
ctx
mem
request
APIRequestContext
Returns
Promise<APIResponse<any>>
Example
undo: ({ request, mem }) => request.delete(`/posts/${mem.get(SeededId)}`)verify?
Defined in: src/engine/block/kinds/api.ts:52