import type { InferRouteBody, InferRouteError, InferRouteOptions, InferRouteOutput, ParsedPathAndMethod } from '@aydee-app/eden'; import { type CreateBaseMutationResult, type CreateMutationOptions, type CreateMutationResult, type DefaultError, type MutateOptions, type QueryClient, type StoreOrVal } from '@tanstack/svelte-query'; import type { RouteSchema } from 'elysia'; import { type Readable } from 'svelte/store'; import type { EdenContextState } from '../../context'; import type { Override } from '../../utils/types'; import type { EdenQueryBaseOptions } from '../internal/query-base-options'; import type { WithEdenQueryExtension } from '../internal/query-hook-extension'; export type EdenCreateMutationOptions = CreateMutationOptions & EdenQueryBaseOptions; export type EdenCreateMutationResult = WithEdenQueryExtension, { mutateAsync: EdenAsyncMutationFunction; mutate: EdenMutationFunction; }>>>; export type EdenCreateMutation, TInput = Partial, 'params'>> & Omit, 'params'>, TData = InferRouteOutput, TError = InferRouteError> = (options?: EdenCreateMutationOptions) => EdenCreateMutationResult; export type EdenAsyncMutationFunction = (variables: TVariables, options: {} extends TInput ? void | (TData & MutateOptions, TContext>) : TData & MutateOptions, TContext>) => Promise; export type EdenMutationFunction = (variables: TContext, options: {} extends TInput ? void | (TData & MutateOptions, TContext>) : TData & 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 :( */ export type EdenCreateMutationVariables = { /** * 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; }); /** * In order to extend the {@link createMutation} API to allow query/headers to be * passed in and forwarded properly, create custom wrapper around {@link createMutation} that * can accept multiple arguments. */ export declare function createEdenMutation(options: StoreOrVal>, queryClient?: QueryClient): CreateMutationResult; export declare function edenCreateMutationOptions(parsedPathsAndMethod: ParsedPathAndMethod, context: EdenContextState, options?: EdenCreateMutationOptions, config?: any): CreateMutationOptions; //# sourceMappingURL=create-mutation.d.ts.map