import { HttpRequest, HttpResponse, HttpErrorResponse, HttpHeaders, HttpContext, HttpParams, HttpClient, HttpInterceptor, HttpHandler, HttpEvent } from '@angular/common/http'; import * as i0 from '@angular/core'; import { InjectionToken } from '@angular/core'; import { SdCacheOption } from '@sdcorejs/angular/services/cache'; import { Observable } from 'rxjs'; type SdApiResponseType = 'arraybuffer' | 'blob' | 'json' | 'text'; type SdApiBivariantCallback = { bivarianceHack(argument: TArgument): TResult; }['bivarianceHack']; interface SdApiHttpOption { headers?: HttpHeaders | Record; context?: HttpContext; params?: HttpParams | Record; observe?: 'body'; reportProgress?: boolean; responseType?: SdApiResponseType; withCredentials?: boolean; transferCache?: { includeHeaders?: string[]; } | boolean; } interface SdApiRetryOption { /** Number of retries after the initial request. Values are clamped to a finite safe limit. */ attempts: number; /** Delay before the first retry. Defaults to 0. */ delayMs?: number; /** Multiplier applied to each subsequent delay. Defaults to 1. */ backoff?: number; /** Overrides the default transient HTTP-status predicate. `attempt` is one-based. */ retryWhen?: (error: unknown, attempt: number) => boolean; /** Required to retry POST, PUT, PATCH, or DELETE. */ mutations?: boolean; } interface SdApiOption { cacheOption?: SdCacheOption; timeout?: number; /** Cancels only this caller; a shared HTTP request continues while another caller remains. */ signal?: AbortSignal; /** Enables request deduplication. Defaults to true for GET and false for mutations. */ dedupe?: boolean; /** Keeps a successful dedupe result replayable for this duration. Defaults to 1000ms. */ dedupeWindowMs?: number; /** Opt-in bounded retry policy. The default is no retries. */ retry?: SdApiRetryOption; /** * @deprecated Use `dedupe`. When both are provided, `dedupe` takes precedence. * Explicit `true` remains a compatibility opt-in for mutation deduplication. */ autoCache?: boolean; } type SdGetOption = SdApiHttpOption & SdApiOption; type SdPostOption = SdApiHttpOption & SdApiOption; type SdPutOption = SdApiHttpOption & SdApiOption; type SdPatchOption = SdApiHttpOption & SdApiOption; type SdDeleteOption = SdApiHttpOption & SdApiOption; type SdApiRequestUpdate = Parameters['clone']>[0]; interface SdApiHandler { /** Danh sách host URL mà handler này sẽ xử lý */ hosts: string[]; /** Can thiệp request: gắn header, token, transform body... */ intercept?: SdApiBivariantCallback, HttpRequest | SdApiRequestUpdate>; /** Hook chạy TRƯỚC khi gửi request (dùng để log, tracking...) */ beforeRemote?: SdApiBivariantCallback, void | Promise>; /** Hook chạy SAU khi nhận response (xử lý lỗi, notify...) */ afterRemote?: SdApiBivariantCallback | HttpErrorResponse | Error, void | Promise>; /** Transform response body thành kiểu dữ liệu mong muốn */ mapResponse?: SdApiBivariantCallback; /** Timeout tính bằng milliseconds. Mặc định: 60000 (60 giây) */ timeout?: number; } interface ISdApiConfiguration { handlers?: SdApiHandler[]; } declare const SD_API_CONFIG: InjectionToken; /** @deprecated Use `SD_API_CONFIG`. This is the same injection token. */ declare const SD_API_CONFIGURATION: InjectionToken; /** * Response generics intentionally default to `unknown` for type safety. * Callers should specify `T`; migration guidance is tracked for Task 13. */ declare class SdApiService { #private; constructor(); get http(): HttpClient; get: (url: string, option?: SdGetOption) => Promise; post: (url: string, body?: unknown, option?: SdPostOption) => Promise; put: (url: string, body?: unknown, option?: SdPutOption) => Promise; patch: (url: string, body?: unknown, option?: SdPatchOption) => Promise; delete: (url: string, option?: SdDeleteOption) => Promise; upload: (url: string, option?: { extensions?: string[]; maxSizeInMb?: number; }) => Promise; uploadFile: (url: string, file: File | null | undefined) => Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class SdHttpInterceptor implements HttpInterceptor { #private; intercept(request: HttpRequest, next: HttpHandler): Observable>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class SdApiModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { SD_API_CONFIG, SD_API_CONFIGURATION, SdApiModule, SdApiService, SdHttpInterceptor }; export type { ISdApiConfiguration, SdApiHandler, SdApiHttpOption, SdApiOption, SdApiRequestUpdate, SdApiResponseType, SdApiRetryOption, SdDeleteOption, SdGetOption, SdPatchOption, SdPostOption, SdPutOption };