@trpc/server 11.0.0-alpha-tmp-app-router-example.364 → 11.0.0-alpha-tmp-rethrow-next-errors.384
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/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +47 -6
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +27 -5
- package/dist/bundle-analysis.json +81 -81
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +2 -1
- package/dist/unstable-core-do-not-import/utils.mjs +2 -1
- package/package.json +3 -3
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +1 -0
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +45 -9
- package/src/unstable-core-do-not-import/utils.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAKjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAKjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,CAyF1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rethrowNextErrors.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rethrowNextErrors.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmCpD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,SAAS,SAqBjD,CAAC"}
|
|
@@ -1,21 +1,62 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var redirect$1 = require('next/dist/client/components/redirect');
|
|
5
|
-
var navigation = require('next/navigation');
|
|
3
|
+
var nextNavigation = require('next/navigation');
|
|
6
4
|
var redirect = require('./redirect.js');
|
|
7
5
|
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var nextNavigation__namespace = /*#__PURE__*/_interopNamespaceDefault(nextNavigation);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
27
|
+
* Inlining them here instead...
|
|
28
|
+
*/ const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
29
|
+
function isRedirectError(error) {
|
|
30
|
+
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
34
|
+
const statusCode = Number(status);
|
|
35
|
+
return errorCode === REDIRECT_ERROR_CODE && (type === 'replace' || type === 'push') && typeof destination === 'string' && !isNaN(statusCode);
|
|
36
|
+
}
|
|
37
|
+
const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
38
|
+
function isNotFoundError(error) {
|
|
39
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
43
|
+
}
|
|
8
44
|
/**
|
|
9
45
|
* Rethrow errors that should be handled by Next.js
|
|
10
46
|
*/ const rethrowNextErrors = (error)=>{
|
|
11
47
|
if (error.code === 'NOT_FOUND') {
|
|
12
|
-
|
|
48
|
+
nextNavigation__namespace.notFound();
|
|
13
49
|
}
|
|
14
50
|
if (error instanceof redirect.TRPCRedirectError) {
|
|
15
|
-
|
|
51
|
+
nextNavigation__namespace.redirect(...error.args);
|
|
16
52
|
}
|
|
17
53
|
const { cause } = error;
|
|
18
|
-
|
|
54
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
55
|
+
if ('unstable_rethrow' in nextNavigation__namespace && typeof nextNavigation__namespace.unstable_rethrow === 'function') {
|
|
56
|
+
nextNavigation__namespace.unstable_rethrow(cause);
|
|
57
|
+
}
|
|
58
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
59
|
+
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
19
60
|
throw error.cause;
|
|
20
61
|
}
|
|
21
62
|
};
|
|
@@ -1,18 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isRedirectError } from 'next/dist/client/components/redirect';
|
|
3
|
-
import { notFound, redirect } from 'next/navigation';
|
|
1
|
+
import * as nextNavigation from 'next/navigation';
|
|
4
2
|
import { TRPCRedirectError } from './redirect.mjs';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
6
|
+
* Inlining them here instead...
|
|
7
|
+
*/ const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
8
|
+
function isRedirectError(error) {
|
|
9
|
+
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
13
|
+
const statusCode = Number(status);
|
|
14
|
+
return errorCode === REDIRECT_ERROR_CODE && (type === 'replace' || type === 'push') && typeof destination === 'string' && !isNaN(statusCode);
|
|
15
|
+
}
|
|
16
|
+
const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
17
|
+
function isNotFoundError(error) {
|
|
18
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
22
|
+
}
|
|
6
23
|
/**
|
|
7
24
|
* Rethrow errors that should be handled by Next.js
|
|
8
25
|
*/ const rethrowNextErrors = (error)=>{
|
|
9
26
|
if (error.code === 'NOT_FOUND') {
|
|
10
|
-
notFound();
|
|
27
|
+
nextNavigation.notFound();
|
|
11
28
|
}
|
|
12
29
|
if (error instanceof TRPCRedirectError) {
|
|
13
|
-
redirect(...error.args);
|
|
30
|
+
nextNavigation.redirect(...error.args);
|
|
14
31
|
}
|
|
15
32
|
const { cause } = error;
|
|
33
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
34
|
+
if ('unstable_rethrow' in nextNavigation && typeof nextNavigation.unstable_rethrow === 'function') {
|
|
35
|
+
nextNavigation.unstable_rethrow(cause);
|
|
36
|
+
}
|
|
37
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
16
38
|
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
17
39
|
throw error.cause;
|
|
18
40
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 104173,
|
|
3
|
+
"bundleOrigSize": 152920,
|
|
4
|
+
"bundleReduction": 31.88,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/stream.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"/src/unstable-core-do-not-import.ts",
|
|
18
18
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
19
|
],
|
|
20
|
-
"percent":
|
|
20
|
+
"percent": 13.88,
|
|
21
21
|
"reduction": 9.37
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependents": [
|
|
33
33
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
34
34
|
],
|
|
35
|
-
"percent": 10.
|
|
35
|
+
"percent": 10.79,
|
|
36
36
|
"reduction": 0
|
|
37
37
|
},
|
|
38
38
|
{
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/unstable-core-do-not-import.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10.
|
|
49
|
+
"percent": 10.04,
|
|
50
50
|
"reduction": 4.19
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 6.
|
|
64
|
+
"percent": 6.07,
|
|
65
65
|
"reduction": 59.52
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
81
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
82
82
|
],
|
|
83
|
-
"percent": 5.
|
|
83
|
+
"percent": 5.75,
|
|
84
84
|
"reduction": 41.05
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"/src/unstable-core-do-not-import.ts",
|
|
96
96
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
97
97
|
],
|
|
98
|
-
"percent": 5.
|
|
98
|
+
"percent": 5.32,
|
|
99
99
|
"reduction": 0
|
|
100
100
|
},
|
|
101
101
|
{
|
|
@@ -109,13 +109,13 @@
|
|
|
109
109
|
"dependents": [
|
|
110
110
|
"/src/adapters/aws-lambda/index.ts"
|
|
111
111
|
],
|
|
112
|
-
"percent": 4.
|
|
112
|
+
"percent": 4.66,
|
|
113
113
|
"reduction": 13.62
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
117
117
|
"size": 3135,
|
|
118
|
-
"origSize":
|
|
118
|
+
"origSize": 4033,
|
|
119
119
|
"renderedExports": [
|
|
120
120
|
"nextAppDirCaller"
|
|
121
121
|
],
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
"dependents": [
|
|
124
124
|
"/src/adapters/next-app-dir.ts"
|
|
125
125
|
],
|
|
126
|
-
"percent": 3.
|
|
127
|
-
"reduction": 22.
|
|
126
|
+
"percent": 3.01,
|
|
127
|
+
"reduction": 22.27
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
130
|
"id": "/src/observable/observable.ts",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"/src/observable/index.ts",
|
|
141
141
|
"/src/observable/operators.ts"
|
|
142
142
|
],
|
|
143
|
-
"percent": 3
|
|
143
|
+
"percent": 3,
|
|
144
144
|
"reduction": 0.67
|
|
145
145
|
},
|
|
146
146
|
{
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"dependents": [
|
|
157
157
|
"/src/observable/index.ts"
|
|
158
158
|
],
|
|
159
|
-
"percent": 2.
|
|
159
|
+
"percent": 2.65,
|
|
160
160
|
"reduction": 0
|
|
161
161
|
},
|
|
162
162
|
{
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"/src/unstable-core-do-not-import/router.ts",
|
|
177
177
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
178
178
|
],
|
|
179
|
-
"percent": 2.
|
|
179
|
+
"percent": 2.63,
|
|
180
180
|
"reduction": 45.94
|
|
181
181
|
},
|
|
182
182
|
{
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"dependents": [
|
|
191
191
|
"/src/unstable-core-do-not-import.ts"
|
|
192
192
|
],
|
|
193
|
-
"percent": 2.
|
|
193
|
+
"percent": 2.6,
|
|
194
194
|
"reduction": 40.91
|
|
195
195
|
},
|
|
196
196
|
{
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
211
211
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
212
212
|
],
|
|
213
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.52,
|
|
214
214
|
"reduction": 55.5
|
|
215
215
|
},
|
|
216
216
|
{
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"dependents": [
|
|
225
225
|
"/src/adapters/fetch/index.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 2.
|
|
227
|
+
"percent": 2.16,
|
|
228
228
|
"reduction": 2.17
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"/src/adapters/node-http/index.ts",
|
|
240
240
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.09,
|
|
243
243
|
"reduction": 14.12
|
|
244
244
|
},
|
|
245
245
|
{
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
"/src/unstable-core-do-not-import.ts",
|
|
256
256
|
"/src/unstable-core-do-not-import/router.ts"
|
|
257
257
|
],
|
|
258
|
-
"percent": 1.
|
|
258
|
+
"percent": 1.92,
|
|
259
259
|
"reduction": 0
|
|
260
260
|
},
|
|
261
261
|
{
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
277
277
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
278
278
|
],
|
|
279
|
-
"percent": 1.
|
|
279
|
+
"percent": 1.66,
|
|
280
280
|
"reduction": 19.47
|
|
281
281
|
},
|
|
282
282
|
{
|
|
@@ -290,9 +290,23 @@
|
|
|
290
290
|
"dependents": [
|
|
291
291
|
"/src/adapters/node-http/index.ts"
|
|
292
292
|
],
|
|
293
|
-
"percent": 1.
|
|
293
|
+
"percent": 1.65,
|
|
294
294
|
"reduction": 20.03
|
|
295
295
|
},
|
|
296
|
+
{
|
|
297
|
+
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
298
|
+
"size": 1626,
|
|
299
|
+
"origSize": 1749,
|
|
300
|
+
"renderedExports": [
|
|
301
|
+
"rethrowNextErrors"
|
|
302
|
+
],
|
|
303
|
+
"removedExports": [],
|
|
304
|
+
"dependents": [
|
|
305
|
+
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
306
|
+
],
|
|
307
|
+
"percent": 1.56,
|
|
308
|
+
"reduction": 7.03
|
|
309
|
+
},
|
|
296
310
|
{
|
|
297
311
|
"id": "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
298
312
|
"size": 1580,
|
|
@@ -302,7 +316,7 @@
|
|
|
302
316
|
],
|
|
303
317
|
"removedExports": [],
|
|
304
318
|
"dependents": [],
|
|
305
|
-
"percent": 1.
|
|
319
|
+
"percent": 1.52,
|
|
306
320
|
"reduction": 21.04
|
|
307
321
|
},
|
|
308
322
|
{
|
|
@@ -314,7 +328,7 @@
|
|
|
314
328
|
],
|
|
315
329
|
"removedExports": [],
|
|
316
330
|
"dependents": [],
|
|
317
|
-
"percent": 1.
|
|
331
|
+
"percent": 1.48,
|
|
318
332
|
"reduction": 26.94
|
|
319
333
|
},
|
|
320
334
|
{
|
|
@@ -327,7 +341,7 @@
|
|
|
327
341
|
],
|
|
328
342
|
"removedExports": [],
|
|
329
343
|
"dependents": [],
|
|
330
|
-
"percent": 1.
|
|
344
|
+
"percent": 1.46,
|
|
331
345
|
"reduction": 27.6
|
|
332
346
|
},
|
|
333
347
|
{
|
|
@@ -341,7 +355,7 @@
|
|
|
341
355
|
"dependents": [
|
|
342
356
|
"/src/adapters/fastify/index.ts"
|
|
343
357
|
],
|
|
344
|
-
"percent": 1.
|
|
358
|
+
"percent": 1.44,
|
|
345
359
|
"reduction": 34.7
|
|
346
360
|
},
|
|
347
361
|
{
|
|
@@ -358,28 +372,13 @@
|
|
|
358
372
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
359
373
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
360
374
|
],
|
|
361
|
-
"percent": 1.
|
|
375
|
+
"percent": 1.22,
|
|
362
376
|
"reduction": 23.5
|
|
363
377
|
},
|
|
364
|
-
{
|
|
365
|
-
"id": "/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
366
|
-
"size": 1132,
|
|
367
|
-
"origSize": 2160,
|
|
368
|
-
"renderedExports": [
|
|
369
|
-
"fastifyRequestHandler"
|
|
370
|
-
],
|
|
371
|
-
"removedExports": [],
|
|
372
|
-
"dependents": [
|
|
373
|
-
"/src/adapters/fastify/index.ts",
|
|
374
|
-
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
375
|
-
],
|
|
376
|
-
"percent": 1.1,
|
|
377
|
-
"reduction": 47.59
|
|
378
|
-
},
|
|
379
378
|
{
|
|
380
379
|
"id": "/src/unstable-core-do-not-import/utils.ts",
|
|
381
|
-
"size":
|
|
382
|
-
"origSize":
|
|
380
|
+
"size": 1152,
|
|
381
|
+
"origSize": 1581,
|
|
383
382
|
"renderedExports": [
|
|
384
383
|
"unsetMarker",
|
|
385
384
|
"mergeWithoutOverrides",
|
|
@@ -401,8 +400,23 @@
|
|
|
401
400
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
402
401
|
"/src/unstable-core-do-not-import/stream/stream.ts"
|
|
403
402
|
],
|
|
404
|
-
"percent": 1.
|
|
405
|
-
"reduction":
|
|
403
|
+
"percent": 1.11,
|
|
404
|
+
"reduction": 27.13
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"id": "/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
408
|
+
"size": 1132,
|
|
409
|
+
"origSize": 2160,
|
|
410
|
+
"renderedExports": [
|
|
411
|
+
"fastifyRequestHandler"
|
|
412
|
+
],
|
|
413
|
+
"removedExports": [],
|
|
414
|
+
"dependents": [
|
|
415
|
+
"/src/adapters/fastify/index.ts",
|
|
416
|
+
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
417
|
+
],
|
|
418
|
+
"percent": 1.09,
|
|
419
|
+
"reduction": 47.59
|
|
406
420
|
},
|
|
407
421
|
{
|
|
408
422
|
"id": "/src/unstable-core-do-not-import/parser.ts",
|
|
@@ -416,7 +430,7 @@
|
|
|
416
430
|
"/src/unstable-core-do-not-import.ts",
|
|
417
431
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
418
432
|
],
|
|
419
|
-
"percent": 0.
|
|
433
|
+
"percent": 0.95,
|
|
420
434
|
"reduction": 56.22
|
|
421
435
|
},
|
|
422
436
|
{
|
|
@@ -433,7 +447,7 @@
|
|
|
433
447
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
434
448
|
"/src/adapters/next-app-dir/rethrowNextErrors.ts"
|
|
435
449
|
],
|
|
436
|
-
"percent": 0.
|
|
450
|
+
"percent": 0.95,
|
|
437
451
|
"reduction": 13.65
|
|
438
452
|
},
|
|
439
453
|
{
|
|
@@ -447,7 +461,7 @@
|
|
|
447
461
|
"dependents": [
|
|
448
462
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
449
463
|
],
|
|
450
|
-
"percent": 0.
|
|
464
|
+
"percent": 0.79,
|
|
451
465
|
"reduction": 0.97
|
|
452
466
|
},
|
|
453
467
|
{
|
|
@@ -459,7 +473,7 @@
|
|
|
459
473
|
],
|
|
460
474
|
"removedExports": [],
|
|
461
475
|
"dependents": [],
|
|
462
|
-
"percent": 0.
|
|
476
|
+
"percent": 0.73,
|
|
463
477
|
"reduction": 66.9
|
|
464
478
|
},
|
|
465
479
|
{
|
|
@@ -473,7 +487,7 @@
|
|
|
473
487
|
"dependents": [
|
|
474
488
|
"/src/unstable-core-do-not-import.ts"
|
|
475
489
|
],
|
|
476
|
-
"percent": 0.
|
|
490
|
+
"percent": 0.64,
|
|
477
491
|
"reduction": 0.6
|
|
478
492
|
},
|
|
479
493
|
{
|
|
@@ -488,7 +502,7 @@
|
|
|
488
502
|
"/src/unstable-core-do-not-import.ts",
|
|
489
503
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
490
504
|
],
|
|
491
|
-
"percent": 0.
|
|
505
|
+
"percent": 0.6,
|
|
492
506
|
"reduction": 43.49
|
|
493
507
|
},
|
|
494
508
|
{
|
|
@@ -501,23 +515,9 @@
|
|
|
501
515
|
],
|
|
502
516
|
"removedExports": [],
|
|
503
517
|
"dependents": [],
|
|
504
|
-
"percent": 0.
|
|
518
|
+
"percent": 0.5,
|
|
505
519
|
"reduction": 67.09
|
|
506
520
|
},
|
|
507
|
-
{
|
|
508
|
-
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
509
|
-
"size": 422,
|
|
510
|
-
"origSize": 704,
|
|
511
|
-
"renderedExports": [
|
|
512
|
-
"rethrowNextErrors"
|
|
513
|
-
],
|
|
514
|
-
"removedExports": [],
|
|
515
|
-
"dependents": [
|
|
516
|
-
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
517
|
-
],
|
|
518
|
-
"percent": 0.41,
|
|
519
|
-
"reduction": 40.06
|
|
520
|
-
},
|
|
521
521
|
{
|
|
522
522
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
523
523
|
"size": 343,
|
|
@@ -705,24 +705,19 @@
|
|
|
705
705
|
"reduction": 100
|
|
706
706
|
},
|
|
707
707
|
{
|
|
708
|
-
"id": "/src/adapters/
|
|
708
|
+
"id": "/src/adapters/fastify/index.ts",
|
|
709
709
|
"size": 0,
|
|
710
|
-
"origSize":
|
|
710
|
+
"origSize": 78,
|
|
711
711
|
"renderedExports": [],
|
|
712
712
|
"removedExports": [],
|
|
713
|
-
"dependents": [
|
|
714
|
-
"/src/adapters/express.ts",
|
|
715
|
-
"/src/adapters/standalone.ts",
|
|
716
|
-
"/src/adapters/next.ts",
|
|
717
|
-
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
718
|
-
],
|
|
713
|
+
"dependents": [],
|
|
719
714
|
"percent": 0,
|
|
720
715
|
"reduction": 100
|
|
721
716
|
},
|
|
722
717
|
{
|
|
723
|
-
"id": "/src/adapters/
|
|
718
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
724
719
|
"size": 0,
|
|
725
|
-
"origSize":
|
|
720
|
+
"origSize": 64,
|
|
726
721
|
"renderedExports": [],
|
|
727
722
|
"removedExports": [],
|
|
728
723
|
"dependents": [],
|
|
@@ -730,12 +725,17 @@
|
|
|
730
725
|
"reduction": 100
|
|
731
726
|
},
|
|
732
727
|
{
|
|
733
|
-
"id": "/src/adapters/
|
|
728
|
+
"id": "/src/adapters/node-http/index.ts",
|
|
734
729
|
"size": 0,
|
|
735
|
-
"origSize":
|
|
730
|
+
"origSize": 111,
|
|
736
731
|
"renderedExports": [],
|
|
737
732
|
"removedExports": [],
|
|
738
|
-
"dependents": [
|
|
733
|
+
"dependents": [
|
|
734
|
+
"/src/adapters/express.ts",
|
|
735
|
+
"/src/adapters/next.ts",
|
|
736
|
+
"/src/adapters/standalone.ts",
|
|
737
|
+
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
738
|
+
],
|
|
739
739
|
"percent": 0,
|
|
740
740
|
"reduction": 100
|
|
741
741
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;AACxE,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,KAAK,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;AACxE,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,KAAK,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN;AAKD,wBAAgB,eAAe,CAAC,MAAM,EACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,aAAa,CAAC,MAAM,CAAC,CAIhC"}
|
|
@@ -31,8 +31,9 @@ function isFunction(fn) {
|
|
|
31
31
|
*/ function omitPrototype(obj) {
|
|
32
32
|
return Object.assign(Object.create(null), obj);
|
|
33
33
|
}
|
|
34
|
+
const asyncIteratorsSupported = typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
34
35
|
function isAsyncIterable(value) {
|
|
35
|
-
return isObject(value) && Symbol.asyncIterator in value;
|
|
36
|
+
return asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
exports.isAsyncIterable = isAsyncIterable;
|
|
@@ -29,8 +29,9 @@ function isFunction(fn) {
|
|
|
29
29
|
*/ function omitPrototype(obj) {
|
|
30
30
|
return Object.assign(Object.create(null), obj);
|
|
31
31
|
}
|
|
32
|
+
const asyncIteratorsSupported = typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
32
33
|
function isAsyncIterable(value) {
|
|
33
|
-
return isObject(value) && Symbol.asyncIterator in value;
|
|
34
|
+
return asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export { isAsyncIterable, isFunction, isObject, mergeWithoutOverrides, omitPrototype, unsetMarker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-
|
|
3
|
+
"version": "11.0.0-alpha-tmp-rethrow-next-errors.384+c8f03d0d8",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
119
|
"@fastify/websocket": "^10.0.1",
|
|
120
|
-
"@tanstack/react-query": "^5.
|
|
120
|
+
"@tanstack/react-query": "^5.25.0",
|
|
121
121
|
"@types/aws-lambda": "^8.10.137",
|
|
122
122
|
"@types/express": "^4.17.17",
|
|
123
123
|
"@types/hash-sum": "^1.0.0",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "c8f03d0d8fd891eccde7cf6d04dba5fa9db43329"
|
|
153
153
|
}
|
|
@@ -46,6 +46,7 @@ export function nextAppDirCaller<TContext, TMeta>(
|
|
|
46
46
|
const createContext = async (): Promise<TContext> => {
|
|
47
47
|
return config?.createContext?.() ?? ({} as TContext);
|
|
48
48
|
};
|
|
49
|
+
|
|
49
50
|
return async (opts) => {
|
|
50
51
|
const path =
|
|
51
52
|
config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';
|
|
@@ -1,24 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isRedirectError } from 'next/dist/client/components/redirect';
|
|
3
|
-
import {
|
|
4
|
-
notFound as __notFound,
|
|
5
|
-
redirect as __redirect,
|
|
6
|
-
} from 'next/navigation';
|
|
1
|
+
import * as nextNavigation from 'next/navigation';
|
|
7
2
|
import type { TRPCError } from '../../@trpc/server';
|
|
8
3
|
import { TRPCRedirectError } from './redirect';
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
|
-
*
|
|
6
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
7
|
+
* Inlining them here instead...
|
|
12
8
|
*/
|
|
9
|
+
const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
10
|
+
function isRedirectError(error: unknown) {
|
|
11
|
+
if (
|
|
12
|
+
typeof error !== 'object' ||
|
|
13
|
+
error === null ||
|
|
14
|
+
!('digest' in error) ||
|
|
15
|
+
typeof error.digest !== 'string'
|
|
16
|
+
) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
20
|
+
const statusCode = Number(status);
|
|
21
|
+
return (
|
|
22
|
+
errorCode === REDIRECT_ERROR_CODE &&
|
|
23
|
+
(type === 'replace' || type === 'push') &&
|
|
24
|
+
typeof destination === 'string' &&
|
|
25
|
+
!isNaN(statusCode)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
13
28
|
|
|
29
|
+
const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
30
|
+
function isNotFoundError(error: unknown) {
|
|
31
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Rethrow errors that should be handled by Next.js
|
|
39
|
+
*/
|
|
14
40
|
export const rethrowNextErrors = (error: TRPCError) => {
|
|
15
41
|
if (error.code === 'NOT_FOUND') {
|
|
16
|
-
|
|
42
|
+
nextNavigation.notFound();
|
|
17
43
|
}
|
|
18
44
|
if (error instanceof TRPCRedirectError) {
|
|
19
|
-
|
|
45
|
+
nextNavigation.redirect(...error.args);
|
|
20
46
|
}
|
|
21
47
|
const { cause } = error;
|
|
48
|
+
|
|
49
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
50
|
+
if (
|
|
51
|
+
'unstable_rethrow' in nextNavigation &&
|
|
52
|
+
typeof nextNavigation.unstable_rethrow === 'function'
|
|
53
|
+
) {
|
|
54
|
+
nextNavigation.unstable_rethrow(cause);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
22
58
|
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
23
59
|
throw error.cause;
|
|
24
60
|
}
|
|
@@ -46,8 +46,13 @@ export function omitPrototype<TObj extends Record<string, unknown>>(
|
|
|
46
46
|
return Object.assign(Object.create(null), obj);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const asyncIteratorsSupported =
|
|
50
|
+
typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
51
|
+
|
|
49
52
|
export function isAsyncIterable<TValue>(
|
|
50
53
|
value: unknown,
|
|
51
54
|
): value is AsyncIterable<TValue> {
|
|
52
|
-
return
|
|
55
|
+
return (
|
|
56
|
+
asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value
|
|
57
|
+
);
|
|
53
58
|
}
|