import type { ContentTypes } from "../enums/content.js"; import type { HttpMethods as HttpMethod, HttpMethodsLower as HttpMethodLower } from "../enums/methods.js"; type ExcludeFields = "method" | "endpoint" | "body"; type GlobalOptions = "secure" | "secureParams" | "errorMessage" | "log"; export type HttpMethods = { [key in Exclude]: (endpoint: string, body: T, config?: HttpConfigMethods) => Promise>; } & { get: (endpoint: string, config?: HttpConfigGet

) => Promise>; }; export interface HttpContract { global(config: HttpGlobalAction): Promise; } export type HttpGlobalConfig = Partial, GlobalOptions>>; export interface HttpConfigInitial extends HttpGlobalConfig { swal?: HttpAlert; headers?: { Authorization?: string; "Content-Type"?: HttpConfigConnection["type"]; "Accept-Language"?: string; } | Headers; params?: Record; } export interface HttpConfigRequest extends Omit { signal?: AbortSignal; body?: T | FormData; method: HttpMethod; headers: Headers; } export interface HttpConfigConnection extends HttpConfigRequest { params?: P; type?: ContentTypes; secure: boolean; secureParams: boolean; endpoint: string; errorMessage?: string; arrayBuffer?: boolean; thrower?: HttpGlobalActionConfig

["thrower"]; clone?: boolean; log?: boolean; } export type HttpConfigMethods = Partial, ExcludeFields>>; export type HttpConfigGet

= HttpConfigMethods; export type HttpConnectionReturn = { success: boolean; message: string; payload: T; response: Response; }; export interface HttpConnectionError { statusText: string; message: string; errors: string[] | string | { description?: string; }; status: number; icon?: string; time?: number; title?: string; } export type HttpAlert = (config: HttpAlertConfig) => Promise; export interface HttpAlertConfig { title: string; text: string; icon: string; className: string; timer: number; } export interface HttpStorage { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; } export interface HttpStorageAsync { getItem(key: string): Promise; setItem(key: string, value: string): Promise; removeItem(key: string): Promise; } export interface HttpGlobalActionConfig { headers: Headers; params: Record; thrower(response: { json: Record; response: Response; }): void; } export type HttpGlobalAction = (config: HttpGlobalActionConfig) => Promise>; export {};