@trpc/server 11.25.2 → 11.25.3-canary.13.g1341462e1
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 +5 -8
- package/dist/adapters/aws-lambda/index.d.cts +13 -5
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +11 -5
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +5 -8
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +4 -5
- package/dist/adapters/express.d.cts +12 -4
- package/dist/adapters/express.d.cts.map +1 -1
- package/dist/adapters/express.d.mts +11 -4
- package/dist/adapters/express.d.mts.map +1 -1
- package/dist/adapters/express.mjs +4 -5
- package/dist/adapters/fastify/index.cjs +6 -8
- package/dist/adapters/fastify/index.d.cts +6 -8
- package/dist/adapters/fastify/index.d.cts.map +1 -1
- package/dist/adapters/fastify/index.d.mts +4 -8
- package/dist/adapters/fastify/index.d.mts.map +1 -1
- package/dist/adapters/fastify/index.mjs +6 -8
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +3 -4
- package/dist/adapters/fetch/index.d.cts +3 -5
- package/dist/adapters/fetch/index.d.cts.map +1 -1
- package/dist/adapters/fetch/index.d.mts +1 -5
- package/dist/adapters/fetch/index.d.mts.map +1 -1
- package/dist/adapters/fetch/index.mjs +3 -4
- package/dist/adapters/next-app-dir.cjs +7 -11
- package/dist/adapters/next-app-dir.d.cts +8 -10
- package/dist/adapters/next-app-dir.d.cts.map +1 -1
- package/dist/adapters/next-app-dir.d.mts +7 -10
- package/dist/adapters/next-app-dir.d.mts.map +1 -1
- package/dist/adapters/next-app-dir.mjs +6 -10
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +5 -6
- package/dist/adapters/next.d.cts +12 -4
- package/dist/adapters/next.d.cts.map +1 -1
- package/dist/adapters/next.d.mts +11 -4
- package/dist/adapters/next.d.mts.map +1 -1
- package/dist/adapters/next.mjs +5 -6
- package/dist/adapters/node-http/index.cjs +1 -1
- package/dist/adapters/node-http/index.d.cts +103 -2
- package/dist/adapters/node-http/index.d.cts.map +1 -0
- package/dist/adapters/node-http/index.d.mts +1 -1
- package/dist/adapters/node-http/index.mjs +1 -2
- package/dist/adapters/standalone.cjs +5 -6
- package/dist/adapters/standalone.d.cts +13 -5
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +12 -5
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +4 -5
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +1 -1
- package/dist/adapters/ws.d.cts +95 -3
- package/dist/adapters/ws.d.cts.map +1 -0
- package/dist/adapters/ws.d.mts +2 -2
- package/dist/adapters/ws.mjs +1 -2
- package/dist/{asyncGeneratorDelegate-JWx0LJUD.mjs → asyncGeneratorDelegate-BRQGtkYG.mjs} +30 -51
- package/dist/{asyncGeneratorDelegate-JWx0LJUD.mjs.map → asyncGeneratorDelegate-BRQGtkYG.mjs.map} +1 -1
- package/dist/{asyncGeneratorDelegate-CMdmcplC.cjs → asyncGeneratorDelegate-o88TWuuI.cjs} +29 -50
- package/dist/{codes-Be-DrYMh.cjs → codes-B96YeNnY.cjs} +2 -4
- package/dist/{codes-nbrm_zWY.mjs → codes-BCsCCyMj.mjs} +3 -5
- package/dist/{codes-nbrm_zWY.mjs.map → codes-BCsCCyMj.mjs.map} +1 -1
- package/dist/{contentTypeParsers-D1EBkFFY.mjs → contentTypeParsers-g-hK2Sqe.mjs} +2 -3
- package/dist/{contentTypeParsers-D1EBkFFY.mjs.map → contentTypeParsers-g-hK2Sqe.mjs.map} +1 -1
- package/dist/{contentTypeParsers-BTdoZrqN.cjs → contentTypeParsers-st4U3xYo.cjs} +1 -2
- package/dist/{getErrorShape-BAuHhNuh.cjs → getErrorShape-B1AlrJBV.cjs} +15 -24
- package/dist/{getErrorShape-B5jPKHJ3.mjs → getErrorShape-CVrl8_-w.mjs} +16 -25
- package/dist/{getErrorShape-B5jPKHJ3.mjs.map → getErrorShape-CVrl8_-w.mjs.map} +1 -1
- package/dist/http-11_NyRWk.d.cts +1 -0
- package/dist/http.cjs +3 -3
- package/dist/http.d.cts +2 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +3 -3
- package/dist/{index-CFQnkrGZ.d.cts → index-BdKWn-Kv.d.cts} +1 -9
- package/dist/index-BdKWn-Kv.d.cts.map +1 -0
- package/dist/{index-CFQnkrGZ.d.mts → index-BdKWn-Kv.d.mts} +1 -9
- package/dist/index-BdKWn-Kv.d.mts.map +1 -0
- package/dist/{index-DVmu6VtT.d.mts → index-C7UHVQQf.d.mts} +2 -8
- package/dist/index-C7UHVQQf.d.mts.map +1 -0
- package/dist/index-DVXG_v0W.d.cts +9 -0
- package/dist/index-DVXG_v0W.d.cts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -11
- package/dist/index.d.mts +1 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{initTRPC-DPoVGUwX.mjs → initTRPC-BRhOzCfA.mjs} +15 -22
- package/dist/{initTRPC-DPoVGUwX.mjs.map → initTRPC-BRhOzCfA.mjs.map} +1 -1
- package/dist/{initTRPC-yeYwDikA.cjs → initTRPC-RIE9F856.cjs} +14 -21
- package/dist/{node-http-CyL_jN-0.mjs → node-http-5y0OmcF3.mjs} +8 -11
- package/dist/{node-http-CyL_jN-0.mjs.map → node-http-5y0OmcF3.mjs.map} +1 -1
- package/dist/{node-http-BnGON5Za.cjs → node-http-962IXGVP.cjs} +7 -10
- 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-Cmd1MFy3.mjs → observable-BjUZYMQq.mjs} +4 -6
- package/dist/{observable-Cmd1MFy3.mjs.map → observable-BjUZYMQq.mjs.map} +1 -1
- package/dist/{observable-kpFFzvou.mjs → observable-CodTG6Sf.mjs} +2 -3
- package/dist/{observable-kpFFzvou.mjs.map → observable-CodTG6Sf.mjs.map} +1 -1
- package/dist/{observable-1zKJIeLl.cjs → observable-DWjyAi42.cjs} +1 -2
- package/dist/{observable-CtU0hoef.cjs → observable-a_nbCVWw.cjs} +3 -5
- package/dist/{parseTRPCMessage-BsPr5reh.cjs → parseTRPCMessage-BHVPK_9B.cjs} +3 -5
- package/dist/{parseTRPCMessage-BO1-cCsX.mjs → parseTRPCMessage-_j-ul9Ni.mjs} +4 -6
- package/dist/{parseTRPCMessage-BO1-cCsX.mjs.map → parseTRPCMessage-_j-ul9Ni.mjs.map} +1 -1
- package/dist/{resolveResponse-2MBY36PP.mjs → resolveResponse-CWLbNRmT.mjs} +22 -39
- package/dist/{resolveResponse-2MBY36PP.mjs.map → resolveResponse-CWLbNRmT.mjs.map} +1 -1
- package/dist/{resolveResponse-CiTYuZCi.cjs → resolveResponse-FM4r4UGZ.cjs} +21 -38
- package/dist/{rolldown-runtime-CFW-PwTP.cjs → rolldown-runtime-Ct0tUeOX.cjs} +1 -2
- 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 +2 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -2
- package/dist/{unstable-core-do-not-import-Db2TnFh8.d.cts → unstable-core-do-not-import-C8Gy-fzS.d.cts} +2 -84
- package/dist/unstable-core-do-not-import-C8Gy-fzS.d.cts.map +1 -0
- package/dist/{unstable-core-do-not-import-CzDUc5m2.d.mts → unstable-core-do-not-import-d-SHdPM9.d.mts} +2 -84
- package/dist/unstable-core-do-not-import-d-SHdPM9.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +8 -9
- package/dist/unstable-core-do-not-import.d.cts +11 -1
- package/dist/unstable-core-do-not-import.d.mts +11 -1
- package/dist/unstable-core-do-not-import.mjs +8 -9
- package/dist/{ws-Bl1WQEXo.mjs → ws-B4qoo-Ep.mjs} +10 -12
- package/dist/{ws-Bl1WQEXo.mjs.map → ws-B4qoo-Ep.mjs.map} +1 -1
- package/dist/{ws-BRFs3IJR.cjs → ws-D3hgtSpa.cjs} +9 -11
- package/dist/{ws-D-DF_k_T.d.cts → ws-DkO_xnzu.d.mts} +3 -5
- package/dist/ws-DkO_xnzu.d.mts.map +1 -0
- package/package.json +26 -26
- 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 +1 -1
- package/skills/error-handling/SKILL.md +1 -1
- package/skills/middlewares/SKILL.md +1 -1
- package/skills/non-json-content-types/SKILL.md +1 -1
- 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 +5 -3
- package/src/adapters/aws-lambda/index.ts +2 -0
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/next-app-dir/redirect.ts +7 -1
- package/src/adapters/standalone.ts +1 -1
- package/dist/index-CFQnkrGZ.d.cts.map +0 -1
- package/dist/index-CFQnkrGZ.d.mts.map +0 -1
- package/dist/index-DVmu6VtT.d.mts.map +0 -1
- package/dist/index-Dn1ucZS5.d.cts +0 -107
- package/dist/index-Dn1ucZS5.d.cts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/unstable-core-do-not-import-CzDUc5m2.d.mts.map +0 -1
- package/dist/unstable-core-do-not-import-Db2TnFh8.d.cts.map +0 -1
- package/dist/ws-D-DF_k_T.d.cts.map +0 -1
- package/dist/ws-lJRDMspc.d.mts +0 -95
- package/dist/ws-lJRDMspc.d.mts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-
|
|
2
|
-
|
|
1
|
+
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-C8Gy-fzS.cjs";
|
|
2
|
+
import "../../index-DVXG_v0W.cjs";
|
|
3
|
+
import "../../http-11_NyRWk.cjs";
|
|
3
4
|
/**
|
|
4
5
|
* What `createContext` gets in the Fetch adapter.
|
|
5
6
|
* @see https://trpc.io/docs/server/adapters/fetch#create-the-context
|
|
@@ -29,8 +30,6 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
|
|
|
29
30
|
/** The path the router is served at, such as `/trpc`. */
|
|
30
31
|
endpoint: string;
|
|
31
32
|
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/adapters/fetch/fetchRequestHandler.d.ts
|
|
34
33
|
/**
|
|
35
34
|
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
36
35
|
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
@@ -43,6 +42,5 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
|
|
|
43
42
|
* @see https://trpc.io/docs/server/adapters/fetch
|
|
44
43
|
*/
|
|
45
44
|
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
|
|
46
|
-
//#endregion
|
|
47
45
|
|
|
48
46
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -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,5 +1,4 @@
|
|
|
1
|
-
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-
|
|
2
|
-
//#region src/adapters/fetch/types.d.ts
|
|
1
|
+
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-d-SHdPM9.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* What `createContext` gets in the Fetch adapter.
|
|
5
4
|
* @see https://trpc.io/docs/server/adapters/fetch#create-the-context
|
|
@@ -29,8 +28,6 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
|
|
|
29
28
|
/** The path the router is served at, such as `/trpc`. */
|
|
30
29
|
endpoint: string;
|
|
31
30
|
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/adapters/fetch/fetchRequestHandler.d.ts
|
|
34
31
|
/**
|
|
35
32
|
* Handles a Fetch API `Request` for a router and returns its `Response`.
|
|
36
33
|
* Works in edge runtimes, Deno, Bun, Cloudflare Workers and Next.js route
|
|
@@ -43,6 +40,5 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
|
|
|
43
40
|
* @see https://trpc.io/docs/server/adapters/fetch
|
|
44
41
|
*/
|
|
45
42
|
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
|
|
46
|
-
//#endregion
|
|
47
43
|
|
|
48
44
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as resolveResponse } from "../../resolveResponse-CWLbNRmT.mjs";
|
|
2
|
+
import { n as _objectSpread2 } from "../../getErrorShape-CVrl8_-w.mjs";
|
|
3
|
+
// 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;
|
|
@@ -58,7 +58,6 @@ async function fetchRequestHandler(opts) {
|
|
|
58
58
|
}
|
|
59
59
|
}));
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { fetchRequestHandler };
|
|
63
62
|
|
|
64
63
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../rolldown-runtime-
|
|
3
|
-
const
|
|
4
|
-
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-CMdmcplC.cjs");
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-Ct0tUeOX.cjs");
|
|
3
|
+
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-o88TWuuI.cjs");
|
|
5
4
|
const require_unstable_core_do_not_import = require("../unstable-core-do-not-import.cjs");
|
|
5
|
+
const require_getErrorShape = require("../getErrorShape-B1AlrJBV.cjs");
|
|
6
6
|
let next_navigation = require("next/navigation");
|
|
7
7
|
next_navigation = require_rolldown_runtime.__toESM(next_navigation, 1);
|
|
8
|
-
|
|
8
|
+
// src/adapters/next-app-dir/redirect.ts
|
|
9
9
|
/**
|
|
10
10
|
* The error `redirect()` returns, which `nextAppDirCaller` turns into a
|
|
11
11
|
* Next.js redirect.
|
|
@@ -31,8 +31,7 @@ var TRPCRedirectError = class extends require_asyncGeneratorDelegate.TRPCError {
|
|
|
31
31
|
const redirect = (url, redirectType) => {
|
|
32
32
|
return new TRPCRedirectError(url, redirectType);
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
//#region src/adapters/next-app-dir/rethrowNextErrors.ts
|
|
34
|
+
// src/adapters/next-app-dir/rethrowNextErrors.ts
|
|
36
35
|
/**
|
|
37
36
|
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
38
37
|
* Inlining them here instead...
|
|
@@ -69,8 +68,7 @@ const rethrowNextErrors = (error) => {
|
|
|
69
68
|
if ("unstable_rethrow" in next_navigation && typeof next_navigation.unstable_rethrow === "function") next_navigation.unstable_rethrow(cause);
|
|
70
69
|
if (isRedirectError(cause) || isNotFoundError(cause)) throw cause;
|
|
71
70
|
};
|
|
72
|
-
|
|
73
|
-
//#region src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
71
|
+
// src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
74
72
|
/**
|
|
75
73
|
* Makes procedures callable as Next.js server actions and from React
|
|
76
74
|
* Server Components. Pass it to `.experimental_caller()`.
|
|
@@ -150,8 +148,7 @@ function nextAppDirCaller(config) {
|
|
|
150
148
|
}
|
|
151
149
|
};
|
|
152
150
|
}
|
|
153
|
-
|
|
154
|
-
//#region src/adapters/next-app-dir/notFound.ts
|
|
151
|
+
// src/adapters/next-app-dir/notFound.ts
|
|
155
152
|
/**
|
|
156
153
|
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
157
154
|
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
@@ -161,7 +158,6 @@ function nextAppDirCaller(config) {
|
|
|
161
158
|
const notFound = () => {
|
|
162
159
|
throw new require_asyncGeneratorDelegate.TRPCError({ code: "NOT_FOUND" });
|
|
163
160
|
};
|
|
164
|
-
//#endregion
|
|
165
161
|
exports.experimental_nextAppDirCaller = nextAppDirCaller;
|
|
166
162
|
exports.experimental_notFound = notFound;
|
|
167
163
|
exports.experimental_redirect = redirect;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import "../index-DVXG_v0W.cjs";
|
|
2
|
+
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-C8Gy-fzS.cjs";
|
|
3
|
+
import { notFound as notFound$1, redirect as redirect$1 } from "next/navigation.js";
|
|
4
4
|
/**
|
|
5
5
|
* Makes procedures callable as Next.js server actions and from React
|
|
6
6
|
* Server Components. Pass it to `.experimental_caller()`.
|
|
@@ -25,8 +25,11 @@ declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
|
25
25
|
*/
|
|
26
26
|
onError?: (opts: ErrorHandlerOptions<TContext>) => void;
|
|
27
27
|
} & CreateContextCallback<TContext, () => MaybePromise<TContext>>>): CallerOverride<TContext>;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Taken from `redirect()`'s signature: Next 15 exports `RedirectType` as an
|
|
30
|
+
* enum, Next 16 only as a value, typed `'push' | 'replace'`.
|
|
31
|
+
*/
|
|
32
|
+
type RedirectType = NonNullable<Parameters<typeof redirect$1>[1]>;
|
|
30
33
|
/**
|
|
31
34
|
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
32
35
|
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
@@ -35,8 +38,6 @@ declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
|
35
38
|
* @public
|
|
36
39
|
*/
|
|
37
40
|
declare const redirect: (url: URL | string, redirectType?: RedirectType) => undefined;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/adapters/next-app-dir/notFound.d.ts
|
|
40
41
|
/**
|
|
41
42
|
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
42
43
|
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
@@ -44,8 +45,6 @@ declare const redirect: (url: URL | string, redirectType?: RedirectType) => unde
|
|
|
44
45
|
* @public
|
|
45
46
|
*/
|
|
46
47
|
declare const notFound: typeof notFound$1;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/adapters/next-app-dir/rethrowNextErrors.d.ts
|
|
49
48
|
/**
|
|
50
49
|
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
51
50
|
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
@@ -54,7 +53,6 @@ declare const notFound: typeof notFound$1;
|
|
|
54
53
|
* as those `nextAppDirCaller` throws, yourself.
|
|
55
54
|
*/
|
|
56
55
|
export declare const rethrowNextErrors: (error: TRPCError) => void;
|
|
57
|
-
//#endregion
|
|
58
56
|
export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect };
|
|
59
57
|
|
|
60
58
|
//# sourceMappingURL=next-app-dir.d.cts.map
|
|
@@ -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":";;;;;;;;iBAwBgB,iBAAiB,UAAU,OACzC,QAAQ;;;;;;EAOJ,iBAAiB;IAAQ,MAAM;;;;;;EAK/B;;;;EAIA,WAAW,MAAM,oBAAoB;IACnC,sBAAsB,gBAAgB,aAAa,cAExD,eAAe
|
|
1
|
+
{"version":3,"file":"next-app-dir.d.cts","names":["nextRedirect","__notFound"],"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;;;;;KCrCb,eAAe,YAAY,kBAAkBA;;;;;;;;cA2BrC,WAAQ,KAAS,cAAY,eAAiB;;;;;;;cCzB9C,iBAAiBC;;;;;;;;qBCwCjB,oBAAiB,OAAW"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
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-
|
|
2
|
-
import {
|
|
3
|
-
//#region src/adapters/next-app-dir/nextAppDirCaller.d.ts
|
|
1
|
+
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-d-SHdPM9.mjs";
|
|
2
|
+
import { notFound as notFound$1, redirect as redirect$1 } from "next/navigation.js";
|
|
4
3
|
/**
|
|
5
4
|
* Makes procedures callable as Next.js server actions and from React
|
|
6
5
|
* Server Components. Pass it to `.experimental_caller()`.
|
|
@@ -25,8 +24,11 @@ declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
|
25
24
|
*/
|
|
26
25
|
onError?: (opts: ErrorHandlerOptions<TContext>) => void;
|
|
27
26
|
} & CreateContextCallback<TContext, () => MaybePromise<TContext>>>): CallerOverride<TContext>;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Taken from `redirect()`'s signature: Next 15 exports `RedirectType` as an
|
|
29
|
+
* enum, Next 16 only as a value, typed `'push' | 'replace'`.
|
|
30
|
+
*/
|
|
31
|
+
type RedirectType = NonNullable<Parameters<typeof redirect$1>[1]>;
|
|
30
32
|
/**
|
|
31
33
|
* Like `redirect()` from `next/navigation`, for procedures called through
|
|
32
34
|
* `nextAppDirCaller`. Return it from a resolver; the caller then
|
|
@@ -35,8 +37,6 @@ declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
|
35
37
|
* @public
|
|
36
38
|
*/
|
|
37
39
|
declare const redirect: (url: URL | string, redirectType?: RedirectType) => undefined;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/adapters/next-app-dir/notFound.d.ts
|
|
40
40
|
/**
|
|
41
41
|
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
42
42
|
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
@@ -44,8 +44,6 @@ declare const redirect: (url: URL | string, redirectType?: RedirectType) => unde
|
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
46
|
declare const notFound: typeof notFound$1;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/adapters/next-app-dir/rethrowNextErrors.d.ts
|
|
49
47
|
/**
|
|
50
48
|
* Turns a caught `TRPCError` into the Next.js control-flow error it stands
|
|
51
49
|
* for: a `NOT_FOUND` code calls `notFound()`, a `TRPCRedirectError` calls
|
|
@@ -54,7 +52,6 @@ declare const notFound: typeof notFound$1;
|
|
|
54
52
|
* as those `nextAppDirCaller` throws, yourself.
|
|
55
53
|
*/
|
|
56
54
|
export declare const rethrowNextErrors: (error: TRPCError) => void;
|
|
57
|
-
//#endregion
|
|
58
55
|
export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect };
|
|
59
56
|
|
|
60
57
|
//# sourceMappingURL=next-app-dir.d.mts.map
|
|
@@ -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":["nextRedirect","__notFound"],"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;;;;;KCrCb,eAAe,YAAY,kBAAkBA;;;;;;;;cA2BrC,WAAQ,KAAS,cAAY,eAAiB;;;;;;;cCzB9C,iBAAiBC;;;;;;;;qBCwCjB,oBAAiB,OAAW"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as getTRPCErrorFromUnknown, x as TRPCError } from "../asyncGeneratorDelegate-JWx0LJUD.mjs";
|
|
1
|
+
import { C as getTRPCErrorFromUnknown, x as TRPCError } from "../asyncGeneratorDelegate-BRQGtkYG.mjs";
|
|
3
2
|
import { formDataToObject } from "../unstable-core-do-not-import.mjs";
|
|
3
|
+
import { r as _defineProperty } from "../getErrorShape-CVrl8_-w.mjs";
|
|
4
4
|
import * as nextNavigation from "next/navigation";
|
|
5
|
-
|
|
5
|
+
// src/adapters/next-app-dir/redirect.ts
|
|
6
6
|
/**
|
|
7
7
|
* The error `redirect()` returns, which `nextAppDirCaller` turns into a
|
|
8
8
|
* Next.js redirect.
|
|
@@ -28,8 +28,7 @@ var TRPCRedirectError = class extends TRPCError {
|
|
|
28
28
|
const redirect = (url, redirectType) => {
|
|
29
29
|
return new TRPCRedirectError(url, redirectType);
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
//#region src/adapters/next-app-dir/rethrowNextErrors.ts
|
|
31
|
+
// src/adapters/next-app-dir/rethrowNextErrors.ts
|
|
33
32
|
/**
|
|
34
33
|
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
35
34
|
* Inlining them here instead...
|
|
@@ -66,8 +65,7 @@ const rethrowNextErrors = (error) => {
|
|
|
66
65
|
if ("unstable_rethrow" in nextNavigation && typeof nextNavigation.unstable_rethrow === "function") nextNavigation.unstable_rethrow(cause);
|
|
67
66
|
if (isRedirectError(cause) || isNotFoundError(cause)) throw cause;
|
|
68
67
|
};
|
|
69
|
-
|
|
70
|
-
//#region src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
68
|
+
// src/adapters/next-app-dir/nextAppDirCaller.ts
|
|
71
69
|
/**
|
|
72
70
|
* Makes procedures callable as Next.js server actions and from React
|
|
73
71
|
* Server Components. Pass it to `.experimental_caller()`.
|
|
@@ -147,8 +145,7 @@ function nextAppDirCaller(config) {
|
|
|
147
145
|
}
|
|
148
146
|
};
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
//#region src/adapters/next-app-dir/notFound.ts
|
|
148
|
+
// src/adapters/next-app-dir/notFound.ts
|
|
152
149
|
/**
|
|
153
150
|
* Like `notFound()` from `next/navigation`, but throws a `NOT_FOUND`
|
|
154
151
|
* `TRPCError`, which `nextAppDirCaller` turns into Next.js's not-found
|
|
@@ -158,7 +155,6 @@ function nextAppDirCaller(config) {
|
|
|
158
155
|
const notFound = () => {
|
|
159
156
|
throw new TRPCError({ code: "NOT_FOUND" });
|
|
160
157
|
};
|
|
161
|
-
//#endregion
|
|
162
158
|
export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect, rethrowNextErrors };
|
|
163
159
|
|
|
164
160
|
|
|
@@ -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 * 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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"}
|
|
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 { redirect as nextRedirect } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * Taken from `redirect()`'s signature: Next 15 exports `RedirectType` as an\n * enum, Next 16 only as a value, typed `'push' | 'replace'`.\n */\ntype RedirectType = NonNullable<Parameters<typeof nextRedirect>[1]>;\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,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-o88TWuuI.cjs");
|
|
3
|
+
const require_codes = require("../codes-B96YeNnY.cjs");
|
|
4
|
+
const require_node_http = require("../node-http-962IXGVP.cjs");
|
|
5
|
+
const require_getErrorShape = require("../getErrorShape-B1AlrJBV.cjs");
|
|
6
|
+
// src/adapters/next.ts
|
|
7
7
|
/**
|
|
8
8
|
* Creates a Next.js API route handler for a router, for the Pages Router.
|
|
9
9
|
* The file must be named `[trpc].ts`. For the App Router, use
|
|
@@ -34,6 +34,5 @@ function createNextApiHandler(opts) {
|
|
|
34
34
|
}, opts)));
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
exports.createNextApiHandler = createNextApiHandler;
|
|
39
38
|
|
package/dist/adapters/next.d.cts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 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`
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
7
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
import { zn as AnyRouter } from "../unstable-core-do-not-import-C8Gy-fzS.cjs";
|
|
11
|
+
import "../index-DVXG_v0W.cjs";
|
|
12
|
+
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from "./node-http/index.cjs";
|
|
3
13
|
import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
|
|
4
|
-
//#region src/adapters/next.d.ts
|
|
5
14
|
/**
|
|
6
15
|
* What `createContext` gets in the Next.js API route adapter: `req`, `res`
|
|
7
16
|
* and the request's `info`.
|
|
@@ -15,7 +24,6 @@ export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiReq
|
|
|
15
24
|
* @see https://trpc.io/docs/server/adapters/nextjs#nextjs-example
|
|
16
25
|
*/
|
|
17
26
|
export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
18
|
-
//#endregion
|
|
19
27
|
export type { NextApiHandler, NextApiRequest, NextApiResponse };
|
|
20
28
|
|
|
21
29
|
//# sourceMappingURL=next.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.cts","names":[],"sources":["../../src/adapters/next.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.d.cts","names":["NextApiRequest","NextApiResponse","NextApiHandler"],"sources":["../../src/adapters/next.ts"],"mappings":";;;;;;;;;;;;;;;;;;YA2BY,2BAA2B,+BACrCA,kBACAC;;;;;;;wBAec,qBAAqB,gBAAgB,WACnD,MAAM,uBAAuB,SAASD,kBAAgBC,qBACrDC"}
|
package/dist/adapters/next.d.mts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 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`
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
7
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
import { zn as AnyRouter } from "../unstable-core-do-not-import-d-SHdPM9.mjs";
|
|
11
|
+
import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-C7UHVQQf.mjs";
|
|
3
12
|
import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
|
|
4
|
-
//#region src/adapters/next.d.ts
|
|
5
13
|
/**
|
|
6
14
|
* What `createContext` gets in the Next.js API route adapter: `req`, `res`
|
|
7
15
|
* and the request's `info`.
|
|
@@ -15,7 +23,6 @@ export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiReq
|
|
|
15
23
|
* @see https://trpc.io/docs/server/adapters/nextjs#nextjs-example
|
|
16
24
|
*/
|
|
17
25
|
export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
18
|
-
//#endregion
|
|
19
26
|
export type { NextApiHandler, NextApiRequest, NextApiResponse };
|
|
20
27
|
|
|
21
28
|
//# sourceMappingURL=next.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.mts","names":[],"sources":["../../src/adapters/next.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.d.mts","names":["NextApiRequest","NextApiResponse","NextApiHandler"],"sources":["../../src/adapters/next.ts"],"mappings":";;;;;;;;;;;;;;;;;YA2BY,2BAA2B,+BACrCA,kBACAC;;;;;;;wBAec,qBAAqB,gBAAgB,WACnD,MAAM,uBAAuB,SAASD,kBAAgBC,qBACrDC"}
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
|
|
1
|
+
import { x as TRPCError } from "../asyncGeneratorDelegate-BRQGtkYG.mjs";
|
|
2
|
+
import { m as run } from "../codes-BCsCCyMj.mjs";
|
|
3
|
+
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-5y0OmcF3.mjs";
|
|
4
|
+
import { n as _objectSpread2 } from "../getErrorShape-CVrl8_-w.mjs";
|
|
5
|
+
// src/adapters/next.ts
|
|
6
6
|
/**
|
|
7
7
|
* Creates a Next.js API route handler for a router, for the Pages Router.
|
|
8
8
|
* The file must be named `[trpc].ts`. For the App Router, use
|
|
@@ -33,7 +33,6 @@ function createNextApiHandler(opts) {
|
|
|
33
33
|
}, opts)));
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
export { createNextApiHandler };
|
|
38
37
|
|
|
39
38
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_node_http = require("../../node-http-
|
|
2
|
+
const require_node_http = require("../../node-http-962IXGVP.cjs");
|
|
3
3
|
exports.createURL = require_node_http.createURL;
|
|
4
4
|
exports.incomingMessageToRequest = require_node_http.incomingMessageToRequest;
|
|
5
5
|
exports.internal_exceptionHandler = require_node_http.internal_exceptionHandler;
|
|
@@ -1,2 +1,103 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import "../../index-DVXG_v0W.cjs";
|
|
2
|
+
import "../../http-11_NyRWk.cjs";
|
|
3
|
+
import { Ln as TRPCRequestInfo, Ti as MaybePromise, gi as DistributiveOmit, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-C8Gy-fzS.cjs";
|
|
4
|
+
import * as http$1 from "http";
|
|
5
|
+
import * as http2 from "http2";
|
|
6
|
+
/** A Node.js HTTP/1 or HTTP/2 request, as the Node.js adapters take it. */
|
|
7
|
+
export type NodeHTTPRequest = DistributiveOmit<http$1.IncomingMessage | http2.Http2ServerRequest, 'socket'> & {
|
|
8
|
+
/**
|
|
9
|
+
* The body, if a framework or middleware parsed it already. tRPC reads
|
|
10
|
+
* it instead of the stream.
|
|
11
|
+
*/
|
|
12
|
+
body?: unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Optional, and maybe partial: some hosts don't give a full Node.js
|
|
15
|
+
* socket (https://github.com/trpc/trpc/issues/6341).
|
|
16
|
+
*/
|
|
17
|
+
socket?: Partial<http$1.IncomingMessage['socket']> | Partial<http2.Http2ServerRequest['socket']>;
|
|
18
|
+
};
|
|
19
|
+
/** A Node.js HTTP/1 or HTTP/2 response, as the Node.js adapters take it. */
|
|
20
|
+
export type NodeHTTPResponse = DistributiveOmit<http$1.ServerResponse | http2.Http2ServerResponse, 'write'> & {
|
|
21
|
+
/**
|
|
22
|
+
* Sends what a compression middleware (such as Express's `compression()`)
|
|
23
|
+
* has buffered so far. tRPC calls it while streaming.
|
|
24
|
+
*/
|
|
25
|
+
flush?: () => void;
|
|
26
|
+
write: (chunk: string | Uint8Array) => boolean;
|
|
27
|
+
};
|
|
28
|
+
/** The Node.js adapters' `createContext` option. */
|
|
29
|
+
export type NodeHTTPCreateContextOption<TRouter extends AnyRouter, TRequest, TResponse> = CreateContextCallback<inferRouterContext<TRouter>, NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>>;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
type ConnectMiddleware<TRequest extends NodeHTTPRequest = NodeHTTPRequest, TResponse extends NodeHTTPResponse = NodeHTTPResponse> = (req: TRequest, res: TResponse, next: (err?: any) => any) => void;
|
|
34
|
+
/** The options of the Node.js adapters. */
|
|
35
|
+
export type NodeHTTPHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = HTTPBaseHandlerOptions<TRouter, TRequest> & {
|
|
36
|
+
/**
|
|
37
|
+
* A Connect-style middleware that runs before tRPC. tRPC doesn't answer
|
|
38
|
+
* `OPTIONS` requests or set CORS headers, so use this for `cors()`.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* createHTTPServer({ middleware: cors(), router: appRouter });
|
|
42
|
+
* ```
|
|
43
|
+
* @see https://trpc.io/docs/server/adapters/standalone#handling-cors--options
|
|
44
|
+
*/
|
|
45
|
+
middleware?: ConnectMiddleware<TRequest, TResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* The largest request body, in bytes. A larger one gets a
|
|
48
|
+
* `PAYLOAD_TOO_LARGE` error. It only applies to bodies tRPC reads from
|
|
49
|
+
* the stream; if a body-parsing middleware sets `req.body`, limit the
|
|
50
|
+
* size there.
|
|
51
|
+
*/
|
|
52
|
+
maxBodySize?: number;
|
|
53
|
+
} & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
|
|
54
|
+
/** The options of `nodeHTTPRequestHandler`. */
|
|
55
|
+
export type NodeHTTPRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
56
|
+
req: TRequest;
|
|
57
|
+
res: TResponse;
|
|
58
|
+
/**
|
|
59
|
+
* The procedure path to handle, such as `post.all`, or several joined by
|
|
60
|
+
* commas for a batch.
|
|
61
|
+
*/
|
|
62
|
+
path: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* What `createContext` gets in the Node.js adapters: `req`, `res` and the
|
|
66
|
+
* request's `info`.
|
|
67
|
+
* @see https://trpc.io/docs/server/context#creating-the-context
|
|
68
|
+
*/
|
|
69
|
+
export type NodeHTTPCreateContextFnOptions<TRequest, TResponse> = {
|
|
70
|
+
req: TRequest;
|
|
71
|
+
res: TResponse;
|
|
72
|
+
info: TRPCRequestInfo;
|
|
73
|
+
};
|
|
74
|
+
/** The `createContext` function the Node.js adapters take. */
|
|
75
|
+
export type NodeHTTPCreateContextFn<TRouter extends AnyRouter, TRequest, TResponse> = (opts: NodeHTTPCreateContextFnOptions<TRequest, TResponse>) => MaybePromise<inferRouterContext<TRouter>>;
|
|
76
|
+
/**
|
|
77
|
+
* Answers with an error response when handling a request throws.
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function internal_exceptionHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>): (cause: unknown) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Handles a Node.js request for a router. The adapters for Express,
|
|
83
|
+
* Next.js and the standalone server use it. The promise never rejects.
|
|
84
|
+
*/
|
|
85
|
+
export declare function nodeHTTPRequestHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* The full URL of a Node.js request, from its `Host` header and socket.
|
|
88
|
+
* Throws a `BAD_REQUEST` error if it isn't a valid URL.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createURL(req: NodeHTTPRequest): URL;
|
|
91
|
+
/**
|
|
92
|
+
* Turns a Node.js `IncomingMessage` into a Fetch API `Request`. The
|
|
93
|
+
* request's signal aborts when the client disconnects.
|
|
94
|
+
*/
|
|
95
|
+
export declare function incomingMessageToRequest(req: NodeHTTPRequest, res: NodeHTTPResponse, opts: {
|
|
96
|
+
/**
|
|
97
|
+
* Max body size in bytes. If the body is larger than this, the request will be aborted
|
|
98
|
+
*/
|
|
99
|
+
maxBodySize: number | null;
|
|
100
|
+
}): Request;
|
|
101
|
+
export {};
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["http"],"sources":["../../../src/adapters/node-http/types.ts","../../../src/adapters/node-http/nodeHTTPRequestHandler.ts","../../../src/adapters/node-http/incomingMessageToRequest.ts"],"mappings":";;;;;;YA6BY,kBAAkB,iBAC5BA,OAAK,kBAAkB,MAAM;;;;;EAO7B;;;;;EAKA,SACI,QAAQA,OAAK,6BACb,QAAQ,MAAM;;;YAIR,mBAAmB,iBAC7BA,OAAK,iBAAiB,MAAM;;;;;EAO5B;EAEA,QAAQ,gBAAgB;;;YAGd,4BACV,gBAAgB,WAChB,UACA,aACE,sBACF,mBAAmB,UACnB,wBAAwB,SAAS,UAAU;;;;KAMxC,kBACH,iBAAiB,kBAAkB,iBACnC,kBAAkB,mBAAmB,qBAClC,KAAK,UAAU,KAAK,WAAW,OAAO;;YAO/B,uBACV,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS;;;;;;;;;;EAUlC,aAAa,kBAAkB,UAAU;;;;;;;EAOzC;IACE,4BAA4B,SAAS,UAAU;;YAGvC,8BACV,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS,UAAU;EAC5C,KAAK;EACL,KAAK;;;;;EAKL;;;;;;;YAQU,+BAA+B,UAAU;EACnD,KAAK;EACL,KAAK;EACL,MAAM;;;YAGI,wBACV,gBAAgB,WAChB,UACA,cAEA,MAAM,+BAA+B,UAAU,eAC5C,aAAa,mBAAmB;;;;;wBC3FrB,0BACd,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,kBAClB,MAAM,8BAA8B,SAAS,UAAU,cAAU;;;;;wBAkD7C,uBACpB,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,kBAClB,MAAM,8BAA8B,SAAS,UAAU,aAAU;;;;;wBCTnD,UAAU,KAAK,kBAAkB;;;;;wBAiDjC,yBACd,KAAK,iBACL,KAAK,kBACL;;;;EAIE;IAED"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as NodeHTTPCreateContextFn, c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, i as nodeHTTPRequestHandler, l as NodeHTTPRequest, n as incomingMessageToRequest, o as NodeHTTPCreateContextFnOptions, r as internal_exceptionHandler, s as NodeHTTPCreateContextOption, t as createURL, u as NodeHTTPRequestHandlerOptions } from "../../index-
|
|
1
|
+
import { a as NodeHTTPCreateContextFn, c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, i as nodeHTTPRequestHandler, l as NodeHTTPRequest, n as incomingMessageToRequest, o as NodeHTTPCreateContextFnOptions, r as internal_exceptionHandler, s as NodeHTTPCreateContextOption, t as createURL, u as NodeHTTPRequestHandlerOptions } from "../../index-C7UHVQQf.mjs";
|
|
2
2
|
export { NodeHTTPCreateContextFn, NodeHTTPCreateContextFnOptions, NodeHTTPCreateContextOption, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse, createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
1
|
+
export { r as createURL, i as incomingMessageToRequest, t as internal_exceptionHandler, n as nodeHTTPRequestHandler } from "../../node-http-5y0OmcF3.mjs";
|
|
3
2
|
|