// Request/Response interceptors
export class InterceptorChain {
  private requestInterceptors: ((config: any) => any)[] = []
  private responseInterceptors: ((response: any) => any)[] = []
  
  addRequestInterceptor(fn: (config: any) => any): void {
    this.requestInterceptors.push(fn)
  }
  
  addResponseInterceptor(fn: (response: any) => any): void {
    this.responseInterceptors.push(fn)
  }
  
  async processRequest(config: any): Promise<any> {
    let result = config
    for (const interceptor of this.requestInterceptors) {
      result = await interceptor(result)
    }
    return result
  }
  
  async processResponse(response: any): Promise<any> {
    let result = response
    for (const interceptor of this.responseInterceptors) {
      result = await interceptor(result)
    }
    return result
  }
}