import { Step } from '../types'; import { StepExecutionContext } from '../types'; import { RetryPolicy } from '../errors/recovery'; export { Step }; /** * Interface for transform operations */ export interface TransformOperation { type: 'map' | 'filter' | 'reduce' | 'flatten' | 'sort' | 'unique' | 'group' | 'join'; using: string; as?: string; initial?: any; } /** * Custom error class for JSON-RPC request errors */ export declare class JsonRpcRequestError extends Error { readonly error: { code: number; message: string; data?: any; }; constructor(message: string, error: { code: number; message: string; data?: any; }); } /** * Base interface for step execution results with stronger typing */ export interface StepExecutionResult { result?: T; error?: { code: number; message: string; data?: any; }; type: StepType; metadata?: Record; } /** * Enum of all possible step types */ export declare enum StepType { Request = "request", Loop = "loop", Condition = "condition", Transform = "transform", Stop = "stop" } /** * Type guard to check if a step is a specific type */ export type StepTypeGuard = (step: Step) => step is T; /** * Base interface for all step executors with improved generic constraints */ export interface StepExecutor { /** * Type guard to check if a step can be handled by this executor */ canExecute: StepTypeGuard; /** * Execute the step and return the result */ execute(step: TStep, context: TContext, extraContext?: Record, signal?: AbortSignal): Promise>; } /** * Specific step types with their corresponding properties */ export interface RequestStep extends Step { request: { method: string; params: Record | any[]; }; /** * @deprecated Use step.policies.retryPolicy instead * Retry policy that overrides the global retry policy for this specific step */ retryPolicy?: RetryPolicy; } export interface LoopStep extends Step { loop: { over: string; as: string; condition?: string; maxIterations?: number; step?: Step; steps?: Step[]; }; } export interface ConditionStep extends Step { condition: { if: string; then: Step; else?: Step; }; } /** * Type guards for each step type */ export declare const isRequestStep: (step: Step) => step is RequestStep; export declare const isLoopStep: (step: Step) => step is LoopStep; export declare const isConditionStep: (step: Step) => step is ConditionStep; export declare const isTransformStep: (step: Step) => step is TransformStep; /** * Type guard for loop results */ export declare const isLoopResult: (result: StepExecutionResult) => result is LoopStepResult; /** * Base type for loop results */ export interface LoopResultBase { iterationCount: number; skippedCount: number; } /** * Loop result with array of values */ export interface LoopResult extends LoopResultBase { value: T[]; } /** * Utility type for loop step results */ export type LoopStepResult = StepExecutionResult>; export interface TransformStep extends Step { timeout?: number; transform: { input: string | any[]; operations: TransformOperation[]; }; }