/** * Polling Utilities * * This module provides utilities for polling HTTP endpoints until completion, * with configurable retry logic and exponential backoff. */ /** * Get the appropriate polling interval based on elapsed time. * Starts with frequent polling and backs off as time passes. * @param elapsedMs Time elapsed since polling started (in milliseconds) * @returns The polling interval to use (in milliseconds) */ export declare function getPollingInterval(elapsedMs: number): number; /** * Options for the polling function */ export interface PollOptions { /** Function that performs the HTTP request */ fetchPoll: () => Promise; /** Maximum time to wait for completion (in milliseconds) */ timeoutMs?: number; /** HTTP status code indicating successful completion */ successStatus?: number; /** HTTP status code indicating the operation is still pending */ pendingStatus?: number; /** Function to check if the response body indicates pending state (return true to continue polling) */ isPending?: (response: unknown) => boolean; /** Function to extract the result from the response */ resultExtractor?: (response: unknown) => TResult; /** Initial delay before the first poll attempt (in milliseconds) */ initialDelay?: number; /** * Abort signal observed by the initial delay, the inter-poll sleep, * and (when forwarded into `fetchPoll`) the in-flight HTTP request. * On abort, this function throws `AbortError` rather than continuing * to poll or treating it as a transient failure. */ signal?: AbortSignal; } declare const enum PollStatus { Success = "success", Continue = "continue" } /** * Result of a poll operation */ export type PollResult = { result?: TResult; status: PollStatus; errorCount: number; }; /** * Polls an endpoint until completion, timeout, or error * @param options Configuration options for polling * @returns The extracted result from the successful response * @throws {ZapierValidationError} When the input parameters are invalid * @throws {ZapierTimeoutError} When the operation times out * @throws {ZapierApiError} When the API returns consecutive errors */ export declare function pollUntilComplete(options: PollOptions): Promise; export {}; //# sourceMappingURL=polling.d.ts.map