@trpc/server 11.0.0-alpha-tmp-12-06-react.674 → 11.0.0-alpha-tmp-issues-6374.696
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/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +10 -3
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +8 -6
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +8 -6
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +128 -112
- 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 +2 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +2 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +154 -188
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +156 -190
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +7 -3
- package/dist/unstable-core-do-not-import/stream/sse.mjs +7 -3
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts +17 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.js +241 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +239 -0
- package/package.json +7 -7
- package/src/adapters/fastify/fastifyRequestHandler.ts +2 -2
- package/src/adapters/node-http/incomingMessageToRequest.ts +19 -11
- package/src/unstable-core-do-not-import/createProxy.ts +3 -2
- package/src/unstable-core-do-not-import/stream/jsonl.ts +14 -46
- package/src/unstable-core-do-not-import/stream/sse.ts +28 -21
- package/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts +193 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE5D,KAAK,4BAA4B,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IACxD,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,EAC9B,IAAI,EAAE,4BAA4B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBAkCjE"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type * as http from 'http';
|
|
2
|
-
export interface
|
|
2
|
+
export interface UniversalIncomingMessage extends Omit<http.IncomingMessage, 'socket'> {
|
|
3
3
|
/**
|
|
4
4
|
* Many adapters will add a `body` property to the incoming message and pre-parse the body
|
|
5
5
|
*/
|
|
6
6
|
body?: unknown;
|
|
7
|
+
/**
|
|
8
|
+
* Socket is not always available in all deployments, so we need to make it optional
|
|
9
|
+
* @see https://github.com/trpc/trpc/issues/6341
|
|
10
|
+
* The socket object provided in the request does not fully implement the expected Node.js Socket interface.
|
|
11
|
+
* @see https://github.com/trpc/trpc/pull/6358
|
|
12
|
+
*/
|
|
13
|
+
socket?: Partial<http.IncomingMessage['socket']>;
|
|
7
14
|
}
|
|
8
|
-
export declare function createURL(req:
|
|
15
|
+
export declare function createURL(req: UniversalIncomingMessage): URL;
|
|
9
16
|
/**
|
|
10
17
|
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
11
18
|
*/
|
|
12
|
-
export declare function incomingMessageToRequest(req:
|
|
19
|
+
export declare function incomingMessageToRequest(req: UniversalIncomingMessage, res: http.ServerResponse, opts: {
|
|
13
20
|
/**
|
|
14
21
|
* Max body size in bytes. If the body is larger than this, the request will be aborted
|
|
15
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,wBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC;IAC5C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CAClD;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,wBAAwB,GAAG,GAAG,CAkB5D;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,wBAAwB,EAC7B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAqCT"}
|
|
@@ -8,14 +8,16 @@ require('../../unstable-core-do-not-import/rootConfig.js');
|
|
|
8
8
|
function createBody(req, opts) {
|
|
9
9
|
// Some adapters will pre-parse the body and add it to the request object
|
|
10
10
|
if ('body' in req) {
|
|
11
|
+
if (req.body === undefined) {
|
|
12
|
+
// If body property exists but is undefined, return undefined
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
11
15
|
// If the body is already a string, return it directly
|
|
12
16
|
if (typeof req.body === 'string') {
|
|
13
17
|
return req.body;
|
|
14
|
-
} else if (req.body !== undefined) {
|
|
15
|
-
return JSON.stringify(req.body);
|
|
16
18
|
}
|
|
17
|
-
// If body
|
|
18
|
-
return
|
|
19
|
+
// If body exists but isn't a string, stringify it as JSON
|
|
20
|
+
return JSON.stringify(req.body);
|
|
19
21
|
}
|
|
20
22
|
let size = 0;
|
|
21
23
|
let hasClosed = false;
|
|
@@ -88,12 +90,12 @@ function createHeaders(incoming) {
|
|
|
88
90
|
const ac = new AbortController();
|
|
89
91
|
const onAbort = ()=>{
|
|
90
92
|
res.off('close', onAbort);
|
|
91
|
-
req.socket
|
|
93
|
+
req.socket?.off?.('end', onAbort);
|
|
92
94
|
// abort the request
|
|
93
95
|
ac.abort();
|
|
94
96
|
};
|
|
95
97
|
res.once('close', onAbort);
|
|
96
|
-
req.socket
|
|
98
|
+
req.socket?.once?.('end', onAbort);
|
|
97
99
|
// Get host from either regular header or HTTP/2 pseudo-header
|
|
98
100
|
const url = createURL(req);
|
|
99
101
|
const init = {
|
|
@@ -6,14 +6,16 @@ import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
|
6
6
|
function createBody(req, opts) {
|
|
7
7
|
// Some adapters will pre-parse the body and add it to the request object
|
|
8
8
|
if ('body' in req) {
|
|
9
|
+
if (req.body === undefined) {
|
|
10
|
+
// If body property exists but is undefined, return undefined
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
9
13
|
// If the body is already a string, return it directly
|
|
10
14
|
if (typeof req.body === 'string') {
|
|
11
15
|
return req.body;
|
|
12
|
-
} else if (req.body !== undefined) {
|
|
13
|
-
return JSON.stringify(req.body);
|
|
14
16
|
}
|
|
15
|
-
// If body
|
|
16
|
-
return
|
|
17
|
+
// If body exists but isn't a string, stringify it as JSON
|
|
18
|
+
return JSON.stringify(req.body);
|
|
17
19
|
}
|
|
18
20
|
let size = 0;
|
|
19
21
|
let hasClosed = false;
|
|
@@ -86,12 +88,12 @@ function createHeaders(incoming) {
|
|
|
86
88
|
const ac = new AbortController();
|
|
87
89
|
const onAbort = ()=>{
|
|
88
90
|
res.off('close', onAbort);
|
|
89
|
-
req.socket
|
|
91
|
+
req.socket?.off?.('end', onAbort);
|
|
90
92
|
// abort the request
|
|
91
93
|
ac.abort();
|
|
92
94
|
};
|
|
93
95
|
res.once('close', onAbort);
|
|
94
|
-
req.socket
|
|
96
|
+
req.socket?.once?.('end', onAbort);
|
|
95
97
|
// Get host from either regular header or HTTP/2 pseudo-header
|
|
96
98
|
const url = createURL(req);
|
|
97
99
|
const init = {
|
package/dist/adapters/ws.js
CHANGED
|
@@ -6,9 +6,9 @@ var utils = require('../unstable-core-do-not-import/utils.js');
|
|
|
6
6
|
var parseConnectionParams = require('../unstable-core-do-not-import/http/parseConnectionParams.js');
|
|
7
7
|
var parseTRPCMessage = require('../unstable-core-do-not-import/rpc/parseTRPCMessage.js');
|
|
8
8
|
var observable = require('../observable/observable.js');
|
|
9
|
-
var unpromise = require('../vendor/unpromise/unpromise.js');
|
|
10
9
|
var asyncIterable = require('../unstable-core-do-not-import/stream/utils/asyncIterable.js');
|
|
11
10
|
require('../unstable-core-do-not-import/stream/utils/disposable.js');
|
|
11
|
+
var unpromise = require('../vendor/unpromise/unpromise.js');
|
|
12
12
|
var tracked = require('../unstable-core-do-not-import/stream/tracked.js');
|
|
13
13
|
var transformer = require('../unstable-core-do-not-import/transformer.js');
|
|
14
14
|
require('../unstable-core-do-not-import/rootConfig.js');
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import { run, isObject, isAsyncIterable } from '../unstable-core-do-not-import/u
|
|
|
4
4
|
import { parseConnectionParamsFromUnknown } from '../unstable-core-do-not-import/http/parseConnectionParams.mjs';
|
|
5
5
|
import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
|
|
6
6
|
import { isObservable, observableToAsyncIterable } from '../observable/observable.mjs';
|
|
7
|
-
import { Unpromise } from '../vendor/unpromise/unpromise.mjs';
|
|
8
7
|
import { iteratorResource } from '../unstable-core-do-not-import/stream/utils/asyncIterable.mjs';
|
|
9
8
|
import '../unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
9
|
+
import { Unpromise } from '../vendor/unpromise/unpromise.mjs';
|
|
10
10
|
import { isTrackedEnvelope } from '../unstable-core-do-not-import/stream/tracked.mjs';
|
|
11
11
|
import { transformTRPCResponse } from '../unstable-core-do-not-import/transformer.mjs';
|
|
12
12
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|