Sanity Library Reference Docs
    Preparing search index...
    type ReadHelpers = {
        activityStatus: (
            instanceId: string,
            activity: string,
        ) => Promise<ActivityStatus | undefined>;
        children: (args: ChildrenArgs) => Promise<WorkflowInstance[]>;
        contextMap: (instanceId: string) => Promise<Record<string, unknown>>;
        currentStage: (instanceId: string) => Promise<string>;
        definitionsForDocument: (
            args: DefinitionsForDocumentArgs,
        ) => Promise<DeployedDefinition[]>;
        effectOutputsMap: (instanceId: string) => Promise<Record<string, unknown>>;
        evaluateStart: (args: EvaluateStartArgs) => Promise<StartEvaluation>;
        findPendingEffects: (
            args: FindPendingEffectsArgs,
        ) => Promise<PendingEffect[]>;
        getInstance: (args: InstanceRefArgs) => Promise<WorkflowInstance>;
        instancesByStage: (
            options: Required<Pick<InstancesQueryFilter, "definition" | "stage">> & Pick<
                InstancesQueryFilter,
                "includeCompleted",
            >,
        ) => Promise<WorkflowInstance[]>;
        instancesForDocument: (
            args: InstancesForDocumentArgs,
        ) => Promise<WorkflowInstance[]>;
        instancesForSubject: (
            subjectRef: string,
            entryName?: string,
        ) => Promise<WorkflowInstance[]>;
        listPendingEffects: (args: InstanceRefArgs) => Promise<PendingEffect[]>;
        snapshot: () => readonly StoreDocument[];
    }
    Index

    Properties

    activityStatus: (
        instanceId: string,
        activity: string,
    ) => Promise<ActivityStatus | undefined>

    Status of a single activity on an instance, or undefined if missing.

    children: (args: ChildrenArgs) => Promise<WorkflowInstance[]>

    Spawned children of the instance, optionally restricted to those spawned by activity. Ordered by startedAt ascending.

    contextMap: (instanceId: string) => Promise<Record<string, unknown>>

    The rendered $context map — the start-time seed + a parent's spawn handoff, keyed by entry name.

    currentStage: (instanceId: string) => Promise<string>

    Current stage name of an instance.

    definitionsForDocument: (
        args: DefinitionsForDocumentArgs,
    ) => Promise<DeployedDefinition[]>

    The startable half of ReadHelpers.instancesForDocument: the latest deployed version of every definition applicable to the LOADED candidate document — startable, the subject-kind entry accepts its _type, start.filter (browse-time-pure) passes. All matches, name ascending.

    effectOutputsMap: (instanceId: string) => Promise<Record<string, unknown>>

    The rendered $effects map — completed effects' outputs, namespaced by effect name.

    evaluateStart: (args: EvaluateStartArgs) => Promise<StartEvaluation>

    Pre-flight startInstance's gates for a definition + candidate initialFields: one ordered result per declared start requirement, plus still-missing required inputs; the read a start surface renders before committing.

    findPendingEffects: (args: FindPendingEffectsArgs) => Promise<PendingEffect[]>

    Pending effects filtered by claim presence and/or effect names.

    getInstance: (args: InstanceRefArgs) => Promise<WorkflowInstance>

    The engine's instance point-read: throws typed InstanceNotFoundError when the doc is missing or belongs to another engine's tag partition.

    instancesByStage: (
        options: Required<Pick<InstancesQueryFilter, "definition" | "stage">> & Pick<
            InstancesQueryFilter,
            "includeCompleted",
        >,
    ) => Promise<WorkflowInstance[]>

    All instances of definition currently at stage. In-flight only by default; includeCompleted: true widens to completed/aborted instances. The options derive from the engine's InstancesQueryFilter, so a vocabulary drift is a compile error here, not a silently-dropped filter.

    instancesForDocument: (
        args: InstancesForDocumentArgs,
    ) => Promise<WorkflowInstance[]>

    Every in-flight instance whose reactive watch-set includes document (a resource-qualified GDR URI) — the reverse of the forward watch-set. Answers "which instances should this changed doc tick?" the way a non-reactive content forwarder needs. Sorted by startedAt ascending.

    instancesForSubject: (
        subjectRef: string,
        entryName?: string,
    ) => Promise<WorkflowInstance[]>

    Instances whose named subject or doc.ref field matches a full global document reference (GDR) URI, such as dataset:test:test:article-1. Bare document IDs accepted by subjectField do not match here. entryName defaults to "subject". Includes completed and aborted instances, ordered by startedAt ascending.

    listPendingEffects: (args: InstanceRefArgs) => Promise<PendingEffect[]>

    Every pending effect on an instance — claimed and unclaimed alike.

    snapshot: () => readonly StoreDocument[]

    Snapshot of all documents in the store — for inspecting the world.