Skip to content
Français

defineArtifactTask

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

Define a workflow task whose output is an ArtifactReference: it runs produce(context) and publishes the value, with producer set from the execution id, task key and attempt. A retried attempt publishes a new reference. Dependents read the value with readArtifact().

Complete example and detailed rules.

  • optionsRequired
    ArtifactTaskOptions<T>
    Task options (key, after, retry, cache…) plus store, contract, produce and parents; the artifact task supplies perform.
  • options.retryOptional
    Retry | undefined
    Retry policy for failed attempts; without it the task runs once. A retried attempt repeats its side effects.
  • options.cacheOptional
    TaskCacheOptions | undefined
    Result cache: a hit restores the stored lossless JSON value with no attempt, usage or side effects. On a miss, a result that is not lossless JSON fails the task. Rejected on gates, interactions and dispatch-result tasks.
  • options.gateOptional
    WorkflowGate | undefined
    Persisted approval or pause definition; execution requires a checkpoint and a matching trusted decision.
  • options.keyRequired
    string
    Unique key in the workflow, matching [A-Za-z0-9][A-Za-z0-9._-]*. Records, events and checkpoints identify the task by it.
  • options.afterOptional
    readonly Task<unknown>[] | undefined
    Tasks that must be done before this one starts, default none; only these can be read with context.value().
  • options.interactionOptional
    TaskInteraction | undefined
    Opt-in durable human-input contract; requires checkpointed scheduling and cannot be combined with a gate.
  • options.conditionOptional
    ((context: TaskContext) => boolean | Promise<boolean>) | undefined
    Evaluated with attempt 0 before the task runs, including when a later start() resumes it; false ends the task as skipped, which skips its dependents.
  • options.timeoutMsOptional
    number | undefined
    Deadline in milliseconds for each attempt, a positive integer up to 2147483647. Expiry aborts context.signal and fails the attempt, which retry may repeat.
  • options.storeRequired
    ArtifactStore
    Store that receives the published artifact.
  • options.contractRequired
    ArtifactContract<T>
    Contract that validates and encodes the produced value.
  • options.produceRequired
    (context: TaskContext) => T | Promise<T>
    Compute the value to publish from the task context, for example from context.value() of a dependency.
  • options.parentsOptional
    ((context: TaskContext) => readonly ArtifactReference[]) | undefined
    Return the parent references to record, usually context.value() of artifact tasks listed in after. Runs before produce().

Task<ArtifactReference>

export declare function defineArtifactTask<T>(
  options: ArtifactTaskOptions<T>,
): Task<ArtifactReference>;