Skip to content
Français

publishArtifact

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

Encode a value with its contract, compute its SHA-256 digest and content-addressed id, then store the bytes with store.put(). Returns the ArtifactReference; producer and parents are recorded as given, not authenticated. Rejects when encoding fails, a parent reference is invalid or the store refuses the bytes.

Complete example and detailed rules.

  • storeRequired
    ArtifactStore
    Store that receives the encoded bytes under the artifact id.
  • contractRequired
    ArtifactContract<T>
    Contract that validates and encodes the value; its name, version and encoding are recorded in the reference.
  • valueRequired
    T
    Value to publish; the contract validates it before encoding.
  • optionsRequired
    PublishArtifactOptions
    Producer to record, ordered parent references and cancellation signal.
  • options.producerRequired
    ArtifactProducer
    Execution, task key and attempt recorded in the reference and its id, as given: Outpost does not authenticate them.
  • options.parentsOptional
    readonly ArtifactReference[] | undefined
    References this artifact was derived from, in order; their ids are recorded in parents and in the id. An invalid or duplicated reference rejects the publication.
  • options.signalOptional
    AbortSignal | undefined
    Aborting it rejects the publication with the signal’s reason; bytes already stored are kept.

Promise<ArtifactReference>

export declare function publishArtifact<T>(
  store: ArtifactStore,
  contract: ArtifactContract<T>,
  value: T,
  options: PublishArtifactOptions,
): Promise<ArtifactReference>;