@trpc/server 11.0.0-rc.619 → 11.0.0-rc.630
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.js +2 -2
- package/dist/adapters/aws-lambda/getPlanner.mjs +2 -2
- package/dist/adapters/aws-lambda/index.js +1 -0
- package/dist/adapters/aws-lambda/index.mjs +1 -0
- package/dist/adapters/express.js +1 -0
- package/dist/adapters/express.mjs +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.js +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +7 -6
- package/dist/adapters/fetch/fetchRequestHandler.mjs +7 -6
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +5 -4
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +5 -4
- package/dist/adapters/next-app-dir/notFound.js +1 -0
- package/dist/adapters/next-app-dir/notFound.mjs +1 -0
- package/dist/adapters/next-app-dir/redirect.js +3 -1
- package/dist/adapters/next-app-dir/redirect.mjs +3 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +1 -1
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/next.mjs +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +7 -2
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +7 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +5 -4
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +5 -4
- package/dist/adapters/standalone.js +1 -0
- package/dist/adapters/standalone.mjs +1 -0
- package/dist/adapters/ws.js +9 -9
- package/dist/adapters/ws.mjs +9 -9
- package/dist/bundle-analysis.json +122 -105
- package/dist/http.js +1 -0
- package/dist/http.mjs +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js +11 -0
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs +9 -0
- package/dist/observable/observable.js +1 -1
- package/dist/observable/observable.mjs +1 -1
- package/dist/rpc.js +1 -0
- package/dist/rpc.mjs +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +1 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +4 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +4 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +1 -1
- package/dist/unstable-core-do-not-import/error/formatter.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +2 -2
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +2 -2
- package/dist/unstable-core-do-not-import/http/contentType.js +3 -3
- package/dist/unstable-core-do-not-import/http/contentType.mjs +3 -3
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +24 -24
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +24 -24
- package/dist/unstable-core-do-not-import/middleware.js +1 -1
- package/dist/unstable-core-do-not-import/middleware.mjs +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -1
- package/dist/unstable-core-do-not-import/router.js +2 -2
- package/dist/unstable-core-do-not-import/router.mjs +2 -2
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +2 -2
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +2 -2
- package/dist/unstable-core-do-not-import/stream/jsonl.js +14 -15
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +14 -15
- package/dist/unstable-core-do-not-import/stream/sse.js +2 -2
- package/dist/unstable-core-do-not-import/stream/sse.mjs +2 -2
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +1 -1
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +1 -1
- package/dist/vendor/unpromise/unpromise.js +21 -16
- package/dist/vendor/unpromise/unpromise.mjs +21 -16
- package/package.json +11 -4
- package/src/adapters/node-http/incomingMessageToRequest.ts +7 -2
|
@@ -68,7 +68,7 @@ const v1Processor = {
|
|
|
68
68
|
},
|
|
69
69
|
getMethod: (event)=>event.httpMethod,
|
|
70
70
|
toResult: async (response)=>{
|
|
71
|
-
const { headers
|
|
71
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
72
72
|
const result = {
|
|
73
73
|
...cookies.length && {
|
|
74
74
|
multiValueHeaders: {
|
|
@@ -115,7 +115,7 @@ const v2Processor = {
|
|
|
115
115
|
},
|
|
116
116
|
getMethod: (event)=>event.requestContext.http.method,
|
|
117
117
|
toResult: async (response)=>{
|
|
118
|
-
const { headers
|
|
118
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
119
119
|
const result = {
|
|
120
120
|
cookies,
|
|
121
121
|
statusCode: response.status,
|
|
@@ -66,7 +66,7 @@ const v1Processor = {
|
|
|
66
66
|
},
|
|
67
67
|
getMethod: (event)=>event.httpMethod,
|
|
68
68
|
toResult: async (response)=>{
|
|
69
|
-
const { headers
|
|
69
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
70
70
|
const result = {
|
|
71
71
|
...cookies.length && {
|
|
72
72
|
multiValueHeaders: {
|
|
@@ -113,7 +113,7 @@ const v2Processor = {
|
|
|
113
113
|
},
|
|
114
114
|
getMethod: (event)=>event.requestContext.http.method,
|
|
115
115
|
toResult: async (response)=>{
|
|
116
|
-
const { headers
|
|
116
|
+
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
117
117
|
const result = {
|
|
118
118
|
cookies,
|
|
119
119
|
statusCode: response.status,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
4
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
5
6
|
var getPlanner = require('./getPlanner.js');
|
|
6
7
|
|
|
7
8
|
function awsLambdaRequestHandler(opts) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
2
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
import { getPlanner } from './getPlanner.mjs';
|
|
4
5
|
|
|
5
6
|
function awsLambdaRequestHandler(opts) {
|
package/dist/adapters/express.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('../unstable-core-do-not-import/utils.js');
|
|
4
|
+
require('../vendor/unpromise/unpromise.js');
|
|
4
5
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
5
6
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
6
7
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { run } from '../unstable-core-do-not-import/utils.mjs';
|
|
2
|
+
import '../vendor/unpromise/unpromise.mjs';
|
|
2
3
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
4
|
import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
4
5
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
4
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
5
6
|
var incomingMessageToRequest = require('../node-http/incomingMessageToRequest.js');
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
2
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
import { incomingMessageToRequest } from '../node-http/incomingMessageToRequest.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -45,7 +45,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
45
45
|
}, async (socket, req)=>{
|
|
46
46
|
await onConnection(socket, req.raw);
|
|
47
47
|
if (trpcOptions?.keepAlive?.enabled) {
|
|
48
|
-
const { pingMs
|
|
48
|
+
const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
|
|
49
49
|
ws.handleKeepAlive(socket, pingMs, pongWaitMs);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
@@ -43,7 +43,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
43
43
|
}, async (socket, req)=>{
|
|
44
44
|
await onConnection(socket, req.raw);
|
|
45
45
|
if (trpcOptions?.keepAlive?.enabled) {
|
|
46
|
-
const { pingMs
|
|
46
|
+
const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
|
|
47
47
|
handleKeepAlive(socket, pingMs, pongWaitMs);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
4
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
@@ -52,13 +53,13 @@ async function fetchRequestHandler(opts) {
|
|
|
52
53
|
} else {
|
|
53
54
|
/**
|
|
54
55
|
* @deprecated, delete in v12
|
|
55
|
-
*/ for (const [
|
|
56
|
-
if (Array.isArray(
|
|
57
|
-
for (const v of
|
|
58
|
-
resHeaders.append(
|
|
56
|
+
*/ for (const [key, value] of Object.entries(meta.headers)){
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
for (const v of value){
|
|
59
|
+
resHeaders.append(key, v);
|
|
59
60
|
}
|
|
60
|
-
} else if (typeof
|
|
61
|
-
resHeaders.set(
|
|
61
|
+
} else if (typeof value === 'string') {
|
|
62
|
+
resHeaders.set(key, value);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
2
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
@@ -50,13 +51,13 @@ async function fetchRequestHandler(opts) {
|
|
|
50
51
|
} else {
|
|
51
52
|
/**
|
|
52
53
|
* @deprecated, delete in v12
|
|
53
|
-
*/ for (const [
|
|
54
|
-
if (Array.isArray(
|
|
55
|
-
for (const v of
|
|
56
|
-
resHeaders.append(
|
|
54
|
+
*/ for (const [key, value] of Object.entries(meta.headers)){
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
for (const v of value){
|
|
57
|
+
resHeaders.append(key, v);
|
|
57
58
|
}
|
|
58
|
-
} else if (typeof
|
|
59
|
-
resHeaders.set(
|
|
59
|
+
} else if (typeof value === 'string') {
|
|
60
|
+
resHeaders.set(key, value);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
4
|
var formDataToObject = require('../../unstable-core-do-not-import/http/formDataToObject.js');
|
|
5
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
5
6
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
7
|
var redirect = require('./redirect.js');
|
|
7
8
|
var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
@@ -9,7 +10,7 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
9
10
|
/**
|
|
10
11
|
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
11
12
|
*/ function nextAppDirCaller(config) {
|
|
12
|
-
const { normalizeFormData =true
|
|
13
|
+
const { normalizeFormData = true } = config;
|
|
13
14
|
const createContext = async ()=>{
|
|
14
15
|
return config?.createContext?.() ?? {};
|
|
15
16
|
};
|
|
@@ -63,13 +64,13 @@ var rethrowNextErrors = require('./rethrowNextErrors.js');
|
|
|
63
64
|
}
|
|
64
65
|
case 'query':
|
|
65
66
|
{
|
|
66
|
-
const
|
|
67
|
+
const input = opts.args[0];
|
|
67
68
|
return await opts.invoke({
|
|
68
69
|
type: opts._def.type,
|
|
69
70
|
ctx,
|
|
70
|
-
getRawInput: async ()=>
|
|
71
|
+
getRawInput: async ()=>input,
|
|
71
72
|
path,
|
|
72
|
-
input
|
|
73
|
+
input,
|
|
73
74
|
signal: undefined
|
|
74
75
|
}).then((data)=>{
|
|
75
76
|
if (data instanceof redirect.TRPCRedirectError) throw data;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TRPCError, getTRPCErrorFromUnknown } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
2
|
import { formDataToObject } from '../../unstable-core-do-not-import/http/formDataToObject.mjs';
|
|
3
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
5
|
import { TRPCRedirectError } from './redirect.mjs';
|
|
5
6
|
import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
@@ -7,7 +8,7 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
7
8
|
/**
|
|
8
9
|
* Create a caller that works with Next.js React Server Components & Server Actions
|
|
9
10
|
*/ function nextAppDirCaller(config) {
|
|
10
|
-
const { normalizeFormData =true
|
|
11
|
+
const { normalizeFormData = true } = config;
|
|
11
12
|
const createContext = async ()=>{
|
|
12
13
|
return config?.createContext?.() ?? {};
|
|
13
14
|
};
|
|
@@ -61,13 +62,13 @@ import { rethrowNextErrors } from './rethrowNextErrors.mjs';
|
|
|
61
62
|
}
|
|
62
63
|
case 'query':
|
|
63
64
|
{
|
|
64
|
-
const
|
|
65
|
+
const input = opts.args[0];
|
|
65
66
|
return await opts.invoke({
|
|
66
67
|
type: opts._def.type,
|
|
67
68
|
ctx,
|
|
68
|
-
getRawInput: async ()=>
|
|
69
|
+
getRawInput: async ()=>input,
|
|
69
70
|
path,
|
|
70
|
-
input
|
|
71
|
+
input,
|
|
71
72
|
signal: undefined
|
|
72
73
|
}).then((data)=>{
|
|
73
74
|
if (data instanceof TRPCRedirectError) throw data;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _define_property = require('../../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js');
|
|
3
4
|
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
4
6
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -11,7 +13,7 @@ require('../../unstable-core-do-not-import/rootConfig.js');
|
|
|
11
13
|
// TODO(?): This should maybe a custom error code
|
|
12
14
|
code: 'UNPROCESSABLE_CONTENT',
|
|
13
15
|
message: `Redirect error to "${url}" that will be handled by Next.js`
|
|
14
|
-
});
|
|
16
|
+
}), _define_property._(this, "args", void 0);
|
|
15
17
|
this.args = [
|
|
16
18
|
url.toString(),
|
|
17
19
|
redirectType
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { _ as _define_property } from '../../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs';
|
|
1
2
|
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
2
4
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -9,7 +11,7 @@ import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
|
9
11
|
// TODO(?): This should maybe a custom error code
|
|
10
12
|
code: 'UNPROCESSABLE_CONTENT',
|
|
11
13
|
message: `Redirect error to "${url}" that will be handled by Next.js`
|
|
12
|
-
});
|
|
14
|
+
}), _define_property(this, "args", void 0);
|
|
13
15
|
this.args = [
|
|
14
16
|
url.toString(),
|
|
15
17
|
redirectType
|
|
@@ -55,7 +55,7 @@ function isNotFoundError(error) {
|
|
|
55
55
|
if (error instanceof redirect.TRPCRedirectError) {
|
|
56
56
|
nextNavigation__namespace.redirect(...error.args);
|
|
57
57
|
}
|
|
58
|
-
const { cause
|
|
58
|
+
const { cause } = error;
|
|
59
59
|
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
60
60
|
if ('unstable_rethrow' in nextNavigation__namespace && typeof nextNavigation__namespace.unstable_rethrow === 'function') {
|
|
61
61
|
nextNavigation__namespace.unstable_rethrow(cause);
|
|
@@ -34,7 +34,7 @@ function isNotFoundError(error) {
|
|
|
34
34
|
if (error instanceof TRPCRedirectError) {
|
|
35
35
|
nextNavigation.redirect(...error.args);
|
|
36
36
|
}
|
|
37
|
-
const { cause
|
|
37
|
+
const { cause } = error;
|
|
38
38
|
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
39
39
|
if ('unstable_rethrow' in nextNavigation && typeof nextNavigation.unstable_rethrow === 'function') {
|
|
40
40
|
nextNavigation.unstable_rethrow(cause);
|
package/dist/adapters/next.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require('../unstable-core-do-not-import/utils.js');
|
|
4
4
|
var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../vendor/unpromise/unpromise.js');
|
|
5
6
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
7
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
7
8
|
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { run } from '../unstable-core-do-not-import/utils.mjs';
|
|
2
2
|
import { TRPCError } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
5
|
import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
5
6
|
|
|
@@ -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,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,GAAG,CAkBxD;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,
|
|
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,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,GAAG,CAkBxD;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAkCT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
4
5
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
6
|
|
|
6
7
|
function createBody(req, opts) {
|
|
@@ -84,9 +85,13 @@ function createHeaders(incoming) {
|
|
|
84
85
|
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
85
86
|
*/ function incomingMessageToRequest(req, opts) {
|
|
86
87
|
const ac = new AbortController();
|
|
87
|
-
|
|
88
|
+
const onAbort = ()=>{
|
|
88
89
|
ac.abort();
|
|
89
|
-
|
|
90
|
+
req.off('aborted', onAbort);
|
|
91
|
+
req.off('close', onAbort);
|
|
92
|
+
};
|
|
93
|
+
req.once('aborted', onAbort);
|
|
94
|
+
req.socket?.once('close', onAbort);
|
|
90
95
|
// Get host from either regular header or HTTP/2 pseudo-header
|
|
91
96
|
const url = createURL(req);
|
|
92
97
|
const init = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
2
3
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
4
|
|
|
4
5
|
function createBody(req, opts) {
|
|
@@ -82,9 +83,13 @@ function createHeaders(incoming) {
|
|
|
82
83
|
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
83
84
|
*/ function incomingMessageToRequest(req, opts) {
|
|
84
85
|
const ac = new AbortController();
|
|
85
|
-
|
|
86
|
+
const onAbort = ()=>{
|
|
86
87
|
ac.abort();
|
|
87
|
-
|
|
88
|
+
req.off('aborted', onAbort);
|
|
89
|
+
req.off('close', onAbort);
|
|
90
|
+
};
|
|
91
|
+
req.once('aborted', onAbort);
|
|
92
|
+
req.socket?.once('close', onAbort);
|
|
88
93
|
// Get host from either regular header or HTTP/2 pseudo-header
|
|
89
94
|
const url = createURL(req);
|
|
90
95
|
const init = {
|
|
@@ -6,6 +6,7 @@ var utils = require('../../unstable-core-do-not-import/utils.js');
|
|
|
6
6
|
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
7
7
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
8
8
|
var transformer = require('../../unstable-core-do-not-import/transformer.js');
|
|
9
|
+
require('../../vendor/unpromise/unpromise.js');
|
|
9
10
|
var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -21,7 +22,7 @@ var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
|
21
22
|
* @internal
|
|
22
23
|
*/ function internal_exceptionHandler(opts) {
|
|
23
24
|
return (cause)=>{
|
|
24
|
-
const { res
|
|
25
|
+
const { res, req } = opts;
|
|
25
26
|
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
26
27
|
const shape = getErrorShape.getErrorShape({
|
|
27
28
|
config: opts.router._def._config,
|
|
@@ -78,7 +79,7 @@ var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
|
-
const { res
|
|
82
|
+
const { res } = opts;
|
|
82
83
|
if (res.statusCode === 200) {
|
|
83
84
|
// if the status code is set, we assume that it's been manually overridden
|
|
84
85
|
res.statusCode = response.status;
|
|
@@ -98,14 +99,14 @@ var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
|
98
99
|
once: true
|
|
99
100
|
});
|
|
100
101
|
while(true){
|
|
101
|
-
const { done
|
|
102
|
+
const { done, value } = await reader.read();
|
|
102
103
|
if (done) {
|
|
103
104
|
break;
|
|
104
105
|
}
|
|
105
106
|
if (!res.writable) {
|
|
106
107
|
break;
|
|
107
108
|
}
|
|
108
|
-
if (res.write(
|
|
109
|
+
if (res.write(value) === false) {
|
|
109
110
|
await new Promise((resolve)=>{
|
|
110
111
|
res.once('drain', resolve);
|
|
111
112
|
});
|
|
@@ -4,6 +4,7 @@ import { run } from '../../unstable-core-do-not-import/utils.mjs';
|
|
|
4
4
|
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
5
5
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
6
6
|
import { transformTRPCResponse } from '../../unstable-core-do-not-import/transformer.mjs';
|
|
7
|
+
import '../../vendor/unpromise/unpromise.mjs';
|
|
7
8
|
import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -19,7 +20,7 @@ import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
|
|
|
19
20
|
* @internal
|
|
20
21
|
*/ function internal_exceptionHandler(opts) {
|
|
21
22
|
return (cause)=>{
|
|
22
|
-
const { res
|
|
23
|
+
const { res, req } = opts;
|
|
23
24
|
const error = getTRPCErrorFromUnknown(cause);
|
|
24
25
|
const shape = getErrorShape({
|
|
25
26
|
config: opts.router._def._config,
|
|
@@ -76,7 +77,7 @@ import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
|
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
|
-
const { res
|
|
80
|
+
const { res } = opts;
|
|
80
81
|
if (res.statusCode === 200) {
|
|
81
82
|
// if the status code is set, we assume that it's been manually overridden
|
|
82
83
|
res.statusCode = response.status;
|
|
@@ -96,14 +97,14 @@ import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
|
|
|
96
97
|
once: true
|
|
97
98
|
});
|
|
98
99
|
while(true){
|
|
99
|
-
const { done
|
|
100
|
+
const { done, value } = await reader.read();
|
|
100
101
|
if (done) {
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
104
|
if (!res.writable) {
|
|
104
105
|
break;
|
|
105
106
|
}
|
|
106
|
-
if (res.write(
|
|
107
|
+
if (res.write(value) === false) {
|
|
107
108
|
await new Promise((resolve)=>{
|
|
108
109
|
res.once('drain', resolve);
|
|
109
110
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var http = require('node:http');
|
|
4
4
|
var utils = require('../unstable-core-do-not-import/utils.js');
|
|
5
|
+
require('../vendor/unpromise/unpromise.js');
|
|
5
6
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
7
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
7
8
|
var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import { run } from '../unstable-core-do-not-import/utils.mjs';
|
|
3
|
+
import '../vendor/unpromise/unpromise.mjs';
|
|
3
4
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
5
|
import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
5
6
|
import { createURL } from './node-http/incomingMessageToRequest.mjs';
|
package/dist/adapters/ws.js
CHANGED
|
@@ -19,13 +19,13 @@ var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js'
|
|
|
19
19
|
*/ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
20
20
|
const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
|
|
21
21
|
function getWSConnectionHandler(opts) {
|
|
22
|
-
const { createContext
|
|
23
|
-
const { transformer: transformer$1
|
|
22
|
+
const { createContext, router: router$1 } = opts;
|
|
23
|
+
const { transformer: transformer$1 } = router$1._def._config;
|
|
24
24
|
return async (client, req)=>{
|
|
25
25
|
const clientSubscriptions = new Map();
|
|
26
26
|
const abortController = new AbortController();
|
|
27
27
|
if (opts.keepAlive?.enabled) {
|
|
28
|
-
const { pingMs
|
|
28
|
+
const { pingMs, pongWaitMs } = opts.keepAlive;
|
|
29
29
|
handleKeepAlive(client, pingMs, pongWaitMs);
|
|
30
30
|
}
|
|
31
31
|
function respond(untransformedJSON) {
|
|
@@ -82,7 +82,7 @@ function getWSConnectionHandler(opts) {
|
|
|
82
82
|
* - if connection params are expected, they will be created once received
|
|
83
83
|
*/ let ctxPromise = incomingMessageToRequest.createURL(req).searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
|
|
84
84
|
async function handleRequest(msg) {
|
|
85
|
-
const { id
|
|
85
|
+
const { id, jsonrpc } = msg;
|
|
86
86
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
|
87
87
|
throw new TRPCError.TRPCError({
|
|
88
88
|
code: 'BAD_REQUEST',
|
|
@@ -93,8 +93,8 @@ function getWSConnectionHandler(opts) {
|
|
|
93
93
|
clientSubscriptions.get(id)?.abort();
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
const { path
|
|
97
|
-
let { input
|
|
96
|
+
const { path, lastEventId } = msg.params;
|
|
97
|
+
let { input } = msg.params;
|
|
98
98
|
const type = msg.method;
|
|
99
99
|
try {
|
|
100
100
|
if (lastEventId !== undefined) {
|
|
@@ -207,10 +207,10 @@ function getWSConnectionHandler(opts) {
|
|
|
207
207
|
data: next.value
|
|
208
208
|
};
|
|
209
209
|
if (tracked.isTrackedEnvelope(next.value)) {
|
|
210
|
-
const [
|
|
211
|
-
result.id =
|
|
210
|
+
const [id, data] = next.value;
|
|
211
|
+
result.id = id;
|
|
212
212
|
result.data = {
|
|
213
|
-
id
|
|
213
|
+
id,
|
|
214
214
|
data
|
|
215
215
|
};
|
|
216
216
|
}
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -17,13 +17,13 @@ import { createURL } from './node-http/incomingMessageToRequest.mjs';
|
|
|
17
17
|
*/ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
18
18
|
const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
|
|
19
19
|
function getWSConnectionHandler(opts) {
|
|
20
|
-
const { createContext
|
|
21
|
-
const { transformer
|
|
20
|
+
const { createContext, router } = opts;
|
|
21
|
+
const { transformer } = router._def._config;
|
|
22
22
|
return async (client, req)=>{
|
|
23
23
|
const clientSubscriptions = new Map();
|
|
24
24
|
const abortController = new AbortController();
|
|
25
25
|
if (opts.keepAlive?.enabled) {
|
|
26
|
-
const { pingMs
|
|
26
|
+
const { pingMs, pongWaitMs } = opts.keepAlive;
|
|
27
27
|
handleKeepAlive(client, pingMs, pongWaitMs);
|
|
28
28
|
}
|
|
29
29
|
function respond(untransformedJSON) {
|
|
@@ -80,7 +80,7 @@ function getWSConnectionHandler(opts) {
|
|
|
80
80
|
* - if connection params are expected, they will be created once received
|
|
81
81
|
*/ let ctxPromise = createURL(req).searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
|
|
82
82
|
async function handleRequest(msg) {
|
|
83
|
-
const { id
|
|
83
|
+
const { id, jsonrpc } = msg;
|
|
84
84
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
|
85
85
|
throw new TRPCError({
|
|
86
86
|
code: 'BAD_REQUEST',
|
|
@@ -91,8 +91,8 @@ function getWSConnectionHandler(opts) {
|
|
|
91
91
|
clientSubscriptions.get(id)?.abort();
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
const { path
|
|
95
|
-
let { input
|
|
94
|
+
const { path, lastEventId } = msg.params;
|
|
95
|
+
let { input } = msg.params;
|
|
96
96
|
const type = msg.method;
|
|
97
97
|
try {
|
|
98
98
|
if (lastEventId !== undefined) {
|
|
@@ -205,10 +205,10 @@ function getWSConnectionHandler(opts) {
|
|
|
205
205
|
data: next.value
|
|
206
206
|
};
|
|
207
207
|
if (isTrackedEnvelope(next.value)) {
|
|
208
|
-
const [
|
|
209
|
-
result.id =
|
|
208
|
+
const [id, data] = next.value;
|
|
209
|
+
result.id = id;
|
|
210
210
|
result.data = {
|
|
211
|
-
id
|
|
211
|
+
id,
|
|
212
212
|
data
|
|
213
213
|
};
|
|
214
214
|
}
|