@trpc/server 11.0.0-rc.403 → 11.0.0-rc.417
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/getPlanner.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.js +19 -2
- package/dist/adapters/aws-lambda/getPlanner.mjs +19 -2
- package/dist/bundle-analysis.json +69 -69
- package/dist/unstable-core-do-not-import/createProxy.d.ts +1 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +8 -6
- package/dist/unstable-core-do-not-import/createProxy.mjs +8 -6
- package/dist/unstable-core-do-not-import/router.js +1 -2
- package/dist/unstable-core-do-not-import/router.mjs +1 -2
- package/package.json +3 -3
- package/src/adapters/aws-lambda/getPlanner.ts +21 -2
- package/src/unstable-core-do-not-import/createProxy.ts +13 -6
- package/src/unstable-core-do-not-import/router.ts +34 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACrC,iCAAiC,GACjC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACrC,iCAAiC,GACjC,KAAK,CAAC;AA6IV,wBAAgB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,KAAK,EAAE,MAAM;;;;EAoCnE"}
|
|
@@ -11,6 +11,15 @@ function determinePayloadFormat(event) {
|
|
|
11
11
|
return unknownEvent.version;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
function getHeadersAndCookiesFromResponse(response) {
|
|
15
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
16
|
+
const cookies = response.headers.getSetCookie().flatMap((value)=>value.split(',')).map((cookie)=>cookie.trim());
|
|
17
|
+
delete headers['set-cookie'];
|
|
18
|
+
return {
|
|
19
|
+
headers,
|
|
20
|
+
cookies
|
|
21
|
+
};
|
|
22
|
+
}
|
|
14
23
|
const v1Processor = {
|
|
15
24
|
// same as getPath above
|
|
16
25
|
getTRPCPath: (event)=>{
|
|
@@ -59,10 +68,16 @@ const v1Processor = {
|
|
|
59
68
|
},
|
|
60
69
|
getMethod: (event)=>event.httpMethod,
|
|
61
70
|
toResult: async (response)=>{
|
|
71
|
+
const { headers , cookies } = getHeadersAndCookiesFromResponse(response);
|
|
62
72
|
const result = {
|
|
73
|
+
...cookies.length && {
|
|
74
|
+
multiValueHeaders: {
|
|
75
|
+
'set-cookie': cookies
|
|
76
|
+
}
|
|
77
|
+
},
|
|
63
78
|
statusCode: response.status,
|
|
64
79
|
body: await response.text(),
|
|
65
|
-
headers
|
|
80
|
+
headers
|
|
66
81
|
};
|
|
67
82
|
return result;
|
|
68
83
|
}
|
|
@@ -100,10 +115,12 @@ const v2Processor = {
|
|
|
100
115
|
},
|
|
101
116
|
getMethod: (event)=>event.requestContext.http.method,
|
|
102
117
|
toResult: async (response)=>{
|
|
118
|
+
const { headers , cookies } = getHeadersAndCookiesFromResponse(response);
|
|
103
119
|
const result = {
|
|
120
|
+
cookies,
|
|
104
121
|
statusCode: response.status,
|
|
105
122
|
body: await response.text(),
|
|
106
|
-
headers
|
|
123
|
+
headers
|
|
107
124
|
};
|
|
108
125
|
return result;
|
|
109
126
|
}
|
|
@@ -9,6 +9,15 @@ function determinePayloadFormat(event) {
|
|
|
9
9
|
return unknownEvent.version;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
function getHeadersAndCookiesFromResponse(response) {
|
|
13
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
14
|
+
const cookies = response.headers.getSetCookie().flatMap((value)=>value.split(',')).map((cookie)=>cookie.trim());
|
|
15
|
+
delete headers['set-cookie'];
|
|
16
|
+
return {
|
|
17
|
+
headers,
|
|
18
|
+
cookies
|
|
19
|
+
};
|
|
20
|
+
}
|
|
12
21
|
const v1Processor = {
|
|
13
22
|
// same as getPath above
|
|
14
23
|
getTRPCPath: (event)=>{
|
|
@@ -57,10 +66,16 @@ const v1Processor = {
|
|
|
57
66
|
},
|
|
58
67
|
getMethod: (event)=>event.httpMethod,
|
|
59
68
|
toResult: async (response)=>{
|
|
69
|
+
const { headers , cookies } = getHeadersAndCookiesFromResponse(response);
|
|
60
70
|
const result = {
|
|
71
|
+
...cookies.length && {
|
|
72
|
+
multiValueHeaders: {
|
|
73
|
+
'set-cookie': cookies
|
|
74
|
+
}
|
|
75
|
+
},
|
|
61
76
|
statusCode: response.status,
|
|
62
77
|
body: await response.text(),
|
|
63
|
-
headers
|
|
78
|
+
headers
|
|
64
79
|
};
|
|
65
80
|
return result;
|
|
66
81
|
}
|
|
@@ -98,10 +113,12 @@ const v2Processor = {
|
|
|
98
113
|
},
|
|
99
114
|
getMethod: (event)=>event.requestContext.http.method,
|
|
100
115
|
toResult: async (response)=>{
|
|
116
|
+
const { headers , cookies } = getHeadersAndCookiesFromResponse(response);
|
|
101
117
|
const result = {
|
|
118
|
+
cookies,
|
|
102
119
|
statusCode: response.status,
|
|
103
120
|
body: await response.text(),
|
|
104
|
-
headers
|
|
121
|
+
headers
|
|
105
122
|
};
|
|
106
123
|
return result;
|
|
107
124
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 31.
|
|
2
|
+
"bundleSize": 106303,
|
|
3
|
+
"bundleOrigSize": 154983,
|
|
4
|
+
"bundleReduction": 31.41,
|
|
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.04,
|
|
21
21
|
"reduction": 8.44
|
|
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.57,
|
|
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.21,
|
|
50
50
|
"reduction": 3.08
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 5.
|
|
64
|
+
"percent": 5.95,
|
|
65
65
|
"reduction": 59.52
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
69
|
-
"size":
|
|
70
|
-
"origSize":
|
|
69
|
+
"size": 6069,
|
|
70
|
+
"origSize": 10288,
|
|
71
71
|
"renderedExports": [
|
|
72
72
|
"createRouterFactory",
|
|
73
73
|
"callProcedure",
|
|
@@ -80,8 +80,8 @@
|
|
|
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.
|
|
84
|
-
"reduction":
|
|
83
|
+
"percent": 5.71,
|
|
84
|
+
"reduction": 41.01
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
"id": "/src/unstable-core-do-not-import/http/contentType.ts",
|
|
@@ -95,13 +95,13 @@
|
|
|
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.22,
|
|
99
99
|
"reduction": 0
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"id": "/src/adapters/aws-lambda/getPlanner.ts",
|
|
103
|
-
"size":
|
|
104
|
-
"origSize":
|
|
103
|
+
"size": 5418,
|
|
104
|
+
"origSize": 6114,
|
|
105
105
|
"renderedExports": [
|
|
106
106
|
"getPlanner"
|
|
107
107
|
],
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
"dependents": [
|
|
110
110
|
"/src/adapters/aws-lambda/index.ts"
|
|
111
111
|
],
|
|
112
|
-
"percent":
|
|
113
|
-
"reduction":
|
|
112
|
+
"percent": 5.1,
|
|
113
|
+
"reduction": 11.38
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"dependents": [
|
|
124
124
|
"/src/adapters/next-app-dir.ts"
|
|
125
125
|
],
|
|
126
|
-
"percent": 2.
|
|
126
|
+
"percent": 2.95,
|
|
127
127
|
"reduction": 22.27
|
|
128
128
|
},
|
|
129
129
|
{
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"/src/observable/index.ts",
|
|
141
141
|
"/src/observable/operators.ts"
|
|
142
142
|
],
|
|
143
|
-
"percent": 2.
|
|
143
|
+
"percent": 2.94,
|
|
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.59,
|
|
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.58,
|
|
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.54,
|
|
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.47,
|
|
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.12,
|
|
228
228
|
"reduction": 2.17
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -239,38 +239,38 @@
|
|
|
239
239
|
"/src/adapters/node-http/index.ts",
|
|
240
240
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.05,
|
|
243
243
|
"reduction": 14.12
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
|
-
"id": "/src/
|
|
247
|
-
"size":
|
|
248
|
-
"origSize":
|
|
246
|
+
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
247
|
+
"size": 2155,
|
|
248
|
+
"origSize": 2067,
|
|
249
249
|
"renderedExports": [
|
|
250
|
-
"
|
|
250
|
+
"createRecursiveProxy",
|
|
251
|
+
"createFlatProxy"
|
|
251
252
|
],
|
|
252
253
|
"removedExports": [],
|
|
253
254
|
"dependents": [
|
|
254
|
-
"/src/
|
|
255
|
+
"/src/unstable-core-do-not-import.ts",
|
|
256
|
+
"/src/unstable-core-do-not-import/router.ts"
|
|
255
257
|
],
|
|
256
|
-
"percent":
|
|
257
|
-
"reduction":
|
|
258
|
+
"percent": 2.03,
|
|
259
|
+
"reduction": 0
|
|
258
260
|
},
|
|
259
261
|
{
|
|
260
|
-
"id": "/src/
|
|
261
|
-
"size":
|
|
262
|
-
"origSize":
|
|
262
|
+
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
263
|
+
"size": 2050,
|
|
264
|
+
"origSize": 2176,
|
|
263
265
|
"renderedExports": [
|
|
264
|
-
"
|
|
265
|
-
"createFlatProxy"
|
|
266
|
+
"rethrowNextErrors"
|
|
266
267
|
],
|
|
267
268
|
"removedExports": [],
|
|
268
269
|
"dependents": [
|
|
269
|
-
"/src/
|
|
270
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
270
|
+
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
271
271
|
],
|
|
272
|
-
"percent": 1.
|
|
273
|
-
"reduction":
|
|
272
|
+
"percent": 1.93,
|
|
273
|
+
"reduction": 5.79
|
|
274
274
|
},
|
|
275
275
|
{
|
|
276
276
|
"id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
291
291
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
292
292
|
],
|
|
293
|
-
"percent": 1.
|
|
293
|
+
"percent": 1.63,
|
|
294
294
|
"reduction": 19.47
|
|
295
295
|
},
|
|
296
296
|
{
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
"dependents": [
|
|
305
305
|
"/src/adapters/node-http/index.ts"
|
|
306
306
|
],
|
|
307
|
-
"percent": 1.
|
|
307
|
+
"percent": 1.62,
|
|
308
308
|
"reduction": 20.03
|
|
309
309
|
},
|
|
310
310
|
{
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
],
|
|
317
317
|
"removedExports": [],
|
|
318
318
|
"dependents": [],
|
|
319
|
-
"percent": 1.
|
|
319
|
+
"percent": 1.49,
|
|
320
320
|
"reduction": 21.04
|
|
321
321
|
},
|
|
322
322
|
{
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
],
|
|
329
329
|
"removedExports": [],
|
|
330
330
|
"dependents": [],
|
|
331
|
-
"percent": 1.
|
|
331
|
+
"percent": 1.45,
|
|
332
332
|
"reduction": 26.94
|
|
333
333
|
},
|
|
334
334
|
{
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
],
|
|
342
342
|
"removedExports": [],
|
|
343
343
|
"dependents": [],
|
|
344
|
-
"percent": 1.
|
|
344
|
+
"percent": 1.43,
|
|
345
345
|
"reduction": 27.6
|
|
346
346
|
},
|
|
347
347
|
{
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
"dependents": [
|
|
356
356
|
"/src/adapters/fastify/index.ts"
|
|
357
357
|
],
|
|
358
|
-
"percent": 1.
|
|
358
|
+
"percent": 1.41,
|
|
359
359
|
"reduction": 34.7
|
|
360
360
|
},
|
|
361
361
|
{
|
|
@@ -372,7 +372,7 @@
|
|
|
372
372
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
373
373
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
374
374
|
],
|
|
375
|
-
"percent": 1.
|
|
375
|
+
"percent": 1.19,
|
|
376
376
|
"reduction": 23.5
|
|
377
377
|
},
|
|
378
378
|
{
|
|
@@ -391,16 +391,16 @@
|
|
|
391
391
|
"dependents": [
|
|
392
392
|
"/src/unstable-core-do-not-import.ts",
|
|
393
393
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
394
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
395
394
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
396
395
|
"/src/unstable-core-do-not-import/router.ts",
|
|
397
396
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
398
397
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
398
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
399
399
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
400
400
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
401
401
|
"/src/unstable-core-do-not-import/stream/stream.ts"
|
|
402
402
|
],
|
|
403
|
-
"percent": 1.
|
|
403
|
+
"percent": 1.08,
|
|
404
404
|
"reduction": 27.13
|
|
405
405
|
},
|
|
406
406
|
{
|
|
@@ -415,7 +415,7 @@
|
|
|
415
415
|
"/src/adapters/fastify/index.ts",
|
|
416
416
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
417
417
|
],
|
|
418
|
-
"percent": 1.
|
|
418
|
+
"percent": 1.06,
|
|
419
419
|
"reduction": 47.59
|
|
420
420
|
},
|
|
421
421
|
{
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
"/src/unstable-core-do-not-import.ts",
|
|
431
431
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
432
432
|
],
|
|
433
|
-
"percent": 0.
|
|
433
|
+
"percent": 0.97,
|
|
434
434
|
"reduction": 58.57
|
|
435
435
|
},
|
|
436
436
|
{
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
],
|
|
474
474
|
"removedExports": [],
|
|
475
475
|
"dependents": [],
|
|
476
|
-
"percent": 0.
|
|
476
|
+
"percent": 0.71,
|
|
477
477
|
"reduction": 66.9
|
|
478
478
|
},
|
|
479
479
|
{
|
|
@@ -542,7 +542,7 @@
|
|
|
542
542
|
],
|
|
543
543
|
"removedExports": [],
|
|
544
544
|
"dependents": [],
|
|
545
|
-
"percent": 0.
|
|
545
|
+
"percent": 0.26,
|
|
546
546
|
"reduction": 72.92
|
|
547
547
|
},
|
|
548
548
|
{
|
|
@@ -643,9 +643,9 @@
|
|
|
643
643
|
"reduction": 100
|
|
644
644
|
},
|
|
645
645
|
{
|
|
646
|
-
"id": "/src/
|
|
646
|
+
"id": "/src/index.ts",
|
|
647
647
|
"size": 0,
|
|
648
|
-
"origSize":
|
|
648
|
+
"origSize": 32,
|
|
649
649
|
"renderedExports": [],
|
|
650
650
|
"removedExports": [],
|
|
651
651
|
"dependents": [],
|
|
@@ -653,9 +653,9 @@
|
|
|
653
653
|
"reduction": 100
|
|
654
654
|
},
|
|
655
655
|
{
|
|
656
|
-
"id": "/src/
|
|
656
|
+
"id": "/src/rpc.ts",
|
|
657
657
|
"size": 0,
|
|
658
|
-
"origSize":
|
|
658
|
+
"origSize": 36,
|
|
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/shared.ts",
|
|
667
667
|
"size": 0,
|
|
668
|
-
"origSize":
|
|
668
|
+
"origSize": 653,
|
|
669
669
|
"renderedExports": [],
|
|
670
670
|
"removedExports": [],
|
|
671
671
|
"dependents": [],
|
|
@@ -714,6 +714,16 @@
|
|
|
714
714
|
"percent": 0,
|
|
715
715
|
"reduction": 100
|
|
716
716
|
},
|
|
717
|
+
{
|
|
718
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
719
|
+
"size": 0,
|
|
720
|
+
"origSize": 64,
|
|
721
|
+
"renderedExports": [],
|
|
722
|
+
"removedExports": [],
|
|
723
|
+
"dependents": [],
|
|
724
|
+
"percent": 0,
|
|
725
|
+
"reduction": 100
|
|
726
|
+
},
|
|
717
727
|
{
|
|
718
728
|
"id": "/src/adapters/node-http/index.ts",
|
|
719
729
|
"size": 0,
|
|
@@ -728,16 +738,6 @@
|
|
|
728
738
|
],
|
|
729
739
|
"percent": 0,
|
|
730
740
|
"reduction": 100
|
|
731
|
-
},
|
|
732
|
-
{
|
|
733
|
-
"id": "/src/adapters/fetch/index.ts",
|
|
734
|
-
"size": 0,
|
|
735
|
-
"origSize": 64,
|
|
736
|
-
"renderedExports": [],
|
|
737
|
-
"removedExports": [],
|
|
738
|
-
"dependents": [],
|
|
739
|
-
"percent": 0,
|
|
740
|
-
"reduction": 100
|
|
741
741
|
}
|
|
742
742
|
],
|
|
743
743
|
"moduleCount": 51
|
|
@@ -8,7 +8,7 @@ type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
|
8
8
|
*
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export declare const createRecursiveProxy: (callback: ProxyCallback) =>
|
|
11
|
+
export declare const createRecursiveProxy: <TFaux = unknown>(callback: ProxyCallback) => TFaux;
|
|
12
12
|
/**
|
|
13
13
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
14
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AA6C7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,8BACrB,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,2BACT,MAAM,GAAG,MAAM,KAAK,KAAK,GAAG,KAC5C,KAWF,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _cache, _cacheKey;
|
|
3
4
|
const noop = ()=>{
|
|
4
5
|
// noop
|
|
5
6
|
};
|
|
6
|
-
function createInnerProxy(callback, path) {
|
|
7
|
-
const
|
|
7
|
+
function createInnerProxy(callback, path, cache) {
|
|
8
|
+
const cacheKey = path.join('.');
|
|
9
|
+
(_cache = cache)[_cacheKey = cacheKey] ?? (_cache[_cacheKey] = new Proxy(noop, {
|
|
8
10
|
get (_obj, key) {
|
|
9
11
|
if (typeof key !== 'string' || key === 'then') {
|
|
10
12
|
// special case for if the proxy is accidentally treated
|
|
@@ -14,7 +16,7 @@ function createInnerProxy(callback, path) {
|
|
|
14
16
|
return createInnerProxy(callback, [
|
|
15
17
|
...path,
|
|
16
18
|
key
|
|
17
|
-
]);
|
|
19
|
+
], cache);
|
|
18
20
|
},
|
|
19
21
|
apply (_1, _2, args) {
|
|
20
22
|
const lastOfPath = path[path.length - 1];
|
|
@@ -38,14 +40,14 @@ function createInnerProxy(callback, path) {
|
|
|
38
40
|
}
|
|
39
41
|
return callback(opts);
|
|
40
42
|
}
|
|
41
|
-
});
|
|
42
|
-
return
|
|
43
|
+
}));
|
|
44
|
+
return cache[cacheKey];
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Creates a proxy that calls the callback with the path and arguments
|
|
46
48
|
*
|
|
47
49
|
* @internal
|
|
48
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
50
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
|
|
49
51
|
/**
|
|
50
52
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
51
53
|
*
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
var _cache, _cacheKey;
|
|
1
2
|
const noop = ()=>{
|
|
2
3
|
// noop
|
|
3
4
|
};
|
|
4
|
-
function createInnerProxy(callback, path) {
|
|
5
|
-
const
|
|
5
|
+
function createInnerProxy(callback, path, cache) {
|
|
6
|
+
const cacheKey = path.join('.');
|
|
7
|
+
(_cache = cache)[_cacheKey = cacheKey] ?? (_cache[_cacheKey] = new Proxy(noop, {
|
|
6
8
|
get (_obj, key) {
|
|
7
9
|
if (typeof key !== 'string' || key === 'then') {
|
|
8
10
|
// special case for if the proxy is accidentally treated
|
|
@@ -12,7 +14,7 @@ function createInnerProxy(callback, path) {
|
|
|
12
14
|
return createInnerProxy(callback, [
|
|
13
15
|
...path,
|
|
14
16
|
key
|
|
15
|
-
]);
|
|
17
|
+
], cache);
|
|
16
18
|
},
|
|
17
19
|
apply (_1, _2, args) {
|
|
18
20
|
const lastOfPath = path[path.length - 1];
|
|
@@ -36,14 +38,14 @@ function createInnerProxy(callback, path) {
|
|
|
36
38
|
}
|
|
37
39
|
return callback(opts);
|
|
38
40
|
}
|
|
39
|
-
});
|
|
40
|
-
return
|
|
41
|
+
}));
|
|
42
|
+
return cache[cacheKey];
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* Creates a proxy that calls the callback with the path and arguments
|
|
44
46
|
*
|
|
45
47
|
* @internal
|
|
46
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
48
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
|
|
47
49
|
/**
|
|
48
50
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
49
51
|
*
|
|
@@ -108,7 +108,7 @@ function createCallerFactory() {
|
|
|
108
108
|
return function createCallerInner(router) {
|
|
109
109
|
const _def = router._def;
|
|
110
110
|
return function createCaller(ctxOrCallback, options) {
|
|
111
|
-
|
|
111
|
+
return createProxy.createRecursiveProxy(async ({ path , args })=>{
|
|
112
112
|
const fullPath = path.join('.');
|
|
113
113
|
if (path.length === 1 && path[0] === '_def') {
|
|
114
114
|
return _def;
|
|
@@ -134,7 +134,6 @@ function createCallerFactory() {
|
|
|
134
134
|
throw cause;
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
|
-
return proxy;
|
|
138
137
|
};
|
|
139
138
|
};
|
|
140
139
|
}
|
|
@@ -106,7 +106,7 @@ function createCallerFactory() {
|
|
|
106
106
|
return function createCallerInner(router) {
|
|
107
107
|
const _def = router._def;
|
|
108
108
|
return function createCaller(ctxOrCallback, options) {
|
|
109
|
-
|
|
109
|
+
return createRecursiveProxy(async ({ path , args })=>{
|
|
110
110
|
const fullPath = path.join('.');
|
|
111
111
|
if (path.length === 1 && path[0] === '_def') {
|
|
112
112
|
return _def;
|
|
@@ -132,7 +132,6 @@ function createCallerFactory() {
|
|
|
132
132
|
throw cause;
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
|
-
return proxy;
|
|
136
135
|
};
|
|
137
136
|
};
|
|
138
137
|
}
|
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.417+94650c185",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"tslib": "^2.5.0",
|
|
142
142
|
"tsx": "^4.0.0",
|
|
143
143
|
"typescript": "^5.4.0",
|
|
144
|
-
"valibot": "^0.
|
|
144
|
+
"valibot": "^0.33.0",
|
|
145
145
|
"ws": "^8.0.0",
|
|
146
146
|
"yup": "^1.0.0",
|
|
147
147
|
"zod": "^3.0.0"
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "94650c185b067c86f2e71fb224b1e70f463632b7"
|
|
153
153
|
}
|
|
@@ -40,6 +40,19 @@ interface Processor<TEvent extends LambdaEvent> {
|
|
|
40
40
|
toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function getHeadersAndCookiesFromResponse(response: Response) {
|
|
44
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
45
|
+
|
|
46
|
+
const cookies: string[] = response.headers
|
|
47
|
+
.getSetCookie()
|
|
48
|
+
.flatMap((value) => value.split(','))
|
|
49
|
+
.map((cookie) => cookie.trim());
|
|
50
|
+
|
|
51
|
+
delete headers['set-cookie'];
|
|
52
|
+
|
|
53
|
+
return { headers, cookies };
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
const v1Processor: Processor<APIGatewayProxyEvent> = {
|
|
44
57
|
// same as getPath above
|
|
45
58
|
getTRPCPath: (event) => {
|
|
@@ -98,10 +111,13 @@ const v1Processor: Processor<APIGatewayProxyEvent> = {
|
|
|
98
111
|
},
|
|
99
112
|
getMethod: (event) => event.httpMethod,
|
|
100
113
|
toResult: async (response) => {
|
|
114
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
115
|
+
|
|
101
116
|
const result: APIGatewayProxyResult = {
|
|
117
|
+
...(cookies.length && { multiValueHeaders: { 'set-cookie': cookies } }),
|
|
102
118
|
statusCode: response.status,
|
|
103
119
|
body: await response.text(),
|
|
104
|
-
headers
|
|
120
|
+
headers,
|
|
105
121
|
};
|
|
106
122
|
|
|
107
123
|
return result;
|
|
@@ -142,10 +158,13 @@ const v2Processor: Processor<APIGatewayProxyEventV2> = {
|
|
|
142
158
|
},
|
|
143
159
|
getMethod: (event) => event.requestContext.http.method,
|
|
144
160
|
toResult: async (response) => {
|
|
161
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
162
|
+
|
|
145
163
|
const result: APIGatewayProxyStructuredResultV2 = {
|
|
164
|
+
cookies,
|
|
146
165
|
statusCode: response.status,
|
|
147
166
|
body: await response.text(),
|
|
148
|
-
headers
|
|
167
|
+
headers,
|
|
149
168
|
};
|
|
150
169
|
|
|
151
170
|
return result;
|
|
@@ -8,15 +8,21 @@ const noop = () => {
|
|
|
8
8
|
// noop
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
function createInnerProxy(
|
|
12
|
-
|
|
11
|
+
function createInnerProxy(
|
|
12
|
+
callback: ProxyCallback,
|
|
13
|
+
path: string[],
|
|
14
|
+
cache: Record<string, unknown>,
|
|
15
|
+
) {
|
|
16
|
+
const cacheKey = path.join('.');
|
|
17
|
+
|
|
18
|
+
cache[cacheKey] ??= new Proxy(noop, {
|
|
13
19
|
get(_obj, key) {
|
|
14
20
|
if (typeof key !== 'string' || key === 'then') {
|
|
15
21
|
// special case for if the proxy is accidentally treated
|
|
16
22
|
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
17
23
|
return undefined;
|
|
18
24
|
}
|
|
19
|
-
return createInnerProxy(callback, [...path, key]);
|
|
25
|
+
return createInnerProxy(callback, [...path, key], cache);
|
|
20
26
|
},
|
|
21
27
|
apply(_1, _2, args) {
|
|
22
28
|
const lastOfPath = path[path.length - 1];
|
|
@@ -38,7 +44,7 @@ function createInnerProxy(callback: ProxyCallback, path: string[]) {
|
|
|
38
44
|
},
|
|
39
45
|
});
|
|
40
46
|
|
|
41
|
-
return
|
|
47
|
+
return cache[cacheKey];
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
/**
|
|
@@ -46,8 +52,9 @@ function createInnerProxy(callback: ProxyCallback, path: string[]) {
|
|
|
46
52
|
*
|
|
47
53
|
* @internal
|
|
48
54
|
*/
|
|
49
|
-
export const createRecursiveProxy =
|
|
50
|
-
|
|
55
|
+
export const createRecursiveProxy = <TFaux = unknown>(
|
|
56
|
+
callback: ProxyCallback,
|
|
57
|
+
): TFaux => createInnerProxy(callback, [], Object.create(null)) as TFaux;
|
|
51
58
|
|
|
52
59
|
/**
|
|
53
60
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
@@ -264,40 +264,40 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
264
264
|
onError?: RouterCallerErrorHandler<Context>;
|
|
265
265
|
},
|
|
266
266
|
) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
267
|
+
return createRecursiveProxy<ReturnType<RouterCaller<any, any>>>(
|
|
268
|
+
async ({ path, args }) => {
|
|
269
|
+
const fullPath = path.join('.');
|
|
270
|
+
|
|
271
|
+
if (path.length === 1 && path[0] === '_def') {
|
|
272
|
+
return _def;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const procedure = _def.procedures[fullPath] as AnyProcedure;
|
|
276
|
+
|
|
277
|
+
let ctx: Context | undefined = undefined;
|
|
278
|
+
try {
|
|
279
|
+
ctx = isFunction(ctxOrCallback)
|
|
280
|
+
? await Promise.resolve(ctxOrCallback())
|
|
281
|
+
: ctxOrCallback;
|
|
282
|
+
|
|
283
|
+
return await procedure({
|
|
284
|
+
path: fullPath,
|
|
285
|
+
getRawInput: async () => args[0],
|
|
286
|
+
ctx,
|
|
287
|
+
type: procedure._def.type,
|
|
288
|
+
});
|
|
289
|
+
} catch (cause) {
|
|
290
|
+
options?.onError?.({
|
|
291
|
+
ctx,
|
|
292
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
293
|
+
input: args[0],
|
|
294
|
+
path: fullPath,
|
|
295
|
+
type: procedure._def.type,
|
|
296
|
+
});
|
|
297
|
+
throw cause;
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
301
|
};
|
|
302
302
|
};
|
|
303
303
|
}
|