import { withExponentialBackoff } from "../util/retry.js";
/**
 * Check if an error is retryable (throttling/rate limiting)
 */
function isRetryableError(error) {
    if (!error)
        return false;
    const errorCode = error.name || error.code || "";
    const errorMessage = error.message || "";
    // Check for common AWS throttling error codes and messages
    return (errorCode === "Throttling" ||
        errorCode === "ThrottlingException" ||
        errorCode === "TooManyRequestsException" ||
        errorCode === "RequestLimitExceeded" ||
        errorMessage.includes("Rate exceeded") ||
        errorMessage.includes("throttling") ||
        errorMessage.includes("Throttling") ||
        errorMessage.includes("Internal server error"));
}
/**
 * Retry function with standardized parameters for AWS throttling
 */
export function retry(operation, extraIsRetryableError) {
    return withExponentialBackoff(operation, (err) => isRetryableError(err) || extraIsRetryableError?.(err) || false, 10, // max attempts
    1000);
}
//# sourceMappingURL=retry.js.map