import { DataPage, StreamingPage } from 'fastapi-rtk/api-types'; import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseQueryOptions } from '../../../.external/lib/@tanstack/react-query'; import { PropsWithChildren } from 'react'; import { ApiFunctions, BulkFunctions, InfoQueryData, RelationParam } from './hooks/types'; import { QueryParams } from './utils/types'; /** * Props accepted by the `ApiProvider` component. * * @typeParam TQuery - Custom query-param keys forwarded to the backend (read off `request.query_params`). * Surfaced typed on `initialQueryParams`; pass the same shape to `useApi<…, TQuery>()` to type `queryParams` / * `setQueryParams` (React context cannot carry the Provider's type param to a distant `useApi` call). */ export type ApiProviderProps = PropsWithChildren<{ /** The name of the resource to be used in the API path. */ resource_name?: string; /** The initial query parameters to be used in the API requests. May include custom keys (typed via `TQuery`) forwarded to the backend. */ initialQueryParams?: QueryParams & Partial; /** The relation to be used in the API requests. */ relation?: RelationParam; /** Whether to fetch the `info` for the API requests when the component mounts. */ fetchInfo?: boolean; /** Whether to clear the `info` on refetch. */ clearInfoOnRefetch?: boolean; /** Whether to clear the `data` on refetch. */ clearDataOnRefetch?: boolean; /** Whether to refetch the `info` when the language changes. Defaults to true. */ refetchInfoBasedOnLang?: boolean; /** Whether to refetch the `data` when the language changes. Defaults to true. */ refetchDataBasedOnLang?: boolean; /** Whether to reset the `queryParams` on path change. */ resetQueryParamsOnPathChange?: boolean; /** The react-query props for the info query. */ infoQueryProps?: Partial>; /** The react-query props for the data query. */ dataQueryProps?: Partial>; /** The react-query props for the streaming (infinite) query. */ streamingQueryProps?: Partial, QueryKey, number>>; /** Whether to enable streaming for the API requests. */ streaming?: boolean; /** Overrides for the API dependency functions. */ apiParams?: ApiFunctions; /** Overrides for the bulk-action dependency functions. */ bulkParams?: BulkFunctions; }>; /** Additional options for the `withApiProvider` HOC. */ export interface WithApiProviderOptions { /** The display name for the wrapped component. */ displayName?: string; /** Whether to forward refs to the wrapped component. */ forwardRef?: boolean; }