shiftlabs Start free

SDK reference

The shiftlabs module is what a TypeScript workflow imports. Every deploy includes it. This page is generated from its TypeScript source.

DurationUnit

The unit of a duration string, singular or plural.

typescripttype
type DurationUnit = "second" | "minute" | "hour" | "day" | "week" | "month" | "year";

Duration

A number of milliseconds or a string such as "30 seconds" or "10 minutes", with units from second to year.

typescripttype
type Duration = number | `${number} ${DurationUnit}` | `${number} ${DurationUnit}s`;

StepConfig

Retries and a timeout for one step, given as step.run(name, config, fn).

Step

Durable steps and sleeps: ctx.step.

Log

ctx.log: one log line per call, shown with the run. fields, if given, follow message as JSON.

Context

The run context: the one object your function receives. Destructure what you need. Payload is the payload type you give workflow.

WorkflowDefinition

What workflow returns. The module's default export must be one.

workflow

The module's default export must be workflow(…). run receives the run context; Payload is the type of the webhook payload and Result of the value run returns. Code outside step.run runs again each time the run resumes, after a sleep or a retry. Only step results are stored. Put side effects inside steps.

typescriptsignature
function workflow<Payload = unknown, Result = unknown>(
  run: (ctx: Context<Payload>) => Promise<Result>,
): WorkflowDefinition<Payload, Result>;