import type { AxiosError, Method } from "axios"; import type { UseQueryResult, DefaultError } from "@tanstack/react-query"; import type { FlexibleConciergeConfig } from "../../../types/concierge"; import type { FunctionlessUseQueryOptions } from "../../../types/tanstack-query"; import type { DatalessAxiosRequestConfig, ServerData, Methodless, AbortControllerless } from "../../../types/axios"; /** * Specifies the available requests that can be performed with `useRetrieve`: * - `retrieve` for `GET` requests * - `status` for `HEAD` requests */ export type UseRetrieveRequest = "retrieve" | "status"; /** Forces the `GET` and `HEAD` requests to not have a payload. */ export type UseRetrievePayload = void; /** Extracts the selected methos from Axios. */ export type UseRetrieveMethod = Extract; /** * Forces the `method` attribute based on the given `UseRetrieveRequest`. * * @template Q The request type. */ type _UseRetrieveMethodGuard = Q extends "retrieve" ? Extract : Extract; /** * Represents the error speficically raised by Axios. * * @template E The error. */ export type UseRetrieveHTTPError = AxiosError; /** * Represents the exception raised by `queryFn` - either a standard error or an * Axios error. * * @template E The error. */ export type UseRetrieveException = DefaultError | UseRetrieveHTTPError; /** * `useRetrieve` hook configuration. Offers `useQuery`, Axios and concierge * configurations separately. * * @template Q The request type. * @template R The response. * @template P The URL parameters. * @template E The error. */ export interface UseRetrieveOptions extends FlexibleConciergeConfig { /** `useQuery` configuration without `queryFn`. */ reactQuery: FunctionlessUseQueryOptions, UseRetrieveException>; /** Axios configuration with forced method and no data & signal. */ axios: AbortControllerless>> & { method: _UseRetrieveMethodGuard; }; } /** * `useRetrieve` hook result. fromServeres TanStack Query's `useQuery` result. * * @template R The response. * @template E The error. */ export type UseRetrieveResult = UseQueryResult, UseRetrieveException>; export {};