{"version":3,"file":"interceptor.mjs","sources":["../../../../../../../packages/utils/http/core/modules/interceptor.ts"],"sourcesContent":["import type { AxiosInstance, AxiosResponse } from 'axios';\n\nimport type {\n  RequestInterceptorConfig,\n  ResponseInterceptorConfig,\n} from '../types';\n\nconst defaultRequestInterceptorConfig: RequestInterceptorConfig = {\n  fulfilled: (response) => response,\n  rejected: (error) => Promise.reject(error),\n};\n\nconst defaultResponseInterceptorConfig: ResponseInterceptorConfig = {\n  fulfilled: (response: AxiosResponse) => response,\n  rejected: (error) => Promise.reject(error),\n};\n\nclass InterceptorManager {\n  private axiosInstance: AxiosInstance;\n\n  constructor(instance: AxiosInstance) {\n    this.axiosInstance = instance;\n  }\n\n  addRequestInterceptor({\n    fulfilled,\n    rejected,\n  }: RequestInterceptorConfig = defaultRequestInterceptorConfig) {\n    this.axiosInstance.interceptors.request.use(fulfilled, rejected);\n  }\n\n  addResponseInterceptor<T = any>({\n    fulfilled,\n    rejected,\n  }: ResponseInterceptorConfig<T> = defaultResponseInterceptorConfig) {\n    this.axiosInstance.interceptors.response.use(fulfilled, rejected);\n  }\n}\n\nexport { InterceptorManager };\n"],"names":[],"mappings":"AAOA,MAAM,+BAAA,GAA4D;AAAA,EAChE,SAAA,EAAW,CAAC,QAAA,KAAa,QAAA;AAAA,EACzB,QAAA,EAAU,CAAC,KAAA,KAAU,OAAA,CAAQ,OAAO,KAAK;AAC3C,CAAA;AAEA,MAAM,gCAAA,GAA8D;AAAA,EAClE,SAAA,EAAW,CAAC,QAAA,KAA4B,QAAA;AAAA,EACxC,QAAA,EAAU,CAAC,KAAA,KAAU,OAAA,CAAQ,OAAO,KAAK;AAC3C,CAAA;AAEA,MAAM,kBAAA,CAAmB;AAAA,EAGvB,YAAY,QAAA,EAAyB;AACnC,IAAA,IAAA,CAAK,aAAA,GAAgB,QAAA;AAAA,EACvB;AAAA,EAEA,qBAAA,CAAsB;AAAA,IACpB,SAAA;AAAA,IACA;AAAA,MAC4B,+BAAA,EAAiC;AAC7D,IAAA,IAAA,CAAK,aAAA,CAAc,YAAA,CAAa,OAAA,CAAQ,GAAA,CAAI,WAAW,QAAQ,CAAA;AAAA,EACjE;AAAA,EAEA,sBAAA,CAAgC;AAAA,IAC9B,SAAA;AAAA,IACA;AAAA,MACgC,gCAAA,EAAkC;AAClE,IAAA,IAAA,CAAK,aAAA,CAAc,YAAA,CAAa,QAAA,CAAS,GAAA,CAAI,WAAW,QAAQ,CAAA;AAAA,EAClE;AACF;;;;"}