/** * Polling Strategy Presets * Pre-configured polling strategies for common use cases */ import type { PollingConfig, PollingStrategyName } from '@plyaz/types/api'; import type { FetchResponse } from 'fetchff'; /** * Pre-configured polling strategies for common use cases * These work with any response type - the actual types come from your endpoint definitions */ export declare const pollingStrategies: { /** * Job Status Monitoring * Use Case: Checking job completion, task progress, async operations * Pattern: Frequent checks with timeout and completion detection * Expected fields: data.status (completed/failed/cancelled), data.progress */ readonly jobStatus: { interval: number; delay: number; maxAttempts: number; shouldStop: (response: FetchResponse, attempt: number) => boolean; }; /** * Health Monitoring * Use Case: Server health checks, service availability monitoring * Pattern: Regular intervals, continuous monitoring */ readonly healthCheck: { interval: number; delay: number; maxAttempts: number; shouldStop: () => false; }; /** * Live Data Feed * Use Case: Real-time dashboards, stock prices, metrics * Pattern: Rapid updates with smart stopping * Expected fields: data.noUpdates */ readonly liveData: { interval: number; delay: number; maxAttempts: number; shouldStop: (response: FetchResponse) => boolean; }; /** * Notification Check * Use Case: New messages, alerts, updates * Pattern: Moderate frequency with backoff */ readonly notifications: { interval: number; delay: number; maxAttempts: number; shouldStop: (_response: FetchResponse, attempt: number) => boolean; }; /** * Long-Running Process * Use Case: File uploads, data processing, migrations * Pattern: Adaptive intervals based on expected duration * Expected fields: data.progress, data.status */ readonly longProcess: { interval: number; delay: number; maxAttempts: number; shouldStop: (response: FetchResponse, attempt: number) => boolean; }; /** * Resource Availability * Use Case: Waiting for resource to become available * Pattern: Exponential backoff-like behavior * Expected fields: data.available */ readonly resourceWait: { interval: number; delay: number; maxAttempts: number; shouldStop: (response: FetchResponse, attempt: number) => boolean; }; /** * Data Sync * Use Case: Syncing with external systems, data reconciliation * Pattern: Periodic checks with conflict detection * Expected fields: data.syncComplete, data.hasConflicts */ readonly dataSync: { interval: number; delay: number; maxAttempts: number; shouldStop: (response: FetchResponse, attempt: number) => boolean; }; }; /** * Create custom polling strategy with defaults * * @param options - Partial polling configuration * @returns Complete polling configuration with defaults * * @example * ```typescript * const customPolling = createPollingStrategy({ * interval: 3000, * maxAttempts: 10 * }); * ``` */ export declare function createPollingStrategy(options: Partial>): PollingConfig; /** * Apply polling strategy by name or config * * @param strategy - Strategy name or config object * @returns Polling configuration * * @example * ```typescript * const config = applyPollingStrategy('jobStatus'); * // or * const config = applyPollingStrategy({ interval: 2000 }); * ``` */ export declare function applyPollingStrategy(strategy: PollingStrategyName | PollingConfig): PollingConfig; //# sourceMappingURL=strategies.d.ts.map