UNPKG

@trpc/server

Version:

The tRPC server library

60 lines (59 loc) • 2.62 kB
import { Ai as Simplify, Ti as MaybePromise, _t as CallerOverride, oi as TRPCError, rt as ErrorHandlerOptions, ur as CreateContextCallback } from "../unstable-core-do-not-import-CzDUc5m2.mjs"; import { RedirectType, notFound as notFound$1 } from "next/navigation.js"; //#region src/adapters/next-app-dir/nextAppDirCaller.d.ts /** * Makes procedures callable as Next.js server actions and from React * Server Components. Pass it to `.experimental_caller()`. * @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller */ declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{ /** * Names the procedure from its metadata, for logs and errors, since * server actions have no router path. * @see https://trpc.io/docs/client/nextjs/server-actions#adding-observability-with-metadata */ pathExtractor?: (opts: { meta: TMeta; }) => string; /** * Turns `FormData` input into an object before validation. * @default true */ normalizeFormData?: boolean; /** * Called when a procedure throws. */ onError?: (opts: ErrorHandlerOptions<TContext>) => void; } & CreateContextCallback<TContext, () => MaybePromise<TContext>>>): CallerOverride<TContext>; //#endregion //#region src/adapters/next-app-dir/redirect.d.ts /** * Like `redirect()` from `next/navigation`, for procedures called through * `nextAppDirCaller`. Return it from a resolver; the caller then * redirects. Its type is `undefined`, which matches what the client gets, * unlike Next.js's `never`. * @public */ declare const redirect: (url: URL | string, redirectType?: RedirectType) => undefined; //#endregion //#region src/adapters/next-app-dir/notFound.d.ts /** * Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND` * `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found * page. * @public */ declare const notFound: typeof notFound$1; //#endregion //#region src/adapters/next-app-dir/rethrowNextErrors.d.ts /** * Turns a caught `TRPCError` into the Next.js control-flow error it stands * for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls * `redirect()`, and a `notFound()` or `redirect()` error in `cause` is * rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such * as those `nextAppDirCaller` throws, yourself. */ export declare const rethrowNextErrors: (error: TRPCError) => void; //#endregion export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect }; //# sourceMappingURL=next-app-dir.d.mts.map