UNPKG

guardz-axios

Version:

Type-safe HTTP client built on top of Axios with runtime validation using guardz. Part of the guardz ecosystem for comprehensive TypeScript type safety.

74 lines 2.46 kB
import { TypeGuardFn } from "guardz"; import { AxiosResponse } from "axios"; import { AxiosResponseGuarded, SuccessStatus, RedirectStatus, ClientErrorStatus, ServerErrorStatus } from "../types/axios-types"; /** * Type guard for basic AxiosResponse structure */ export declare const isAxiosResponse: TypeGuardFn<AxiosResponse>; /** * Creates a type guard for AxiosResponse with specific data type validation */ export declare function isAxiosResponseWithData<T>(dataGuard: TypeGuardFn<T>): TypeGuardFn<AxiosResponseGuarded<T>>; /** * Type guard for successful HTTP response (2xx status codes) */ export declare const isSuccessResponse: TypeGuardFn<AxiosResponse & { status: SuccessStatus; }>; /** * Creates a type guard for successful response with specific data type */ export declare function isSuccessResponseWithData<T>(dataGuard: TypeGuardFn<T>): TypeGuardFn<AxiosResponseGuarded<T> & { status: SuccessStatus; }>; /** * Type guard for redirect response (3xx status codes) */ export declare const isRedirectResponse: TypeGuardFn<AxiosResponse & { status: RedirectStatus; }>; /** * Type guard for client error response (4xx status codes) */ export declare const isClientErrorResponse: TypeGuardFn<AxiosResponse & { status: ClientErrorStatus; }>; /** * Type guard for server error response (5xx status codes) */ export declare const isServerErrorResponse: TypeGuardFn<AxiosResponse & { status: ServerErrorStatus; }>; /** * Type guard for specific status code */ export declare function isResponseWithStatus<T extends number>(statusCode: T): TypeGuardFn<AxiosResponse & { status: T; }>; /** * Type guard for response with specific content type */ export declare function isResponseWithContentType(contentType: string): TypeGuardFn<AxiosResponse>; /** * Type guard for JSON response */ export declare const isJsonResponse: TypeGuardFn<AxiosResponse>; /** * Type guard for empty response (204 No Content) */ export declare const isEmptyResponse: TypeGuardFn<AxiosResponse & { status: 204; }>; /** * Type guard for created response (201 Created) */ export declare const isCreatedResponse: TypeGuardFn<AxiosResponse & { status: 201; }>; /** * Creates a type guard for created response with specific data type */ export declare function isCreatedResponseWithData<T>(dataGuard: TypeGuardFn<T>): TypeGuardFn<AxiosResponseGuarded<T> & { status: 201; }>; //# sourceMappingURL=axios-response-guards.d.ts.map