{"version":3,"file":"RetryPolicy.cjs","sources":["../../../src/retry/RetryPolicy.ts"],"sourcesContent":["import { NonRetriableError } from '../types'\nimport { BackoffCalculator } from './BackoffCalculator'\nimport type { RetryPolicy } from '../types'\n\nexport class DefaultRetryPolicy implements RetryPolicy {\n  private backoffCalculator: BackoffCalculator\n  private maxRetries: number\n\n  constructor(maxRetries = Number.POSITIVE_INFINITY, jitter = true) {\n    this.backoffCalculator = new BackoffCalculator(jitter)\n    this.maxRetries = maxRetries\n  }\n\n  calculateDelay(retryCount: number): number {\n    return this.backoffCalculator.calculate(retryCount)\n  }\n\n  shouldRetry(error: Error, retryCount: number): boolean {\n    if (retryCount >= this.maxRetries) {\n      return false\n    }\n\n    if (error instanceof NonRetriableError) {\n      return false\n    }\n\n    if (error.name === `AbortError`) {\n      return false\n    }\n\n    if (error.message.includes(`401`) || error.message.includes(`403`)) {\n      return false\n    }\n\n    if (error.message.includes(`422`) || error.message.includes(`400`)) {\n      return false\n    }\n\n    return true\n  }\n}\n"],"names":["BackoffCalculator","NonRetriableError"],"mappings":";;;;AAIO,MAAM,mBAA0C;AAAA,EAIrD,YAAY,aAAa,OAAO,mBAAmB,SAAS,MAAM;AAChE,SAAK,oBAAoB,IAAIA,kBAAAA,kBAAkB,MAAM;AACrD,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,eAAe,YAA4B;AACzC,WAAO,KAAK,kBAAkB,UAAU,UAAU;AAAA,EACpD;AAAA,EAEA,YAAY,OAAc,YAA6B;AACrD,QAAI,cAAc,KAAK,YAAY;AACjC,aAAO;AAAA,IACT;AAEA,QAAI,iBAAiBC,MAAAA,mBAAmB;AACtC,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,SAAS,cAAc;AAC/B,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,QAAQ,SAAS,KAAK,KAAK,MAAM,QAAQ,SAAS,KAAK,GAAG;AAClE,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,QAAQ,SAAS,KAAK,KAAK,MAAM,QAAQ,SAAS,KAAK,GAAG;AAClE,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;;"}