@trpc/server 11.0.0-rc.374 → 11.0.0-rc.377
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 +7 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +6 -3
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +6 -3
- package/dist/bundle-analysis.json +43 -43
- package/package.json +2 -2
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +10 -4
|
@@ -5,7 +5,13 @@ import type { MaybePromise, Simplify } from '../../unstable-core-do-not-import/t
|
|
|
5
5
|
/**
|
|
6
6
|
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
7
7
|
*/
|
|
8
|
-
export declare function nextAppDirCaller<TContext>(config: Simplify<{
|
|
8
|
+
export declare function nextAppDirCaller<TContext, TMeta>(config: Simplify<{
|
|
9
|
+
/**
|
|
10
|
+
* Extract the path from the procedure metadata
|
|
11
|
+
*/
|
|
12
|
+
pathExtractor?: (opts: {
|
|
13
|
+
meta: TMeta;
|
|
14
|
+
}) => string;
|
|
9
15
|
/**
|
|
10
16
|
* Transform form data to a `Record` before passing it to the procedure
|
|
11
17
|
* @default true
|
|
@@ -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,
|
|
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,CAwF1B"}
|
|
@@ -14,6 +14,9 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
14
14
|
return config?.createContext?.() ?? {};
|
|
15
15
|
};
|
|
16
16
|
return async (opts)=>{
|
|
17
|
+
const path = config.pathExtractor?.({
|
|
18
|
+
meta: opts._def.meta
|
|
19
|
+
}) ?? '';
|
|
17
20
|
const ctx = await createContext().catch((cause)=>{
|
|
18
21
|
const error = new TRPCError.TRPCError({
|
|
19
22
|
code: 'INTERNAL_SERVER_ERROR',
|
|
@@ -28,7 +31,7 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
28
31
|
ctx,
|
|
29
32
|
error,
|
|
30
33
|
input: opts.args[0],
|
|
31
|
-
path
|
|
34
|
+
path,
|
|
32
35
|
type: opts._def.type
|
|
33
36
|
});
|
|
34
37
|
rethrowNextErrors.rethrowNextErrors(error);
|
|
@@ -50,7 +53,7 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
50
53
|
type: opts._def.type,
|
|
51
54
|
ctx,
|
|
52
55
|
getRawInput: async ()=>input,
|
|
53
|
-
path
|
|
56
|
+
path,
|
|
54
57
|
input
|
|
55
58
|
}).then((data)=>{
|
|
56
59
|
if (data instanceof redirect.TRPCRedirectError) throw data;
|
|
@@ -64,7 +67,7 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
64
67
|
type: opts._def.type,
|
|
65
68
|
ctx,
|
|
66
69
|
getRawInput: async ()=>input1,
|
|
67
|
-
path
|
|
70
|
+
path,
|
|
68
71
|
input: input1
|
|
69
72
|
}).then((data)=>{
|
|
70
73
|
if (data instanceof redirect.TRPCRedirectError) throw data;
|
|
@@ -12,6 +12,9 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
12
12
|
return config?.createContext?.() ?? {};
|
|
13
13
|
};
|
|
14
14
|
return async (opts)=>{
|
|
15
|
+
const path = config.pathExtractor?.({
|
|
16
|
+
meta: opts._def.meta
|
|
17
|
+
}) ?? '';
|
|
15
18
|
const ctx = await createContext().catch((cause)=>{
|
|
16
19
|
const error = new TRPCError({
|
|
17
20
|
code: 'INTERNAL_SERVER_ERROR',
|
|
@@ -26,7 +29,7 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
26
29
|
ctx,
|
|
27
30
|
error,
|
|
28
31
|
input: opts.args[0],
|
|
29
|
-
path
|
|
32
|
+
path,
|
|
30
33
|
type: opts._def.type
|
|
31
34
|
});
|
|
32
35
|
rethrowNextErrors(error);
|
|
@@ -48,7 +51,7 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
48
51
|
type: opts._def.type,
|
|
49
52
|
ctx,
|
|
50
53
|
getRawInput: async ()=>input,
|
|
51
|
-
path
|
|
54
|
+
path,
|
|
52
55
|
input
|
|
53
56
|
}).then((data)=>{
|
|
54
57
|
if (data instanceof TRPCRedirectError) throw data;
|
|
@@ -62,7 +65,7 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
62
65
|
type: opts._def.type,
|
|
63
66
|
ctx,
|
|
64
67
|
getRawInput: async ()=>input1,
|
|
65
|
-
path
|
|
68
|
+
path,
|
|
66
69
|
input: input1
|
|
67
70
|
}).then((data)=>{
|
|
68
71
|
if (data instanceof TRPCRedirectError) throw data;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 32.
|
|
2
|
+
"bundleSize": 102854,
|
|
3
|
+
"bundleOrigSize": 151746,
|
|
4
|
+
"bundleReduction": 32.22,
|
|
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": 14.
|
|
20
|
+
"percent": 14.06,
|
|
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.93,
|
|
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.17,
|
|
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.15,
|
|
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.82,
|
|
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.39,
|
|
99
99
|
"reduction": 0
|
|
100
100
|
},
|
|
101
101
|
{
|
|
@@ -112,6 +112,20 @@
|
|
|
112
112
|
"percent": 4.72,
|
|
113
113
|
"reduction": 13.62
|
|
114
114
|
},
|
|
115
|
+
{
|
|
116
|
+
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
117
|
+
"size": 3135,
|
|
118
|
+
"origSize": 4032,
|
|
119
|
+
"renderedExports": [
|
|
120
|
+
"nextAppDirCaller"
|
|
121
|
+
],
|
|
122
|
+
"removedExports": [],
|
|
123
|
+
"dependents": [
|
|
124
|
+
"/src/adapters/next-app-dir.ts"
|
|
125
|
+
],
|
|
126
|
+
"percent": 3.05,
|
|
127
|
+
"reduction": 22.25
|
|
128
|
+
},
|
|
115
129
|
{
|
|
116
130
|
"id": "/src/observable/observable.ts",
|
|
117
131
|
"size": 3129,
|
|
@@ -129,20 +143,6 @@
|
|
|
129
143
|
"percent": 3.04,
|
|
130
144
|
"reduction": 0.67
|
|
131
145
|
},
|
|
132
|
-
{
|
|
133
|
-
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
134
|
-
"size": 3050,
|
|
135
|
-
"origSize": 3818,
|
|
136
|
-
"renderedExports": [
|
|
137
|
-
"nextAppDirCaller"
|
|
138
|
-
],
|
|
139
|
-
"removedExports": [],
|
|
140
|
-
"dependents": [
|
|
141
|
-
"/src/adapters/next-app-dir.ts"
|
|
142
|
-
],
|
|
143
|
-
"percent": 2.97,
|
|
144
|
-
"reduction": 20.12
|
|
145
|
-
},
|
|
146
146
|
{
|
|
147
147
|
"id": "/src/observable/operators.ts",
|
|
148
148
|
"size": 2756,
|
|
@@ -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.55,
|
|
214
214
|
"reduction": 55.5
|
|
215
215
|
},
|
|
216
216
|
{
|
|
@@ -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.94,
|
|
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.68,
|
|
280
280
|
"reduction": 19.47
|
|
281
281
|
},
|
|
282
282
|
{
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
"/src/unstable-core-do-not-import.ts",
|
|
417
417
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
418
418
|
],
|
|
419
|
-
"percent": 0.
|
|
419
|
+
"percent": 0.96,
|
|
420
420
|
"reduction": 56.22
|
|
421
421
|
},
|
|
422
422
|
{
|
|
@@ -570,7 +570,7 @@
|
|
|
570
570
|
"dependents": [
|
|
571
571
|
"/src/unstable-core-do-not-import.ts"
|
|
572
572
|
],
|
|
573
|
-
"percent": 0.
|
|
573
|
+
"percent": 0.21,
|
|
574
574
|
"reduction": 94.55
|
|
575
575
|
},
|
|
576
576
|
{
|
|
@@ -653,9 +653,9 @@
|
|
|
653
653
|
"reduction": 100
|
|
654
654
|
},
|
|
655
655
|
{
|
|
656
|
-
"id": "/src/
|
|
656
|
+
"id": "/src/shared.ts",
|
|
657
657
|
"size": 0,
|
|
658
|
-
"origSize":
|
|
658
|
+
"origSize": 653,
|
|
659
659
|
"renderedExports": [],
|
|
660
660
|
"removedExports": [],
|
|
661
661
|
"dependents": [],
|
|
@@ -663,9 +663,9 @@
|
|
|
663
663
|
"reduction": 100
|
|
664
664
|
},
|
|
665
665
|
{
|
|
666
|
-
"id": "/src/
|
|
666
|
+
"id": "/src/rpc.ts",
|
|
667
667
|
"size": 0,
|
|
668
|
-
"origSize":
|
|
668
|
+
"origSize": 36,
|
|
669
669
|
"renderedExports": [],
|
|
670
670
|
"removedExports": [],
|
|
671
671
|
"dependents": [],
|
|
@@ -715,27 +715,27 @@
|
|
|
715
715
|
"reduction": 100
|
|
716
716
|
},
|
|
717
717
|
{
|
|
718
|
-
"id": "/src/adapters/
|
|
718
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
719
719
|
"size": 0,
|
|
720
|
-
"origSize":
|
|
720
|
+
"origSize": 64,
|
|
721
721
|
"renderedExports": [],
|
|
722
722
|
"removedExports": [],
|
|
723
|
-
"dependents": [
|
|
724
|
-
"/src/adapters/express.ts",
|
|
725
|
-
"/src/adapters/standalone.ts",
|
|
726
|
-
"/src/adapters/next.ts",
|
|
727
|
-
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
728
|
-
],
|
|
723
|
+
"dependents": [],
|
|
729
724
|
"percent": 0,
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.377+4a672ddd6",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "4a672ddd64db2dafccecb0ef86a6443942afd917"
|
|
153
153
|
}
|
|
@@ -19,9 +19,13 @@ import { rethrowNextErrors } from './rethrowNextErrors';
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
21
21
|
*/
|
|
22
|
-
export function nextAppDirCaller<TContext>(
|
|
22
|
+
export function nextAppDirCaller<TContext, TMeta>(
|
|
23
23
|
config: Simplify<
|
|
24
24
|
{
|
|
25
|
+
/**
|
|
26
|
+
* Extract the path from the procedure metadata
|
|
27
|
+
*/
|
|
28
|
+
pathExtractor?: (opts: { meta: TMeta }) => string;
|
|
25
29
|
/**
|
|
26
30
|
* Transform form data to a `Record` before passing it to the procedure
|
|
27
31
|
* @default true
|
|
@@ -43,6 +47,8 @@ export function nextAppDirCaller<TContext>(
|
|
|
43
47
|
return config?.createContext?.() ?? ({} as TContext);
|
|
44
48
|
};
|
|
45
49
|
return async (opts) => {
|
|
50
|
+
const path =
|
|
51
|
+
config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';
|
|
46
52
|
const ctx: TContext = await createContext().catch((cause) => {
|
|
47
53
|
const error = new TRPCError({
|
|
48
54
|
code: 'INTERNAL_SERVER_ERROR',
|
|
@@ -60,7 +66,7 @@ export function nextAppDirCaller<TContext>(
|
|
|
60
66
|
ctx,
|
|
61
67
|
error,
|
|
62
68
|
input: opts.args[0],
|
|
63
|
-
path
|
|
69
|
+
path,
|
|
64
70
|
type: opts._def.type,
|
|
65
71
|
});
|
|
66
72
|
|
|
@@ -86,7 +92,7 @@ export function nextAppDirCaller<TContext>(
|
|
|
86
92
|
type: opts._def.type,
|
|
87
93
|
ctx,
|
|
88
94
|
getRawInput: async () => input,
|
|
89
|
-
path
|
|
95
|
+
path,
|
|
90
96
|
input,
|
|
91
97
|
})
|
|
92
98
|
.then((data) => {
|
|
@@ -102,7 +108,7 @@ export function nextAppDirCaller<TContext>(
|
|
|
102
108
|
type: opts._def.type,
|
|
103
109
|
ctx,
|
|
104
110
|
getRawInput: async () => input,
|
|
105
|
-
path
|
|
111
|
+
path,
|
|
106
112
|
input,
|
|
107
113
|
})
|
|
108
114
|
.then((data) => {
|