import { DIDMessage, Publisher, Signer, Verifier } from "@hiero-did-sdk/core"; //#region src/interfaces/steps.d.ts /** * A step in the lifecycle pipeline. * A step that calls a callback function with a message and a publisher. */ interface CallbackStep { type: 'callback'; label: string; callback: (message: Message, publisher: Publisher, context: Context) => void | Promise; } /** * A step in the lifecycle pipeline. * A step that signs a message using provided Signer to lifecycle pipeline. */ interface SignStep { type: 'sign'; label: string; } /** * A step in the lifecycle pipeline. * A step that adds a provided signature to a message. */ interface SignatureStep { type: 'signature'; label: string; } /** * A step in the lifecycle pipeline. * A step that pauses the lifecycle pipeline. */ interface PauseStep { type: 'pause'; label: string; } /** * A step in the lifecycle pipeline. * A special step that catches errors in the lifecycle pipeline. */ interface CatchStep { type: 'catch'; label: string; callback: (error: unknown) => void | Promise; } /** * An aggregation of all possible steps in the lifecycle pipeline. */ type Steps = CallbackStep | SignStep | SignatureStep | PauseStep; //#endregion //#region src/builder.d.ts /** * A builder for constructing a lifecycle pipeline. * A lifecycle pipeline is a series of steps that are executed in order. */ declare class LifecycleBuilder { protected readonly pipeline: Steps[]; catchStep?: CatchStep; /** * The number of steps in the pipeline. * @returns The number of steps in the pipeline. */ get length(): number; /** * Gets the step at the specified index. * @param stepIndex The index of the step to get. * @returns The step at the specified index. * @throws If the step does not exist. */ getByIndex(stepIndex: number): Steps; /** * Gets the step with the specified label. * @param stepLabel The label of the step to get. * @returns The step with the specified label. * @throws If the step does not exist. */ getByLabel(stepLabel: string): Steps; /** * Gets the step with the specified label. * @param stepLabel The label of the step to get. * @returns The step with the specified label. * @throws If the step does not exist. */ getIndexByLabel(stepLabel: string): number; /** * Adds a callback step to the pipeline. * A callback step is a step that calls a callback function with a message and a publisher. * The callback function can be used to perform any operation on the message, such as signing or verifying. * @param label The label of the step. * @param callback The callback function to be executed. * @returns The builder instance. */ callback(label: string, callback: CallbackStep['callback']): this; /** * Adds a signature step to the pipeline. * A signature step is a step that adds a provided signature to a message. * @param label The label of the step. * @returns The builder instance. */ signature(label: string): this; /** * Adds a sign step to the pipeline. * A sign step is a step that signs a message using a provided Signer to the lifecycle pipeline. * @param label The label of the step. * @returns The builder instance. */ signWithSigner(label: string): this; /** * Adds a pause step to the pipeline. * A pause step is a step that pauses the lifecycle pipeline. The pipeline can be resumed from the paused step. * @param label The label of the step. * @returns The builder instance. */ pause(label: string): this; /** * Adds a catch step to the pipeline. * A catch step is a special step that catches errors in the whole lifecycle pipeline. * Only one catch step can be added to the pipeline. * @param label The label of the step. * @param callback The callback function to be executed. * @returns The builder instance. */ catch(label: string, callback: CatchStep['callback']): this; private validateLabel; } //#endregion //#region src/interfaces/runner-state.d.ts type StateStatus = 'success' | 'error' | 'pause'; interface RunnerState { message: Message; status: StateStatus; index: number; label: string; } //#endregion //#region src/interfaces/hooks.d.ts /** * A hook function that can be registered with a lifecycle. */ type HookFunction = (message: Message) => void | Promise; //#endregion //#region src/runner.d.ts /** * Options for the lifecycle runner. */ interface LifecycleRunnerOptions { /** * Additional arguments to pass to the runner. */ args?: { /** * Signature to use for the message. */ signature?: Uint8Array; /** * Verifier to use for verifying the signature. */ verifier?: Verifier; }; /** * The signer to use for signing the message. */ signer?: Signer; /** * The step label to resume from. */ label?: string; /** * The publisher to use for publishing the message. */ publisher: Publisher; /** * The context to use for the runner. */ context?: Context; } /** * A runner for executing a lifecycle pipeline. * A lifecycle pipeline is a series of steps that are executed in order. */ declare class LifecycleRunner { private readonly builder; private readonly hooks; /** * Creates a new instance of the LifecycleRunner class. * @param builder - The lifecycle builder to use. * @returns A new instance of the LifecycleRunner class. */ constructor(builder: LifecycleBuilder); /** * Resumes the lifecycle pipeline from the specified state. * @param state - The state to resume from. * @param options - The options to use. * @returns The state of the lifecycle pipeline after resuming. * @throws If an error occurs during the process. */ resume(state: RunnerState, options: LifecycleRunnerOptions): Promise>; /** * Starts the lifecycle pipeline from the beginning and processes the message. * @param message - The message to process. * @param options - The options to use. * @returns The state of the lifecycle pipeline after processing. * @throws If an error occurs during the process. If a catch step is not provided, the error is rethrown. */ process(message: Message, options: LifecycleRunnerOptions): Promise>; /** * Registers a hook to be called when the specified label is completed. * Hooks are called in the parallel been the completion of the label and the next step. * @param label Name of the label to hook into. * @param callback The hook function to call. */ onComplete(label: string, callback: HookFunction): void; /** * Calls the hooks for the specified label. * @param label The label to call the hooks for. */ private callHooks; } //#endregion export { CallbackStep, CatchStep, LifecycleBuilder, LifecycleRunner, LifecycleRunnerOptions, PauseStep, RunnerState, SignStep, SignatureStep, StateStatus, Steps }; //# sourceMappingURL=index.d.cts.map