@trpc/server 11.23.0 → 11.23.1-canary.14.507382d73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/index.cjs +12 -2
- package/dist/adapters/aws-lambda/index.d.cts +24 -1
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +24 -1
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +12 -2
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +8 -3
- package/dist/adapters/express.d.cts +12 -2
- package/dist/adapters/express.d.cts.map +1 -1
- package/dist/adapters/express.d.mts +12 -2
- package/dist/adapters/express.d.mts.map +1 -1
- package/dist/adapters/express.mjs +8 -3
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +20 -4
- package/dist/adapters/fastify/index.d.cts +38 -4
- package/dist/adapters/fastify/index.d.cts.map +1 -1
- package/dist/adapters/fastify/index.d.mts +38 -4
- package/dist/adapters/fastify/index.d.mts.map +1 -1
- package/dist/adapters/fastify/index.mjs +20 -4
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +13 -2
- package/dist/adapters/fetch/index.d.cts +26 -1
- package/dist/adapters/fetch/index.d.cts.map +1 -1
- package/dist/adapters/fetch/index.d.mts +26 -1
- package/dist/adapters/fetch/index.d.mts.map +1 -1
- package/dist/adapters/fetch/index.mjs +13 -2
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +19 -9
- package/dist/adapters/next-app-dir.d.cts +21 -11
- package/dist/adapters/next-app-dir.d.cts.map +1 -1
- package/dist/adapters/next-app-dir.d.mts +21 -11
- package/dist/adapters/next-app-dir.d.mts.map +1 -1
- package/dist/adapters/next-app-dir.mjs +19 -9
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +10 -4
- package/dist/adapters/next.d.cts +13 -2
- package/dist/adapters/next.d.cts.map +1 -1
- package/dist/adapters/next.d.mts +13 -2
- package/dist/adapters/next.d.mts.map +1 -1
- package/dist/adapters/next.mjs +10 -4
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +1 -1
- package/dist/adapters/node-http/index.d.cts +1 -1
- package/dist/adapters/node-http/index.d.mts +1 -1
- package/dist/adapters/node-http/index.mjs +1 -1
- package/dist/adapters/standalone.cjs +19 -3
- package/dist/adapters/standalone.d.cts +32 -6
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +32 -6
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +19 -3
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +1 -1
- package/dist/adapters/ws.d.cts +2 -2
- package/dist/adapters/ws.d.mts +2 -2
- package/dist/adapters/ws.mjs +1 -1
- package/dist/{asyncGeneratorDelegate-FcEJT04i.mjs → asyncGeneratorDelegate-Bl41FGB5.mjs} +41 -8
- package/dist/asyncGeneratorDelegate-Bl41FGB5.mjs.map +1 -0
- package/dist/{asyncGeneratorDelegate-Dj-8tGhf.cjs → asyncGeneratorDelegate-CPV0O1Hn.cjs} +40 -7
- package/dist/{codes-HK4UsP07.cjs → codes-Be-DrYMh.cjs} +8 -4
- package/dist/{codes-C9N0z0an.mjs → codes-nbrm_zWY.mjs} +9 -5
- package/dist/codes-nbrm_zWY.mjs.map +1 -0
- package/dist/{contentTypeParsers-B1e2ZNvN.cjs → contentTypeParsers-BTdoZrqN.cjs} +12 -0
- package/dist/contentTypeParsers-D1EBkFFY.mjs +26 -0
- package/dist/contentTypeParsers-D1EBkFFY.mjs.map +1 -0
- package/dist/{getErrorShape-hncV8cPE.cjs → getErrorShape-8t0oLscZ.cjs} +16 -5
- package/dist/{getErrorShape-zlj81BiC.mjs → getErrorShape-B6z8u8q0.mjs} +17 -6
- package/dist/getErrorShape-B6z8u8q0.mjs.map +1 -0
- package/dist/http.cjs +3 -3
- package/dist/http.d.cts +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +3 -3
- package/dist/{index-BI3Qi_F-.d.cts → index-BGYvuCEh.d.cts} +68 -8
- package/dist/index-BGYvuCEh.d.cts.map +1 -0
- package/dist/{index-BI3Qi_F-.d.mts → index-BGYvuCEh.d.mts} +68 -8
- package/dist/index-BGYvuCEh.d.mts.map +1 -0
- package/dist/{index-Tpw5OCTF.d.cts → index-CTfJHk7_.d.cts} +41 -29
- package/dist/index-CTfJHk7_.d.cts.map +1 -0
- package/dist/{index-CtkOmZzm.d.mts → index-DD2oXVyh.d.mts} +41 -29
- package/dist/index-DD2oXVyh.d.mts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{initTRPC-RMeQIy9H.mjs → initTRPC-JhlmAV6P.mjs} +31 -22
- package/dist/initTRPC-JhlmAV6P.mjs.map +1 -0
- package/dist/{initTRPC-DP-s8c4t.cjs → initTRPC-jn7uHFOx.cjs} +30 -21
- package/dist/{node-http-X8RiQEuH.cjs → node-http-CCpTZ1zd.cjs} +13 -6
- package/dist/{node-http-ChhZEv1k.mjs → node-http-DTcc6qM4.mjs} +14 -7
- package/dist/node-http-DTcc6qM4.mjs.map +1 -0
- package/dist/observable/index.cjs +2 -2
- package/dist/observable/index.d.cts +1 -1
- package/dist/observable/index.d.mts +1 -1
- package/dist/observable/index.mjs +2 -2
- package/dist/{observable-C-LvH26G.cjs → observable-B8nn0anr.cjs} +27 -4
- package/dist/{observable-yEyhfXUI.mjs → observable-CdPmrXKY.mjs} +28 -5
- package/dist/observable-CdPmrXKY.mjs.map +1 -0
- package/dist/{observable-CkXWrCsV.mjs → observable-F1Nt_3e4.mjs} +16 -4
- package/dist/observable-F1Nt_3e4.mjs.map +1 -0
- package/dist/{observable-xBsJ11Ns.cjs → observable-N4F1yT7s.cjs} +15 -3
- package/dist/{parseTRPCMessage-CJ4DJVBp.mjs → parseTRPCMessage-BO1-cCsX.mjs} +7 -3
- package/dist/parseTRPCMessage-BO1-cCsX.mjs.map +1 -0
- package/dist/{parseTRPCMessage-CPEfSSFx.cjs → parseTRPCMessage-BsPr5reh.cjs} +6 -2
- package/dist/{resolveResponse-DksrxZ2k.mjs → resolveResponse-B2MQmLSr.mjs} +17 -5
- package/dist/resolveResponse-B2MQmLSr.mjs.map +1 -0
- package/dist/{resolveResponse-CoGjFxK0.cjs → resolveResponse-BQcrvKyB.cjs} +16 -4
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.d.cts +1 -1
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +2 -2
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/{unstable-core-do-not-import-B8epiErP.d.cts → unstable-core-do-not-import-DYnAWlN7.d.cts} +517 -161
- package/dist/unstable-core-do-not-import-DYnAWlN7.d.cts.map +1 -0
- package/dist/{unstable-core-do-not-import-Dbo98mkh.d.mts → unstable-core-do-not-import-hC2_7K-s.d.mts} +517 -161
- package/dist/unstable-core-do-not-import-hC2_7K-s.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +7 -7
- package/dist/unstable-core-do-not-import.d.cts +1 -1
- package/dist/unstable-core-do-not-import.d.mts +1 -1
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{ws-BYfo-HED.mjs → ws-B9v4J-4P.mjs} +30 -11
- package/dist/ws-B9v4J-4P.mjs.map +1 -0
- package/dist/ws-DVHbmgfC.d.mts +95 -0
- package/dist/ws-DVHbmgfC.d.mts.map +1 -0
- package/dist/ws-JzZs-0Zd.d.cts +95 -0
- package/dist/ws-JzZs-0Zd.d.cts.map +1 -0
- package/dist/{ws-7qWW7Uec.cjs → ws-_SClUVOu.cjs} +29 -10
- package/package.json +2 -2
- package/skills/adapter-aws-lambda/SKILL.md +1 -1
- package/skills/adapter-express/SKILL.md +1 -1
- package/skills/adapter-fastify/SKILL.md +1 -1
- package/skills/adapter-fetch/SKILL.md +1 -1
- package/skills/adapter-standalone/SKILL.md +1 -1
- package/skills/auth/SKILL.md +1 -1
- package/skills/caching/SKILL.md +2 -2
- package/skills/error-handling/SKILL.md +1 -1
- package/skills/middlewares/SKILL.md +1 -1
- package/skills/non-json-content-types/SKILL.md +13 -4
- package/skills/server-setup/SKILL.md +1 -1
- package/skills/server-side-calls/SKILL.md +1 -1
- package/skills/service-oriented-architecture/SKILL.md +1 -1
- package/skills/subscriptions/SKILL.md +1 -1
- package/skills/trpc-router/SKILL.md +1 -1
- package/skills/validators/SKILL.md +1 -1
- package/src/@trpc/server/index.ts +2 -2
- package/src/adapters/aws-lambda/index.ts +23 -0
- package/src/adapters/express.ts +10 -0
- package/src/adapters/fastify/fastifyRequestHandler.ts +5 -0
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +30 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +11 -0
- package/src/adapters/fetch/types.ts +14 -0
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +8 -4
- package/src/adapters/next-app-dir/notFound.ts +3 -1
- package/src/adapters/next-app-dir/redirect.ts +6 -4
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +5 -1
- package/src/adapters/next.ts +13 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +6 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +3 -1
- package/src/adapters/node-http/types.ts +30 -25
- package/src/adapters/standalone.ts +30 -4
- package/src/adapters/ws.ts +42 -8
- package/src/adapters/wsEncoder.ts +5 -6
- package/src/observable/behaviorSubject.ts +6 -2
- package/src/observable/observable.ts +31 -5
- package/src/observable/operators.ts +12 -0
- package/src/observable/types.ts +18 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +22 -1
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +5 -2
- package/src/unstable-core-do-not-import/createProxy.ts +4 -4
- package/src/unstable-core-do-not-import/error/TRPCError.ts +19 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +15 -2
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +2 -0
- package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +15 -2
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +9 -0
- package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +8 -0
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +4 -0
- package/src/unstable-core-do-not-import/http/types.ts +55 -27
- package/src/unstable-core-do-not-import/initTRPC.ts +51 -27
- package/src/unstable-core-do-not-import/middleware.ts +25 -5
- package/src/unstable-core-do-not-import/procedure.ts +28 -2
- package/src/unstable-core-do-not-import/procedureBuilder.ts +56 -35
- package/src/unstable-core-do-not-import/rootConfig.ts +28 -19
- package/src/unstable-core-do-not-import/router.ts +71 -11
- package/src/unstable-core-do-not-import/rpc/codes.ts +13 -5
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +45 -9
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +5 -1
- package/src/unstable-core-do-not-import/stream/tracked.ts +17 -5
- package/src/unstable-core-do-not-import/transformer.ts +12 -1
- package/src/unstable-core-do-not-import/types.ts +2 -0
- package/src/unstable-core-do-not-import/utils.ts +4 -1
- package/dist/asyncGeneratorDelegate-FcEJT04i.mjs.map +0 -1
- package/dist/codes-C9N0z0an.mjs.map +0 -1
- package/dist/contentTypeParsers-Bb-9hUEf.mjs +0 -14
- package/dist/contentTypeParsers-Bb-9hUEf.mjs.map +0 -1
- package/dist/getErrorShape-zlj81BiC.mjs.map +0 -1
- package/dist/index-BI3Qi_F-.d.cts.map +0 -1
- package/dist/index-BI3Qi_F-.d.mts.map +0 -1
- package/dist/index-CtkOmZzm.d.mts.map +0 -1
- package/dist/index-Tpw5OCTF.d.cts.map +0 -1
- package/dist/initTRPC-RMeQIy9H.mjs.map +0 -1
- package/dist/node-http-ChhZEv1k.mjs.map +0 -1
- package/dist/observable-CkXWrCsV.mjs.map +0 -1
- package/dist/observable-yEyhfXUI.mjs.map +0 -1
- package/dist/parseTRPCMessage-CJ4DJVBp.mjs.map +0 -1
- package/dist/resolveResponse-DksrxZ2k.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-B8epiErP.d.cts.map +0 -1
- package/dist/unstable-core-do-not-import-Dbo98mkh.d.mts.map +0 -1
- package/dist/ws-BYfo-HED.mjs.map +0 -1
- package/dist/ws-DD1ukLuC.d.cts +0 -61
- package/dist/ws-DD1ukLuC.d.cts.map +0 -1
- package/dist/ws-DT37N43e.d.mts +0 -61
- package/dist/ws-DT37N43e.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"sourcesContent":["/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport {\n resolveResponse,\n type HTTPBaseHandlerOptions,\n type ResolveHTTPRequestOptionsContextFn,\n} from '../../@trpc/server/http';\n// @trpc/server/node-http\nimport type { NodeHTTPRequest } from '../node-http';\nimport {\n incomingMessageToRequest,\n type NodeHTTPCreateContextOption,\n} from '../node-http';\n\nexport type FastifyHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = HTTPBaseHandlerOptions<TRouter, TRequest> &\n NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;\n\ntype FastifyRequestHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = FastifyHandlerOptions<TRouter, TRequest, TResponse> & {\n req: TRequest;\n res: TResponse;\n path: string;\n};\n\nexport async function fastifyRequestHandler<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({\n ...opts,\n ...innerOpts,\n });\n };\n\n const incomingMessage: NodeHTTPRequest = opts.req.raw;\n\n // monkey-path body to the IncomingMessage\n if ('body' in opts.req) {\n incomingMessage.body = opts.req.body;\n }\n const req = incomingMessageToRequest(incomingMessage, opts.res.raw, {\n maxBodySize: null,\n });\n\n const res = await resolveResponse({\n ...opts,\n req,\n error: null,\n createContext,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: opts.req,\n });\n },\n });\n\n await opts.res.send(res);\n}\n","/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n/// <reference types=\"@fastify/websocket\" />\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport type { NodeHTTPCreateContextFnOptions } from '../node-http';\n// @trpc/server/ws\nimport { getWSConnectionHandler, type WSSHandlerOptions } from '../ws';\nimport type { FastifyHandlerOptions } from './fastifyRequestHandler';\nimport { fastifyRequestHandler } from './fastifyRequestHandler';\n\nexport interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {\n prefix?: string;\n useWSS?: boolean;\n /**\n * `keepAlive`, `dangerouslyDisablePong
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"sourcesContent":["/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport {\n resolveResponse,\n type HTTPBaseHandlerOptions,\n type ResolveHTTPRequestOptionsContextFn,\n} from '../../@trpc/server/http';\n// @trpc/server/node-http\nimport type { NodeHTTPRequest } from '../node-http';\nimport {\n incomingMessageToRequest,\n type NodeHTTPCreateContextOption,\n} from '../node-http';\n\n/** The options of the Fastify adapter's request handler. */\nexport type FastifyHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = HTTPBaseHandlerOptions<TRouter, TRequest> &\n NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;\n\ntype FastifyRequestHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = FastifyHandlerOptions<TRouter, TRequest, TResponse> & {\n req: TRequest;\n res: TResponse;\n path: string;\n};\n\n/**\n * Handles one Fastify request for a router. `fastifyTRPCPlugin` uses it;\n * call it yourself to mount tRPC on your own route.\n */\nexport async function fastifyRequestHandler<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({\n ...opts,\n ...innerOpts,\n });\n };\n\n const incomingMessage: NodeHTTPRequest = opts.req.raw;\n\n // monkey-path body to the IncomingMessage\n if ('body' in opts.req) {\n incomingMessage.body = opts.req.body;\n }\n const req = incomingMessageToRequest(incomingMessage, opts.res.raw, {\n maxBodySize: null,\n });\n\n const res = await resolveResponse({\n ...opts,\n req,\n error: null,\n createContext,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: opts.req,\n });\n },\n });\n\n await opts.res.send(res);\n}\n","/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n/// <reference types=\"@fastify/websocket\" />\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport type { NodeHTTPCreateContextFnOptions } from '../node-http';\n// @trpc/server/ws\nimport { getWSConnectionHandler, type WSSHandlerOptions } from '../ws';\nimport type { FastifyHandlerOptions } from './fastifyRequestHandler';\nimport { fastifyRequestHandler } from './fastifyRequestHandler';\n\n/**\n * The options of `fastifyTRPCPlugin`.\n * @see https://trpc.io/docs/server/adapters/fastify#fastify-plugin-options\n */\nexport interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {\n /** The path the router is served at, such as `/trpc`. */\n prefix?: string;\n /**\n * Whether to serve WebSockets too. Needs `@fastify/websocket` to be\n * registered first.\n * @see https://trpc.io/docs/server/adapters/fastify#enable-websockets\n */\n useWSS?: boolean;\n /**\n * The router and handler options. `keepAlive`, `dangerouslyDisablePong`\n * and `experimental_encoder` only apply with `useWSS`.\n */\n trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply> &\n Pick<\n WSSHandlerOptions<TRouter>,\n 'keepAlive' | 'dangerouslyDisablePong' | 'experimental_encoder'\n >;\n}\n\n/**\n * What `createContext` gets in the Fastify adapter: `req`, `res` and the\n * request's `info`. With `useWSS`, WebSocket connections get the raw\n * `IncomingMessage` as `req` and the `WebSocket` as `res` instead.\n * @see https://trpc.io/docs/server/adapters/fastify#create-the-context\n */\nexport type CreateFastifyContextOptions = NodeHTTPCreateContextFnOptions<\n FastifyRequest,\n FastifyReply\n>;\n\n/**\n * A Fastify plugin that serves a router over HTTP, and over WebSockets\n * with `useWSS`.\n * @example\n * ```ts\n * server.register(fastifyTRPCPlugin, {\n * prefix: '/trpc',\n * trpcOptions: { router: appRouter, createContext },\n * });\n * ```\n * @see https://trpc.io/docs/server/adapters/fastify#create-fastify-server\n */\nexport function fastifyTRPCPlugin<TRouter extends AnyRouter>(\n fastify: FastifyInstance,\n opts: FastifyTRPCPluginOptions<TRouter>,\n done: (err?: Error) => void,\n) {\n fastify.removeContentTypeParser('application/json');\n fastify.addContentTypeParser(\n 'application/json',\n { parseAs: 'string' },\n function (_, body, _done) {\n _done(null, body);\n },\n );\n fastify.removeContentTypeParser('multipart/form-data');\n fastify.addContentTypeParser(\n 'multipart/form-data',\n {},\n function (_, body, _done) {\n _done(null, body);\n },\n );\n\n let prefix = opts.prefix ?? '';\n\n // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11\n // @ts-expect-error property 'default' does not exists on type ...\n if (typeof fastifyTRPCPlugin.default !== 'function') {\n prefix = ''; // handled by fastify internally\n }\n\n fastify.all(`${prefix}/:path`, async (req, res) => {\n const path = (req.params as any).path;\n await fastifyRequestHandler({ ...opts.trpcOptions, req, res, path });\n });\n\n if (opts.useWSS) {\n const trpcOptions =\n opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>;\n\n const onConnection = getWSConnectionHandler<TRouter>({\n ...trpcOptions,\n });\n\n fastify.get(prefix ?? '/', { websocket: true }, (socket, req) => {\n // keepalive is registered by getWSConnectionHandler, which every\n // adapter goes through — registering it here as well gave each socket\n // two ping intervals and two pong-wait timers\n onConnection(socket, req.raw);\n });\n }\n\n done();\n}\n"],"mappings":";;;;;;;;;AA+CA,eAAsB,sBAIpB,MAAkE;CAClE,MAAM,gBAA6D,OACjE,cACG;;EACH,OAAO,QAAA,sBAAM,KAAK,mBAAA,QAAA,wBAAA,KAAA,IAAA,KAAA,IAAA,oBAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACb,IAAA,GACA,SACL,CAAC;CACH;CAEA,MAAM,kBAAmC,KAAK,IAAI;CAGlD,IAAI,UAAU,KAAK,KACjB,gBAAgB,OAAO,KAAK,IAAI;CAElC,MAAM,MAAM,yBAAyB,iBAAiB,KAAK,IAAI,KAAK,EAClE,aAAa,KACf,CAAC;CAED,MAAM,MAAM,MAAM,gBAAA,eAAA,eAAA,CAAA,GACb,IAAA,GAAA,CAAA,GAAA;EACH;EACA,OAAO;EACP;EACA,QAAQ,GAAG;;GACT,SAAA,QAAA,SAAA,KAAA,MAAA,gBAAA,KAAM,aAAA,QAAA,kBAAA,KAAA,KAAA,cAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACD,CAAA,GAAA,CAAA,GAAA,EACH,KAAK,KAAK,IAAA,CACZ,CAAC;EACH;CACF,CAAA,CAAC;CAED,MAAM,KAAK,IAAI,KAAK,GAAG;AACzB;;;;;;;;;;;;;;;AClBA,SAAgB,kBACd,SACA,MACA,MACA;;CACA,QAAQ,wBAAwB,kBAAkB;CAClD,QAAQ,qBACN,oBACA,EAAE,SAAS,SAAS,GACpB,SAAU,GAAG,MAAM,OAAO;EACxB,MAAM,MAAM,IAAI;CAClB,CACF;CACA,QAAQ,wBAAwB,qBAAqB;CACrD,QAAQ,qBACN,uBACA,CAAC,GACD,SAAU,GAAG,MAAM,OAAO;EACxB,MAAM,MAAM,IAAI;CAClB,CACF;CAEA,IAAI,UAAA,eAAS,KAAK,YAAA,QAAA,iBAAA,KAAA,IAAA,eAAU;CAI5B,IAAI,OAAO,kBAAkB,YAAY,YACvC,SAAS;CAGX,QAAQ,IAAI,GAAG,OAAO,SAAS,OAAO,KAAK,QAAQ;EACjD,MAAM,OAAQ,IAAI,OAAe;EACjC,MAAM,sBAAA,eAAA,eAAA,CAAA,GAA2B,KAAK,WAAA,GAAA,CAAA,GAAA;GAAa;GAAK;GAAK;EAAK,CAAA,CAAC;CACrE,CAAC;CAED,IAAI,KAAK,QAAQ;;EACf,MAAM,cACJ,KAAK;EAEP,MAAM,eAAe,uBAAA,eAAA,CAAA,GAChB,WACL,CAAC;EAED,QAAQ,KAAA,UAAI,YAAA,QAAA,YAAA,KAAA,IAAA,UAAU,KAAK,EAAE,WAAW,KAAK,IAAI,QAAQ,QAAQ;GAI/D,aAAa,QAAQ,IAAI,GAAG;EAC9B,CAAC;CACH;CAEA,KAAK;AACP"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_getErrorShape = require("../../getErrorShape-
|
|
3
|
-
const require_resolveResponse = require("../../resolveResponse-
|
|
2
|
+
const require_getErrorShape = require("../../getErrorShape-8t0oLscZ.cjs");
|
|
3
|
+
const require_resolveResponse = require("../../resolveResponse-BQcrvKyB.cjs");
|
|
4
4
|
//#region src/adapters/fetch/fetchRequestHandler.ts
|
|
5
5
|
const trimSlashes = (path) => {
|
|
6
6
|
path = path.startsWith("/") ? path.slice(1) : path;
|
|
7
7
|
path = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
8
8
|
return path;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
12
|
+
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
13
|
+
* handlers.
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const handler = (req: Request) =>
|
|
17
|
+
* fetchRequestHandler({ endpoint: '/trpc', req, router: appRouter });
|
|
18
|
+
* ```
|
|
19
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
20
|
+
*/
|
|
10
21
|
async function fetchRequestHandler(opts) {
|
|
11
22
|
const resHeaders = new Headers();
|
|
12
23
|
const createContext = async (innerOpts) => {
|
|
@@ -1,22 +1,47 @@
|
|
|
1
|
-
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-
|
|
1
|
+
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-DYnAWlN7.cjs";
|
|
2
2
|
//#region src/adapters/fetch/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What `createContext` gets in the Fetch adapter.
|
|
5
|
+
* @see https://trpc.io/docs/server/adapters/fetch#create-the-context
|
|
6
|
+
*/
|
|
3
7
|
export type FetchCreateContextFnOptions = {
|
|
4
8
|
req: Request;
|
|
9
|
+
/** The response's headers, which you can add to, such as to set cookies. */
|
|
5
10
|
resHeaders: Headers;
|
|
6
11
|
info: TRPCRequestInfo;
|
|
7
12
|
};
|
|
13
|
+
/** The `createContext` function the Fetch adapter takes. */
|
|
8
14
|
export type FetchCreateContextFn<TRouter extends AnyRouter> = (opts: FetchCreateContextFnOptions) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
15
|
+
/** The Fetch adapter's `createContext` option. */
|
|
9
16
|
export type FetchCreateContextOption<TRouter extends AnyRouter> = CreateContextCallback<inferRouterContext<TRouter>, FetchCreateContextFn<TRouter>>;
|
|
17
|
+
/** The options of the Fetch adapter. */
|
|
10
18
|
export type FetchHandlerOptions<TRouter extends AnyRouter> = FetchCreateContextOption<TRouter> & HTTPBaseHandlerOptions<TRouter, Request> & {
|
|
11
19
|
req: Request;
|
|
20
|
+
/** The path the router is served at, such as `/trpc`. */
|
|
12
21
|
endpoint: string;
|
|
13
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* The options of `fetchRequestHandler`.
|
|
25
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
26
|
+
*/
|
|
14
27
|
export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHandlerOptions<TRouter, Request> & CreateContextCallback<inferRouterContext<TRouter>, FetchCreateContextFn<TRouter>> & {
|
|
15
28
|
req: Request;
|
|
29
|
+
/** The path the router is served at, such as `/trpc`. */
|
|
16
30
|
endpoint: string;
|
|
17
31
|
};
|
|
18
32
|
//#endregion
|
|
19
33
|
//#region src/adapters/fetch/fetchRequestHandler.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
36
|
+
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
37
|
+
* handlers.
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const handler = (req: Request) =>
|
|
41
|
+
* fetchRequestHandler({ endpoint: '/trpc', req, router: appRouter });
|
|
42
|
+
* ```
|
|
43
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
44
|
+
*/
|
|
20
45
|
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
|
|
21
46
|
//#endregion
|
|
22
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/fetch/types.ts","../../../src/adapters/fetch/fetchRequestHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/fetch/types.ts","../../../src/adapters/fetch/fetchRequestHandler.ts"],"mappings":";;;;;;YAyBY;EACV,KAAK;;EAEL,YAAY;EACZ,MAAM;;;YAII,qBAAqB,gBAAgB,cAC/C,MAAM,gCACH,mBAAmB,WAAW,QAAQ,mBAAmB;;YAGlD,yBAAyB,gBAAgB,aACnD,sBACE,mBAAmB,UACnB,qBAAqB;;YAIb,oBAAoB,gBAAgB,aAC9C,yBAAyB,WACvB,uBAAuB,SAAS;EAC9B,KAAK;;EAEL;;;;;;YAOM,2BAA2B,gBAAgB,aACrD,uBAAuB,SAAS,WAC9B,sBACE,mBAAmB,UACnB,qBAAqB;EAErB,KAAK;;EAEL;;;;;;;;;;;;;;;wBC/BgB,oBAAoB,gBAAgB,WACxD,MAAM,2BAA2B,WAChC,QAAQ"}
|
|
@@ -1,22 +1,47 @@
|
|
|
1
|
-
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-
|
|
1
|
+
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-hC2_7K-s.mjs";
|
|
2
2
|
//#region src/adapters/fetch/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What `createContext` gets in the Fetch adapter.
|
|
5
|
+
* @see https://trpc.io/docs/server/adapters/fetch#create-the-context
|
|
6
|
+
*/
|
|
3
7
|
export type FetchCreateContextFnOptions = {
|
|
4
8
|
req: Request;
|
|
9
|
+
/** The response's headers, which you can add to, such as to set cookies. */
|
|
5
10
|
resHeaders: Headers;
|
|
6
11
|
info: TRPCRequestInfo;
|
|
7
12
|
};
|
|
13
|
+
/** The `createContext` function the Fetch adapter takes. */
|
|
8
14
|
export type FetchCreateContextFn<TRouter extends AnyRouter> = (opts: FetchCreateContextFnOptions) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
15
|
+
/** The Fetch adapter's `createContext` option. */
|
|
9
16
|
export type FetchCreateContextOption<TRouter extends AnyRouter> = CreateContextCallback<inferRouterContext<TRouter>, FetchCreateContextFn<TRouter>>;
|
|
17
|
+
/** The options of the Fetch adapter. */
|
|
10
18
|
export type FetchHandlerOptions<TRouter extends AnyRouter> = FetchCreateContextOption<TRouter> & HTTPBaseHandlerOptions<TRouter, Request> & {
|
|
11
19
|
req: Request;
|
|
20
|
+
/** The path the router is served at, such as `/trpc`. */
|
|
12
21
|
endpoint: string;
|
|
13
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* The options of `fetchRequestHandler`.
|
|
25
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
26
|
+
*/
|
|
14
27
|
export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHandlerOptions<TRouter, Request> & CreateContextCallback<inferRouterContext<TRouter>, FetchCreateContextFn<TRouter>> & {
|
|
15
28
|
req: Request;
|
|
29
|
+
/** The path the router is served at, such as `/trpc`. */
|
|
16
30
|
endpoint: string;
|
|
17
31
|
};
|
|
18
32
|
//#endregion
|
|
19
33
|
//#region src/adapters/fetch/fetchRequestHandler.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
36
|
+
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
37
|
+
* handlers.
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const handler = (req: Request) =>
|
|
41
|
+
* fetchRequestHandler({ endpoint: '/trpc', req, router: appRouter });
|
|
42
|
+
* ```
|
|
43
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
44
|
+
*/
|
|
20
45
|
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
|
|
21
46
|
//#endregion
|
|
22
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/fetch/types.ts","../../../src/adapters/fetch/fetchRequestHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/fetch/types.ts","../../../src/adapters/fetch/fetchRequestHandler.ts"],"mappings":";;;;;;YAyBY;EACV,KAAK;;EAEL,YAAY;EACZ,MAAM;;;YAII,qBAAqB,gBAAgB,cAC/C,MAAM,gCACH,mBAAmB,WAAW,QAAQ,mBAAmB;;YAGlD,yBAAyB,gBAAgB,aACnD,sBACE,mBAAmB,UACnB,qBAAqB;;YAIb,oBAAoB,gBAAgB,aAC9C,yBAAyB,WACvB,uBAAuB,SAAS;EAC9B,KAAK;;EAEL;;;;;;YAOM,2BAA2B,gBAAgB,aACrD,uBAAuB,SAAS,WAC9B,sBACE,mBAAmB,UACnB,qBAAqB;EAErB,KAAK;;EAEL;;;;;;;;;;;;;;;wBC/BgB,oBAAoB,gBAAgB,WACxD,MAAM,2BAA2B,WAChC,QAAQ"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { n as _objectSpread2 } from "../../getErrorShape-
|
|
2
|
-
import { t as resolveResponse } from "../../resolveResponse-
|
|
1
|
+
import { n as _objectSpread2 } from "../../getErrorShape-B6z8u8q0.mjs";
|
|
2
|
+
import { t as resolveResponse } from "../../resolveResponse-B2MQmLSr.mjs";
|
|
3
3
|
//#region src/adapters/fetch/fetchRequestHandler.ts
|
|
4
4
|
const trimSlashes = (path) => {
|
|
5
5
|
path = path.startsWith("/") ? path.slice(1) : path;
|
|
6
6
|
path = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
11
|
+
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
12
|
+
* handlers.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const handler = (req: Request) =>
|
|
16
|
+
* fetchRequestHandler({ endpoint: '/trpc', req, router: appRouter });
|
|
17
|
+
* ```
|
|
18
|
+
* @see https://trpc.io/docs/server/adapters/fetch
|
|
19
|
+
*/
|
|
9
20
|
async function fetchRequestHandler(opts) {
|
|
10
21
|
const resHeaders = new Headers();
|
|
11
22
|
const createContext = async (innerOpts) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"sourcesContent":["/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n// @trpc/server\n\nimport type { AnyRouter } from '../../@trpc/server';\nimport type { ResolveHTTPRequestOptionsContextFn } from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { FetchHandlerRequestOptions } from './types';\n\nconst trimSlashes = (path: string): string => {\n path = path.startsWith('/') ? path.slice(1) : path;\n path = path.endsWith('/') ? path.slice(0, -1) : path;\n\n return path;\n};\n\nexport async function fetchRequestHandler<TRouter extends AnyRouter>(\n opts: FetchHandlerRequestOptions<TRouter>,\n): Promise<Response> {\n const resHeaders = new Headers();\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return opts.createContext?.({ req: opts.req, resHeaders, ...innerOpts });\n };\n\n const url = new URL(opts.req.url);\n\n const pathname = trimSlashes(url.pathname);\n const endpoint = trimSlashes(opts.endpoint);\n const path = trimSlashes(pathname.slice(endpoint.length));\n\n return await resolveResponse({\n ...opts,\n req: opts.req,\n createContext,\n path,\n error: null,\n onError(o) {\n opts?.onError?.({ ...o, req: opts.req });\n },\n responseMeta(data) {\n const meta = opts.responseMeta?.(data);\n\n if (meta?.headers) {\n if (meta.headers instanceof Headers) {\n for (const [key, value] of meta.headers.entries()) {\n resHeaders.append(key, value);\n }\n } else {\n /**\n * @deprecated, delete in v12\n */\n for (const [key, value] of Object.entries(meta.headers)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n resHeaders.append(key, v);\n }\n } else if (typeof value === 'string') {\n resHeaders.set(key, value);\n }\n }\n }\n }\n\n return {\n headers: resHeaders,\n status: meta?.status,\n };\n },\n });\n}\n"],"mappings":";;;AAgBA,MAAM,eAAe,SAAyB;CAC5C,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI;CAC9C,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;CAEhD,OAAO;AACT
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"sourcesContent":["/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n// @trpc/server\n\nimport type { AnyRouter } from '../../@trpc/server';\nimport type { ResolveHTTPRequestOptionsContextFn } from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { FetchHandlerRequestOptions } from './types';\n\nconst trimSlashes = (path: string): string => {\n path = path.startsWith('/') ? path.slice(1) : path;\n path = path.endsWith('/') ? path.slice(0, -1) : path;\n\n return path;\n};\n\n/**\n * Handles a Fetch API `Request` for a router and returns its `Response`.\n * Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route\n * handlers.\n * @example\n * ```ts\n * const handler = (req: Request) =>\n * fetchRequestHandler({ endpoint: '/trpc', req, router: appRouter });\n * ```\n * @see https://trpc.io/docs/server/adapters/fetch\n */\nexport async function fetchRequestHandler<TRouter extends AnyRouter>(\n opts: FetchHandlerRequestOptions<TRouter>,\n): Promise<Response> {\n const resHeaders = new Headers();\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return opts.createContext?.({ req: opts.req, resHeaders, ...innerOpts });\n };\n\n const url = new URL(opts.req.url);\n\n const pathname = trimSlashes(url.pathname);\n const endpoint = trimSlashes(opts.endpoint);\n const path = trimSlashes(pathname.slice(endpoint.length));\n\n return await resolveResponse({\n ...opts,\n req: opts.req,\n createContext,\n path,\n error: null,\n onError(o) {\n opts?.onError?.({ ...o, req: opts.req });\n },\n responseMeta(data) {\n const meta = opts.responseMeta?.(data);\n\n if (meta?.headers) {\n if (meta.headers instanceof Headers) {\n for (const [key, value] of meta.headers.entries()) {\n resHeaders.append(key, value);\n }\n } else {\n /**\n * @deprecated, delete in v12\n */\n for (const [key, value] of Object.entries(meta.headers)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n resHeaders.append(key, v);\n }\n } else if (typeof value === 'string') {\n resHeaders.set(key, value);\n }\n }\n }\n }\n\n return {\n headers: resHeaders,\n status: meta?.status,\n };\n },\n });\n}\n"],"mappings":";;;AAgBA,MAAM,eAAe,SAAyB;CAC5C,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI;CAC9C,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;CAEhD,OAAO;AACT;;;;;;;;;;;;AAaA,eAAsB,oBACpB,MACmB;CACnB,MAAM,aAAa,IAAI,QAAQ;CAE/B,MAAM,gBAA6D,OACjE,cACG;;EACH,QAAA,sBAAO,KAAK,mBAAA,QAAA,wBAAA,KAAA,IAAA,KAAA,IAAA,oBAAA,KAAA,MAAA,eAAA;GAAkB,KAAK,KAAK;GAAK;EAAe,GAAA,SAAU,CAAC;CACzE;CAEA,MAAM,MAAM,IAAI,IAAI,KAAK,IAAI,GAAG;CAEhC,MAAM,WAAW,YAAY,IAAI,QAAQ;CACzC,MAAM,WAAW,YAAY,KAAK,QAAQ;CAC1C,MAAM,OAAO,YAAY,SAAS,MAAM,SAAS,MAAM,CAAC;CAExD,OAAO,MAAM,gBAAA,eAAA,eAAA,CAAA,GACR,IAAA,GAAA,CAAA,GAAA;EACH,KAAK,KAAK;EACV;EACA;EACA,OAAO;EACP,QAAQ,GAAG;;GACT,SAAA,QAAA,SAAA,KAAA,MAAA,gBAAA,KAAM,aAAA,QAAA,kBAAA,KAAA,KAAA,cAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GAAe,CAAA,GAAA,CAAA,GAAA,EAAG,KAAK,KAAK,IAAA,CAAI,CAAC;EACzC;EACA,aAAa,MAAM;;GACjB,MAAM,QAAA,qBAAO,KAAK,kBAAA,QAAA,uBAAA,KAAA,IAAA,KAAA,IAAA,mBAAA,KAAA,MAAe,IAAI;GAErC,IAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,SAAS;IACjB,IAAI,KAAK,mBAAmB,SAC1B,KAAK,MAAM,CAAC,KAAK,UAAU,KAAK,QAAQ,QAAQ,GAC9C,WAAW,OAAO,KAAK,KAAK;;;;;IAM9B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,GACpD,IAAI,MAAM,QAAQ,KAAK,GACrB,KAAK,MAAM,KAAK,OACd,WAAW,OAAO,KAAK,CAAC;SAErB,IAAI,OAAO,UAAU,UAC1B,WAAW,IAAI,KAAK,KAAK;GAIjC;GAEA,OAAO;IACL,SAAS;IACT,QAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAQ,KAAM;GAChB;EACF;CACF,CAAA,CAAC;AACH"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("../rolldown-runtime-CFW-PwTP.cjs");
|
|
3
|
-
const require_getErrorShape = require("../getErrorShape-
|
|
4
|
-
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-
|
|
3
|
+
const require_getErrorShape = require("../getErrorShape-8t0oLscZ.cjs");
|
|
4
|
+
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-CPV0O1Hn.cjs");
|
|
5
5
|
const require_unstable_core_do_not_import = require("../unstable-core-do-not-import.cjs");
|
|
6
6
|
let next_navigation = require("next/navigation");
|
|
7
7
|
next_navigation = require_rolldown_runtime.__toESM(next_navigation, 1);
|
|
8
8
|
//#region src/adapters/next-app-dir/redirect.ts
|
|
9
9
|
/**
|
|
10
|
+
* The error `redirect()` returns, which `nextAppDirCaller` turns into a
|
|
11
|
+
* Next.js redirect.
|
|
10
12
|
* @internal
|
|
11
13
|
*/
|
|
12
14
|
var TRPCRedirectError = class extends require_asyncGeneratorDelegate.TRPCError {
|
|
@@ -20,11 +22,11 @@ var TRPCRedirectError = class extends require_asyncGeneratorDelegate.TRPCError {
|
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
|
-
* Like `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
26
|
+
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
27
|
+
* redirects. Its type is `undefined`, which matches what the client gets,
|
|
28
|
+
* unlike Next.js's `never`.
|
|
26
29
|
* @public
|
|
27
|
-
* @remark You should only use this if you're also using `nextAppDirCaller`.
|
|
28
30
|
*/
|
|
29
31
|
const redirect = (url, redirectType) => {
|
|
30
32
|
return new TRPCRedirectError(url, redirectType);
|
|
@@ -54,7 +56,11 @@ function isNotFoundError(error) {
|
|
|
54
56
|
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
59
|
+
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
60
|
+
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
61
|
+
* `redirect()`, and a `notFound()` or `redirect()` error in `cause` is
|
|
62
|
+
* rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such
|
|
63
|
+
* as those `nextAppDirCaller` throws, yourself.
|
|
58
64
|
*/
|
|
59
65
|
const rethrowNextErrors = (error) => {
|
|
60
66
|
if (error.code === "NOT_FOUND") next_navigation.notFound();
|
|
@@ -66,7 +72,9 @@ const rethrowNextErrors = (error) => {
|
|
|
66
72
|
//#endregion
|
|
67
73
|
//#region src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
68
74
|
/**
|
|
69
|
-
*
|
|
75
|
+
* Makes procedures callable as Next.js server actions and from React
|
|
76
|
+
* Server Components. Pass it to `.experimental_caller()`.
|
|
77
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller
|
|
70
78
|
*/
|
|
71
79
|
function nextAppDirCaller(config) {
|
|
72
80
|
const { normalizeFormData = true } = config;
|
|
@@ -145,7 +153,9 @@ function nextAppDirCaller(config) {
|
|
|
145
153
|
//#endregion
|
|
146
154
|
//#region src/adapters/next-app-dir/notFound.ts
|
|
147
155
|
/**
|
|
148
|
-
* Like `
|
|
156
|
+
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
157
|
+
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
158
|
+
* page.
|
|
149
159
|
* @public
|
|
150
160
|
*/
|
|
151
161
|
const notFound = () => {
|
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import { Ei as Simplify, _t as CallerOverride, ni as TRPCError, rt as ErrorHandlerOptions, ur as CreateContextCallback, xi as MaybePromise } from "../unstable-core-do-not-import-
|
|
1
|
+
import { Ei as Simplify, _t as CallerOverride, ni as TRPCError, rt as ErrorHandlerOptions, ur as CreateContextCallback, xi as MaybePromise } from "../unstable-core-do-not-import-DYnAWlN7.cjs";
|
|
2
2
|
import { RedirectType, notFound as notFound$1 } from "next/navigation.js";
|
|
3
3
|
//#region src/adapters/next-app-dir/nextAppDirCaller.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Makes procedures callable as Next.js server actions and from React
|
|
6
|
+
* Server Components. Pass it to `.experimental_caller()`.
|
|
7
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller
|
|
6
8
|
*/
|
|
7
9
|
declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* Names the procedure from its metadata, for logs and errors, since
|
|
12
|
+
* server actions have no router path.
|
|
13
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#adding-observability-with-metadata
|
|
10
14
|
*/
|
|
11
15
|
pathExtractor?: (opts: {
|
|
12
16
|
meta: TMeta;
|
|
13
17
|
}) => string;
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
19
|
+
* Turns `FormData` input into an object before validation.
|
|
16
20
|
* @default true
|
|
17
21
|
*/
|
|
18
22
|
normalizeFormData?: boolean;
|
|
19
23
|
/**
|
|
20
|
-
* Called when
|
|
24
|
+
* Called when a procedure throws.
|
|
21
25
|
*/
|
|
22
26
|
onError?: (opts: ErrorHandlerOptions<TContext>) => void;
|
|
23
27
|
} & CreateContextCallback<TContext, () => MaybePromise<TContext>>>): CallerOverride<TContext>;
|
|
24
28
|
//#endregion
|
|
25
29
|
//#region src/adapters/next-app-dir/redirect.d.ts
|
|
26
30
|
/**
|
|
27
|
-
* Like `
|
|
28
|
-
*
|
|
29
|
-
*
|
|
31
|
+
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
32
|
+
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
33
|
+
* redirects. Its type is `undefined`, which matches what the client gets,
|
|
34
|
+
* unlike Next.js's `never`.
|
|
30
35
|
* @public
|
|
31
|
-
* @remark You should only use this if you're also using `nextAppDirCaller`.
|
|
32
36
|
*/
|
|
33
37
|
declare const redirect: (url: URL | string, redirectType?: RedirectType) => undefined;
|
|
34
38
|
//#endregion
|
|
35
39
|
//#region src/adapters/next-app-dir/notFound.d.ts
|
|
36
40
|
/**
|
|
37
|
-
* Like `
|
|
41
|
+
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
42
|
+
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
43
|
+
* page.
|
|
38
44
|
* @public
|
|
39
45
|
*/
|
|
40
46
|
declare const notFound: typeof notFound$1;
|
|
41
47
|
//#endregion
|
|
42
48
|
//#region src/adapters/next-app-dir/rethrowNextErrors.d.ts
|
|
43
49
|
/**
|
|
44
|
-
*
|
|
50
|
+
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
51
|
+
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
52
|
+
* `redirect()`, and a `notFound()` or `redirect()` error in `cause` is
|
|
53
|
+
* rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such
|
|
54
|
+
* as those `nextAppDirCaller` throws, yourself.
|
|
45
55
|
*/
|
|
46
56
|
export declare const rethrowNextErrors: (error: TRPCError) => void;
|
|
47
57
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-dir.d.cts","names":[],"sources":["../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/notFound.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-app-dir.d.cts","names":[],"sources":["../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/notFound.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"mappings":";;;;;;;;iBAwBgB,iBAAiB,UAAU,OACzC,QAAQ;;;;;;EAOJ,iBAAiB;IAAQ,MAAM;;;;;;EAK/B;;;;EAIA,WAAW,MAAM,oBAAoB;IACnC,sBAAsB,gBAAgB,aAAa,cAExD,eAAe;;;;;;;;;;cChBL,WAAQ,KAAS,cAAY,eAAiB;;;;;;;;;cCnB9C,iBAAiB;;;;;;;;;;qBCwCjB,oBAAiB,OAAW"}
|
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import { Ei as Simplify, _t as CallerOverride, ni as TRPCError, rt as ErrorHandlerOptions, ur as CreateContextCallback, xi as MaybePromise } from "../unstable-core-do-not-import-
|
|
1
|
+
import { Ei as Simplify, _t as CallerOverride, ni as TRPCError, rt as ErrorHandlerOptions, ur as CreateContextCallback, xi as MaybePromise } from "../unstable-core-do-not-import-hC2_7K-s.mjs";
|
|
2
2
|
import { RedirectType, notFound as notFound$1 } from "next/navigation.js";
|
|
3
3
|
//#region src/adapters/next-app-dir/nextAppDirCaller.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Makes procedures callable as Next.js server actions and from React
|
|
6
|
+
* Server Components. Pass it to `.experimental_caller()`.
|
|
7
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller
|
|
6
8
|
*/
|
|
7
9
|
declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* Names the procedure from its metadata, for logs and errors, since
|
|
12
|
+
* server actions have no router path.
|
|
13
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#adding-observability-with-metadata
|
|
10
14
|
*/
|
|
11
15
|
pathExtractor?: (opts: {
|
|
12
16
|
meta: TMeta;
|
|
13
17
|
}) => string;
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
19
|
+
* Turns `FormData` input into an object before validation.
|
|
16
20
|
* @default true
|
|
17
21
|
*/
|
|
18
22
|
normalizeFormData?: boolean;
|
|
19
23
|
/**
|
|
20
|
-
* Called when
|
|
24
|
+
* Called when a procedure throws.
|
|
21
25
|
*/
|
|
22
26
|
onError?: (opts: ErrorHandlerOptions<TContext>) => void;
|
|
23
27
|
} & CreateContextCallback<TContext, () => MaybePromise<TContext>>>): CallerOverride<TContext>;
|
|
24
28
|
//#endregion
|
|
25
29
|
//#region src/adapters/next-app-dir/redirect.d.ts
|
|
26
30
|
/**
|
|
27
|
-
* Like `
|
|
28
|
-
*
|
|
29
|
-
*
|
|
31
|
+
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
32
|
+
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
33
|
+
* redirects. Its type is `undefined`, which matches what the client gets,
|
|
34
|
+
* unlike Next.js's `never`.
|
|
30
35
|
* @public
|
|
31
|
-
* @remark You should only use this if you're also using `nextAppDirCaller`.
|
|
32
36
|
*/
|
|
33
37
|
declare const redirect: (url: URL | string, redirectType?: RedirectType) => undefined;
|
|
34
38
|
//#endregion
|
|
35
39
|
//#region src/adapters/next-app-dir/notFound.d.ts
|
|
36
40
|
/**
|
|
37
|
-
* Like `
|
|
41
|
+
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
42
|
+
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
43
|
+
* page.
|
|
38
44
|
* @public
|
|
39
45
|
*/
|
|
40
46
|
declare const notFound: typeof notFound$1;
|
|
41
47
|
//#endregion
|
|
42
48
|
//#region src/adapters/next-app-dir/rethrowNextErrors.d.ts
|
|
43
49
|
/**
|
|
44
|
-
*
|
|
50
|
+
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
51
|
+
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
52
|
+
* `redirect()`, and a `notFound()` or `redirect()` error in `cause` is
|
|
53
|
+
* rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such
|
|
54
|
+
* as those `nextAppDirCaller` throws, yourself.
|
|
45
55
|
*/
|
|
46
56
|
export declare const rethrowNextErrors: (error: TRPCError) => void;
|
|
47
57
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-dir.d.mts","names":[],"sources":["../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/notFound.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-app-dir.d.mts","names":[],"sources":["../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/notFound.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"mappings":";;;;;;;;iBAwBgB,iBAAiB,UAAU,OACzC,QAAQ;;;;;;EAOJ,iBAAiB;IAAQ,MAAM;;;;;;EAK/B;;;;EAIA,WAAW,MAAM,oBAAoB;IACnC,sBAAsB,gBAAgB,aAAa,cAExD,eAAe;;;;;;;;;;cChBL,WAAQ,KAAS,cAAY,eAAiB;;;;;;;;;cCnB9C,iBAAiB;;;;;;;;;;qBCwCjB,oBAAiB,OAAW"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { r as _defineProperty } from "../getErrorShape-
|
|
2
|
-
import { b as getTRPCErrorFromUnknown, v as TRPCError } from "../asyncGeneratorDelegate-
|
|
1
|
+
import { r as _defineProperty } from "../getErrorShape-B6z8u8q0.mjs";
|
|
2
|
+
import { b as getTRPCErrorFromUnknown, v as TRPCError } from "../asyncGeneratorDelegate-Bl41FGB5.mjs";
|
|
3
3
|
import { formDataToObject } from "../unstable-core-do-not-import.mjs";
|
|
4
4
|
import * as nextNavigation from "next/navigation";
|
|
5
5
|
//#region src/adapters/next-app-dir/redirect.ts
|
|
6
6
|
/**
|
|
7
|
+
* The error `redirect()` returns, which `nextAppDirCaller` turns into a
|
|
8
|
+
* Next.js redirect.
|
|
7
9
|
* @internal
|
|
8
10
|
*/
|
|
9
11
|
var TRPCRedirectError = class extends TRPCError {
|
|
@@ -17,11 +19,11 @@ var TRPCRedirectError = class extends TRPCError {
|
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
|
-
* Like `
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
23
|
+
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
24
|
+
* redirects. Its type is `undefined`, which matches what the client gets,
|
|
25
|
+
* unlike Next.js's `never`.
|
|
23
26
|
* @public
|
|
24
|
-
* @remark You should only use this if you're also using `nextAppDirCaller`.
|
|
25
27
|
*/
|
|
26
28
|
const redirect = (url, redirectType) => {
|
|
27
29
|
return new TRPCRedirectError(url, redirectType);
|
|
@@ -51,7 +53,11 @@ function isNotFoundError(error) {
|
|
|
51
53
|
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
57
|
+
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
58
|
+
* `redirect()`, and a `notFound()` or `redirect()` error in `cause` is
|
|
59
|
+
* rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such
|
|
60
|
+
* as those `nextAppDirCaller` throws, yourself.
|
|
55
61
|
*/
|
|
56
62
|
const rethrowNextErrors = (error) => {
|
|
57
63
|
if (error.code === "NOT_FOUND") nextNavigation.notFound();
|
|
@@ -63,7 +69,9 @@ const rethrowNextErrors = (error) => {
|
|
|
63
69
|
//#endregion
|
|
64
70
|
//#region src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
65
71
|
/**
|
|
66
|
-
*
|
|
72
|
+
* Makes procedures callable as Next.js server actions and from React
|
|
73
|
+
* Server Components. Pass it to `.experimental_caller()`.
|
|
74
|
+
* @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller
|
|
67
75
|
*/
|
|
68
76
|
function nextAppDirCaller(config) {
|
|
69
77
|
const { normalizeFormData = true } = config;
|
|
@@ -142,7 +150,9 @@ function nextAppDirCaller(config) {
|
|
|
142
150
|
//#endregion
|
|
143
151
|
//#region src/adapters/next-app-dir/notFound.ts
|
|
144
152
|
/**
|
|
145
|
-
* Like `
|
|
153
|
+
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
154
|
+
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
155
|
+
* page.
|
|
146
156
|
* @public
|
|
147
157
|
*/
|
|
148
158
|
const notFound = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-dir.mjs","names":[],"sources":["../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts","../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/notFound.ts"],"sourcesContent":["import type { RedirectType } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * @internal\n */\nexport class TRPCRedirectError extends TRPCError {\n public readonly args;\n constructor(url: URL | string, redirectType?: RedirectType) {\n super({\n // TODO(?): This should maybe a custom error code\n code: 'UNPROCESSABLE_CONTENT',\n message: `Redirect error to \"${url}\" that will be handled by Next.js`,\n });\n\n this.args = [url.toString(), redirectType] as const;\n }\n}\n\n/**\n * Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js\n * This provides better typesafety than the `next/navigation`'s `redirect()` since the action continues\n * to execute on the frontend even if Next's `redirect()` has a return type of `never`.\n * @public\n * @remark You should only use this if you're also using `nextAppDirCaller`.\n */\nexport const redirect = (url: URL | string, redirectType?: RedirectType) => {\n // We rethrow this internally so the returntype on the client is undefined.\n return new TRPCRedirectError(url, redirectType) as unknown as undefined;\n};\n","import * as nextNavigation from 'next/navigation';\nimport type { TRPCError } from '../../@trpc/server';\nimport { TRPCRedirectError } from './redirect';\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123\n */\nconst REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';\nfunction isRedirectError(error: unknown) {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('digest' in error) ||\n typeof error.digest !== 'string'\n ) {\n return false;\n }\n const [errorCode, type, destination, status] = error.digest.split(';', 4);\n const statusCode = Number(status);\n return (\n errorCode === REDIRECT_ERROR_CODE &&\n (type === 'replace' || type === 'push') &&\n typeof destination === 'string' &&\n !isNaN(statusCode)\n );\n}\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39\n */\nconst NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';\nfunction isNotFoundError(error: unknown) {\n if (typeof error !== 'object' || error === null || !('digest' in error)) {\n return false;\n }\n return error.digest === NOT_FOUND_ERROR_CODE;\n}\n\n/**\n * Rethrow errors that should be handled by Next.js\n */\nexport const rethrowNextErrors = (error: TRPCError) => {\n if (error.code === 'NOT_FOUND') {\n nextNavigation.notFound();\n }\n if (error instanceof TRPCRedirectError) {\n nextNavigation.redirect(...error.args);\n }\n const { cause } = error;\n\n // Next.js 15 has `unstable_rethrow`. Use that if it exists.\n if (\n 'unstable_rethrow' in nextNavigation &&\n typeof nextNavigation.unstable_rethrow === 'function'\n ) {\n nextNavigation.unstable_rethrow(cause);\n }\n\n // Before Next.js 15, we have to check and rethrow the error manually.\n if (isRedirectError(cause) || isNotFoundError(cause)) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n throw cause!;\n }\n};\n","import type { CreateContextCallback } from '../../@trpc/server';\nimport { getTRPCErrorFromUnknown, TRPCError } from '../../@trpc/server';\n// oxlint-disable-next-line no-restricted-imports\nimport { formDataToObject } from '../../unstable-core-do-not-import';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { CallerOverride } from '../../unstable-core-do-not-import/procedureBuilder';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type {\n MaybePromise,\n Simplify,\n} from '../../unstable-core-do-not-import/types';\nimport { TRPCRedirectError } from './redirect';\nimport { rethrowNextErrors } from './rethrowNextErrors';\n\n/**\n * Create a caller that works with Next.js React Server Components & Server Actions\n */\nexport function nextAppDirCaller<TContext, TMeta>(\n config: Simplify<\n {\n /**\n * Extract the path from the procedure metadata\n */\n pathExtractor?: (opts: { meta: TMeta }) => string;\n /**\n * Transform form data to a `Record` before passing it to the procedure\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when an error occurs in the handler\n */\n onError?: (opts: ErrorHandlerOptions<TContext>) => void;\n } & CreateContextCallback<TContext, () => MaybePromise<TContext>>\n >,\n): CallerOverride<TContext> {\n const {\n normalizeFormData = true,\n\n // rethrowNextErrors = true\n } = config;\n const createContext = async (): Promise<TContext> => {\n return config?.createContext?.() ?? ({} as TContext);\n };\n\n return async (opts) => {\n const path =\n config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';\n const ctx: TContext = await createContext().catch((cause) => {\n const error = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Failed to create context',\n cause,\n });\n\n throw error;\n });\n\n const handleError = (cause: unknown) => {\n const error = getTRPCErrorFromUnknown(cause);\n\n config.onError?.({\n ctx,\n error,\n input: opts.args[0],\n path,\n type: opts._def.type,\n });\n\n rethrowNextErrors(error);\n\n throw error;\n };\n switch (opts._def.type) {\n case 'mutation': {\n /**\n * When you wrap an action with useFormState, it gets an extra argument as its first argument.\n * The submitted form data is therefore its second argument instead of its first as it would usually be.\n * The new first argument that gets added is the current state of the form.\n * @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data\n */\n let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];\n if (normalizeFormData && input instanceof FormData) {\n input = formDataToObject(input);\n }\n\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'query': {\n const input = opts.args[0];\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'subscription':\n default: {\n throw new TRPCError({\n code: 'NOT_IMPLEMENTED',\n message: `Not implemented for type ${opts._def.type}`,\n });\n }\n }\n };\n}\n","import type { notFound as __notFound } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js\n * @public\n */\nexport const notFound: typeof __notFound = () => {\n throw new TRPCError({\n code: 'NOT_FOUND',\n });\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"next-app-dir.mjs","names":[],"sources":["../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts","../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/notFound.ts"],"sourcesContent":["import type { RedirectType } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * The error `redirect()` returns, which `nextAppDirCaller` turns into a\n * Next.js redirect.\n * @internal\n */\nexport class TRPCRedirectError extends TRPCError {\n public readonly args;\n constructor(url: URL | string, redirectType?: RedirectType) {\n super({\n // TODO(?): This should maybe a custom error code\n code: 'UNPROCESSABLE_CONTENT',\n message: `Redirect error to \"${url}\" that will be handled by Next.js`,\n });\n\n this.args = [url.toString(), redirectType] as const;\n }\n}\n\n/**\n * Like `redirect()` from `next/navigation`, for procedures called through\n * `nextAppDirCaller`. Return it from a resolver; the caller then\n * redirects. Its type is `undefined`, which matches what the client gets,\n * unlike Next.js's `never`.\n * @public\n */\nexport const redirect = (url: URL | string, redirectType?: RedirectType) => {\n // We rethrow this internally so the returntype on the client is undefined.\n return new TRPCRedirectError(url, redirectType) as unknown as undefined;\n};\n","import * as nextNavigation from 'next/navigation';\nimport type { TRPCError } from '../../@trpc/server';\nimport { TRPCRedirectError } from './redirect';\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123\n */\nconst REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';\nfunction isRedirectError(error: unknown) {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('digest' in error) ||\n typeof error.digest !== 'string'\n ) {\n return false;\n }\n const [errorCode, type, destination, status] = error.digest.split(';', 4);\n const statusCode = Number(status);\n return (\n errorCode === REDIRECT_ERROR_CODE &&\n (type === 'replace' || type === 'push') &&\n typeof destination === 'string' &&\n !isNaN(statusCode)\n );\n}\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39\n */\nconst NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';\nfunction isNotFoundError(error: unknown) {\n if (typeof error !== 'object' || error === null || !('digest' in error)) {\n return false;\n }\n return error.digest === NOT_FOUND_ERROR_CODE;\n}\n\n/**\n * Turns a caught `TRPCError` into the Next.js control-flow error it stands\n * for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls\n * `redirect()`, and a `notFound()` or `redirect()` error in `cause` is\n * rethrown. It only takes a `TRPCError`; rethrow Next.js's own errors, such\n * as those `nextAppDirCaller` throws, yourself.\n */\nexport const rethrowNextErrors = (error: TRPCError) => {\n if (error.code === 'NOT_FOUND') {\n nextNavigation.notFound();\n }\n if (error instanceof TRPCRedirectError) {\n nextNavigation.redirect(...error.args);\n }\n const { cause } = error;\n\n // Next.js 15 has `unstable_rethrow`. Use that if it exists.\n if (\n 'unstable_rethrow' in nextNavigation &&\n typeof nextNavigation.unstable_rethrow === 'function'\n ) {\n nextNavigation.unstable_rethrow(cause);\n }\n\n // Before Next.js 15, we have to check and rethrow the error manually.\n if (isRedirectError(cause) || isNotFoundError(cause)) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n throw cause!;\n }\n};\n","import type { CreateContextCallback } from '../../@trpc/server';\nimport { getTRPCErrorFromUnknown, TRPCError } from '../../@trpc/server';\n// oxlint-disable-next-line no-restricted-imports\nimport { formDataToObject } from '../../unstable-core-do-not-import';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { CallerOverride } from '../../unstable-core-do-not-import/procedureBuilder';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type {\n MaybePromise,\n Simplify,\n} from '../../unstable-core-do-not-import/types';\nimport { TRPCRedirectError } from './redirect';\nimport { rethrowNextErrors } from './rethrowNextErrors';\n\n/**\n * Makes procedures callable as Next.js server actions and from React\n * Server Components. Pass it to `.experimental_caller()`.\n * @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller\n */\nexport function nextAppDirCaller<TContext, TMeta>(\n config: Simplify<\n {\n /**\n * Names the procedure from its metadata, for logs and errors, since\n * server actions have no router path.\n * @see https://trpc.io/docs/client/nextjs/server-actions#adding-observability-with-metadata\n */\n pathExtractor?: (opts: { meta: TMeta }) => string;\n /**\n * Turns `FormData` input into an object before validation.\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when a procedure throws.\n */\n onError?: (opts: ErrorHandlerOptions<TContext>) => void;\n } & CreateContextCallback<TContext, () => MaybePromise<TContext>>\n >,\n): CallerOverride<TContext> {\n const {\n normalizeFormData = true,\n\n // rethrowNextErrors = true\n } = config;\n const createContext = async (): Promise<TContext> => {\n return config?.createContext?.() ?? ({} as TContext);\n };\n\n return async (opts) => {\n const path =\n config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';\n const ctx: TContext = await createContext().catch((cause) => {\n const error = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Failed to create context',\n cause,\n });\n\n throw error;\n });\n\n const handleError = (cause: unknown) => {\n const error = getTRPCErrorFromUnknown(cause);\n\n config.onError?.({\n ctx,\n error,\n input: opts.args[0],\n path,\n type: opts._def.type,\n });\n\n rethrowNextErrors(error);\n\n throw error;\n };\n switch (opts._def.type) {\n case 'mutation': {\n /**\n * When you wrap an action with useFormState, it gets an extra argument as its first argument.\n * The submitted form data is therefore its second argument instead of its first as it would usually be.\n * The new first argument that gets added is the current state of the form.\n * @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data\n */\n let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];\n if (normalizeFormData && input instanceof FormData) {\n input = formDataToObject(input);\n }\n\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'query': {\n const input = opts.args[0];\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'subscription':\n default: {\n throw new TRPCError({\n code: 'NOT_IMPLEMENTED',\n message: `Not implemented for type ${opts._def.type}`,\n });\n }\n }\n };\n}\n","import type { notFound as __notFound } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`\n * `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found\n * page.\n * @public\n */\nexport const notFound: typeof __notFound = () => {\n throw new TRPCError({\n code: 'NOT_FOUND',\n });\n};\n"],"mappings":"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"}
|
package/dist/adapters/next.cjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_codes = require("../codes-
|
|
3
|
-
const require_getErrorShape = require("../getErrorShape-
|
|
4
|
-
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-
|
|
5
|
-
const require_node_http = require("../node-http-
|
|
2
|
+
const require_codes = require("../codes-Be-DrYMh.cjs");
|
|
3
|
+
const require_getErrorShape = require("../getErrorShape-8t0oLscZ.cjs");
|
|
4
|
+
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-CPV0O1Hn.cjs");
|
|
5
|
+
const require_node_http = require("../node-http-CCpTZ1zd.cjs");
|
|
6
6
|
//#region src/adapters/next.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Next.js API route handler for a router, for the Pages Router.
|
|
9
|
+
* The file must be named `[trpc].ts`. For the App Router, use
|
|
10
|
+
* `fetchRequestHandler`.
|
|
11
|
+
* @see https://trpc.io/docs/server/adapters/nextjs#nextjs-example
|
|
12
|
+
*/
|
|
7
13
|
function createNextApiHandler(opts) {
|
|
8
14
|
return async (req, res) => {
|
|
9
15
|
let path = "";
|