Skip to content
Français

defineApprovalTask

import { defineApprovalTask } from "@elie-laloum/outpost";

Define a gate task that pauses the run once its dependencies are done and waits for approve or reject from a listed actor. Approve makes the WorkflowDecisionRecord the gate’s value; reject skips dependent tasks and fails the run. Throws on a blank prompt or on empty, blank or duplicate actors; scheduling it without a checkpoint throws.

Complete example and detailed rules.

  • optionsRequired
    WorkflowGateOptions
    Gate key, dependencies, prompt, actors allowed to approve or reject, and the optional signed authentication.
  • options.authenticationOptional
    "signed" | undefined
    Set to signed to require a verified Ed25519 proof on every decision for this gate. Stored in the gate and in checkpoint identity.
  • options.keyRequired
    string
    Task key of the gate, unique in the workflow and named by each decision. Letters, digits, dot, underscore and hyphen, starting with a letter or digit.
  • options.afterOptional
    readonly Task<unknown>[] | undefined
    Tasks that must be done before the gate pauses. If one fails or is skipped, cancelled or rejected, the gate is skipped.
  • options.promptRequired
    string
    Question put to the actors, copied into the pending request. A blank prompt throws.
  • options.actorsRequired
    readonly string[]
    Names allowed to decide the gate: at least one, unique and nonblank. Outpost trusts the actor your application submits unless the gate is signed.

Task<WorkflowDecisionRecord>

export declare function defineApprovalTask(
  options: WorkflowGateOptions,
): Task<WorkflowDecisionRecord>;