import type { AxiosError } from "axios"; import type { UseInfiniteQueryResult, InfiniteData, DefaultError } from "@tanstack/react-query"; import type { FlexibleConciergeConfig } from "../../../types/concierge"; import type { FunctionInitialPageParamlessUseInfiniteQueryOptions } from "../../../types/tanstack-query"; import type { InfiniteConfig, InfiniteResult } from "../../../types/pagination"; import type { DatalessAxiosRequestConfig, ServerData, Methodless, AbortControllerless } from "../../../types/axios"; /** Forces the `GET` request to not have a payload. */ export type UseInfiniteRetrievePayload = void; /** * Represents the error speficically raised by Axios. * * @template E The error. */ export type UseInfiniteRetrieveHTTPError = AxiosError; /** * Represents the exception raised by `queryFn` - either a standard error or an * Axios error. * * @template E The error. */ export type UseInfiniteRetrieveException = DefaultError | UseInfiniteRetrieveHTTPError; /** * `useInfiniteRetrieve` hook configuration. Offers `useInfiniteQuery`, Axios, * concierge and custom configurations separately. * * @template R The response. * @template P The URL parameters. * @template E The error. */ export interface UseInfiniteRetrieveOptions extends FlexibleConciergeConfig { /** * `useInfiniteQuery` configuration without `queryFn` and `initialPageParam`. */ reactQuery: FunctionInitialPageParamlessUseInfiniteQueryOptions, UseInfiniteRetrieveException>; /** Axios configuration with no data, method & signal. */ axios?: AbortControllerless>>; /** Custom pagination configuration. */ rules: InfiniteConfig; } /** * `useInfiniteRetrieve` hook result. fromServeres TanStack Query's * `useInfiniteQuery` result. * * @template R The response. * @template E The error. */ export type UseInfiniteRetrieveResult = UseInfiniteQueryResult>, UseInfiniteRetrieveException> & { /** Custom results. */ extra: InfiniteResult; }; /** * `useInfiniteRetrieve` hook factory configuration. It can be used to create a * `useInfiniteRetrieve` wrapper. Offers `useInfiniteQuery`, Axios and concierge * configurations separately. * * @template R The response. * @template P The URL parameters. * @template E The error. */ export interface UseInfiniteRetrieveFactory extends Omit, "rules" | "reactQuery"> { /** * `useInfiniteRetrieve`'s TanStack Query configuration without * `getNextPageParam`. */ reactQuery: Omit["reactQuery"], "getNextPageParam">; }