import * as internal from "./internal.js"; import { Condition, type ExpressionSource, ExpressionValue } from "./expression.js"; /** Anything usable as an `if` condition: a Condition, an expression, or raw text. */ export type ConditionLike = Condition | ExpressionValue | string; /** A value usable in a step's `with`/`env` map. */ export type ConfigValue = string | number | boolean | ExpressionValue; /** * The declarative configuration of a single step. * * A config object must not be mutated after it has been used: `id`, `outputs` * and the shape validation are consumed when the {@linkcode Step} is built, and * the object doubles as the identity of the step it produced. */ export interface StepConfig { readonly name?: string; readonly id?: string; readonly uses?: string; readonly run?: string | string[]; readonly with?: Readonly>; readonly env?: Readonly>; readonly if?: ConditionLike; readonly shell?: string; readonly workingDirectory?: string; readonly continueOnError?: boolean | string; readonly timeoutMinutes?: number; readonly outputs?: readonly O[]; /** Runs the step asynchronously so the job continues without waiting for it. */ readonly background?: boolean; /** * Makes this a `wait` step that blocks until the referenced background * step(s) finish. Prefer `step.waitFor(...)`, which also wires up ordering. */ readonly wait?: StepLike | readonly StepLike[]; /** * Makes this a `wait-all` step that blocks until all active background steps * finish. Prefer `step.waitForAll()`. */ readonly waitAll?: boolean; /** * Makes this a `cancel` step that terminates the referenced background step. * Prefer `step.cancel(...)`, which also wires up ordering. */ readonly cancel?: StepLike; } /** * Resets the counter used to generate internal step ids. * * This deliberately does not clear the config-to-step memo table: a config * object already turned into a step keeps that step, and therefore its id. * Generated ids never reach the YAML and steps are identified by object * identity, so a reused id is harmless. * * Exported for testing only. */ export declare function resetStepCounter(): void; /** Anything accepted where a step is expected. */ export type StepLike = Step | StepRef | StepConfig; /** * How a composite step's children relate to each other. "sequential" children * run one after another (the default); "parallel" children run concurrently and * serialize to a GitHub Actions `parallel:` block. */ export type CompositeKind = "sequential" | "parallel"; /** * A single workflow step, or a composite grouping several steps together. * * Instances are immutable — `dependsOn`, `comesAfter` and `if` return a * {@link StepRef} carrying the per-usage modifiers rather than mutating the * step, so the same step can be reused across jobs with different conditions. */ export declare class Step implements ExpressionSource { #private; /** The configuration this step was created from (empty for composites). */ readonly config: StepConfig; /** Typed expressions for the outputs declared by `config.outputs`. */ readonly outputs: { [K in O]: ExpressionValue; }; /** The children of a composite step, or an empty array for a leaf step. */ readonly children: readonly StepLike[]; constructor(config: StepConfig, crossJobDeps?: readonly Step[]); constructor(children: readonly StepLike[], kind?: CompositeKind); /** The explicit `config.id`, or a generated internal id. */ get id(): string; /** Whether this composite's children run sequentially or in parallel. */ get kind(): CompositeKind; /** Orders this step after `deps`, pulling them into the job if absent. */ dependsOn(...deps: StepLike[]): StepRef; /** Orders this step after `deps`, but only those already in the job. */ comesAfter(...deps: StepLike[]): StepRef; /** Applies a condition to this usage of the step. */ if(condition: ConditionLike): StepRef; /** * Serializes this step to its YAML object form. `effectiveIf` overrides * `config.if` with the condition resolved by the job's dependency graph. */ [internal.toYaml](effectiveIf?: Condition): Record; } export interface StepBuilder { (...args: (StepConfig | Step | StepRef)[]): StepRef; if(condition: ConditionLike): StepBuilder; dependsOn(...deps: StepLike[]): StepBuilder; comesAfter(...deps: StepLike[]): StepBuilder; /** Builds a parallel group from the args, carrying this builder's deps/condition. */ parallel(...args: (StepConfig | Step | StepRef)[]): StepRef; } export interface StepFunction { (...args: (StepConfig | Step | StepRef)[]): Step; if(condition: ConditionLike): StepBuilder; dependsOn(...deps: StepLike[]): StepBuilder; comesAfter(...deps: StepLike[]): StepBuilder; /** * Groups steps into a parallel block. The steps run concurrently and * serialize to a GitHub Actions `parallel:` block. Shared dependencies * (pulled in via `dependsOn`) are hoisted to run before the block. */ parallel(...args: (StepConfig | Step | StepRef)[]): Step; /** * Creates a `wait` step that blocks until the given background step(s) * finish. The referenced steps are ordered before this one and must each be * a background step with an explicit `id`. */ waitFor(...steps: (Step | StepRef)[]): StepRef; /** Creates a `wait-all` step that blocks until all background steps finish. */ waitForAll(): Step; /** * Creates a `cancel` step that terminates the given background step. The * referenced step is ordered before this one and must be a background step * with an explicit `id`. */ cancel(target: Step | StepRef): StepRef; } export declare const step: StepFunction; /** * One usage of a {@link Step} within a job, carrying the modifiers applied at * that usage. Modifier methods return a new StepRef rather than mutating, so a * step can appear in several places with different conditions and dependencies. */ export declare class StepRef { /** The step this reference wraps. */ readonly step: Step; /** The condition applied to this usage, ANDed with the step's own `if`. */ readonly condition?: ConditionLike; /** Steps ordered before this usage, pulled into the job if absent. */ readonly dependencies: readonly StepLike[]; /** Steps ordered before this usage, but only those already in the job. */ readonly afterDependencies: readonly StepLike[]; constructor(step: Step, init?: { condition?: ConditionLike; dependencies?: readonly StepLike[]; afterDependencies?: readonly StepLike[]; }); /** The wrapped step's id. */ get id(): string; /** The wrapped step's config. */ get config(): StepConfig; /** The wrapped step's typed output expressions. */ get outputs(): { [K in O]: ExpressionValue; }; /** Adds dependencies, pulling them into the job if absent. */ dependsOn(...deps: StepLike[]): StepRef; /** Adds ordering-only dependencies on steps already in the job. */ comesAfter(...deps: StepLike[]): StepRef; /** ANDs an additional condition onto this usage. */ if(condition: ConditionLike): StepRef; } /** Renders a condition as the raw expression text used in an `if` field. */ export declare function serializeConditionLike(c: ConditionLike): string; /** Converts a ConditionLike to a Condition, preserving its expression sources. */ export declare function toCondition(c: ConditionLike): Condition; /** Serializes a `with`/`env` map, wrapping expressions in `${{ }}`. */ export declare function serializeConfigValues(record: Record): Record; /** Normalizes a StepLike to a Step or StepRef, auto-wrapping plain objects. */ export declare function normalizeStepLike(item: StepLike): Step | StepRef; /** Extracts the underlying Step from a StepLike (Step, StepRef, or plain config). */ export declare function unwrapStep(item: StepLike): Step; /** Extracts all underlying leaf Steps from a StepLike (recursively for composites). */ export declare function unwrapSteps(item: StepLike): Step[]; /** * Returns the cross-job step references a step was created with, used to infer * job `needs` — an artifact download referencing its uploads, for example. * * Resolved on each call rather than captured at construction, so steps * registered after this one was created are still picked up. The returned array * is a copy; the underlying list stays owned by whoever registered it. */ export declare function crossJobDepsOf(step: Step): readonly Step[]; //# sourceMappingURL=step.d.ts.map