import type { DefaultError, FetchQueryOptions, GetNextPageParamFunction, InitialPageParam, QueryFunction, } from '@tanstack/react-query'; import type { AreAllOptional } from './AreAllOptional.js'; import type { DeepReadonly } from './DeepReadonly.js'; import type { OperationInfiniteData } from './OperationInfiniteData.js'; import type { PartialParameters } from './PartialParameters.js'; import type { RequestFn } from './RequestFn.js'; import type { ServiceOperationInfiniteQueryKey } from './ServiceOperationKey.js'; export type ServiceOperationFetchInfiniteQueryOptions< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TPageParam, TError = DefaultError, > = | (FetchInfiniteQueryOptionsByQueryKey< TSchema, TQueryFnData, TParams, TPageParam, TError > & FetchInfiniteQueryOptionsQueryFn) | (FetchInfiniteQueryOptionsByParameters< TSchema, TQueryFnData, TParams, TPageParam, TError > & FetchInfiniteQueryOptionsQueryFn); export type ServiceOperationEnsureInfiniteQueryDataOptions< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TPageParam, TError = DefaultError, > = | ((FetchInfiniteQueryOptionsByQueryKey< TSchema, TQueryFnData, TParams, TPageParam, TError > & FetchInfiniteQueryOptionsQueryFn< TSchema, TQueryFnData, TParams, TError >) & { revalidateIfStale?: boolean }) | ((FetchInfiniteQueryOptionsByParameters< TSchema, TQueryFnData, TParams, TPageParam, TError > & FetchInfiniteQueryOptionsQueryFn< TSchema, TQueryFnData, TParams, TError >) & { revalidateIfStale?: boolean }); type FetchInfiniteQueryPages = | { pages?: never; } | { pages: number; getNextPageParam: GetNextPageParamFunction< PartialParameters>, TQueryFnData >; }; type FetchInfiniteQueryOptionsBase< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TPageParam = unknown, TError = DefaultError, > = Omit< FetchQueryOptions< TQueryFnData, TError, OperationInfiniteData, ServiceOperationInfiniteQueryKey, TPageParam >, 'queryKey' | 'initialPageParam' > & (AreAllOptional extends true ? Partial>> : InitialPageParam>) & FetchInfiniteQueryPages; type FetchInfiniteQueryOptionsByQueryKey< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TPageParam, TError = DefaultError, > = FetchInfiniteQueryOptionsBase< TSchema, TQueryFnData, TParams, TPageParam, TError > & (AreAllOptional extends true ? Partial> : FetchInfiniteQueryOptionsQueryKey); type FetchInfiniteQueryOptionsQueryKey< TSchema extends { url: string; method: string }, TParams, > = { /** * Fetch Queries by query key */ queryKey: ServiceOperationInfiniteQueryKey; parameters?: never; }; type FetchInfiniteQueryOptionsByParameters< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TPageParam, TError = DefaultError, > = FetchInfiniteQueryOptionsBase< TSchema, TQueryFnData, TParams, TPageParam, TError > & (AreAllOptional extends true ? Partial> : FetchInfiniteQueryOptionsParameters); type FetchInfiniteQueryOptionsParameters = { /** * Fetch Queries by parameters */ parameters: DeepReadonly; queryKey?: never; }; type FetchInfiniteQueryOptionsQueryFn< TSchema extends { url: string; method: string }, TQueryFnData, TParams, TError, > = | { queryFn: QueryFunction< TQueryFnData, ServiceOperationInfiniteQueryKey >; } | { /** * Custom request function to use for the query */ requestFn?: RequestFn; /** * Base URL to use for the request (used in the `queryFn`) * @example 'https://api.example.com' */ baseUrl?: string | undefined; queryFn?: never; // Workaround to fix union type error };