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.

71 lines 2.6 kB
import { TypeGuardFn } from "guardz"; import { HttpStatus, SuccessStatus, RedirectStatus, ClientErrorStatus, ServerErrorStatus } from "../types/axios-types"; /** * Type guard for valid HTTP status codes */ export declare const isHttpStatus: TypeGuardFn<HttpStatus>; /** * Type guard for success status codes (2xx) */ export declare const isSuccessStatus: TypeGuardFn<SuccessStatus>; /** * Type guard for redirect status codes (3xx) */ export declare const isRedirectStatus: TypeGuardFn<RedirectStatus>; /** * Type guard for client error status codes (4xx) */ export declare const isClientErrorStatus: TypeGuardFn<ClientErrorStatus>; /** * Type guard for server error status codes (5xx) */ export declare const isServerErrorStatus: TypeGuardFn<ServerErrorStatus>; /** * Type guard for specific status codes */ export declare const isStatus200: TypeGuardFn<200>; export declare const isStatus201: TypeGuardFn<201>; export declare const isStatus204: TypeGuardFn<204>; export declare const isStatus400: TypeGuardFn<400>; export declare const isStatus401: TypeGuardFn<401>; export declare const isStatus403: TypeGuardFn<403>; export declare const isStatus404: TypeGuardFn<404>; export declare const isStatus422: TypeGuardFn<422>; export declare const isStatus429: TypeGuardFn<429>; export declare const isStatus500: TypeGuardFn<500>; export declare const isStatus502: TypeGuardFn<502>; export declare const isStatus503: TypeGuardFn<503>; /** * Creates a type guard for a specific status code */ export declare function createStatusGuard<T extends number>(statusCode: T): TypeGuardFn<T>; /** * Status code category checker */ export declare function getStatusCategory(status: number): "success" | "redirect" | "client-error" | "server-error" | "unknown"; /** * Check if status indicates retryable error */ export declare function isRetryableStatus(status: number): boolean; /** * Check if status indicates success that might have response body */ export declare function hasResponseBody(status: number): boolean; /** * Common status code validators */ export declare const StatusValidators: Readonly<{ isOk: TypeGuardFn<200>; isCreated: TypeGuardFn<201>; isNoContent: TypeGuardFn<204>; isBadRequest: TypeGuardFn<400>; isUnauthorized: TypeGuardFn<401>; isForbidden: TypeGuardFn<403>; isNotFound: TypeGuardFn<404>; isValidationError: TypeGuardFn<422>; isRateLimit: TypeGuardFn<429>; isInternalServerError: TypeGuardFn<500>; isBadGateway: TypeGuardFn<502>; isServiceUnavailable: TypeGuardFn<503>; }>; //# sourceMappingURL=status-guards.d.ts.map