Release candidate — 1.0.0-rc.6
StitchAPI
Reference

Event types

The StitchEvent union and the shape of each event in the stream.

The events a stitch emits as it runs. A stitch streams an async iterable of StitchEvent values; this page documents their shapes.

StitchEvent

StitchEvent<T> is a discriminated union on type. The T parameter is the type of the value carried by the result event.

import type {  } from 'stitchapi';

Prop

Type

The events

A union table can render sparsely, so here is each of the eight variants and its fields. Every event carries an at field — a millisecond timestamp.

  • start — the request is about to go out. Fields: name (the stitch label), method, url, input (the StitchInput for this call), at.
  • progress — a lifecycle beat within an attempt. Fields: phase (a ProgressPhase), attempt (1-based), detail?, waitedMs? (set when the phase involved a wait, e.g. throttled or retry), at.
  • info — an auth strategy announcing a decision it made (e.g. which env var a bearer token resolved from, or that oauth2 fetched a token); it never carries the secret itself. Fields: topic, detail?, at.
  • drift — a single contract-drift observation against the response. Fields: finding (a DriftFinding with level, path, change, detail?), at.
  • delta — a streamed chunk of the response body. Fields: chunk (unknown), at.
  • result — the call succeeded and produced a value. Fields: data (the T), status (HTTP status), attempts (how many it took), at.
  • error — the call failed. Fields: name, message, status?, attempts, at.
  • done — the stream is finished, success or failure. Fields: ok, ms (total duration), attempts, at.

ProgressPhase is one of 'auth', 'request', 'throttled', 'retry', 'paginate', or 'circuit'.

result and error are mutually exclusive within one stream, but done always fires last — read done.ok to know which way it went.

See also

On this page