@trpc/server 11.7.2 → 11.7.3-canary.4
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 +13 -3
- package/dist/adapters/aws-lambda/index.d.cts +1 -1
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +1 -1
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +13 -3
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +72 -72
- package/dist/adapters/next-app-dir.mjs +72 -72
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/aws-lambda/getPlanner.ts +28 -6
- package/src/adapters/aws-lambda/index.ts +2 -10
- package/adapters/aws-lambda/index.d.ts +0 -1
- package/adapters/aws-lambda/index.js +0 -1
- package/adapters/express/index.d.ts +0 -1
- package/adapters/express/index.js +0 -1
- package/adapters/fastify/index.d.ts +0 -1
- package/adapters/fastify/index.js +0 -1
- package/adapters/fetch/index.d.ts +0 -1
- package/adapters/fetch/index.js +0 -1
- package/adapters/next/index.d.ts +0 -1
- package/adapters/next/index.js +0 -1
- package/adapters/next-app-dir/index.d.ts +0 -1
- package/adapters/next-app-dir/index.js +0 -1
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/adapters/node-http/index.d.ts +0 -1
- package/adapters/node-http/index.js +0 -1
- package/adapters/standalone/index.d.ts +0 -1
- package/adapters/standalone/index.js +0 -1
- package/adapters/ws/index.d.ts +0 -1
- package/adapters/ws/index.js +0 -1
- package/http/index.d.ts +0 -1
- package/http/index.js +0 -1
- package/observable/index.d.ts +0 -1
- package/observable/index.js +0 -1
- package/rpc/index.d.ts +0 -1
- package/rpc/index.js +0 -1
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@trpc/server",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "11.7.
|
|
5
|
+
"version": "11.7.3-canary.4+9a17cef99",
|
|
6
6
|
"description": "The tRPC server library",
|
|
7
7
|
"author": "KATT",
|
|
8
8
|
"license": "MIT",
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
"superstruct": "^2.0.0",
|
|
218
218
|
"tsdown": "0.12.7",
|
|
219
219
|
"typescript": "^5.9.2",
|
|
220
|
-
"valibot": "1.
|
|
220
|
+
"valibot": "1.2.0",
|
|
221
221
|
"ws": "^8.0.0",
|
|
222
222
|
"yup": "^1.0.0",
|
|
223
223
|
"zod": "^3.25.51"
|
|
@@ -228,5 +228,5 @@
|
|
|
228
228
|
"peerDependencies": {
|
|
229
229
|
"typescript": ">=5.7.2"
|
|
230
230
|
},
|
|
231
|
-
"gitHead": "
|
|
231
|
+
"gitHead": "9a17cef999278555a0e1e6322f1a2579180eecb9"
|
|
232
232
|
}
|
|
@@ -41,7 +41,7 @@ interface Processor<TEvent extends LambdaEvent> {
|
|
|
41
41
|
getHeaders: (event: TEvent) => Headers;
|
|
42
42
|
getMethod: (event: TEvent) => string;
|
|
43
43
|
toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;
|
|
44
|
-
toStream
|
|
44
|
+
toStream: (response: Response, stream: Writable) => Promise<void>;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function getHeadersAndCookiesFromResponse(response: Response) {
|
|
@@ -98,18 +98,23 @@ const v1Processor: Processor<APIGatewayProxyEvent> = {
|
|
|
98
98
|
},
|
|
99
99
|
getHeaders: (event) => {
|
|
100
100
|
const headers = new Headers();
|
|
101
|
-
for (const [key, value] of Object.entries(event.headers ?? {})) {
|
|
102
|
-
if (value !== undefined) {
|
|
103
|
-
headers.append(key, value);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
101
|
|
|
102
|
+
// Process multiValueHeaders first (takes precedence per AWS docs)
|
|
103
|
+
// This handles headers that can have multiple values
|
|
107
104
|
for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})) {
|
|
108
105
|
if (values) {
|
|
109
106
|
values.forEach((v) => headers.append(k, v));
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
109
|
|
|
110
|
+
// Then process single-value headers, but skip any that were already
|
|
111
|
+
// added from multiValueHeaders to avoid duplication
|
|
112
|
+
for (const [key, value] of Object.entries(event.headers ?? {})) {
|
|
113
|
+
if (value !== undefined && !headers.has(key)) {
|
|
114
|
+
headers.append(key, value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
return headers;
|
|
114
119
|
},
|
|
115
120
|
getMethod: (event) => event.httpMethod,
|
|
@@ -125,6 +130,23 @@ const v1Processor: Processor<APIGatewayProxyEvent> = {
|
|
|
125
130
|
|
|
126
131
|
return result;
|
|
127
132
|
},
|
|
133
|
+
toStream: async (response, stream) => {
|
|
134
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
135
|
+
|
|
136
|
+
const metadata = {
|
|
137
|
+
statusCode: response.status,
|
|
138
|
+
headers,
|
|
139
|
+
cookies,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const responseStream = awslambda.HttpResponseStream.from(stream, metadata);
|
|
143
|
+
|
|
144
|
+
if (response.body) {
|
|
145
|
+
await pipeline(Readable.fromWeb(response.body as any), responseStream);
|
|
146
|
+
} else {
|
|
147
|
+
responseStream.end();
|
|
148
|
+
}
|
|
149
|
+
},
|
|
128
150
|
};
|
|
129
151
|
|
|
130
152
|
const v2Processor: Processor<APIGatewayProxyEventV2> = {
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
APIGatewayProxyEventV2,
|
|
12
|
-
Context as APIGWContext,
|
|
13
|
-
StreamifyHandler,
|
|
14
|
-
} from 'aws-lambda';
|
|
10
|
+
import type { Context as APIGWContext, StreamifyHandler } from 'aws-lambda';
|
|
15
11
|
// @trpc/server
|
|
16
12
|
import type {
|
|
17
13
|
AnyRouter,
|
|
@@ -89,15 +85,11 @@ export function awsLambdaRequestHandler<
|
|
|
89
85
|
|
|
90
86
|
export function awsLambdaStreamingRequestHandler<
|
|
91
87
|
TRouter extends AnyRouter,
|
|
92
|
-
TEvent extends
|
|
88
|
+
TEvent extends LambdaEvent,
|
|
93
89
|
>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent> {
|
|
94
90
|
return async (event, responseStream, context) => {
|
|
95
91
|
const planner = getPlanner(event);
|
|
96
92
|
|
|
97
|
-
if (!planner.toStream) {
|
|
98
|
-
throw new Error('Streaming is not supported for this event version');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
93
|
const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (
|
|
102
94
|
innerOpts,
|
|
103
95
|
) => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/aws-lambda';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/aws-lambda');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/express';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/express');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/fastify';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/fastify');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/fetch';
|
package/adapters/fetch/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/fetch');
|
package/adapters/next/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/next';
|
package/adapters/next/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/next');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/next-app-dir';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/next-app-dir');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../../../dist/adapters/node-http/content-type/form-data';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../../../dist/adapters/node-http/content-type/form-data');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../../../dist/adapters/node-http/content-type/json';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../../../dist/adapters/node-http/content-type/json');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/node-http';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/node-http');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/standalone';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/standalone');
|
package/adapters/ws/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/adapters/ws';
|
package/adapters/ws/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/adapters/ws');
|
package/http/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/http';
|
package/http/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/http');
|
package/observable/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/observable';
|
package/observable/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/observable');
|
package/rpc/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/rpc';
|
package/rpc/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/rpc');
|
package/shared/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/shared';
|
package/shared/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/shared');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/unstable-core-do-not-import';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/unstable-core-do-not-import');
|