@trpc/server 11.0.0-rc.729 → 11.0.0-rc.740

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.
Files changed (39) hide show
  1. package/dist/@trpc/server/index.d.ts +1 -1
  2. package/dist/@trpc/server/index.d.ts.map +1 -1
  3. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  4. package/dist/adapters/node-http/incomingMessageToRequest.d.ts +3 -16
  5. package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
  6. package/dist/adapters/node-http/incomingMessageToRequest.js +5 -3
  7. package/dist/adapters/node-http/incomingMessageToRequest.mjs +5 -3
  8. package/dist/adapters/node-http/types.d.ts +15 -4
  9. package/dist/adapters/node-http/types.d.ts.map +1 -1
  10. package/dist/adapters/standalone.d.ts +4 -0
  11. package/dist/adapters/standalone.d.ts.map +1 -1
  12. package/dist/adapters/standalone.js +10 -3
  13. package/dist/adapters/standalone.mjs +10 -4
  14. package/dist/adapters/ws.d.ts.map +1 -1
  15. package/dist/adapters/ws.js +2 -1
  16. package/dist/adapters/ws.mjs +2 -1
  17. package/dist/bundle-analysis.json +51 -50
  18. package/dist/unstable-core-do-not-import/http/contentType.d.ts +1 -0
  19. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  20. package/dist/unstable-core-do-not-import/http/contentType.js +6 -3
  21. package/dist/unstable-core-do-not-import/http/contentType.mjs +6 -3
  22. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
  23. package/dist/unstable-core-do-not-import/http/resolveResponse.js +2 -1
  24. package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +2 -1
  25. package/dist/unstable-core-do-not-import/http/types.d.ts +4 -0
  26. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  27. package/dist/unstable-core-do-not-import/procedure.d.ts +0 -11
  28. package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -1
  29. package/package.json +4 -4
  30. package/src/@trpc/server/index.ts +0 -1
  31. package/src/adapters/fastify/fastifyRequestHandler.ts +2 -2
  32. package/src/adapters/node-http/incomingMessageToRequest.ts +11 -22
  33. package/src/adapters/node-http/types.ts +28 -5
  34. package/src/adapters/standalone.ts +38 -6
  35. package/src/adapters/ws.ts +1 -0
  36. package/src/unstable-core-do-not-import/http/contentType.ts +4 -0
  37. package/src/unstable-core-do-not-import/http/resolveResponse.ts +1 -0
  38. package/src/unstable-core-do-not-import/http/types.ts +4 -0
  39. package/src/unstable-core-do-not-import/procedure.ts +0 -13
@@ -2,7 +2,7 @@ export { TRPCError,
2
2
  /**
3
3
  * @deprecated use `experimental_trpcMiddleware` instead
4
4
  */
5
- experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, callProcedure as callTRPCProcedure, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferProcedureBuilderResolverOptions, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferClientTypes as inferTRPCClientTypes, type AnyClientTypes as AnyTRPCClientTypes, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type RouterRecord as TRPCRouterRecord, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, type ProcedureOptions as TRPCProcedureOptions, type CreateContextCallback, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, StandardSchemaV1Error,
5
+ experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, callProcedure as callTRPCProcedure, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferProcedureBuilderResolverOptions, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferClientTypes as inferTRPCClientTypes, type AnyClientTypes as AnyTRPCClientTypes, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type RouterRecord as TRPCRouterRecord, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, type CreateContextCallback, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, StandardSchemaV1Error,
6
6
  /**
7
7
  * @deprecated use `tracked(id, data)` instead
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS;AACT;;GAEG;AACH,iCAAiC,EACjC,iCAAiC,IAAI,2BAA2B,EAChE,QAAQ,EAER,aAAa,IAAI,iBAAiB,EAClC,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,IAAI,mBAAmB,EACtC,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oCAAoC,EACzC,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,IAAI,oBAAoB,EAC7C,KAAK,cAAc,IAAI,kBAAkB,EACzC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,YAAY,IAAI,gBAAgB,E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Q,EAAE,SAAS,CAAC,iBAkCjE"}
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;AAGjC,OAAO,EAEL,KAAK,2BAA2B,EACjC,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,22 +1,9 @@
1
- import type * as http from 'http';
2
- export interface UniversalIncomingMessage extends Omit<http.IncomingMessage, 'socket'> {
3
- /**
4
- * Many adapters will add a `body` property to the incoming message and pre-parse the body
5
- */
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']>;
14
- }
15
- export declare function createURL(req: UniversalIncomingMessage): URL;
1
+ import type { NodeHTTPRequest, NodeHTTPResponse } from './types';
2
+ export declare function createURL(req: NodeHTTPRequest): URL;
16
3
  /**
17
4
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
18
5
  */
19
- export declare function incomingMessageToRequest(req: UniversalIncomingMessage, res: http.ServerResponse, opts: {
6
+ export declare function incomingMessageToRequest(req: NodeHTTPRequest, res: NodeHTTPResponse, opts: {
20
7
  /**
21
8
  * Max body size in bytes. If the body is larger than this, the request will be aborted
22
9
  */
@@ -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,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"}
1
+ {"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAiEjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,GAAG,CAqBnD;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAqCT"}
@@ -55,8 +55,10 @@ function createBody(req, opts) {
55
55
  }
56
56
  function createURL(req) {
57
57
  try {
58
- const protocol = req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
59
- const host = req.headers.host ?? 'localhost';
58
+ const protocol = // http2
59
+ req.headers[':scheme'] && req.headers[':scheme'] === 'https' || // http1
60
+ req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
61
+ const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';
60
62
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
63
  return new URL(req.url, `${protocol}//${host}`);
62
64
  } catch (cause) {
@@ -95,7 +97,7 @@ function createHeaders(incoming) {
95
97
  ac.abort();
96
98
  };
97
99
  res.once('close', onAbort);
98
- req.socket?.once?.('end', onAbort);
100
+ req.socket?.once?.('close', onAbort);
99
101
  // Get host from either regular header or HTTP/2 pseudo-header
100
102
  const url = createURL(req);
101
103
  const init = {
@@ -53,8 +53,10 @@ function createBody(req, opts) {
53
53
  }
54
54
  function createURL(req) {
55
55
  try {
56
- const protocol = req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
57
- const host = req.headers.host ?? 'localhost';
56
+ const protocol = // http2
57
+ req.headers[':scheme'] && req.headers[':scheme'] === 'https' || // http1
58
+ req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
59
+ const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';
58
60
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
59
61
  return new URL(req.url, `${protocol}//${host}`);
60
62
  } catch (cause) {
@@ -93,7 +95,7 @@ function createHeaders(incoming) {
93
95
  ac.abort();
94
96
  };
95
97
  res.once('close', onAbort);
96
- req.socket?.once?.('end', onAbort);
98
+ req.socket?.once?.('close', onAbort);
97
99
  // Get host from either regular header or HTTP/2 pseudo-header
98
100
  const url = createURL(req);
99
101
  const init = {
@@ -8,14 +8,24 @@
8
8
  * ```
9
9
  */
10
10
  import type * as http from 'http';
11
+ import type * as http2 from 'http2';
11
12
  import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../../@trpc/server';
12
13
  import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
13
- import type { MaybePromise } from '../../unstable-core-do-not-import';
14
- export type NodeHTTPRequest = http.IncomingMessage & {
14
+ import type { DistributiveOmit, MaybePromise } from '../../unstable-core-do-not-import';
15
+ export type NodeHTTPRequest = DistributiveOmit<http.IncomingMessage | http2.Http2ServerRequest, 'socket'> & {
16
+ /**
17
+ * Many adapters will add a `body` property to the incoming message and pre-parse the body
18
+ */
15
19
  body?: unknown;
16
- query?: unknown;
20
+ /**
21
+ * Socket is not always available in all deployments, so we need to make it optional
22
+ * @see https://github.com/trpc/trpc/issues/6341
23
+ * The socket object provided in the request does not fully implement the expected Node.js Socket interface.
24
+ * @see https://github.com/trpc/trpc/pull/6358
25
+ */
26
+ socket?: Partial<http.IncomingMessage['socket']> | Partial<http2.Http2ServerRequest['socket']>;
17
27
  };
18
- export type NodeHTTPResponse = http.ServerResponse & {
28
+ export type NodeHTTPResponse = DistributiveOmit<http.ServerResponse | http2.Http2ServerResponse, 'write'> & {
19
29
  /**
20
30
  * Force the partially-compressed response to be flushed to the client.
21
31
  *
@@ -25,6 +35,7 @@ export type NodeHTTPResponse = http.ServerResponse & {
25
35
  * e.g. Express w/ `compression()`)
26
36
  */
27
37
  flush?: () => void;
38
+ write: (chunk: string | Uint8Array) => boolean;
28
39
  };
29
40
  export type NodeHTTPCreateContextOption<TRouter extends AnyRouter, TRequest, TResponse> = CreateContextCallback<inferRouterContext<TRouter>, NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>>;
30
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAElC,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,GAAG;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,GAAG;IACnD;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,CACrC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,qBAAqB,CACvB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CACtD,CAAC;AAEF;;GAEG;AACH,KAAK,iBAAiB,CACpB,QAAQ,SAAS,eAAe,GAAG,eAAe,EAClD,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,IACnD,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAA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GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,CAAC;AAEtE,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IAC1D;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEJ,MAAM,MAAM,6BAA6B,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC;IACF,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEzD,MAAM,MAAM,8BAA8B,CAAC,QAAQ,EAAE,SAAS,IAAI;IAChE,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,CACF,IAAI,EAAE,8BAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,KACtD,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -8,6 +8,7 @@
8
8
  * ```
9
9
  */
10
10
  import http from 'http';
11
+ import type * as http2 from 'http2';
11
12
  import { type AnyRouter } from '../@trpc/server';
12
13
  import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from './node-http';
13
14
  export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
@@ -17,4 +18,7 @@ export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.Incom
17
18
  */
18
19
  export declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
19
20
  export declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
21
+ export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
22
+ export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
23
+ export declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
20
24
  //# sourceMappingURL=standalone.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CACnE,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,IAAI,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C,IAAI,EAAE,yBAAyB,CAAC,SAAS,CAAC,gGAvDvC,IAAI,CAyDzC"}
@@ -8,9 +8,7 @@ require('../unstable-core-do-not-import/rootConfig.js');
8
8
  var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
9
9
  var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js');
10
10
 
11
- /**
12
- * @internal
13
- */ function createHTTPHandler(opts) {
11
+ function createHandler(opts) {
14
12
  return (req, res)=>{
15
13
  let path = '';
16
14
  utils.run(async ()=>{
@@ -32,9 +30,18 @@ var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js'
32
30
  }));
33
31
  };
34
32
  }
33
+ /**
34
+ * @internal
35
+ */ function createHTTPHandler(opts) {
36
+ return createHandler(opts);
37
+ }
35
38
  function createHTTPServer(opts) {
36
39
  return http.createServer(createHTTPHandler(opts));
37
40
  }
41
+ function createHTTP2Handler(opts) {
42
+ return createHandler(opts);
43
+ }
38
44
 
45
+ exports.createHTTP2Handler = createHTTP2Handler;
39
46
  exports.createHTTPHandler = createHTTPHandler;
40
47
  exports.createHTTPServer = createHTTPServer;
@@ -6,9 +6,7 @@ import '../unstable-core-do-not-import/rootConfig.mjs';
6
6
  import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/nodeHTTPRequestHandler.mjs';
7
7
  import { createURL } from './node-http/incomingMessageToRequest.mjs';
8
8
 
9
- /**
10
- * @internal
11
- */ function createHTTPHandler(opts) {
9
+ function createHandler(opts) {
12
10
  return (req, res)=>{
13
11
  let path = '';
14
12
  run(async ()=>{
@@ -30,8 +28,16 @@ import { createURL } from './node-http/incomingMessageToRequest.mjs';
30
28
  }));
31
29
  };
32
30
  }
31
+ /**
32
+ * @internal
33
+ */ function createHTTPHandler(opts) {
34
+ return createHandler(opts);
35
+ }
33
36
  function createHTTPServer(opts) {
34
37
  return http.createServer(createHTTPHandler(opts));
35
38
  }
39
+ function createHTTP2Handler(opts) {
40
+ return createHandler(opts);
41
+ }
36
42
 
37
- export { createHTTPHandler, createHTTPServer };
43
+ export { createHTTP2Handler, createHTTPHandler, createHTTPServer };
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAa/D,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,EAAa,KAAK,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQ7E;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CACpE,eAAe,EACf,EAAE,CAAC,SAAS,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,MAAM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SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,YAKV,EAAE,CAAC,SAAS,OAAO,eAAe,mBAmYzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,EAAE,CAAC,SAAS,EACpB,MAAM,SAAS,EACf,UAAU,SAAQ,QAiCnB;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAwCjC"}
@@ -109,7 +109,8 @@ function getWSConnectionHandler(opts) {
109
109
  isBatchCall: false,
110
110
  accept: null,
111
111
  type: 'unknown',
112
- signal: abortController.signal
112
+ signal: abortController.signal,
113
+ url: null
113
114
  }
114
115
  });
115
116
  return ctx;
@@ -107,7 +107,8 @@ function getWSConnectionHandler(opts) {
107
107
  isBatchCall: false,
108
108
  accept: null,
109
109
  type: 'unknown',
110
- signal: abortController.signal
110
+ signal: abortController.signal,
111
+ url: null
111
112
  }
112
113
  });
113
114
  return ctx;
@@ -1,12 +1,12 @@
1
1
  {
2
- "bundleSize": 194424,
3
- "bundleOrigSize": 224908,
4
- "bundleReduction": 13.55,
2
+ "bundleSize": 194829,
3
+ "bundleOrigSize": 225251,
4
+ "bundleReduction": 13.51,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
8
- "size": 21013,
9
- "origSize": 19389,
8
+ "size": 21038,
9
+ "origSize": 19404,
10
10
  "renderedExports": [
11
11
  "resolveResponse"
12
12
  ],
@@ -14,13 +14,13 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 10.81,
17
+ "percent": 10.8,
18
18
  "reduction": 0
19
19
  },
20
20
  {
21
21
  "id": "/src/adapters/ws.ts",
22
- "size": 20133,
23
- "origSize": 15932,
22
+ "size": 20168,
23
+ "origSize": 15955,
24
24
  "renderedExports": [
25
25
  "getWSConnectionHandler",
26
26
  "handleKeepAlive",
@@ -30,7 +30,7 @@
30
30
  "dependents": [
31
31
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
32
32
  ],
33
- "percent": 10.36,
33
+ "percent": 10.35,
34
34
  "reduction": 0
35
35
  },
36
36
  {
@@ -47,7 +47,7 @@
47
47
  "/src/unstable-core-do-not-import.ts",
48
48
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
49
49
  ],
50
- "percent": 10.3,
50
+ "percent": 10.27,
51
51
  "reduction": 0
52
52
  },
53
53
  {
@@ -64,7 +64,7 @@
64
64
  "/src/unstable-core-do-not-import.ts",
65
65
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
66
66
  ],
67
- "percent": 6.49,
67
+ "percent": 6.48,
68
68
  "reduction": 0
69
69
  },
70
70
  {
@@ -77,7 +77,7 @@
77
77
  ],
78
78
  "removedExports": [],
79
79
  "dependents": [],
80
- "percent": 6.25,
80
+ "percent": 6.24,
81
81
  "reduction": 11.62
82
82
  },
83
83
  {
@@ -91,13 +91,13 @@
91
91
  "dependents": [
92
92
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
93
93
  ],
94
- "percent": 4.18,
94
+ "percent": 4.17,
95
95
  "reduction": 0
96
96
  },
97
97
  {
98
98
  "id": "/src/unstable-core-do-not-import/http/contentType.ts",
99
- "size": 7685,
100
- "origSize": 7608,
99
+ "size": 7766,
100
+ "origSize": 7690,
101
101
  "renderedExports": [
102
102
  "getRequestInfo"
103
103
  ],
@@ -106,7 +106,7 @@
106
106
  "/src/unstable-core-do-not-import.ts",
107
107
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
108
108
  ],
109
- "percent": 3.95,
109
+ "percent": 3.99,
110
110
  "reduction": 0
111
111
  },
112
112
  {
@@ -124,7 +124,7 @@
124
124
  "/src/unstable-core-do-not-import.ts",
125
125
  "/src/unstable-core-do-not-import/initTRPC.ts"
126
126
  ],
127
- "percent": 3.32,
127
+ "percent": 3.31,
128
128
  "reduction": 39.41
129
129
  },
130
130
  {
@@ -143,7 +143,7 @@
143
143
  "/src/unstable-core-do-not-import/stream/sse.ts",
144
144
  "/src/unstable-core-do-not-import/stream/utils/withPing.ts"
145
145
  ],
146
- "percent": 3,
146
+ "percent": 2.99,
147
147
  "reduction": 0
148
148
  },
149
149
  {
@@ -158,7 +158,7 @@
158
158
  "/src/unstable-core-do-not-import.ts",
159
159
  "/src/unstable-core-do-not-import/initTRPC.ts"
160
160
  ],
161
- "percent": 2.98,
161
+ "percent": 2.97,
162
162
  "reduction": 65.01
163
163
  },
164
164
  {
@@ -192,7 +192,7 @@
192
192
  "/src/observable/operators.ts",
193
193
  "/src/observable/behaviorSubject.ts"
194
194
  ],
195
- "percent": 2.49,
195
+ "percent": 2.48,
196
196
  "reduction": 0
197
197
  },
198
198
  {
@@ -212,8 +212,8 @@
212
212
  },
213
213
  {
214
214
  "id": "/src/adapters/node-http/incomingMessageToRequest.ts",
215
- "size": 3918,
216
- "origSize": 4751,
215
+ "size": 4047,
216
+ "origSize": 4343,
217
217
  "renderedExports": [
218
218
  "createURL",
219
219
  "incomingMessageToRequest"
@@ -223,8 +223,8 @@
223
223
  "/src/adapters/node-http/index.ts",
224
224
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
225
225
  ],
226
- "percent": 2.02,
227
- "reduction": 17.53
226
+ "percent": 2.08,
227
+ "reduction": 6.82
228
228
  },
229
229
  {
230
230
  "id": "/src/observable/operators.ts",
@@ -351,18 +351,18 @@
351
351
  "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
352
352
  "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
353
353
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
354
+ "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
354
355
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
355
356
  "/src/unstable-core-do-not-import/transformer.ts",
356
357
  "/src/unstable-core-do-not-import/middleware.ts",
357
358
  "/src/unstable-core-do-not-import/router.ts",
358
- "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
359
359
  "/src/unstable-core-do-not-import/http/contentType.ts",
360
360
  "/src/unstable-core-do-not-import/http/isAbortError.ts",
361
361
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
362
362
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
363
363
  "/src/unstable-core-do-not-import/stream/sse.ts"
364
364
  ],
365
- "percent": 1.27,
365
+ "percent": 1.26,
366
366
  "reduction": 17.51
367
367
  },
368
368
  {
@@ -574,7 +574,7 @@
574
574
  {
575
575
  "id": "/src/adapters/fastify/fastifyRequestHandler.ts",
576
576
  "size": 1146,
577
- "origSize": 2174,
577
+ "origSize": 2185,
578
578
  "renderedExports": [
579
579
  "fastifyRequestHandler"
580
580
  ],
@@ -584,7 +584,7 @@
584
584
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
585
585
  ],
586
586
  "percent": 0.59,
587
- "reduction": 47.29
587
+ "reduction": 47.55
588
588
  },
589
589
  {
590
590
  "id": "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
@@ -613,7 +613,7 @@
613
613
  "dependents": [
614
614
  "/src/unstable-core-do-not-import.ts"
615
615
  ],
616
- "percent": 0.55,
616
+ "percent": 0.54,
617
617
  "reduction": 0
618
618
  },
619
619
  {
@@ -630,6 +630,20 @@
630
630
  "percent": 0.5,
631
631
  "reduction": 32.89
632
632
  },
633
+ {
634
+ "id": "/src/adapters/standalone.ts",
635
+ "size": 900,
636
+ "origSize": 2580,
637
+ "renderedExports": [
638
+ "createHTTPHandler",
639
+ "createHTTPServer",
640
+ "createHTTP2Handler"
641
+ ],
642
+ "removedExports": [],
643
+ "dependents": [],
644
+ "percent": 0.46,
645
+ "reduction": 65.12
646
+ },
633
647
  {
634
648
  "id": "/src/adapters/express.ts",
635
649
  "size": 887,
@@ -659,19 +673,6 @@
659
673
  "percent": 0.4,
660
674
  "reduction": 44.13
661
675
  },
662
- {
663
- "id": "/src/adapters/standalone.ts",
664
- "size": 765,
665
- "origSize": 1765,
666
- "renderedExports": [
667
- "createHTTPHandler",
668
- "createHTTPServer"
669
- ],
670
- "removedExports": [],
671
- "dependents": [],
672
- "percent": 0.39,
673
- "reduction": 56.66
674
- },
675
676
  {
676
677
  "id": "/src/adapters/aws-lambda/index.ts",
677
678
  "size": 759,
@@ -823,7 +824,7 @@
823
824
  {
824
825
  "id": "/src/unstable-core-do-not-import/procedure.ts",
825
826
  "size": 75,
826
- "origSize": 2668,
827
+ "origSize": 2473,
827
828
  "renderedExports": [
828
829
  "procedureTypes"
829
830
  ],
@@ -833,7 +834,7 @@
833
834
  "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts"
834
835
  ],
835
836
  "percent": 0.04,
836
- "reduction": 97.19
837
+ "reduction": 96.97
837
838
  },
838
839
  {
839
840
  "id": "/src/unstable-core-do-not-import/error/formatter.ts",
@@ -864,9 +865,9 @@
864
865
  "reduction": 100
865
866
  },
866
867
  {
867
- "id": "/src/index.ts",
868
+ "id": "/src/rpc.ts",
868
869
  "size": 0,
869
- "origSize": 32,
870
+ "origSize": 36,
870
871
  "renderedExports": [],
871
872
  "removedExports": [],
872
873
  "dependents": [],
@@ -874,9 +875,9 @@
874
875
  "reduction": 100
875
876
  },
876
877
  {
877
- "id": "/src/rpc.ts",
878
+ "id": "/src/index.ts",
878
879
  "size": 0,
879
- "origSize": 36,
880
+ "origSize": 32,
880
881
  "renderedExports": [],
881
882
  "removedExports": [],
882
883
  "dependents": [],
@@ -901,8 +902,8 @@
901
902
  "removedExports": [],
902
903
  "dependents": [
903
904
  "/src/adapters/express.ts",
904
- "/src/adapters/next.ts",
905
905
  "/src/adapters/standalone.ts",
906
+ "/src/adapters/next.ts",
906
907
  "/src/adapters/ws.ts",
907
908
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
908
909
  "/src/adapters/next-app-dir/nextAppDirCaller.ts",
@@ -961,8 +962,8 @@
961
962
  "removedExports": [],
962
963
  "dependents": [
963
964
  "/src/adapters/express.ts",
964
- "/src/adapters/next.ts",
965
965
  "/src/adapters/standalone.ts",
966
+ "/src/adapters/next.ts",
966
967
  "/src/adapters/ws.ts",
967
968
  "/src/adapters/fastify/fastifyRequestHandler.ts"
968
969
  ],
@@ -3,6 +3,7 @@ import type { TRPCRequestInfo } from './types';
3
3
  type GetRequestInfoOptions = {
4
4
  path: string;
5
5
  req: Request;
6
+ url: URL | null;
6
7
  searchParams: URLSearchParams;
7
8
  headers: Headers;
8
9
  router: AnyRouter;
@@ -1 +1 @@
1
- {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAwQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,eAAe,CAG3E"}
1
+ {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAChB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AA2QF,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,eAAe,CAG3E"}
@@ -129,7 +129,8 @@ const jsonContentTypeHandler = {
129
129
  calls,
130
130
  type,
131
131
  connectionParams: connectionParamsStr === null ? null : parseConnectionParams.parseConnectionParamsFromString(connectionParamsStr),
132
- signal: req.signal
132
+ signal: req.signal,
133
+ url: opts.url
133
134
  };
134
135
  return info;
135
136
  }
@@ -163,7 +164,8 @@ const formDataContentTypeHandler = {
163
164
  isBatchCall: false,
164
165
  type: 'mutation',
165
166
  connectionParams: null,
166
- signal: req.signal
167
+ signal: req.signal,
168
+ url: opts.url
167
169
  };
168
170
  }
169
171
  };
@@ -195,7 +197,8 @@ const octetStreamContentTypeHandler = {
195
197
  accept: null,
196
198
  type: 'mutation',
197
199
  connectionParams: null,
198
- signal: req.signal
200
+ signal: req.signal,
201
+ url: opts.url
199
202
  };
200
203
  }
201
204
  };
@@ -127,7 +127,8 @@ const jsonContentTypeHandler = {
127
127
  calls,
128
128
  type,
129
129
  connectionParams: connectionParamsStr === null ? null : parseConnectionParamsFromString(connectionParamsStr),
130
- signal: req.signal
130
+ signal: req.signal,
131
+ url: opts.url
131
132
  };
132
133
  return info;
133
134
  }
@@ -161,7 +162,8 @@ const formDataContentTypeHandler = {
161
162
  isBatchCall: false,
162
163
  type: 'mutation',
163
164
  connectionParams: null,
164
- signal: req.signal
165
+ signal: req.signal,
166
+ url: opts.url
165
167
  };
166
168
  }
167
169
  };
@@ -193,7 +195,8 @@ const octetStreamContentTypeHandler = {
193
195
  accept: null,
194
196
  type: 'mutation',
195
197
  connectionParams: null,
196
- signal: req.signal
198
+ signal: req.signal,
199
+ url: opts.url
197
200
  };
198
201
  }
199
202
  };
@@ -1 +1 @@
1
- {"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA+BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AA2ID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAmfnB"}
1
+ {"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA+BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AA2ID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAofnB"}
@@ -151,7 +151,8 @@ async function resolveResponse(opts) {
151
151
  path: decodeURIComponent(opts.path),
152
152
  router,
153
153
  searchParams: url.searchParams,
154
- headers: opts.req.headers
154
+ headers: opts.req.headers,
155
+ url
155
156
  })
156
157
  ];
157
158
  } catch (cause) {
@@ -149,7 +149,8 @@ async function resolveResponse(opts) {
149
149
  path: decodeURIComponent(opts.path),
150
150
  router,
151
151
  searchParams: url.searchParams,
152
- headers: opts.req.headers
152
+ headers: opts.req.headers,
153
+ url
153
154
  })
154
155
  ];
155
156
  } catch (cause) {
@@ -88,6 +88,10 @@ export interface TRPCRequestInfo {
88
88
  * Can be used to abort async operations during the request, e.g. `fetch()`-requests
89
89
  */
90
90
  signal: AbortSignal;
91
+ /**
92
+ * The URL of the request if available
93
+ */
94
+ url: URL | null;
91
95
  }
92
96
  /**
93
97
  * Inner createContext function for `resolveResponse` used to forward `TRPCRequestInfo` to `createContext`
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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QAAQ,CACnE,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxD,GAAG,EAAE,QAAQ,CAAC;CACf;AACD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,IAAI,CAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAC7C,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -5,17 +5,6 @@ export declare const procedureTypes: readonly ["query", "mutation", "subscriptio
5
5
  * @public
6
6
  */
7
7
  export type ProcedureType = (typeof procedureTypes)[number];
8
- type ClientContext = Record<string, unknown>;
9
- /**
10
- * @internal
11
- */
12
- export interface ProcedureOptions {
13
- /**
14
- * Client-side context
15
- */
16
- context?: ClientContext;
17
- signal?: AbortSignal;
18
- }
19
8
  interface BuiltProcedureDef {
20
9
  input: unknown;
21
10
  output: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,eAAO,MAAM,cAAc,gDAAiD,CAAC;AAC7E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CA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.0.0-rc.729+a60413241",
3
+ "version": "11.0.0-rc.740+df313f4ad",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -120,7 +120,7 @@
120
120
  "@fastify/websocket": "^10.0.1",
121
121
  "@tanstack/react-query": "^5.62.8",
122
122
  "@types/aws-lambda": "^8.10.137",
123
- "@types/express": "^4.17.17",
123
+ "@types/express": "^5.0.0",
124
124
  "@types/hash-sum": "^1.0.0",
125
125
  "@types/node": "^22.9.0",
126
126
  "@types/react": "^19.0.0",
@@ -141,7 +141,7 @@
141
141
  "superstruct": "^2.0.0",
142
142
  "tsx": "^4.0.0",
143
143
  "typescript": "^5.7.2",
144
- "valibot": "1.0.0-beta.14",
144
+ "valibot": "1.0.0-beta.15",
145
145
  "ws": "^8.0.0",
146
146
  "yup": "^1.0.0",
147
147
  "zod": "^3.0.0"
@@ -152,5 +152,5 @@
152
152
  "peerDependencies": {
153
153
  "typescript": ">=5.7.2"
154
154
  },
155
- "gitHead": "a60413241c05b258da0cbc7cbfb8b4097aeb3f72"
155
+ "gitHead": "df313f4ade37202545103974aeeb4975e9c032cb"
156
156
  }
@@ -31,7 +31,6 @@ export {
31
31
  type AnyQueryProcedure as AnyTRPCQueryProcedure,
32
32
  type RouterRecord as TRPCRouterRecord,
33
33
  type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure,
34
- type ProcedureOptions as TRPCProcedureOptions,
35
34
  type CreateContextCallback,
36
35
  type MutationProcedure as TRPCMutationProcedure,
37
36
  type QueryProcedure as TRPCQueryProcedure,
@@ -17,10 +17,10 @@ import {
17
17
  type ResolveHTTPRequestOptionsContextFn,
18
18
  } from '../../@trpc/server/http';
19
19
  // @trpc/server/node-http
20
+ import type { NodeHTTPRequest } from '../node-http';
20
21
  import {
21
22
  incomingMessageToRequest,
22
23
  type NodeHTTPCreateContextOption,
23
- type UniversalIncomingMessage,
24
24
  } from '../node-http';
25
25
 
26
26
  export type FastifyHandlerOptions<
@@ -54,7 +54,7 @@ export async function fastifyRequestHandler<
54
54
  });
55
55
  };
56
56
 
57
- const incomingMessage: UniversalIncomingMessage = opts.req.raw;
57
+ const incomingMessage: NodeHTTPRequest = opts.req.raw;
58
58
 
59
59
  // monkey-path body to the IncomingMessage
60
60
  if ('body' in opts.req) {
@@ -1,23 +1,9 @@
1
1
  import type * as http from 'http';
2
2
  import { TRPCError } from '../../@trpc/server';
3
-
4
- export interface UniversalIncomingMessage
5
- extends Omit<http.IncomingMessage, 'socket'> {
6
- /**
7
- * Many adapters will add a `body` property to the incoming message and pre-parse the body
8
- */
9
- body?: unknown;
10
- /**
11
- * Socket is not always available in all deployments, so we need to make it optional
12
- * @see https://github.com/trpc/trpc/issues/6341
13
- * The socket object provided in the request does not fully implement the expected Node.js Socket interface.
14
- * @see https://github.com/trpc/trpc/pull/6358
15
- */
16
- socket?: Partial<http.IncomingMessage['socket']>;
17
- }
3
+ import type { NodeHTTPRequest, NodeHTTPResponse } from './types';
18
4
 
19
5
  function createBody(
20
- req: UniversalIncomingMessage,
6
+ req: NodeHTTPRequest,
21
7
  opts: {
22
8
  /**
23
9
  * Max body size in bytes. If the body is larger than this, the request will be aborted
@@ -79,14 +65,17 @@ function createBody(
79
65
  },
80
66
  });
81
67
  }
82
- export function createURL(req: UniversalIncomingMessage): URL {
68
+ export function createURL(req: NodeHTTPRequest): URL {
83
69
  try {
84
70
  const protocol =
85
- req.socket && 'encrypted' in req.socket && req.socket.encrypted
71
+ // http2
72
+ (req.headers[':scheme'] && req.headers[':scheme'] === 'https') ||
73
+ // http1
74
+ (req.socket && 'encrypted' in req.socket && req.socket.encrypted)
86
75
  ? 'https:'
87
76
  : 'http:';
88
77
 
89
- const host = req.headers.host ?? 'localhost';
78
+ const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';
90
79
 
91
80
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
92
81
  return new URL(req.url!, `${protocol}//${host}`);
@@ -125,8 +114,8 @@ function createHeaders(incoming: http.IncomingHttpHeaders): Headers {
125
114
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
126
115
  */
127
116
  export function incomingMessageToRequest(
128
- req: UniversalIncomingMessage,
129
- res: http.ServerResponse,
117
+ req: NodeHTTPRequest,
118
+ res: NodeHTTPResponse,
130
119
  opts: {
131
120
  /**
132
121
  * Max body size in bytes. If the body is larger than this, the request will be aborted
@@ -145,7 +134,7 @@ export function incomingMessageToRequest(
145
134
  };
146
135
 
147
136
  res.once('close', onAbort);
148
- req.socket?.once?.('end', onAbort);
137
+ req.socket?.once?.('close', onAbort);
149
138
 
150
139
  // Get host from either regular header or HTTP/2 pseudo-header
151
140
  const url = createURL(req);
@@ -8,6 +8,7 @@
8
8
  * ```
9
9
  */
10
10
  import type * as http from 'http';
11
+ import type * as http2 from 'http2';
11
12
  // @trpc/server
12
13
  import type {
13
14
  AnyRouter,
@@ -20,13 +21,34 @@ import type {
20
21
  TRPCRequestInfo,
21
22
  } from '../../@trpc/server/http';
22
23
  // eslint-disable-next-line no-restricted-imports
23
- import type { MaybePromise } from '../../unstable-core-do-not-import';
24
+ import type {
25
+ DistributiveOmit,
26
+ MaybePromise,
27
+ } from '../../unstable-core-do-not-import';
24
28
 
25
- export type NodeHTTPRequest = http.IncomingMessage & {
29
+ export type NodeHTTPRequest = DistributiveOmit<
30
+ http.IncomingMessage | http2.Http2ServerRequest,
31
+ 'socket'
32
+ > & {
33
+ /**
34
+ * Many adapters will add a `body` property to the incoming message and pre-parse the body
35
+ */
26
36
  body?: unknown;
27
- query?: unknown;
37
+ /**
38
+ * Socket is not always available in all deployments, so we need to make it optional
39
+ * @see https://github.com/trpc/trpc/issues/6341
40
+ * The socket object provided in the request does not fully implement the expected Node.js Socket interface.
41
+ * @see https://github.com/trpc/trpc/pull/6358
42
+ */
43
+ socket?:
44
+ | Partial<http.IncomingMessage['socket']>
45
+ | Partial<http2.Http2ServerRequest['socket']>;
28
46
  };
29
- export type NodeHTTPResponse = http.ServerResponse & {
47
+
48
+ export type NodeHTTPResponse = DistributiveOmit<
49
+ http.ServerResponse | http2.Http2ServerResponse,
50
+ 'write'
51
+ > & {
30
52
  /**
31
53
  * Force the partially-compressed response to be flushed to the client.
32
54
  *
@@ -36,8 +58,9 @@ export type NodeHTTPResponse = http.ServerResponse & {
36
58
  * e.g. Express w/ `compression()`)
37
59
  */
38
60
  flush?: () => void;
39
- };
40
61
 
62
+ write: (chunk: string | Uint8Array) => boolean;
63
+ };
41
64
  export type NodeHTTPCreateContextOption<
42
65
  TRouter extends AnyRouter,
43
66
  TRequest,
@@ -9,6 +9,8 @@
9
9
  */
10
10
 
11
11
  import http from 'http';
12
+ // --- http2 ---
13
+ import type * as http2 from 'http2';
12
14
  // @trpc/server
13
15
  import { type AnyRouter } from '../@trpc/server';
14
16
  // eslint-disable-next-line no-restricted-imports
@@ -16,6 +18,8 @@ import { run } from '../unstable-core-do-not-import';
16
18
  import type {
17
19
  NodeHTTPCreateContextFnOptions,
18
20
  NodeHTTPHandlerOptions,
21
+ NodeHTTPRequest,
22
+ NodeHTTPResponse,
19
23
  } from './node-http';
20
24
  import {
21
25
  createURL,
@@ -23,6 +27,7 @@ import {
23
27
  nodeHTTPRequestHandler,
24
28
  } from './node-http';
25
29
 
30
+ // --- http1 ---
26
31
  export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> =
27
32
  NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
28
33
 
@@ -31,12 +36,13 @@ export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<
31
36
  http.ServerResponse
32
37
  >;
33
38
 
34
- /**
35
- * @internal
36
- */
37
- export function createHTTPHandler<TRouter extends AnyRouter>(
38
- opts: CreateHTTPHandlerOptions<TRouter>,
39
- ): http.RequestListener {
39
+ function createHandler<
40
+ TRouter extends AnyRouter,
41
+ TRequest extends NodeHTTPRequest,
42
+ TResponse extends NodeHTTPResponse,
43
+ >(
44
+ opts: NodeHTTPHandlerOptions<TRouter, TRequest, TResponse>,
45
+ ): (req: TRequest, res: TResponse) => void {
40
46
  return (req, res) => {
41
47
  let path = '';
42
48
  run(async () => {
@@ -63,8 +69,34 @@ export function createHTTPHandler<TRouter extends AnyRouter>(
63
69
  };
64
70
  }
65
71
 
72
+ /**
73
+ * @internal
74
+ */
75
+ export function createHTTPHandler<TRouter extends AnyRouter>(
76
+ opts: CreateHTTPHandlerOptions<TRouter>,
77
+ ): http.RequestListener {
78
+ return createHandler(opts);
79
+ }
80
+
66
81
  export function createHTTPServer<TRouter extends AnyRouter>(
67
82
  opts: CreateHTTPHandlerOptions<TRouter>,
68
83
  ) {
69
84
  return http.createServer(createHTTPHandler(opts));
70
85
  }
86
+
87
+ // --- http2 ---
88
+ export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> =
89
+ NodeHTTPHandlerOptions<
90
+ TRouter,
91
+ http2.Http2ServerRequest,
92
+ http2.Http2ServerResponse
93
+ >;
94
+
95
+ export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<
96
+ http2.Http2ServerRequest,
97
+ http2.Http2ServerResponse
98
+ >;
99
+
100
+ export function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>) {
101
+ return createHandler(opts);
102
+ }
@@ -136,6 +136,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
136
136
  accept: null,
137
137
  type: 'unknown',
138
138
  signal: abortController.signal,
139
+ url: null,
139
140
  },
140
141
  });
141
142
 
@@ -8,6 +8,7 @@ import type { TRPCAcceptHeader, TRPCRequestInfo } from './types';
8
8
  type GetRequestInfoOptions = {
9
9
  path: string;
10
10
  req: Request;
11
+ url: URL | null;
11
12
  searchParams: URLSearchParams;
12
13
  headers: Headers;
13
14
  router: AnyRouter;
@@ -174,6 +175,7 @@ const jsonContentTypeHandler: ContentTypeHandler = {
174
175
  ? null
175
176
  : parseConnectionParamsFromString(connectionParamsStr),
176
177
  signal: req.signal,
178
+ url: opts.url,
177
179
  };
178
180
  return info;
179
181
  },
@@ -210,6 +212,7 @@ const formDataContentTypeHandler: ContentTypeHandler = {
210
212
  type: 'mutation',
211
213
  connectionParams: null,
212
214
  signal: req.signal,
215
+ url: opts.url,
213
216
  };
214
217
  },
215
218
  };
@@ -246,6 +249,7 @@ const octetStreamContentTypeHandler: ContentTypeHandler = {
246
249
  type: 'mutation',
247
250
  connectionParams: null,
248
251
  signal: req.signal,
252
+ url: opts.url,
249
253
  };
250
254
  },
251
255
  };
@@ -233,6 +233,7 @@ export async function resolveResponse<TRouter extends AnyRouter>(
233
233
  router,
234
234
  searchParams: url.searchParams,
235
235
  headers: opts.req.headers,
236
+ url,
236
237
  }),
237
238
  ];
238
239
  } catch (cause) {
@@ -104,6 +104,10 @@ export interface TRPCRequestInfo {
104
104
  * Can be used to abort async operations during the request, e.g. `fetch()`-requests
105
105
  */
106
106
  signal: AbortSignal;
107
+ /**
108
+ * The URL of the request if available
109
+ */
110
+ url: URL | null;
107
111
  }
108
112
 
109
113
  /**
@@ -7,19 +7,6 @@ export const procedureTypes = ['query', 'mutation', 'subscription'] as const;
7
7
  */
8
8
  export type ProcedureType = (typeof procedureTypes)[number];
9
9
 
10
- type ClientContext = Record<string, unknown>;
11
-
12
- /**
13
- * @internal
14
- */
15
- export interface ProcedureOptions {
16
- /**
17
- * Client-side context
18
- */
19
- context?: ClientContext;
20
- signal?: AbortSignal;
21
- }
22
-
23
10
  interface BuiltProcedureDef {
24
11
  input: unknown;
25
12
  output: unknown;