import { MutationKey, UseMutationOptions } from '@tanstack/react-query'; import { BetterFetchError } from 'better-auth/client'; /** * Write-style Better Auth client method. Variables are a single object that * may carry top-level params plus `fetchOptions` (e.g. `signIn.email` takes * `{ email, password, rememberMe?, fetchOptions? }`). * * Read-style endpoints use `AuthQueryFn` / `useAuthQuery` instead. */ export type AuthMutationFn = (variables: any) => Promise; /** * Resolved data type returned by an {@link AuthMutationFn}. */ export type AuthMutationFnData = Awaited>; /** * Variables type accepted by `mutate` / `mutateAsync` for a given * {@link AuthMutationFn}. * * If the method's params are entirely optional (e.g. `authClient.signOut`), * this resolves to `Variables | void` so `mutate()` is callable without * arguments. Otherwise it resolves to the exact required shape so the type * checker rejects `mutate()` when the underlying call needs params. */ export type AuthMutationFnVariables = Parameters[0] extends infer P ? undefined extends P ? // biome-ignore lint/suspicious/noConfusingVoidType: void allows no-arg mutate NonNullable

| void : P : never; /** * Return type of {@link authMutationOptions}, matching the shape produced by * TanStack Query's own `mutationOptions` helper. */ export type AuthMutationOptions = Omit, BetterFetchError, AuthMutationFnVariables>, "mutationKey"> & { mutationKey: TMutationKey; }; /** * Build `mutationOptions` for a write-style Better Auth endpoint. * * Injects `throw: true` into `fetchOptions` so the promise rejects with a * `BetterFetchError` on failure instead of resolving to `{ data, error }`. * * @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`). * @param mutationKey - Stable key for the mutation (used by `useIsMutating`, `MutationCache`, …). */ export declare function authMutationOptions(authFn: TFn, mutationKey: TMutationKey): AuthMutationOptions;