UNPKG

ai-patterns

Version:

Production-ready TypeScript patterns to build solid and robust AI applications. Retry logic, circuit breakers, rate limiting, human-in-the-loop escalation, prompt versioning, response validation, context window management, and more—all with complete type

73 lines 1.51 kB
/** * Types for Fan-Out Pattern */ import { AsyncFunction, Logger } from "./common"; /** * Options for fan-out pattern */ export interface FanOutOptions<TInput, TOutput> { /** * Array of items to process */ items: TInput[]; /** * Transformation function to apply to each item */ execute: AsyncFunction<TOutput, [TInput]>; /** * Maximum concurrency level * @default Infinity (no limit) */ concurrency?: number; /** * Continue processing even if some items fail * @default false */ continueOnError?: boolean; /** * Logger */ logger?: Logger; /** * Progress callback */ onProgress?: (completed: number, total: number) => void; /** * Error callback for individual items */ onItemError?: (item: TInput, error: Error, index: number) => void; } /** * Result of fan-out operation */ export interface FanOutResult<TOutput> { /** * Successful results */ results: TOutput[]; /** * Errors (empty array if no errors) */ errors: Error[]; /** * Total number of items processed */ total: number; /** * Number of successes */ successCount: number; /** * Number of failures */ errorCount: number; /** * Number of failures (alias for errorCount) */ failureCount: number; /** * Total duration in ms */ duration: number; } //# sourceMappingURL=fan-out.d.ts.map