import { type QueryObserverResult, type UseQueryOptions } from "@tanstack/react-query"; import type { BaseRecord, CrudFilter, CrudSort, CustomResponse, HttpError, MetaQuery, Prettify } from "../../contexts/data/types"; import type { SuccessErrorNotification } from "../../contexts/notification/types"; import { type UseLoadingOvertimeOptionsProps, type UseLoadingOvertimeReturnType } from "../useLoadingOvertime"; interface UseCustomConfig { sorters?: CrudSort[]; filters?: CrudFilter[]; query?: TQuery; payload?: TPayload; headers?: {}; } export type UseCustomQueryOptions = Omit, TError, CustomResponse>, "queryKey" | "queryFn"> & { queryKey?: UseQueryOptions, TError, CustomResponse>["queryKey"]; queryFn?: UseQueryOptions, TError, CustomResponse>["queryFn"]; }; export type UseCustomProps = { /** * request's URL */ url: string; /** * request's method (`GET`, `POST`, etc.) */ method: "get" | "delete" | "head" | "options" | "post" | "put" | "patch"; /** * The config of your request. You can send headers, payload, query, filters and sorters using this field */ config?: UseCustomConfig; /** * react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options */ queryOptions?: UseCustomQueryOptions; /** * meta data for `dataProvider` */ meta?: MetaQuery; /** * meta data for `dataProvider` /** * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use. */ dataProviderName?: string; } & SuccessErrorNotification, TError, Prettify & MetaQuery>> & UseLoadingOvertimeOptionsProps; /** * `useCustom` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for custom requests. * * It uses the `custom` method from the `dataProvider` which is passed to ``. * * @see {@link https://refine.dev/docs/api-reference/core/hooks/data/useCustom} for more details. * * @typeParam TQueryFnData - Result data returned by the query function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`} * @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`} * @typeParam TQuery - Values for query params * @typeParam TPayload - Values for params * @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TQueryFnData` * */ export type UseCustomReturnType = { query: QueryObserverResult, TError>; result: { data: CustomResponse["data"]; }; } & UseLoadingOvertimeReturnType; export declare const useCustom: ({ url, method, config, queryOptions, successNotification, errorNotification, meta, dataProviderName, overtimeOptions, }: UseCustomProps) => UseCustomReturnType; export {}; //# sourceMappingURL=useCustom.d.ts.map