/** * Types for Composition and Middleware */ /** * Middleware type - transforms a function by wrapping it */ export type Middleware = (next: (input: TInput) => Promise) => (input: TInput) => Promise; /** * Configuration for compose function */ export interface ComposeConfig<_TInput = void, TOutput = unknown> { /** * Called before execution starts */ onStart?: () => void | Promise; /** * Called after successful completion */ onComplete?: (result: TOutput, duration: number) => void | Promise; /** * Called on error */ onError?: (error: Error) => void | Promise; } /** * Options for timeout middleware */ export interface TimeoutMiddlewareOptions { /** * Timeout duration in milliseconds */ duration: number; /** * Custom error message */ message?: string; } /** * Options for fallback middleware */ export interface FallbackMiddlewareOptions { /** * Fallback function(s) to execute if primary fails */ fallback: ((input: TInput) => TOutput | Promise) | Array<(input: TInput) => TOutput | Promise>; /** * Predicate to determine if fallback should be used * @default () => true */ shouldFallback?: (error: Error) => boolean; } /** * Options for cache middleware */ export interface CacheMiddlewareOptions { /** * Time-to-live in milliseconds */ ttl?: number; /** * Custom key generation function * @default JSON.stringify */ keyFn?: (input: TInput) => string; } //# sourceMappingURL=composition.d.ts.map