UNPKG

@mondaydotcomorg/atp-compiler

Version:

Production-ready compiler for transforming async iteration patterns into resumable operations with checkpoint-based state management

53 lines 1.44 kB
/** * Example Plugin: Async Timeout Wrapper * * Automatically wraps await expressions with timeout protection * * @example * // Before: * const result = await fetch('https://api.example.com'); * * // After: * const result = await Promise.race([ * fetch('https://api.example.com'), * new Promise((_, reject) => * setTimeout(() => reject(new Error('Timeout')), 5000) * ) * ]); */ import type { TransformationPlugin, BabelVisitor } from '../plugin-api.js'; import type { CompilerConfig, TransformMetadata } from '../../types.js'; export interface TimeoutPluginOptions { /** * Default timeout in milliseconds */ timeout?: number; /** * Patterns to match (namespace.method) */ patterns?: string[]; /** * Whether to add timeout to all await expressions */ wrapAll?: boolean; } export declare class AsyncTimeoutPlugin implements TransformationPlugin { name: string; version: string; priority: number; private options; private transformCount; constructor(options?: TimeoutPluginOptions); getVisitor(config: CompilerConfig): BabelVisitor; getMetadata(): Partial<TransformMetadata>; reset(): void; /** * Check if this await should be wrapped with timeout */ private shouldWrap; /** * Get function name from call expression */ private getFunctionName; } //# sourceMappingURL=timeout-plugin.d.ts.map