export type ShouldRetryResult = | { shouldRetry: false; } | { shouldRetry: true; retryAfter: number; // in milliseconds }; export type RetryableOperation = () => Promise; export default interface IRetryPolicy { shouldRetry(details: R): Promise; // `signal` cancels a pending backoff sleep: aborting it rejects with `signal.reason` // instead of waiting for the sleep to finish (the operation itself must honour the signal). invokeWithRetry(operation: RetryableOperation, signal?: AbortSignal): Promise; }