import * as _aydee_app_eden from '@aydee-app/eden'; import { EdenRequestOptions, InferRouteOptions, EdenClient, EdenClientError, InferRouteOutput, InferRouteError, EmptyToVoid, InferRouteBody, EdenTreatyClient, ExtractEdenTreatyRouteParams, HttpQueryMethod, HttpMutationMethod, ExtractEdenTreatyRouteParamsInput, EdenCreateClient, HTTPLinkOptions, HttpBatchLinkOptions, HttpSubscriptionMethod } from '@aydee-app/eden'; export * from '@aydee-app/eden'; import { AnyElysia, MaybePromise, RouteSchema } from 'elysia'; import { Prettify } from 'elysia/types'; import * as _tanstack_react_query from '@tanstack/react-query'; import { QueryClient, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, InvalidateQueryFilters, InvalidateOptions, QueryFilters, ResetOptions, RefetchQueryFilters, RefetchOptions, CancelOptions, Updater, SetDataOptions, QueryKey, MutationOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult, SkipToken, UseMutationOptions, UseBaseMutationResult, MutateOptions, UseBaseQueryOptions, UseQueryResult, InitialDataFunction, DefinedUseQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult, UseSuspenseQueryOptions, UseSuspenseQueryResult, Query, UseQueryOptions, QueriesResults, QueriesOptions, SuspenseQueriesOptions } from '@tanstack/react-query'; import * as React$1 from 'react'; /** * Options to customize the behavior of the query or fetch. */ type EdenQueryRequestOptions = /** * Use svelte-query's internal AbortSignals instead of allowing user provided signals. */ Omit, 'signal'> & { /** * Opt out or into aborting request on unmount. * * @todo * * This should actually be renamed based on {@see https://github.com/trpc/trpc/issues/4448}. * * TLDR: * This property actually means "forward the queryFn's context.signal", * which has __more__ functionality than simply aborting the request. */ abortOnUnmount?: boolean; /** * Opt out of SSR for this query by passing `ssr: false`. */ ssr?: boolean; /** * Overrides for svelte-query hooks. */ overrides?: EdenQueryOverrides; }; /** * Top-level overrides applied to the generated eden-query hooks. */ type EdenQueryOverrides = { /** * Override the default options provided to `useMutation`. */ useMutation?: Partial; }; /** * Default props that can be provided to the generated `useMutation` hooks. */ type UseMutationOverrides = { onSuccess: (options: UseMutationOverridesOnSuccessOptions) => MaybePromise; }; type UseMutationOverridesOnSuccessOptions = { /** * Calls the original function that was defined in the query's `onSuccess` option */ originalFn: () => MaybePromise; queryClient: QueryClient; /** * Meta data passed in from the `useMutation()` hook */ meta: Record; }; type EdenQueryConfig = EdenQueryRequestOptions & { /** * Override the default context provider * @default undefined */ context?: React.Context; }; /** * Makes the object recursively optional * @internal */ type DeepPartial = TObject extends object ? { [P in keyof TObject]?: DeepPartial; } : TObject; /** * Omits the key without removing a potential union * @internal */ type DistributiveOmit = TObj extends any ? Omit : never; /** * @internal */ type IntersectionError = `The property '${TKey}' in your router collides with a built-in method, rename this router or procedure on your backend.`; /** * @internal */ type ProtectedIntersection = keyof TType & keyof TWith extends never ? TType & TWith : IntersectionError; /** * Simple utility that overrides top level properties from `T` with the matching properties from `U`. */ type Override = Omit & U; /** * Key in params or query that indicates GET routes that are eligible for infinite queries. */ type InfiniteCursorKey = 'cursor'; /** * When providing request input to infinite queries, omit the "cursor" and "direction" properties * since these will be set by the integration. */ type ReservedInfiniteQueryKeys = InfiniteCursorKey | 'direction'; /** * Given T, which is presumably a {@link RouteSchema}, merge the "params" and "query" types, * then extract the "cursor". */ type ExtractCursorType = T extends Record ? (T['params'] & T['query'])['cursor'] : unknown; type ExtractQueryCursor = T extends Record ? T['cursor'] : unknown; /** * Additional options for queries. */ type EdenQueryBaseOptions = { /** * eden-related options */ eden?: EdenQueryRequestOptions; }; /** * A well-defined query type used when creating query keys for a specific type of operation. */ type EdenKnownQueryType = 'query' | 'infinite'; /** * Valid query types for creating query keys. */ type EdenQueryType = EdenKnownQueryType | 'any'; /** * QueryKey used internally. Consists of a tuple with an array key and metadata. */ type EdenQueryKey = [key: TKey, metadata?: { input?: TInput; type?: TType; }]; type EdenQueryKeyOptions = InferRouteOptions & { body?: any; }; type EdenMutationKey = [readonly string[]]; type EdenFetchInfiniteQueryOptions = DistributiveOmit>, 'queryKey' | 'initialPageParam'> & EdenQueryBaseOptions & { initialCursor?: ExtractCursorType; }; type EdenFetchQueryOptions = DistributiveOmit, 'queryKey'> & EdenQueryBaseOptions; /** * @internal */ type EdenQueryUtils = { /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchquery */ fetchQuery: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchinfinitequery */ fetchInfiniteQuery: (queryKey: EdenQueryKey, opts?: EdenFetchInfiniteQueryOptions>) => Promise>; /** * @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching */ prefetchQuery: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchinfinitequery */ prefetchInfiniteQuery: (queryKey: EdenQueryKey, opts?: EdenFetchInfiniteQueryOptions>) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientensurequerydata */ ensureQueryData: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; /** * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-invalidation */ invalidateQueries: (queryKey: EdenQueryKey, filters?: InvalidateQueryFilters, options?: InvalidateOptions) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientresetqueries */ resetQueries: (queryKey: EdenQueryKey, filters?: QueryFilters, options?: ResetOptions) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientrefetchqueries */ refetchQueries: (queryKey: EdenQueryKey, filters?: RefetchQueryFilters, options?: RefetchOptions) => Promise; /** * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-cancellation */ cancelQuery: (queryKey: EdenQueryKey, options?: CancelOptions) => Promise; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata */ setQueryData: (queryKey: EdenQueryKey, updater: Updater, options?: SetDataOptions) => void; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetqueriesdata */ setQueriesData: (queryKey: EdenQueryKey, filters: QueryFilters, updater: Updater, options?: SetDataOptions) => [QueryKey, unknown][]; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata */ getQueryData: (queryKey: EdenQueryKey) => unknown; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata */ setInfiniteQueryData: (queryKey: EdenQueryKey, updater: Updater | undefined, InfiniteData | undefined>, options?: SetDataOptions) => void; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata */ getInfiniteQueryData: (queryKey: EdenQueryKey) => InfiniteData | undefined; /** * @link https://tanstack.com/query/latest/docs/reference/QueryClient/#queryclientsetmutationdefaults */ setMutationDefaults: (mutationKey: EdenMutationKey, options: MutationOptions | ((args: { canonicalMutationFn: (input: unknown) => Promise; }) => MutationOptions)) => void; /** * @link https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientgetmutationdefaults */ getMutationDefaults: (mutationKey: EdenMutationKey) => MutationOptions | undefined; /** * @link https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientismutating */ isMutating: (filters: { mutationKey: EdenMutationKey; }) => number; }; type SSRState = 'mounted' | 'mounting' | 'prepass' | false; type EdenContextPropsBase = { /** * The `TRPCClient` */ client: EdenClient; /** * The SSR context when server-side rendering * @default null */ ssrContext?: TSSRContext | null; /** * State of SSR hydration. * - `false` if not using SSR. * - `prepass` when doing a prepass to fetch queries' data * - `mounting` before TRPCProvider has been rendered on the client * - `mounted` when the TRPCProvider has been rendered on the client * @default false */ ssrState?: SSRState; /** * @deprecated pass abortOnUnmount to `createTRPCReact` instead * Abort loading query calls when unmounting a component - usually when navigating to a new page * @default false */ abortOnUnmount?: boolean; }; type EdenProviderProps = EdenContextProps & { children: React$1.ReactNode; }; type EdenProvider = (props: EdenProviderProps) => React$1.JSX.Element; type EdenContextProps = EdenContextPropsBase & { /** * The react-query `QueryClient` */ queryClient: QueryClient; }; type EdenContextState = Required> & EdenQueryUtils; /** * Additional properties appended to react-query hooks by the library. * * The hooks are scoped to an `eden` property on the hook. * * @example * * const hello = eden.hello.useQuery() * * const edenPath = hello.eden.path */ type WithEdenQueryExtension = T & { /** * Additional object appended by eden-query. */ eden: EdenExtendedQueryHooks; }; /** * Additional hooks added to the original react-query hook result. */ type EdenExtendedQueryHooks = { /** * The path used to make the request. * * @example * * '/api/a/index' */ path: string; }; interface EdenUseInfiniteQueryOptions extends DistributiveOmit>, 'queryKey' | 'initialPageParam'>, EdenQueryBaseOptions { initialCursor?: ExtractQueryCursor; } type EdenUseInfiniteQueryResult = WithEdenQueryExtension> | null>, TError>>; type EdenUseInfiniteQuery['query'], TOutput = InferRouteOutput, TError = InferRouteError, TInfiniteInput = InferRouteOptions['query']> = (input: EmptyToVoid | SkipToken, options: EdenUseInfiniteQueryOptions) => EdenUseInfiniteQueryResult; type EdenUseMutationOptions = UseMutationOptions & EdenQueryBaseOptions; type EdenUseMutationResult = WithEdenQueryExtension, { mutateAsync: EdenAsyncMutationFunction; mutate: EdenMutationFunction; }>>; type EdenUseMutation, TInput = Partial, 'params'>> & Omit, 'params'>, TData = InferRouteOutput, TError = InferRouteError> = (options?: EdenUseMutationOptions) => EdenUseMutationResult; type EdenAsyncMutationFunction = (variables: {} extends TVariables ? void : unknown extends TVariables ? void : TVariables, options: {} extends TInput ? void | (TInput & MutateOptions, TContext>) : TInput & MutateOptions, TContext>) => Promise; type EdenMutationFunction = (variables: {} extends TVariables ? void : unknown extends TVariables ? void : TVariables, options: {} extends TInput ? void | (TInput & MutateOptions, TContext>) : TInput & MutateOptions, TContext>) => void; /** * @internal * * Need to be able to provide multiple arguments to `useMutation`, since * Eden's mutations accept a body as the first argument, and additional options * as the second argument -- which are sometimes required. * * To accomplish this, eden-query intercepts the hook call to grab the args as a single object, * then destructures it in custom `mutate` and `asyncMutate` implementations. * * This "hack" is needed since the vanilla `useMutation` hook doesn't allow multiple args :( */ type EdenUseMutationVariables = { /** * The first argument provided to the `useMutation` hook, i.e. the request body. */ body: TBody; } & ({} extends TOptions ? { /** * The second argument provided to the `useMutation` hook, i.e. request options. */ options?: TOptions; } : { /** * The second argument provided to the `useMutation` hook, i.e. request options. */ options: TOptions; }); type EdenUseQueryOptions = DistributiveOmit, 'queryKey'> & EdenQueryBaseOptions; type EdenDefinedUseQueryOptions = DistributiveOmit, 'queryKey'> & EdenQueryBaseOptions & { initialData: InitialDataFunction | TQueryOptsData; }; type EdenUseQueryResult = WithEdenQueryExtension>; type EdenDefinedUseQueryResult = WithEdenQueryExtension>; interface EdenUseQuery['query'], TOutput = InferRouteOutput, TError = InferRouteError> { (input: EmptyToVoid, options: EdenDefinedUseQueryOptions): EdenDefinedUseQueryResult; (input: EmptyToVoid | SkipToken, options?: EdenUseQueryOptions): EdenUseQueryResult; } interface EdenUseSuspenseInfiniteQueryOptions extends DistributiveOmit>, 'queryKey' | 'initialPageParam'>, EdenQueryBaseOptions { initialCursor?: ExtractCursorType; } /** * @internal */ type EdenUseSuspenseInfiniteQueryResult = [ InfiniteData> | null>, WithEdenQueryExtension> | null>, TError>> ]; type EdenUseSuspenseInfiniteQuery['query'], TOutput = InferRouteOutput, TError = InferRouteError> = (input: EmptyToVoid, options?: EdenUseSuspenseInfiniteQueryOptions) => EdenUseSuspenseInfiniteQueryResult; interface EdenUseSuspenseQueryOptions extends DistributiveOmit, 'queryKey'>, EdenQueryBaseOptions { } /** * @internal */ type EdenUseSuspenseQueryResult = [ TData, WithEdenQueryExtension> ]; type EdenUseSuspenseQuery['query'], TOutput = InferRouteOutput, TError = InferRouteError> = (input: EmptyToVoid, options?: EdenUseSuspenseQueryOptions) => EdenUseSuspenseQueryResult; type EdenTreatyReactQueryUtils = ProtectedIntersection, EdenTreatyReactQueryUtilsProxy>; type DecoratedEdenTreatyReactQueryContextProps = Omit, 'client'> & { client: EdenTreatyClient; }; type EdenTreatyReactQueryContextProps = EdenContextPropsBase & { client: EdenClient; }; type EdenTreatyReactQueryUtilsProxy, TPath extends any[] = [], TRouteParams = ExtractEdenTreatyRouteParams> = EdenTreatyQueryUtilsUniversalUtils & { [K in keyof TSchema]: TSchema[K] extends RouteSchema ? EdenTreatyReactQueryUtilsMapping : EdenTreatyReactQueryUtilsProxy; } & ({} extends TRouteParams ? {} : (params: ExtractEdenTreatyRouteParamsInput) => EdenTreatyReactQueryUtilsProxy], TPath>); type EdenTreatyReactQueryUtilsMapping = InferRouteOptions> = TMethod extends HttpQueryMethod ? EdenTreatyQueryUtilsQueryUtils & (InfiniteCursorKey extends keyof (TInput['params'] & TInput['query']) ? EdenTreatyQueryUtilsInfiniteUtils : {}) : TMethod extends HttpMutationMethod ? EdenQueryUtilsMutationUtils : `Unknown HTTP Method: ${TMethod & string}`; type EdenTreatyQueryUtilsQueryUtils['query'], TOutput = InferRouteOutput, TError = InferRouteError, TKey extends QueryKey = EdenQueryKey> = { fetch: (input: EmptyToVoid, options?: EdenFetchQueryOptions) => Promise; prefetch: (input: EmptyToVoid, options?: EdenFetchQueryOptions) => Promise; ensureData: (input: EmptyToVoid, options?: EdenFetchQueryOptions) => Promise; invalidate: (input?: DeepPartial, filters?: Override) => boolean; }>, options?: InvalidateOptions) => Promise; refetch: (input?: TInput, filters?: RefetchQueryFilters, options?: RefetchOptions) => Promise; cancel: (input?: TInput, filters?: QueryFilters, options?: CancelOptions) => Promise; reset: (input?: TInput, options?: ResetOptions) => Promise; setData: (input: TInput, updater: Updater, options?: SetDataOptions) => void; /** * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata */ setQueriesData(input: TInput, filters: QueryFilters, updater: Updater, options?: SetDataOptions): [QueryKey, TOutput]; getData: (input: EmptyToVoid) => TOutput | undefined; options: (input: EmptyToVoid, options?: UseQueryOptions) => UseQueryOptions; }; type EdenTreatyQueryUtilsInfiniteUtils['query'], TOutput = InferRouteOutput, TError = InferRouteError, TKey extends QueryKey = EdenQueryKey> = { fetchInfinite: (input: EmptyToVoid, options?: EdenFetchInfiniteQueryOptions) => Promise>>>; prefetchInfinite: (input: EmptyToVoid, options?: EdenFetchQueryOptions) => Promise; getInfiniteData: (input: EmptyToVoid) => InfiniteData>> | undefined; setInfiniteData: (input: TInput, updater: Updater>> | undefined, InfiniteData>> | undefined>, options?: SetDataOptions) => void; infiniteOptions: (input: EmptyToVoid, options?: EdenUseInfiniteQueryOptions) => UseInfiniteQueryOptions; }; type EdenQueryUtilsMutationUtils, TOutput = InferRouteOutput, TError = InferRouteError, _TKey extends QueryKey = EdenQueryKey> = { setMutationDefaults(options: EdenUseMutationOptions | ((args: { canonicalMutationFn: NonNullable['mutationFn']>; }) => EdenUseMutationOptions)): void; getMutationDefaults(): EdenUseMutationOptions | undefined; isMutating(): number; }; /** * Utility hooks available at all levels of the utilities proxy. */ type EdenTreatyQueryUtilsUniversalUtils = { /** * Invalidate the full router * @link https://trpc.io/docs/v10/useContext#query-invalidation * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-invalidation */ invalidate(input?: undefined, filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; }; declare function createEdenTreatyQueryUtils(context: EdenContextState, config?: EdenQueryConfig): EdenTreatyReactQueryUtils; /** * @todo use config for something... */ declare function createEdenTreatyQueryUtilsProxy(context: EdenContextState, config?: EdenQueryConfig, originalPaths?: string[], pathParams?: Record[]): EdenTreatyReactQueryUtils; /** * @todo Eden-subscription? */ interface EdenUseSubscriptionOptions { enabled?: boolean; onStarted?: () => void; onData: (data: TOutput) => void; onError?: (err: TError) => void; } type UseQueryOptionsForUseQueries = DistributiveOmit, 'queryKey'>; /** * A function that accepts a callback that's called with a proxy object. * Invoking the proxy object returns strongly typed query options. */ type EdenTreatyUseQueries = >(callback: (t: EdenTreatyUseQueriesProxy) => readonly [...QueriesOptions]) => TCombinedResult; /** * A proxy object that returns {@link CreateQueryOptions} (instead of an actual create query result). * Passed to `createQueries` caller to use. */ type EdenTreatyUseQueriesProxy = T extends { _routes: infer TSchema extends Record; } ? EdenTreatyUseQueriesProxyMapping : 'Please install Elysia before using Eden'; /** * Implementation. */ type EdenTreatyUseQueriesProxyMapping, TPath extends any[] = [], TRouteParams = ExtractEdenTreatyRouteParams> = { [K in Exclude]: TSchema[K] extends RouteSchema ? EdenTreatyUseQueriesHook : EdenTreatyUseQueriesProxyMapping; } & ({} extends TRouteParams ? {} : (params: ExtractEdenTreatyRouteParamsInput) => EdenTreatyUseQueriesProxyMapping], TPath>); /** * When a route is encountered, it is replaced with a callable function that takes the same inputs. */ type EdenTreatyUseQueriesHook['query'], TOutput = InferRouteOutput, TError = InferRouteError, TKey extends QueryKey = EdenQueryKey> = (input: EmptyToVoid, opts?: UseQueryOptionsForUseQueries) => UseQueryOptions; declare function createTreatyUseQueriesProxy(client: EdenClient, originalPaths?: string[], config?: EdenQueryConfig, pathParams?: Record[]): EdenTreatyUseQueriesProxy; type UseQueryOptionsForUseSuspenseQueries = DistributiveOmit, 'queryKey'>; type EdenTreatyUseSuspenseQueries = >(queriesCallback: (t: EdenTreatyUseSuspenseQueriesProxy) => readonly [...TQueriesOptions]) => UseSuspenseQueriesResult; /** * A proxy object that returns {@link CreateQueryOptions} (instead of an actual create query result). * Passed to `createQueries` caller to use. */ type EdenTreatyUseSuspenseQueriesProxy = T extends { _routes: infer TSchema extends Record; } ? EdenTreatyUseSuspenseQueriesProxyMapping : 'Please install Elysia before using Eden'; type EdenTreatyUseSuspenseQueriesProxyMapping, TPath extends any[] = [], TRouteParams = ExtractEdenTreatyRouteParams> = { [K in Exclude]: TSchema[K] extends RouteSchema ? UseSuspenseQueriesHook : EdenTreatyUseSuspenseQueriesProxyMapping; } & ({} extends TRouteParams ? {} : (params: ExtractEdenTreatyRouteParamsInput) => EdenTreatyUseSuspenseQueriesProxyMapping], TPath>); /** * When a route is encountered, it is replaced with a callable function that takes the same inputs. */ type UseSuspenseQueriesHook['query'], TOutput = InferRouteOutput, TError = InferRouteError> = (input: EmptyToVoid, opts?: UseQueryOptionsForUseSuspenseQueries) => UseQueryOptionsForUseSuspenseQueries; declare function createTreatyUseSuspenseQueriesProxy(client: EdenClient, paths?: string[]): EdenTreatyUseSuspenseQueriesProxy; type UseSuspenseQueriesResult[]> = [ { [TKey in keyof TQueriesOptions]: TQueriesOptions[TKey] extends UseQueryOptionsForUseSuspenseQueries ? unknown extends TData ? TQueryFnData : TData : never; }, { [TKey in keyof TQueriesOptions]: TQueriesOptions[TKey] extends UseQueryOptionsForUseSuspenseQueries ? UseSuspenseQueryResult : never; } ]; declare function createEdenTreatyQueryRootHooks>(config?: EdenQueryConfig): { Provider: EdenProvider; createClient: EdenCreateClient; createHttpClient: (options?: HTTPLinkOptions) => EdenClient; createHttpBatchClient: (options?: HttpBatchLinkOptions) => EdenClient; createContext: (props: EdenContextProps) => { fetchQuery: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; fetchInfiniteQuery: (queryKey: EdenQueryKey, opts?: EdenFetchInfiniteQueryOptions>) => Promise<_tanstack_react_query.InfiniteData>; prefetchQuery: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; prefetchInfiniteQuery: (queryKey: EdenQueryKey, opts?: EdenFetchInfiniteQueryOptions>) => Promise; ensureQueryData: (queryKey: EdenQueryKey, opts?: EdenFetchQueryOptions>) => Promise; invalidateQueries: (queryKey: EdenQueryKey, filters?: _tanstack_react_query.InvalidateQueryFilters, options?: _tanstack_react_query.InvalidateOptions) => Promise; resetQueries: (queryKey: EdenQueryKey, filters?: _tanstack_react_query.QueryFilters, options?: _tanstack_react_query.ResetOptions) => Promise; refetchQueries: (queryKey: EdenQueryKey, filters?: _tanstack_react_query.RefetchQueryFilters, options?: _tanstack_react_query.RefetchOptions) => Promise; cancelQuery: (queryKey: EdenQueryKey, options?: _tanstack_react_query.CancelOptions) => Promise; setQueryData: (queryKey: EdenQueryKey, updater: _tanstack_react_query.Updater, options?: _tanstack_react_query.SetDataOptions) => void; setQueriesData: (queryKey: EdenQueryKey, filters: _tanstack_react_query.QueryFilters, updater: _tanstack_react_query.Updater, options?: _tanstack_react_query.SetDataOptions) => [_tanstack_react_query.QueryKey, unknown][]; getQueryData: (queryKey: EdenQueryKey) => unknown; setInfiniteQueryData: (queryKey: EdenQueryKey, updater: _tanstack_react_query.Updater<_tanstack_react_query.InfiniteData | undefined, _tanstack_react_query.InfiniteData | undefined>, options?: _tanstack_react_query.SetDataOptions) => void; getInfiniteQueryData: (queryKey: EdenQueryKey) => _tanstack_react_query.InfiniteData | undefined; setMutationDefaults: (mutationKey: EdenMutationKey, options: _tanstack_react_query.MutationOptions | ((args: { canonicalMutationFn: (input: unknown) => Promise; }) => _tanstack_react_query.MutationOptions)) => void; getMutationDefaults: (mutationKey: EdenMutationKey) => _tanstack_react_query.MutationOptions | undefined; isMutating: (filters: { mutationKey: EdenMutationKey; }) => number; abortOnUnmount: boolean; queryClient: _tanstack_react_query.QueryClient; client: EdenClient; ssrContext: TSSRContext | null; ssrState: SSRState; }; createUtils: (props: EdenContextProps) => ProtectedIntersection, EdenTreatyReactQueryUtilsProxy>>; useContext: (context?: EdenContextState) => ProtectedIntersection, EdenTreatyReactQueryUtilsProxy>>; useUtils: (context?: EdenContextState) => ProtectedIntersection, EdenTreatyReactQueryUtilsProxy>>; useQuery: (originalPaths: readonly string[], input?: InferRouteOptions | SkipToken, options?: EdenUseQueryOptions) => EdenUseQueryResult; useSuspenseQuery: (originalPaths: readonly string[], input: InferRouteOptions, options?: EdenUseSuspenseQueryOptions) => EdenUseSuspenseQueryResult; useInfiniteQuery: (originalPaths: readonly string[], input?: InferRouteOptions | SkipToken, options?: EdenUseInfiniteQueryOptions) => EdenUseInfiniteQueryResult; useSuspenseInfiniteQuery: (originalPaths: readonly string[], input: InferRouteOptions, options?: EdenUseSuspenseInfiniteQueryOptions) => EdenUseSuspenseInfiniteQueryResult; useQueries: EdenTreatyUseQueries; useSuspenseQueries: EdenTreatyUseSuspenseQueries; useMutation: (originalPaths: readonly string[], input?: InferRouteOptions, options?: EdenUseMutationOptions) => EdenUseMutationResult; useSubscription: (path: readonly string[], input: unknown, opts: EdenUseSubscriptionOptions) => void; }; type EdenTreatyQueryRootHooks = ReturnType>; type InferTreatyQueryIO = T extends { _routes: infer TSchema extends Record; } ? InferTreatyQueryIOMapping : 'Please install Elysia before using Eden'; type InferTreatyQueryIOMapping, TPath extends any[] = []> = { [K in keyof TSchema]: TSchema[K] extends RouteSchema ? { input: K extends HttpQueryMethod ? InferRouteOptions> : [ InferRouteBody>, InferRouteOptions> ]; output: InferRouteOutput; } : InferTreatyQueryIOMapping; }; type InferTreatyQueryInput = T extends { _routes: infer TSchema extends Record; } ? InferTreatyQueryInputMapping : 'Please install Elysia before using Eden'; type InferTreatyQueryInputMapping, TPath extends any[] = []> = { [K in keyof TSchema]: TSchema[K] extends RouteSchema ? K extends HttpQueryMethod ? InferRouteOptions> : [ InferRouteBody>, InferRouteOptions> ] : InferTreatyQueryInputMapping; }; type InferTreatyQueryOutput = T extends { _routes: infer TSchema extends Record; } ? InferTreatyQueryOutputMapping : 'Please install Elysia before using Eden'; type InferTreatyQueryOutputMapping, TPath extends any[] = []> = { [K in keyof TSchema]: TSchema[K] extends RouteSchema ? InferRouteOutput : InferTreatyQueryOutputMapping; }; /** * The treaty-query API provides utility methods that are available at the root, as well as * a strongly-typed proxy representing the {@link AnyElysia} API. */ type EdenTreatyReactQuery = EdenTreatyReactQueryBase & EdenTreatyReactQueryHooks; /** * Utilities available at the eden-treaty + react-query root. */ interface EdenTreatyReactQueryBase { /** * Get utilities provided via the context API. * * @see https://trpc.io/docs/v11/client/react/useUtils */ useUtils(): EdenTreatyReactQueryUtils; /** * Returns everything that will be provided from context. * * e.g. the root utility functions, and root configuration settings. */ createContext(props: EdenContextProps): EdenContextState; /** * Creates a proxy that can invoke tanstack-query helper functions. */ createUtils(props: EdenContextProps): EdenTreatyReactQueryUtils; /** * Get utilities provided via the context API. * * @deprecated renamed to {@link useUtils} and will be removed in a future tRPC version * * @link https://trpc.io/docs/v11/client/react/useUtils */ useContext(): EdenTreatyReactQueryUtils; /** * React.Provider to set the context. */ Provider: EdenProvider; /** * Wraps the `useQueries` react-query hook in a type-safe proxy. */ useQueries: EdenTreatyUseQueries; /** * Wraps the `useSuspenseQueries` react-query hook in a type-safe proxy. */ useSuspenseQueries: EdenTreatyUseSuspenseQueries; /** * Create a raw, untyped-client. */ createClient: EdenCreateClient; /** * Convenience method for creating and configuring a client with a single HTTPLink. */ createHttpClient: (options?: HTTPLinkOptions) => EdenClient; /** * Convenience method for creating and configuring a client with a single HttpBatchLink. */ createHttpBatchClient: (options?: HttpBatchLinkOptions) => EdenClient; } /** * A strongly-typed proxy with svelte-query hooks for interacting with the {@link AnyElysia} backend. */ type EdenTreatyReactQueryHooks = T extends { _routes: infer TSchema extends Record; } ? EdenTreatyReactQueryHooksProxy : 'Please install Elysia before using Eden'; /** * Recursively iterate over all keys in {@link AnyElyisa._routes}, processing path parameters * and regular path segments separately. * * Regular path parameters will be mapped to a nested object, and then intersected * with anything generated by dynamic path parameters. * * @template TSchema The current level of {@link AnyElysia._routes} being processed. * @template TPath The current path segments up to this point (excluding dynamic path parameters). * @template TRouteParams Keys that are considered path parameters instead of regular path segments. */ type EdenTreatyReactQueryHooksProxy, TPath extends any[] = [], TRouteParams = ExtractEdenTreatyRouteParams> = EdenTreatyReactQueryPathHooks & EdenTreatyReactQueryHooksPathParameterHook; /** * Recursively handle regular path segments (i.e. NOT path parameters). * * If the value is a {@link RouteSchema}, then it's a "leaf" that does not need to be * recursively processed. The result should be the key, an HTTP method, mapped to svelte-query hooks. * * @template TSchema The current level of {@link AnyElysia._routes} being processed. * @template TPath The current path segments up to this point (excluding dynamic path parameters). * @template TRouteParams Keys that are considered path parameters instead of regular path segments. */ type EdenTreatyReactQueryPathHooks, TPath extends any[] = [], TRouteParams = ExtractEdenTreatyRouteParams> = { [K in Exclude]: TSchema[K] extends RouteSchema ? EdenTreatyReactQueryRouteLeaf : EdenTreatyReactQueryHooksProxy; }; /** * This intersects the object created by {@link EdenTreatyPathHooks} * (for regular path parameters) to handle dynamic path parameters. * * If there are no dynamic path parameters, then return an empty object. * Intersecting with empty object does nothing. * * Otherwise, return a function that returns the next level of the proxy, omitting * the current dynamic path parameter. * * @template TSchema The current level of {@link AnyElysia._routes} being processed. * @template TPath The current path segments up to this point (excluding dynamic path parameters). * @template TRouteParams Keys that are considered path parameters instead of regular path segments. */ type EdenTreatyReactQueryHooksPathParameterHook, TPath extends any[] = [], TRouteParams = {}> = {} extends TRouteParams ? {} : (params: ExtractEdenTreatyRouteParamsInput) => EdenTreatyReactQueryHooksProxy], TPath>; /** * When a {@link RouteSchema} is found, map it to leaves and stop recursive processing. * Leaves are objects with svelte-query hooks related to the HTTP method. * * For example, the object would contain hooks for queries if {@link TMethod} was "get". * * @template TRoute The {@link RouteSchema} that was found. * @template TMethod The most recent key that was mapped to the {@link TRoute}. e.g. "get", "post", etc. * @template TPath The current path segments up to this point (excluding dynamic path parameters). */ type EdenTreatyReactQueryRouteLeaf = TMethod extends HttpQueryMethod ? EdenTreatyReactQueryLeaf : TMethod extends HttpMutationMethod ? EdenTreatyReactQueryMutationLeaf : TMethod extends HttpSubscriptionMethod ? EdenTreatyReactQuerySubscriptionLeaf : EdenTreatyReactQueryUnknownLeaf; /** * react-query hooks for "infinite-queries". * e.g. routes with a "GET" endpoint that also expects "cursor" as a query parameter. */ type EdenTreatyReactQueryLeaf = InferRouteOptions> = { useQuery: EdenUseQuery; useSuspenseQuery: EdenUseSuspenseQuery; } & (InfiniteCursorKey extends keyof (TInput['params'] & TInput['query']) ? EdenTreatyReactQueryInfiniteQueryLeaf : {}); /** * react-query hooks for "infinite-queries". * e.g. routes with a "GET" endpoint that also expects "cursor" as a query parameter. */ type EdenTreatyReactQueryInfiniteQueryLeaf = { useInfiniteQuery: EdenUseInfiniteQuery; useSuspenseInfiniteQuery: EdenUseSuspenseInfiniteQuery; }; /** * react-query hooks for "mutations". e.g. Basically routes with any HTTP methods other than "GET." */ type EdenTreatyReactQueryMutationLeaf = { useMutation: EdenUseMutation; }; /** * @todo: svelte-query hooks for "subscriptions". e.g. Basically routes that support "CONNECT" or "SUBSCRIBE" requests. * * @see https://github.com/trpc/trpc/blob/52a57eaa9c12394778abf5f0e6b52ec6f46288ed/packages/react-query/src/shared/hooks/createHooksInternal.tsx#L347 * @see https://tkdodo.eu/blog/using-web-sockets-with-react-query */ type EdenTreatyReactQuerySubscriptionLeaf> = { options: Prettify; queryKey: EdenQueryKey; }; /** * react-query hooks for any unknown HTTP methods will just expose all known hooks for now. * * @todo Decide what hooks to expose... */ type EdenTreatyReactQueryUnknownLeaf = EdenTreatyReactQueryLeaf & EdenTreatyReactQueryInfiniteQueryLeaf & EdenTreatyReactQueryMutationLeaf & EdenTreatyReactQuerySubscriptionLeaf; declare function createEdenTreatyReactQuery(config?: EdenQueryConfig): EdenTreatyReactQuery; /** * Creates the recursive proxy. * * @param config Root hooks that were created. * * @param rootHooks The original configuration for eden-treaty. * * @param paths Path parameter strings including the current path parameter as a placeholder. * @example [ 'products', ':id', ':cursor' ] * * @param pathParams An array of objects representing path parameter replacements. * @example [ { id: 123 }, { cursor: '456' } ] */ declare function createEdenTreatyReactQueryProxy(rootHooks: EdenTreatyQueryRootHooks, config?: EdenQueryConfig, paths?: (string | symbol)[], pathParams?: Record[]): () => void; declare function getQueryKey>(route: EdenTreatyReactQueryHooksProxy, input?: TSchema extends RouteSchema ? InferRouteOptions : any, type?: EdenQueryType): EdenQueryKey; declare function getMutationKey(route: EdenTreatyReactQueryHooksProxy, options?: EdenQueryKeyOptions): EdenMutationKey; declare const routeDefinitionSymbol: unique symbol; export { type DecoratedEdenTreatyReactQueryContextProps, type EdenQueryUtilsMutationUtils, type EdenTreatyQueryRootHooks, type EdenTreatyQueryUtilsInfiniteUtils, type EdenTreatyQueryUtilsQueryUtils, type EdenTreatyQueryUtilsUniversalUtils, type EdenTreatyReactQuery, type EdenTreatyReactQueryBase, type EdenTreatyReactQueryContextProps, type EdenTreatyReactQueryHooks, type EdenTreatyReactQueryHooksPathParameterHook, type EdenTreatyReactQueryHooksProxy, type EdenTreatyReactQueryInfiniteQueryLeaf, type EdenTreatyReactQueryLeaf, type EdenTreatyReactQueryMutationLeaf, type EdenTreatyReactQueryPathHooks, type EdenTreatyReactQueryRouteLeaf, type EdenTreatyReactQuerySubscriptionLeaf, type EdenTreatyReactQueryUnknownLeaf, type EdenTreatyReactQueryUtils, type EdenTreatyReactQueryUtilsProxy, type EdenTreatyUseQueries, type EdenTreatyUseQueriesHook, type EdenTreatyUseQueriesProxy, type EdenTreatyUseQueriesProxyMapping, type EdenTreatyUseSuspenseQueries, type EdenTreatyUseSuspenseQueriesProxy, type EdenTreatyUseSuspenseQueriesProxyMapping, type InferTreatyQueryIO, type InferTreatyQueryIOMapping, type InferTreatyQueryInput, type InferTreatyQueryInputMapping, type InferTreatyQueryOutput, type InferTreatyQueryOutputMapping, type UseSuspenseQueriesHook, type UseSuspenseQueriesResult, createEdenTreatyQueryRootHooks, createEdenTreatyQueryUtils, createEdenTreatyQueryUtilsProxy, createEdenTreatyReactQuery, createEdenTreatyReactQueryProxy, createTreatyUseQueriesProxy, createTreatyUseSuspenseQueriesProxy, getMutationKey, getQueryKey, routeDefinitionSymbol };