import sharp from 'sharp'; import type z from 'zod'; import type { OnProgress, ProgressInfo } from '../merges/types.js'; export interface MergeContext { inputs: sharp.SharpInput[]; progressInfo: ProgressInfo; images: sharp.Sharp[]; canvas?: sharp.Sharp; composites: sharp.OverlayOptions[]; captions: string[]; state: TState; } export type MergeStep = (context: MergeContext, options: TOptions, onProgress?: OnProgress) => Promise; /** * Pipeline orchestrator for running a sequence of merge steps that * progressively build or modify a final merged image. * * Generic type parameters: * - TOptions: the shape of the validated options object passed to each step. * - TState: the shape of the pipeline's runtime state held in MergeContext. * * The pipeline: * - Validates incoming options via a Zod schema (see createPipeline). * - Maintains an ordered list of MergeStep functions to execute. * - Provides optional progress reporting via an OnProgress callback. * * Usage: * - Create an instance via createPipeline to ensure options are validated and * progressInfo is initialized on the supplied MergeContext. * - Register steps with use(...). * - Execute with run() — in normal usage this returns a Buffer containing the * final image. When run in "test" mode (testOptions supplied) the pipeline * may perform a dry-run and return void. * * Errors: * - Validation-related errors thrown from createPipeline are surfaced as * MergeError instances with type 'validation' or 'internal'. * - During execution, any thrown non-MergeError is converted into a runtime * Error indicating the offending step name. * * @template TOptions - Validated options shape used by registered steps. * @template TState - Context/state shape managed by the pipeline. */ export declare class MergePipeline { private options; private context; private onProgress?; private steps; private optionsCounter; private stateCounter; constructor(options: TOptions, context: MergeContext, onProgress?: OnProgress | undefined); static createPipeline(schema: TZodSchema, options: TOptions, context: Omit, 'progressInfo'>, onProgress?: OnProgress): Promise, TState>>; use(step: MergeStep): this; run(): Promise; run(testOptions: { logOptions?: boolean; logContext?: boolean; }): Promise; private logForDebugging; }