Skip to content
Trigora
Start building →

TypeScript SDK

Import from @trigora/sdk. These functions throw outside an Execution. Program globs and triggers live in trigora.toml.

function effect<T>(name: string, run: () => T | Promise<T>): Promise<T>

Commits the outcome of run under name. Reused after commit. May run again if the outcome never committed. Empty name throws. Details.

function waitForEvent<TPayload>(
eventOrName: EventDefinition<TPayload> | string,
options?: { timeout?: string | number; match?: Record<string, unknown> },
): Promise<TPayload>

Suspends until trigora send delivers that event name. Returns the payload. Details.

function sleep(duration: string | number): Promise<void>

Number of milliseconds, or a duration string. Prefer a number. Details.

function invoke(program: string, ...args: unknown[]): Promise<unknown>

Starts one child and returns its result. The values after the program id are the ordered argument vector. Details.

execution.id
execution.attempt
execution.programId
execution.signal

Reads the current Execution. signal is the cancellation signal for this attempt.

function event<TPayload>(name: string): EventDefinition<TPayload>

Optional typed name for waitForEvent and send. A string works without it.