@trpc/server 11.21.1-canary.20.10e2ef98f → 11.21.1-canary.64.fa0d7c75f

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 (177) hide show
  1. package/dist/adapters/aws-lambda/index.cjs +3 -2
  2. package/dist/adapters/aws-lambda/index.d.cts +2 -1
  3. package/dist/adapters/aws-lambda/index.d.mts +2 -1
  4. package/dist/adapters/aws-lambda/index.mjs +3 -2
  5. package/dist/adapters/aws-lambda/index.mjs.map +1 -1
  6. package/dist/adapters/express.cjs +4 -3
  7. package/dist/adapters/express.d.cts +3 -2
  8. package/dist/adapters/express.d.mts +3 -2
  9. package/dist/adapters/express.mjs +4 -3
  10. package/dist/adapters/express.mjs.map +1 -1
  11. package/dist/adapters/fastify/index.cjs +5 -9
  12. package/dist/adapters/fastify/index.d.cts +8 -3
  13. package/dist/adapters/fastify/index.d.cts.map +1 -1
  14. package/dist/adapters/fastify/index.d.mts +8 -3
  15. package/dist/adapters/fastify/index.d.mts.map +1 -1
  16. package/dist/adapters/fastify/index.mjs +5 -9
  17. package/dist/adapters/fastify/index.mjs.map +1 -1
  18. package/dist/adapters/fetch/index.cjs +3 -2
  19. package/dist/adapters/fetch/index.d.cts +2 -1
  20. package/dist/adapters/fetch/index.d.mts +2 -1
  21. package/dist/adapters/fetch/index.mjs +3 -2
  22. package/dist/adapters/next-app-dir.cjs +4 -3
  23. package/dist/adapters/next-app-dir.d.cts +2 -1
  24. package/dist/adapters/next-app-dir.d.mts +2 -1
  25. package/dist/adapters/next-app-dir.mjs +3 -2
  26. package/dist/adapters/next.cjs +5 -4
  27. package/dist/adapters/next.d.cts +3 -2
  28. package/dist/adapters/next.d.mts +3 -2
  29. package/dist/adapters/next.mjs +5 -4
  30. package/dist/adapters/next.mjs.map +1 -1
  31. package/dist/adapters/node-http/index.cjs +2 -1
  32. package/dist/adapters/node-http/index.d.cts +2 -2
  33. package/dist/adapters/node-http/index.d.mts +2 -2
  34. package/dist/adapters/node-http/index.mjs +2 -1
  35. package/dist/adapters/standalone.cjs +5 -4
  36. package/dist/adapters/standalone.d.cts +3 -2
  37. package/dist/adapters/standalone.d.mts +3 -2
  38. package/dist/adapters/standalone.mjs +4 -3
  39. package/dist/adapters/standalone.mjs.map +1 -1
  40. package/dist/adapters/ws.cjs +2 -1
  41. package/dist/adapters/ws.d.cts +2 -85
  42. package/dist/adapters/ws.d.mts +2 -85
  43. package/dist/adapters/ws.mjs +2 -1
  44. package/dist/{asyncGeneratorDelegate-D2tFgl_z.cjs → asyncGeneratorDelegate-Dj-8tGhf.cjs} +29 -15
  45. package/dist/{asyncGeneratorDelegate-mPyp1u6d.mjs → asyncGeneratorDelegate-FcEJT04i.mjs} +30 -16
  46. package/dist/asyncGeneratorDelegate-FcEJT04i.mjs.map +1 -0
  47. package/dist/{codes-D6C_OiJy.mjs → codes-C9N0z0an.mjs} +2 -1
  48. package/dist/{codes-D6C_OiJy.mjs.map → codes-C9N0z0an.mjs.map} +1 -1
  49. package/dist/{codes-BwD4QurF.cjs → codes-HK4UsP07.cjs} +1 -0
  50. package/dist/{contentTypeParsers-DUzXRHT1.cjs → contentTypeParsers-B1e2ZNvN.cjs} +1 -0
  51. package/dist/{contentTypeParsers-KFMy_fwz.mjs → contentTypeParsers-Bb-9hUEf.mjs} +2 -1
  52. package/dist/{contentTypeParsers-KFMy_fwz.mjs.map → contentTypeParsers-Bb-9hUEf.mjs.map} +1 -1
  53. package/dist/{getErrorShape-CVxLwJgN.cjs → getErrorShape-hncV8cPE.cjs} +2 -1
  54. package/dist/{getErrorShape-BziUKLM_.mjs → getErrorShape-zlj81BiC.mjs} +3 -2
  55. package/dist/{getErrorShape-BziUKLM_.mjs.map → getErrorShape-zlj81BiC.mjs.map} +1 -1
  56. package/dist/http.cjs +4 -3
  57. package/dist/http.d.cts +2 -2
  58. package/dist/http.d.mts +2 -2
  59. package/dist/http.mjs +4 -3
  60. package/dist/{index-BMimGNYb.d.cts → index-BI3Qi_F-.d.cts} +2 -1
  61. package/dist/{index-BMimGNYb.d.cts.map → index-BI3Qi_F-.d.cts.map} +1 -1
  62. package/dist/{index-BMimGNYb.d.mts → index-BI3Qi_F-.d.mts} +2 -1
  63. package/dist/{index-BMimGNYb.d.mts.map → index-BI3Qi_F-.d.mts.map} +1 -1
  64. package/dist/{index-BDZDS1SD.d.mts → index-D7foMQMh.d.cts} +5 -4
  65. package/dist/index-D7foMQMh.d.cts.map +1 -0
  66. package/dist/{index-BzKrDvzg.d.cts → index-DPj2-I1U.d.mts} +5 -4
  67. package/dist/index-DPj2-I1U.d.mts.map +1 -0
  68. package/dist/index.cjs +4 -3
  69. package/dist/index.d.cts +2 -1
  70. package/dist/index.d.mts +2 -1
  71. package/dist/index.mjs +4 -3
  72. package/dist/{initTRPC-DLNeKv0z.cjs → initTRPC-DP-s8c4t.cjs} +5 -4
  73. package/dist/{initTRPC-DpOypWK_.mjs → initTRPC-RMeQIy9H.mjs} +6 -5
  74. package/dist/initTRPC-RMeQIy9H.mjs.map +1 -0
  75. package/dist/{node-http-B_z10Yky.mjs → node-http-B5jkpWn7.mjs} +29 -12
  76. package/dist/node-http-B5jkpWn7.mjs.map +1 -0
  77. package/dist/{node-http-Bti3aBT6.cjs → node-http-BZ0HlzkC.cjs} +28 -11
  78. package/dist/observable/index.cjs +3 -2
  79. package/dist/observable/index.d.cts +2 -2
  80. package/dist/observable/index.d.mts +2 -2
  81. package/dist/observable/index.mjs +3 -2
  82. package/dist/{observable-CIyO2eSm.cjs → observable-C-LvH26G.cjs} +1 -0
  83. package/dist/{observable-CSprJVOf.mjs → observable-CkXWrCsV.mjs} +60 -31
  84. package/dist/observable-CkXWrCsV.mjs.map +1 -0
  85. package/dist/{observable-D8mqXlHG.cjs → observable-xBsJ11Ns.cjs} +59 -30
  86. package/dist/{observable-DwUFSuKv.mjs → observable-yEyhfXUI.mjs} +2 -1
  87. package/dist/{observable-DwUFSuKv.mjs.map → observable-yEyhfXUI.mjs.map} +1 -1
  88. package/dist/{parseTRPCMessage-CSh-CVPr.mjs → parseTRPCMessage-CJ4DJVBp.mjs} +3 -2
  89. package/dist/{parseTRPCMessage-CSh-CVPr.mjs.map → parseTRPCMessage-CJ4DJVBp.mjs.map} +1 -1
  90. package/dist/{parseTRPCMessage-RJS87G_t.cjs → parseTRPCMessage-CPEfSSFx.cjs} +2 -1
  91. package/dist/{resolveResponse-CrB_9MSD.mjs → resolveResponse-DH5L33sC.mjs} +108 -40
  92. package/dist/resolveResponse-DH5L33sC.mjs.map +1 -0
  93. package/dist/{resolveResponse-D5JAuwvU.cjs → resolveResponse-b9D_SrLs.cjs} +112 -38
  94. package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CFW-PwTP.cjs} +1 -0
  95. package/dist/rpc.cjs +3 -2
  96. package/dist/rpc.d.cts +2 -2
  97. package/dist/rpc.d.mts +2 -2
  98. package/dist/rpc.mjs +3 -2
  99. package/dist/shared.cjs +2 -1
  100. package/dist/shared.d.cts +2 -2
  101. package/dist/shared.d.mts +2 -2
  102. package/dist/shared.mjs +2 -1
  103. package/dist/{unstable-core-do-not-import-JE3NCpqt.d.mts → unstable-core-do-not-import-BkTO4Ekx.d.cts} +41 -5
  104. package/dist/unstable-core-do-not-import-BkTO4Ekx.d.cts.map +1 -0
  105. package/dist/{unstable-core-do-not-import-Jynlfuqc.d.cts → unstable-core-do-not-import-DElJf3aU.d.mts} +41 -5
  106. package/dist/unstable-core-do-not-import-DElJf3aU.d.mts.map +1 -0
  107. package/dist/unstable-core-do-not-import.cjs +9 -7
  108. package/dist/unstable-core-do-not-import.d.cts +2 -2
  109. package/dist/unstable-core-do-not-import.d.mts +2 -2
  110. package/dist/unstable-core-do-not-import.mjs +9 -8
  111. package/dist/{ws-BgBeYgGS.cjs → ws-83TNWW-W.cjs} +8 -7
  112. package/dist/ws-BR3-CM6m.d.mts +86 -0
  113. package/dist/ws-BR3-CM6m.d.mts.map +1 -0
  114. package/dist/ws-CaI8wmsh.d.cts +86 -0
  115. package/dist/ws-CaI8wmsh.d.cts.map +1 -0
  116. package/dist/{ws-CNjkWAs9.mjs → ws-DJ2SSChC.mjs} +9 -8
  117. package/dist/{ws-CNjkWAs9.mjs.map → ws-DJ2SSChC.mjs.map} +1 -1
  118. package/package.json +3 -3
  119. package/src/adapters/aws-lambda/getPlanner.ts +1 -1
  120. package/src/adapters/express.ts +1 -1
  121. package/src/adapters/fastify/fastifyTRPCPlugin.ts +12 -10
  122. package/src/adapters/next.ts +1 -1
  123. package/src/adapters/node-http/incomingMessageToRequest.ts +45 -14
  124. package/src/adapters/node-http/types.ts +24 -21
  125. package/src/adapters/node-http/writeResponse.ts +2 -0
  126. package/src/adapters/standalone.ts +1 -1
  127. package/src/observable/operators.ts +69 -28
  128. package/src/unstable-core-do-not-import/clientish/serialize.ts +12 -1
  129. package/src/unstable-core-do-not-import/error/TRPCError.ts +17 -1
  130. package/src/unstable-core-do-not-import/http/contentType.ts +24 -9
  131. package/src/unstable-core-do-not-import/http/resolveResponse.ts +92 -31
  132. package/src/unstable-core-do-not-import/rootConfig.ts +23 -1
  133. package/src/unstable-core-do-not-import/router.ts +27 -18
  134. package/src/unstable-core-do-not-import/stream/sse.ts +26 -1
  135. package/adapters/aws-lambda/index.d.ts +0 -1
  136. package/adapters/aws-lambda/index.js +0 -1
  137. package/adapters/express/index.d.ts +0 -1
  138. package/adapters/express/index.js +0 -1
  139. package/adapters/fastify/index.d.ts +0 -1
  140. package/adapters/fastify/index.js +0 -1
  141. package/adapters/fetch/index.d.ts +0 -1
  142. package/adapters/fetch/index.js +0 -1
  143. package/adapters/next/index.d.ts +0 -1
  144. package/adapters/next/index.js +0 -1
  145. package/adapters/next-app-dir/index.d.ts +0 -1
  146. package/adapters/next-app-dir/index.js +0 -1
  147. package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
  148. package/adapters/node-http/content-type/form-data/index.js +0 -1
  149. package/adapters/node-http/content-type/json/index.d.ts +0 -1
  150. package/adapters/node-http/content-type/json/index.js +0 -1
  151. package/adapters/node-http/index.d.ts +0 -1
  152. package/adapters/node-http/index.js +0 -1
  153. package/adapters/standalone/index.d.ts +0 -1
  154. package/adapters/standalone/index.js +0 -1
  155. package/adapters/ws/index.d.ts +0 -1
  156. package/adapters/ws/index.js +0 -1
  157. package/dist/adapters/ws.d.cts.map +0 -1
  158. package/dist/adapters/ws.d.mts.map +0 -1
  159. package/dist/asyncGeneratorDelegate-mPyp1u6d.mjs.map +0 -1
  160. package/dist/index-BDZDS1SD.d.mts.map +0 -1
  161. package/dist/index-BzKrDvzg.d.cts.map +0 -1
  162. package/dist/initTRPC-DpOypWK_.mjs.map +0 -1
  163. package/dist/node-http-B_z10Yky.mjs.map +0 -1
  164. package/dist/observable-CSprJVOf.mjs.map +0 -1
  165. package/dist/resolveResponse-CrB_9MSD.mjs.map +0 -1
  166. package/dist/unstable-core-do-not-import-JE3NCpqt.d.mts.map +0 -1
  167. package/dist/unstable-core-do-not-import-Jynlfuqc.d.cts.map +0 -1
  168. package/http/index.d.ts +0 -1
  169. package/http/index.js +0 -1
  170. package/observable/index.d.ts +0 -1
  171. package/observable/index.js +0 -1
  172. package/rpc/index.d.ts +0 -1
  173. package/rpc/index.js +0 -1
  174. package/shared/index.d.ts +0 -1
  175. package/shared/index.js +0 -1
  176. package/unstable-core-do-not-import/index.d.ts +0 -1
  177. package/unstable-core-do-not-import/index.js +0 -1
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_getErrorShape = require("../../getErrorShape-CVxLwJgN.cjs");
3
- const require_resolveResponse = require("../../resolveResponse-D5JAuwvU.cjs");
2
+ const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
3
+ const require_resolveResponse = require("../../resolveResponse-b9D_SrLs.cjs");
4
4
  let node_stream = require("node:stream");
5
5
  let node_stream_promises = require("node:stream/promises");
6
6
  //#region src/vendor/cookie-es/set-cookie/split.ts
@@ -260,3 +260,4 @@ function awsLambdaStreamingRequestHandler(opts) {
260
260
  //#endregion
261
261
  exports.awsLambdaRequestHandler = awsLambdaRequestHandler;
262
262
  exports.awsLambdaStreamingRequestHandler = awsLambdaStreamingRequestHandler;
263
+
@@ -1,4 +1,4 @@
1
- import { $n as inferRouterContext, Dn as HTTPBaseHandlerOptions, Fn as AnyRouter, Nn as TRPCRequestInfo, or as CreateContextCallback } from "../../unstable-core-do-not-import-Jynlfuqc.cjs";
1
+ import { Fn as TRPCRequestInfo, Ln as AnyRouter, cr as CreateContextCallback, kn as HTTPBaseHandlerOptions, tr as inferRouterContext } from "../../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
2
  import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, StreamifyHandler } from "aws-lambda";
3
3
  //#region src/adapters/aws-lambda/getPlanner.d.ts
4
4
  type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
@@ -18,4 +18,5 @@ export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends L
18
18
  export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
19
19
  export declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
20
20
  //#endregion
21
+
21
22
  //# sourceMappingURL=index.d.cts.map
@@ -1,4 +1,4 @@
1
- import { $n as inferRouterContext, Dn as HTTPBaseHandlerOptions, Fn as AnyRouter, Nn as TRPCRequestInfo, or as CreateContextCallback } from "../../unstable-core-do-not-import-JE3NCpqt.mjs";
1
+ import { Fn as TRPCRequestInfo, Ln as AnyRouter, cr as CreateContextCallback, kn as HTTPBaseHandlerOptions, tr as inferRouterContext } from "../../unstable-core-do-not-import-DElJf3aU.mjs";
2
2
  import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, StreamifyHandler } from "aws-lambda";
3
3
  //#region src/adapters/aws-lambda/getPlanner.d.ts
4
4
  type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
@@ -18,4 +18,5 @@ export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends L
18
18
  export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
19
19
  export declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
20
20
  //#endregion
21
+
21
22
  //# sourceMappingURL=index.d.mts.map
@@ -1,5 +1,5 @@
1
- import { n as _objectSpread2 } from "../../getErrorShape-BziUKLM_.mjs";
2
- import { t as resolveResponse } from "../../resolveResponse-CrB_9MSD.mjs";
1
+ import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
2
+ import { t as resolveResponse } from "../../resolveResponse-DH5L33sC.mjs";
3
3
  import { Readable } from "node:stream";
4
4
  import { pipeline } from "node:stream/promises";
5
5
  //#region src/vendor/cookie-es/set-cookie/split.ts
@@ -259,4 +259,5 @@ function awsLambdaStreamingRequestHandler(opts) {
259
259
  //#endregion
260
260
  export { awsLambdaRequestHandler, awsLambdaStreamingRequestHandler };
261
261
 
262
+
262
263
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/vendor/cookie-es/set-cookie/split.ts","../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"sourcesContent":["/**\n * Based on https://github.com/unjs/cookie-es/tree/v1.2.2\n * MIT License\n * \n * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>\n * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser\n * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)\n * \n * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts\n */\n\n/**\n * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas\n * that are within a single set-cookie field-value, such as in the Expires portion.\n *\n * See https://tools.ietf.org/html/rfc2616#section-4.2\n */\nexport function splitSetCookieString(\n cookiesString: string | string[],\n ): string[] {\n if (Array.isArray(cookiesString)) {\n return cookiesString.flatMap((c) => splitSetCookieString(c));\n }\n \n if (typeof cookiesString !== \"string\") {\n return [];\n }\n \n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n \n const skipWhitespace = () => {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n };\n \n const notSpecialChar = () => {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n \n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n \n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n \n skipWhitespace();\n nextStart = pos;\n \n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n \n // currently special character\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n \n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start));\n }\n }\n \n return cookiesStrings;\n }","import { Readable, type Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n APIGatewayProxyStructuredResultV2,\n} from 'aws-lambda';\nimport { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split';\n\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\n\nexport type APIGatewayResult =\n APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;\n\nfunction determinePayloadFormat(event: LambdaEvent): string {\n // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html\n // According to AWS support, version is is extracted from the version property in the event.\n // If there is no version property, then the version is implied as 1.0\n const unknownEvent = event as { version?: string };\n if (typeof unknownEvent.version === 'undefined') {\n return '1.0';\n } else {\n return unknownEvent.version;\n }\n}\n\n/** 1:1 mapping of v1 or v2 input events, deduces which is which.\n * @internal\n **/\nexport type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent\n ? APIGatewayProxyResult\n : TEvent extends APIGatewayProxyEventV2\n ? APIGatewayProxyStructuredResultV2\n : never;\n\ninterface Processor<TEvent extends LambdaEvent> {\n getTRPCPath: (event: TEvent) => string;\n url(event: TEvent): Pick<URL, 'hostname' | 'pathname' | 'search'>;\n getHeaders: (event: TEvent) => Headers;\n getMethod: (event: TEvent) => string;\n toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;\n toStream: (response: Response, stream: Writable) => Promise<void>;\n}\n\nfunction getHeadersAndCookiesFromResponse(response: Response) {\n const headers = Object.fromEntries(response.headers.entries());\n\n const cookies: string[] = splitSetCookieString(\n response.headers.getSetCookie(),\n ).map((cookie) => cookie.trim());\n\n delete headers['set-cookie'];\n\n return { headers, cookies };\n}\n\nconst v1Processor: Processor<APIGatewayProxyEvent> = {\n // same as getPath above\n getTRPCPath: (event) => {\n if (!event.pathParameters) {\n // Then this event was not triggered by a resource denoted with {proxy+}\n return event.path.split('/').pop() ?? '';\n }\n const matches = event.resource.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.path.slice(1);\n },\n url(event) {\n const hostname: string =\n event.requestContext.domainName ??\n event.headers['host'] ??\n event.multiValueHeaders?.['host']?.[0] ??\n 'localhost';\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(\n event.queryStringParameters ?? {},\n )) {\n if (value !== undefined) {\n searchParams.append(key, value);\n }\n }\n const qs = searchParams.toString();\n return {\n hostname,\n pathname: event.path,\n search: qs && `?${qs}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n\n // Process multiValueHeaders first (takes precedence per AWS docs)\n // This handles headers that can have multiple values\n for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})) {\n if (values) {\n values.forEach((v) => headers.append(k, v));\n }\n }\n\n // Then process single-value headers, but skip any that were already\n // added from multiValueHeaders to avoid duplication\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined && !headers.has(key)) {\n headers.append(key, value);\n }\n }\n\n return headers;\n },\n getMethod: (event) => event.httpMethod,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyResult = {\n ...(cookies.length && { multiValueHeaders: { 'set-cookie': cookies } }),\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nconst v2Processor: Processor<APIGatewayProxyEventV2> = {\n getTRPCPath: (event) => {\n const matches = event.routeKey.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.rawPath.slice(1);\n },\n url(event) {\n return {\n hostname: event.requestContext.domainName,\n pathname: event.rawPath,\n search: event.rawQueryString && `?${event.rawQueryString}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined) {\n headers.append(key, value);\n }\n }\n\n if (event.cookies) {\n headers.append('cookie', event.cookies.join('; '));\n }\n return headers;\n },\n getMethod: (event) => event.requestContext.http.method,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyStructuredResultV2 = {\n cookies,\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nexport function getPlanner<TEvent extends LambdaEvent>(event: TEvent) {\n const version = determinePayloadFormat(event);\n let processor: Processor<TEvent>;\n switch (version) {\n case '1.0':\n processor = v1Processor as Processor<TEvent>;\n break;\n case '2.0':\n processor = v2Processor as Processor<TEvent>;\n break;\n default:\n throw new Error(`Unsupported version: ${version}`);\n }\n\n const urlParts = processor.url(event);\n const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;\n\n const init: RequestInit = {\n headers: processor.getHeaders(event),\n method: processor.getMethod(event),\n // @ts-expect-error this is fine\n duplex: 'half',\n };\n if (event.body) {\n init.body = event.isBase64Encoded\n ? Buffer.from(event.body, 'base64')\n : event.body;\n }\n\n const request = new Request(url, init);\n\n return {\n path: processor.getTRPCPath(event),\n request,\n toResult: processor.toResult,\n toStream: processor.toStream,\n };\n}\n","/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { Context as APIGWContext, StreamifyHandler } from 'aws-lambda';\n// @trpc/server\nimport type {\n AnyRouter,\n CreateContextCallback,\n inferRouterContext,\n} from '../../@trpc/server';\n// @trpc/server\nimport type {\n HTTPBaseHandlerOptions,\n ResolveHTTPRequestOptionsContextFn,\n TRPCRequestInfo,\n} from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { inferAPIGWReturn, LambdaEvent } from './getPlanner';\nimport { getPlanner } from './getPlanner';\n\nexport type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {\n event: TEvent;\n context: APIGWContext;\n info: TRPCRequestInfo;\n};\n\nexport type AWSLambdaOptions<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = HTTPBaseHandlerOptions<TRouter, TEvent> &\n CreateContextCallback<\n inferRouterContext<AnyRouter>,\n AWSLambdaCreateContextFn<TRouter, TEvent>\n >;\n\nexport type AWSLambdaCreateContextFn<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = ({\n event,\n context,\n info,\n}: CreateAWSLambdaContextOptions<TEvent>) =>\n inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;\n\nexport function awsLambdaRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(\n opts: AWSLambdaOptions<TRouter, TEvent>,\n): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>> {\n return async (event, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n return await planner.toResult(response);\n };\n}\n\nexport function awsLambdaStreamingRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent> {\n return async (event, responseStream, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n await planner.toStream(response, responseStream);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBACZ,eACU;CACV,IAAI,MAAM,QAAQ,aAAa,GAC7B,OAAO,cAAc,SAAS,MAAM,qBAAqB,CAAC,CAAC;CAG7D,IAAI,OAAO,kBAAkB,UAC3B,OAAO,CAAC;CAGV,MAAM,iBAA2B,CAAC;CAClC,IAAI,MAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,uBAAuB;EAC3B,OAAO,MAAM,cAAc,UAAU,KAAK,KAAK,cAAc,OAAO,GAAG,CAAC,GACtE,OAAO;EAET,OAAO,MAAM,cAAc;CAC7B;CAEA,MAAM,uBAAuB;EAC3B,KAAK,cAAc,OAAO,GAAG;EAC7B,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;CAC5C;CAEA,OAAO,MAAM,cAAc,QAAQ;EACjC,QAAQ;EACR,wBAAwB;EAExB,OAAO,eAAe,GAAG;GACvB,KAAK,cAAc,OAAO,GAAG;GAC7B,IAAI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,KAAA,MAAA,eAAA;IAAkB;IAAO;GAAY,GAAA,SAAU,CAAC;EACpE;EAEA,MAAM,WAAW,MAAM,gBAAA,eAAA,eAAA,CAAA,GAClB,IAAA,GAAA,CAAA,GAAA;GACH;GACA,KAAK,QAAQ;GACb,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,GAAG;;IACT,SAAA,QAAA,SAAA,KAAA,MAAA,gBAAA,KAAM,aAAA,QAAA,kBAAA,KAAA,KAAA,cAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACD,CAAA,GAAA,CAAA,GAAA,EACH,KAAK,MAAA,CACP,CAAC;GACH;EACF,CAAA,CAAC;EAED,OAAO,MAAM,QAAQ,SAAS,QAAQ;CACxC;AACF;AAEA,SAAgB,iCAGd,MAAmE;CACnE,OAAO,OAAO,OAAO,gBAAgB,YAAY;EAC/C,MAAM,UAAU,WAAW,KAAK;EAEhC,MAAM,gBAA6D,OACjE,cACG;;GACH,OAAO,QAAA,uBAAM,KAAK,mBAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAA,KAAA,MAAA,eAAA;IAAkB;IAAO;GAAY,GAAA,SAAU,CAAC;EACpE;EAEA,MAAM,WAAW,MAAM,gBAAA,eAAA,eAAA,CAAA,GAClB,IAAA,GAAA,CAAA,GAAA;GACH;GACA,KAAK,QAAQ;GACb,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,GAAG;;IACT,SAAA,QAAA,SAAA,KAAA,MAAA,iBAAA,KAAM,aAAA,QAAA,mBAAA,KAAA,KAAA,eAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACD,CAAA,GAAA,CAAA,GAAA,EACH,KAAK,MAAA,CACP,CAAC;GACH;EACF,CAAA,CAAC;EAED,MAAM,QAAQ,SAAS,UAAU,cAAc;CACjD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/vendor/cookie-es/set-cookie/split.ts","../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"sourcesContent":["/**\n * Based on https://github.com/unjs/cookie-es/tree/v1.2.2\n * MIT License\n * \n * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>\n * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser\n * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)\n * \n * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts\n */\n\n/**\n * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas\n * that are within a single set-cookie field-value, such as in the Expires portion.\n *\n * See https://tools.ietf.org/html/rfc2616#section-4.2\n */\nexport function splitSetCookieString(\n cookiesString: string | string[],\n ): string[] {\n if (Array.isArray(cookiesString)) {\n return cookiesString.flatMap((c) => splitSetCookieString(c));\n }\n \n if (typeof cookiesString !== \"string\") {\n return [];\n }\n \n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n \n const skipWhitespace = () => {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n };\n \n const notSpecialChar = () => {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n \n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n \n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n \n skipWhitespace();\n nextStart = pos;\n \n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n \n // currently special character\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n \n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start));\n }\n }\n \n return cookiesStrings;\n }","import { Readable, type Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n APIGatewayProxyStructuredResultV2,\n} from 'aws-lambda';\nimport { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split';\n\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\n\nexport type APIGatewayResult =\n APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;\n\nfunction determinePayloadFormat(event: LambdaEvent): string {\n // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html\n // According to AWS support, version is extracted from the version property in the event.\n // If there is no version property, then the version is implied as 1.0\n const unknownEvent = event as { version?: string };\n if (typeof unknownEvent.version === 'undefined') {\n return '1.0';\n } else {\n return unknownEvent.version;\n }\n}\n\n/** 1:1 mapping of v1 or v2 input events, deduces which is which.\n * @internal\n **/\nexport type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent\n ? APIGatewayProxyResult\n : TEvent extends APIGatewayProxyEventV2\n ? APIGatewayProxyStructuredResultV2\n : never;\n\ninterface Processor<TEvent extends LambdaEvent> {\n getTRPCPath: (event: TEvent) => string;\n url(event: TEvent): Pick<URL, 'hostname' | 'pathname' | 'search'>;\n getHeaders: (event: TEvent) => Headers;\n getMethod: (event: TEvent) => string;\n toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;\n toStream: (response: Response, stream: Writable) => Promise<void>;\n}\n\nfunction getHeadersAndCookiesFromResponse(response: Response) {\n const headers = Object.fromEntries(response.headers.entries());\n\n const cookies: string[] = splitSetCookieString(\n response.headers.getSetCookie(),\n ).map((cookie) => cookie.trim());\n\n delete headers['set-cookie'];\n\n return { headers, cookies };\n}\n\nconst v1Processor: Processor<APIGatewayProxyEvent> = {\n // same as getPath above\n getTRPCPath: (event) => {\n if (!event.pathParameters) {\n // Then this event was not triggered by a resource denoted with {proxy+}\n return event.path.split('/').pop() ?? '';\n }\n const matches = event.resource.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.path.slice(1);\n },\n url(event) {\n const hostname: string =\n event.requestContext.domainName ??\n event.headers['host'] ??\n event.multiValueHeaders?.['host']?.[0] ??\n 'localhost';\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(\n event.queryStringParameters ?? {},\n )) {\n if (value !== undefined) {\n searchParams.append(key, value);\n }\n }\n const qs = searchParams.toString();\n return {\n hostname,\n pathname: event.path,\n search: qs && `?${qs}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n\n // Process multiValueHeaders first (takes precedence per AWS docs)\n // This handles headers that can have multiple values\n for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})) {\n if (values) {\n values.forEach((v) => headers.append(k, v));\n }\n }\n\n // Then process single-value headers, but skip any that were already\n // added from multiValueHeaders to avoid duplication\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined && !headers.has(key)) {\n headers.append(key, value);\n }\n }\n\n return headers;\n },\n getMethod: (event) => event.httpMethod,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyResult = {\n ...(cookies.length && { multiValueHeaders: { 'set-cookie': cookies } }),\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nconst v2Processor: Processor<APIGatewayProxyEventV2> = {\n getTRPCPath: (event) => {\n const matches = event.routeKey.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.rawPath.slice(1);\n },\n url(event) {\n return {\n hostname: event.requestContext.domainName,\n pathname: event.rawPath,\n search: event.rawQueryString && `?${event.rawQueryString}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined) {\n headers.append(key, value);\n }\n }\n\n if (event.cookies) {\n headers.append('cookie', event.cookies.join('; '));\n }\n return headers;\n },\n getMethod: (event) => event.requestContext.http.method,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyStructuredResultV2 = {\n cookies,\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nexport function getPlanner<TEvent extends LambdaEvent>(event: TEvent) {\n const version = determinePayloadFormat(event);\n let processor: Processor<TEvent>;\n switch (version) {\n case '1.0':\n processor = v1Processor as Processor<TEvent>;\n break;\n case '2.0':\n processor = v2Processor as Processor<TEvent>;\n break;\n default:\n throw new Error(`Unsupported version: ${version}`);\n }\n\n const urlParts = processor.url(event);\n const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;\n\n const init: RequestInit = {\n headers: processor.getHeaders(event),\n method: processor.getMethod(event),\n // @ts-expect-error this is fine\n duplex: 'half',\n };\n if (event.body) {\n init.body = event.isBase64Encoded\n ? Buffer.from(event.body, 'base64')\n : event.body;\n }\n\n const request = new Request(url, init);\n\n return {\n path: processor.getTRPCPath(event),\n request,\n toResult: processor.toResult,\n toStream: processor.toStream,\n };\n}\n","/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { Context as APIGWContext, StreamifyHandler } from 'aws-lambda';\n// @trpc/server\nimport type {\n AnyRouter,\n CreateContextCallback,\n inferRouterContext,\n} from '../../@trpc/server';\n// @trpc/server\nimport type {\n HTTPBaseHandlerOptions,\n ResolveHTTPRequestOptionsContextFn,\n TRPCRequestInfo,\n} from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { inferAPIGWReturn, LambdaEvent } from './getPlanner';\nimport { getPlanner } from './getPlanner';\n\nexport type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {\n event: TEvent;\n context: APIGWContext;\n info: TRPCRequestInfo;\n};\n\nexport type AWSLambdaOptions<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = HTTPBaseHandlerOptions<TRouter, TEvent> &\n CreateContextCallback<\n inferRouterContext<AnyRouter>,\n AWSLambdaCreateContextFn<TRouter, TEvent>\n >;\n\nexport type AWSLambdaCreateContextFn<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = ({\n event,\n context,\n info,\n}: CreateAWSLambdaContextOptions<TEvent>) =>\n inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;\n\nexport function awsLambdaRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(\n opts: AWSLambdaOptions<TRouter, TEvent>,\n): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>> {\n return async (event, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n return await planner.toResult(response);\n };\n}\n\nexport function awsLambdaStreamingRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent> {\n return async (event, responseStream, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n await planner.toStream(response, responseStream);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBACZ,eACU;CACV,IAAI,MAAM,QAAQ,aAAa,GAC7B,OAAO,cAAc,SAAS,MAAM,qBAAqB,CAAC,CAAC;CAG7D,IAAI,OAAO,kBAAkB,UAC3B,OAAO,CAAC;CAGV,MAAM,iBAA2B,CAAC;CAClC,IAAI,MAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,uBAAuB;EAC3B,OAAO,MAAM,cAAc,UAAU,KAAK,KAAK,cAAc,OAAO,GAAG,CAAC,GACtE,OAAO;EAET,OAAO,MAAM,cAAc;CAC7B;CAEA,MAAM,uBAAuB;EAC3B,KAAK,cAAc,OAAO,GAAG;EAC7B,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;CAC5C;CAEA,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;AACF"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_codes = require("../codes-BwD4QurF.cjs");
3
- const require_getErrorShape = require("../getErrorShape-CVxLwJgN.cjs");
4
- const require_node_http = require("../node-http-Bti3aBT6.cjs");
2
+ const require_codes = require("../codes-HK4UsP07.cjs");
3
+ const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
4
+ const require_node_http = require("../node-http-BZ0HlzkC.cjs");
5
5
  //#region src/adapters/express.ts
6
6
  function createExpressMiddleware(opts) {
7
7
  return (req, res) => {
@@ -22,3 +22,4 @@ function createExpressMiddleware(opts) {
22
22
  }
23
23
  //#endregion
24
24
  exports.createExpressMiddleware = createExpressMiddleware;
25
+
@@ -1,8 +1,9 @@
1
- import { Fn as AnyRouter } from "../unstable-core-do-not-import-Jynlfuqc.cjs";
2
- import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BzKrDvzg.cjs";
1
+ import { Ln as AnyRouter } from "../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
+ import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-D7foMQMh.cjs";
3
3
  import * as express from "express";
4
4
  //#region src/adapters/express.d.ts
5
5
  export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<express.Request, express.Response>;
6
6
  export declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
7
7
  //#endregion
8
+
8
9
  //# sourceMappingURL=express.d.cts.map
@@ -1,8 +1,9 @@
1
- import { Fn as AnyRouter } from "../unstable-core-do-not-import-JE3NCpqt.mjs";
2
- import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BDZDS1SD.mjs";
1
+ import { Ln as AnyRouter } from "../unstable-core-do-not-import-DElJf3aU.mjs";
2
+ import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-DPj2-I1U.mjs";
3
3
  import * as express from "express";
4
4
  //#region src/adapters/express.d.ts
5
5
  export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<express.Request, express.Response>;
6
6
  export declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
7
7
  //#endregion
8
+
8
9
  //# sourceMappingURL=express.d.mts.map
@@ -1,6 +1,6 @@
1
- import { m as run } from "../codes-D6C_OiJy.mjs";
2
- import { n as _objectSpread2 } from "../getErrorShape-BziUKLM_.mjs";
3
- import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-B_z10Yky.mjs";
1
+ import { m as run } from "../codes-C9N0z0an.mjs";
2
+ import { n as _objectSpread2 } from "../getErrorShape-zlj81BiC.mjs";
3
+ import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-B5jkpWn7.mjs";
4
4
  //#region src/adapters/express.ts
5
5
  function createExpressMiddleware(opts) {
6
6
  return (req, res) => {
@@ -22,4 +22,5 @@ function createExpressMiddleware(opts) {
22
22
  //#endregion
23
23
  export { createExpressMiddleware };
24
24
 
25
+
25
26
  //# sourceMappingURL=express.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"express.mjs","names":[],"sources":["../../src/adapters/express.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type * as express from 'express';\nimport type { AnyRouter } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<\n express.Request,\n express.Response\n>;\n\nexport function createExpressMiddleware<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>,\n): express.Handler {\n return (req, res) => {\n let path = '';\n run(async () => {\n path = req.path.slice(req.path.lastIndexOf('/') + 1);\n\n await nodeHTTPRequestHandler({\n ...(opts as any),\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;AAwBA,SAAgB,wBACd,MACiB;CACjB,QAAQ,KAAK,QAAQ;EACnB,IAAI,OAAO;EACX,IAAI,YAAY;GACd,OAAO,IAAI,KAAK,MAAM,IAAI,KAAK,YAAY,GAAG,IAAI,CAAC;GAEnD,MAAM,uBAAA,eAAA,eAAA,CAAA,GACA,IAAA,GAAA,CAAA,GAAA;IACJ;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"express.mjs","names":[],"sources":["../../src/adapters/express.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type * as express from 'express';\nimport type { AnyRouter } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<\n express.Request,\n express.Response\n>;\n\nexport function createExpressMiddleware<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>,\n): express.Handler {\n return (req, res) => {\n let path = '';\n run(async () => {\n path = req.path.slice(req.path.lastIndexOf('/') + 1);\n\n await nodeHTTPRequestHandler({\n ...opts,\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;AAwBA,SAAgB,wBACd,MACiB;CACjB,QAAQ,KAAK,QAAQ;EACnB,IAAI,OAAO;EACX,IAAI,YAAY;GACd,OAAO,IAAI,KAAK,MAAM,IAAI,KAAK,YAAY,GAAG,IAAI,CAAC;GAEnD,MAAM,uBAAA,eAAA,eAAA,CAAA,GACD,IAAA,GAAA,CAAA,GAAA;IACH;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_getErrorShape = require("../../getErrorShape-CVxLwJgN.cjs");
3
- const require_resolveResponse = require("../../resolveResponse-D5JAuwvU.cjs");
4
- const require_node_http = require("../../node-http-Bti3aBT6.cjs");
5
- const require_ws = require("../../ws-BgBeYgGS.cjs");
2
+ const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
3
+ const require_resolveResponse = require("../../resolveResponse-b9D_SrLs.cjs");
4
+ const require_node_http = require("../../node-http-BZ0HlzkC.cjs");
5
+ const require_ws = require("../../ws-83TNWW-W.cjs");
6
6
  //#region src/adapters/fastify/fastifyRequestHandler.ts
7
7
  async function fastifyRequestHandler(opts) {
8
8
  const createContext = async (innerOpts) => {
@@ -50,12 +50,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
50
50
  const trpcOptions = opts.trpcOptions;
51
51
  const onConnection = require_ws.getWSConnectionHandler(require_getErrorShape._objectSpread2({}, trpcOptions));
52
52
  fastify.get((_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : "/", { websocket: true }, (socket, req) => {
53
- var _trpcOptions$keepAliv;
54
53
  onConnection(socket, req.raw);
55
- if (trpcOptions === null || trpcOptions === void 0 || (_trpcOptions$keepAliv = trpcOptions.keepAlive) === null || _trpcOptions$keepAliv === void 0 ? void 0 : _trpcOptions$keepAliv.enabled) {
56
- const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
57
- require_ws.handleKeepAlive(socket, pingMs, pongWaitMs);
58
- }
59
54
  });
60
55
  }
61
56
  done();
@@ -63,3 +58,4 @@ function fastifyTRPCPlugin(fastify, opts, done) {
63
58
  //#endregion
64
59
  exports.fastifyRequestHandler = fastifyRequestHandler;
65
60
  exports.fastifyTRPCPlugin = fastifyTRPCPlugin;
61
+
@@ -1,5 +1,6 @@
1
- import { Dn as HTTPBaseHandlerOptions, Fn as AnyRouter } from "../../unstable-core-do-not-import-Jynlfuqc.cjs";
2
- import { o as NodeHTTPCreateContextFnOptions, s as NodeHTTPCreateContextOption } from "../../index-BzKrDvzg.cjs";
1
+ import { Ln as AnyRouter, kn as HTTPBaseHandlerOptions } from "../../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
+ import { o as NodeHTTPCreateContextFnOptions, s as NodeHTTPCreateContextOption } from "../../index-D7foMQMh.cjs";
3
+ import { i as WSSHandlerOptions } from "../../ws-CaI8wmsh.cjs";
3
4
  import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
4
5
  //#region src/adapters/fastify/fastifyRequestHandler.d.ts
5
6
  export type FastifyHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = HTTPBaseHandlerOptions<TRouter, TRequest> & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
@@ -14,9 +15,13 @@ export declare function fastifyRequestHandler<TRouter extends AnyRouter, TReques
14
15
  export interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {
15
16
  prefix?: string;
16
17
  useWSS?: boolean;
17
- trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply>;
18
+ /**
19
+ * `keepAlive`, `dangerouslyDisablePong` and `experimental_encoder` are only used when `useWSS` is enabled
20
+ */
21
+ trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply> & Pick<WSSHandlerOptions<TRouter>, 'keepAlive' | 'dangerouslyDisablePong' | 'experimental_encoder'>;
18
22
  }
19
23
  export type CreateFastifyContextOptions = NodeHTTPCreateContextFnOptions<FastifyRequest, FastifyReply>;
20
24
  export declare function fastifyTRPCPlugin<TRouter extends AnyRouter>(fastify: FastifyInstance, opts: FastifyTRPCPluginOptions<TRouter>, done: (err?: Error) => void): void;
21
25
  //#endregion
26
+
22
27
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"mappings":";;;;YAyBY,sBACV,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,uBAAuB,SAAS,YAClC,4BAA4B,SAAS,UAAU;KAE5C,6BACH,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,sBAAsB,SAAS,UAAU;EAC3C,KAAK;EACL,KAAK;EACL;;wBAGoB,sBACpB,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,cAClB,MAAM,6BAA6B,SAAS,UAAU,aAAU;;;iBCtBjD,yBAAyB,gBAAgB;EACxD;EACA;EACA,aAAa,sBAAsB,SAAS,gBAAgB;;YAGlD,8BAA8B,+BACxC,gBACA;wBAGc,kBAAkB,gBAAgB,WAChD,SAAS,iBACT,MAAM,yBAAyB,UAC/B,OAAO,MAAM"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"mappings":";;;;;YAyBY,sBACV,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,uBAAuB,SAAS,YAClC,4BAA4B,SAAS,UAAU;KAE5C,6BACH,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,sBAAsB,SAAS,UAAU;EAC3C,KAAK;EACL,KAAK;EACL;;wBAGoB,sBACpB,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,cAClB,MAAM,6BAA6B,SAAS,UAAU,aAAU;;;iBC1BjD,yBAAyB,gBAAgB;EACxD;EACA;;;;EAIA,aAAa,sBAAsB,SAAS,gBAAgB,gBAC1D,KACE,kBAAkB;;YAKZ,8BAA8B,+BACxC,gBACA;wBAGc,kBAAkB,gBAAgB,WAChD,SAAS,iBACT,MAAM,yBAAyB,UAC/B,OAAO,MAAM"}
@@ -1,5 +1,6 @@
1
- import { Dn as HTTPBaseHandlerOptions, Fn as AnyRouter } from "../../unstable-core-do-not-import-JE3NCpqt.mjs";
2
- import { o as NodeHTTPCreateContextFnOptions, s as NodeHTTPCreateContextOption } from "../../index-BDZDS1SD.mjs";
1
+ import { Ln as AnyRouter, kn as HTTPBaseHandlerOptions } from "../../unstable-core-do-not-import-DElJf3aU.mjs";
2
+ import { o as NodeHTTPCreateContextFnOptions, s as NodeHTTPCreateContextOption } from "../../index-DPj2-I1U.mjs";
3
+ import { i as WSSHandlerOptions } from "../../ws-BR3-CM6m.mjs";
3
4
  import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
4
5
  //#region src/adapters/fastify/fastifyRequestHandler.d.ts
5
6
  export type FastifyHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = HTTPBaseHandlerOptions<TRouter, TRequest> & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
@@ -14,9 +15,13 @@ export declare function fastifyRequestHandler<TRouter extends AnyRouter, TReques
14
15
  export interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {
15
16
  prefix?: string;
16
17
  useWSS?: boolean;
17
- trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply>;
18
+ /**
19
+ * `keepAlive`, `dangerouslyDisablePong` and `experimental_encoder` are only used when `useWSS` is enabled
20
+ */
21
+ trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply> & Pick<WSSHandlerOptions<TRouter>, 'keepAlive' | 'dangerouslyDisablePong' | 'experimental_encoder'>;
18
22
  }
19
23
  export type CreateFastifyContextOptions = NodeHTTPCreateContextFnOptions<FastifyRequest, FastifyReply>;
20
24
  export declare function fastifyTRPCPlugin<TRouter extends AnyRouter>(fastify: FastifyInstance, opts: FastifyTRPCPluginOptions<TRouter>, done: (err?: Error) => void): void;
21
25
  //#endregion
26
+
22
27
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"mappings":";;;;YAyBY,sBACV,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,uBAAuB,SAAS,YAClC,4BAA4B,SAAS,UAAU;KAE5C,6BACH,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,sBAAsB,SAAS,UAAU;EAC3C,KAAK;EACL,KAAK;EACL;;wBAGoB,sBACpB,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,cAClB,MAAM,6BAA6B,SAAS,UAAU,aAAU;;;iBCtBjD,yBAAyB,gBAAgB;EACxD;EACA;EACA,aAAa,sBAAsB,SAAS,gBAAgB;;YAGlD,8BAA8B,+BACxC,gBACA;wBAGc,kBAAkB,gBAAgB,WAChD,SAAS,iBACT,MAAM,yBAAyB,UAC/B,OAAO,MAAM"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"mappings":";;;;;YAyBY,sBACV,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,uBAAuB,SAAS,YAClC,4BAA4B,SAAS,UAAU;KAE5C,6BACH,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,gBAChB,sBAAsB,SAAS,UAAU;EAC3C,KAAK;EACL,KAAK;EACL;;wBAGoB,sBACpB,gBAAgB,WAChB,iBAAiB,gBACjB,kBAAkB,cAClB,MAAM,6BAA6B,SAAS,UAAU,aAAU;;;iBC1BjD,yBAAyB,gBAAgB;EACxD;EACA;;;;EAIA,aAAa,sBAAsB,SAAS,gBAAgB,gBAC1D,KACE,kBAAkB;;YAKZ,8BAA8B,+BACxC,gBACA;wBAGc,kBAAkB,gBAAgB,WAChD,SAAS,iBACT,MAAM,yBAAyB,UAC/B,OAAO,MAAM"}
@@ -1,7 +1,7 @@
1
- import { n as _objectSpread2 } from "../../getErrorShape-BziUKLM_.mjs";
2
- import { t as resolveResponse } from "../../resolveResponse-CrB_9MSD.mjs";
3
- import { i as incomingMessageToRequest } from "../../node-http-B_z10Yky.mjs";
4
- import { n as getWSConnectionHandler, r as handleKeepAlive } from "../../ws-CNjkWAs9.mjs";
1
+ import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
2
+ import { t as resolveResponse } from "../../resolveResponse-DH5L33sC.mjs";
3
+ import { i as incomingMessageToRequest } from "../../node-http-B5jkpWn7.mjs";
4
+ import { n as getWSConnectionHandler } from "../../ws-DJ2SSChC.mjs";
5
5
  //#region src/adapters/fastify/fastifyRequestHandler.ts
6
6
  async function fastifyRequestHandler(opts) {
7
7
  const createContext = async (innerOpts) => {
@@ -49,12 +49,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
49
49
  const trpcOptions = opts.trpcOptions;
50
50
  const onConnection = getWSConnectionHandler(_objectSpread2({}, trpcOptions));
51
51
  fastify.get((_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : "/", { websocket: true }, (socket, req) => {
52
- var _trpcOptions$keepAliv;
53
52
  onConnection(socket, req.raw);
54
- if (trpcOptions === null || trpcOptions === void 0 || (_trpcOptions$keepAliv = trpcOptions.keepAlive) === null || _trpcOptions$keepAliv === void 0 ? void 0 : _trpcOptions$keepAliv.enabled) {
55
- const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
56
- handleKeepAlive(socket, pingMs, pongWaitMs);
57
- }
58
53
  });
59
54
  }
60
55
  done();
@@ -62,4 +57,5 @@ function fastifyTRPCPlugin(fastify, opts, done) {
62
57
  //#endregion
63
58
  export { fastifyRequestHandler, fastifyTRPCPlugin };
64
59
 
60
+
65
61
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport {\n resolveResponse,\n type HTTPBaseHandlerOptions,\n type ResolveHTTPRequestOptionsContextFn,\n} from '../../@trpc/server/http';\n// @trpc/server/node-http\nimport type { NodeHTTPRequest } from '../node-http';\nimport {\n incomingMessageToRequest,\n type NodeHTTPCreateContextOption,\n} from '../node-http';\n\nexport type FastifyHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = HTTPBaseHandlerOptions<TRouter, TRequest> &\n NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;\n\ntype FastifyRequestHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = FastifyHandlerOptions<TRouter, TRequest, TResponse> & {\n req: TRequest;\n res: TResponse;\n path: string;\n};\n\nexport async function fastifyRequestHandler<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({\n ...opts,\n ...innerOpts,\n });\n };\n\n const incomingMessage: NodeHTTPRequest = opts.req.raw;\n\n // monkey-path body to the IncomingMessage\n if ('body' in opts.req) {\n incomingMessage.body = opts.req.body;\n }\n const req = incomingMessageToRequest(incomingMessage, opts.res.raw, {\n maxBodySize: null,\n });\n\n const res = await resolveResponse({\n ...opts,\n req,\n error: null,\n createContext,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: opts.req,\n });\n },\n });\n\n await opts.res.send(res);\n}\n","/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n/// <reference types=\"@fastify/websocket\" />\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport type { NodeHTTPCreateContextFnOptions } from '../node-http';\n// @trpc/server/ws\nimport {\n getWSConnectionHandler,\n handleKeepAlive,\n type WSSHandlerOptions,\n} from '../ws';\nimport type { FastifyHandlerOptions } from './fastifyRequestHandler';\nimport { fastifyRequestHandler } from './fastifyRequestHandler';\n\nexport interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {\n prefix?: string;\n useWSS?: boolean;\n trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply>;\n}\n\nexport type CreateFastifyContextOptions = NodeHTTPCreateContextFnOptions<\n FastifyRequest,\n FastifyReply\n>;\n\nexport function fastifyTRPCPlugin<TRouter extends AnyRouter>(\n fastify: FastifyInstance,\n opts: FastifyTRPCPluginOptions<TRouter>,\n done: (err?: Error) => void,\n) {\n fastify.removeContentTypeParser('application/json');\n fastify.addContentTypeParser(\n 'application/json',\n { parseAs: 'string' },\n function (_, body, _done) {\n _done(null, body);\n },\n );\n fastify.removeContentTypeParser('multipart/form-data');\n fastify.addContentTypeParser(\n 'multipart/form-data',\n {},\n function (_, body, _done) {\n _done(null, body);\n },\n );\n\n let prefix = opts.prefix ?? '';\n\n // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11\n // @ts-expect-error property 'default' does not exists on type ...\n if (typeof fastifyTRPCPlugin.default !== 'function') {\n prefix = ''; // handled by fastify internally\n }\n\n fastify.all(`${prefix}/:path`, async (req, res) => {\n const path = (req.params as any).path;\n await fastifyRequestHandler({ ...opts.trpcOptions, req, res, path });\n });\n\n if (opts.useWSS) {\n const trpcOptions =\n opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>;\n\n const onConnection = getWSConnectionHandler<TRouter>({\n ...trpcOptions,\n });\n\n fastify.get(prefix ?? '/', { websocket: true }, (socket, req) => {\n onConnection(socket, req.raw);\n if (trpcOptions?.keepAlive?.enabled) {\n const { pingMs, pongWaitMs } = trpcOptions.keepAlive;\n handleKeepAlive(socket, pingMs, pongWaitMs);\n }\n });\n }\n\n done();\n}\n"],"mappings":";;;;;AA0CA,eAAsB,sBAIpB,MAAkE;CAClE,MAAM,gBAA6D,OACjE,cACG;;EACH,OAAO,QAAA,sBAAM,KAAK,mBAAA,QAAA,wBAAA,KAAA,IAAA,KAAA,IAAA,oBAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACb,IAAA,GACA,SACL,CAAC;CACH;CAEA,MAAM,kBAAmC,KAAK,IAAI;CAGlD,IAAI,UAAU,KAAK,KACjB,gBAAgB,OAAO,KAAK,IAAI;CAElC,MAAM,MAAM,yBAAyB,iBAAiB,KAAK,IAAI,KAAK,EAClE,aAAa,KACf,CAAC;CAED,MAAM,MAAM,MAAM,gBAAA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,MAAA,wBAAI,YAAa,eAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAW,SAAS;IACnC,MAAM,EAAE,QAAQ,eAAe,YAAY;IAC3C,gBAAgB,QAAQ,QAAQ,UAAU;GAC5C;EACF,CAAC;CACH;CAEA,KAAK;AACP"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts","../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport {\n resolveResponse,\n type HTTPBaseHandlerOptions,\n type ResolveHTTPRequestOptionsContextFn,\n} from '../../@trpc/server/http';\n// @trpc/server/node-http\nimport type { NodeHTTPRequest } from '../node-http';\nimport {\n incomingMessageToRequest,\n type NodeHTTPCreateContextOption,\n} from '../node-http';\n\nexport type FastifyHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = HTTPBaseHandlerOptions<TRouter, TRequest> &\n NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;\n\ntype FastifyRequestHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n> = FastifyHandlerOptions<TRouter, TRequest, TResponse> & {\n req: TRequest;\n res: TResponse;\n path: string;\n};\n\nexport async function fastifyRequestHandler<\n TRouter extends AnyRouter,\n TRequest extends FastifyRequest,\n TResponse extends FastifyReply,\n>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({\n ...opts,\n ...innerOpts,\n });\n };\n\n const incomingMessage: NodeHTTPRequest = opts.req.raw;\n\n // monkey-path body to the IncomingMessage\n if ('body' in opts.req) {\n incomingMessage.body = opts.req.body;\n }\n const req = incomingMessageToRequest(incomingMessage, opts.res.raw, {\n maxBodySize: null,\n });\n\n const res = await resolveResponse({\n ...opts,\n req,\n error: null,\n createContext,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: opts.req,\n });\n },\n });\n\n await opts.res.send(res);\n}\n","/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n/// <reference types=\"@fastify/websocket\" />\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';\n// @trpc/server\nimport type { AnyRouter } from '../../@trpc/server';\n// @trpc/server/http\nimport type { NodeHTTPCreateContextFnOptions } from '../node-http';\n// @trpc/server/ws\nimport { getWSConnectionHandler, type WSSHandlerOptions } from '../ws';\nimport type { FastifyHandlerOptions } from './fastifyRequestHandler';\nimport { fastifyRequestHandler } from './fastifyRequestHandler';\n\nexport interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {\n prefix?: string;\n useWSS?: boolean;\n /**\n * `keepAlive`, `dangerouslyDisablePong` and `experimental_encoder` are only used when `useWSS` is enabled\n */\n trpcOptions: FastifyHandlerOptions<TRouter, FastifyRequest, FastifyReply> &\n Pick<\n WSSHandlerOptions<TRouter>,\n 'keepAlive' | 'dangerouslyDisablePong' | 'experimental_encoder'\n >;\n}\n\nexport type CreateFastifyContextOptions = NodeHTTPCreateContextFnOptions<\n FastifyRequest,\n FastifyReply\n>;\n\nexport function fastifyTRPCPlugin<TRouter extends AnyRouter>(\n fastify: FastifyInstance,\n opts: FastifyTRPCPluginOptions<TRouter>,\n done: (err?: Error) => void,\n) {\n fastify.removeContentTypeParser('application/json');\n fastify.addContentTypeParser(\n 'application/json',\n { parseAs: 'string' },\n function (_, body, _done) {\n _done(null, body);\n },\n );\n fastify.removeContentTypeParser('multipart/form-data');\n fastify.addContentTypeParser(\n 'multipart/form-data',\n {},\n function (_, body, _done) {\n _done(null, body);\n },\n );\n\n let prefix = opts.prefix ?? '';\n\n // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11\n // @ts-expect-error property 'default' does not exists on type ...\n if (typeof fastifyTRPCPlugin.default !== 'function') {\n prefix = ''; // handled by fastify internally\n }\n\n fastify.all(`${prefix}/:path`, async (req, res) => {\n const path = (req.params as any).path;\n await fastifyRequestHandler({ ...opts.trpcOptions, req, res, path });\n });\n\n if (opts.useWSS) {\n const trpcOptions =\n opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>;\n\n const onConnection = getWSConnectionHandler<TRouter>({\n ...trpcOptions,\n });\n\n fastify.get(prefix ?? '/', { websocket: true }, (socket, req) => {\n // keepalive is registered by getWSConnectionHandler, which every\n // adapter goes through — registering it here as well gave each socket\n // two ping intervals and two pong-wait timers\n onConnection(socket, req.raw);\n });\n }\n\n done();\n}\n"],"mappings":";;;;;AA0CA,eAAsB,sBAIpB,MAAkE;CAClE,MAAM,gBAA6D,OACjE,cACG;;EACH,OAAO,QAAA,sBAAM,KAAK,mBAAA,QAAA,wBAAA,KAAA,IAAA,KAAA,IAAA,oBAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACb,IAAA,GACA,SACL,CAAC;CACH;CAEA,MAAM,kBAAmC,KAAK,IAAI;CAGlD,IAAI,UAAU,KAAK,KACjB,gBAAgB,OAAO,KAAK,IAAI;CAElC,MAAM,MAAM,yBAAyB,iBAAiB,KAAK,IAAI,KAAK,EAClE,aAAa,KACf,CAAC;CAED,MAAM,MAAM,MAAM,gBAAA,eAAA,eAAA,CAAA,GACb,IAAA,GAAA,CAAA,GAAA;EACH;EACA,OAAO;EACP;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getErrorShape = require("../../getErrorShape-CVxLwJgN.cjs");
3
- const require_resolveResponse = require("../../resolveResponse-D5JAuwvU.cjs");
2
+ const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
3
+ const require_resolveResponse = require("../../resolveResponse-b9D_SrLs.cjs");
4
4
  //#region src/adapters/fetch/fetchRequestHandler.ts
5
5
  const trimSlashes = (path) => {
6
6
  path = path.startsWith("/") ? path.slice(1) : path;
@@ -50,3 +50,4 @@ async function fetchRequestHandler(opts) {
50
50
  }
51
51
  //#endregion
52
52
  exports.fetchRequestHandler = fetchRequestHandler;
53
+
@@ -1,4 +1,4 @@
1
- import { $n as inferRouterContext, Dn as HTTPBaseHandlerOptions, Fn as AnyRouter, Nn as TRPCRequestInfo, or as CreateContextCallback } from "../../unstable-core-do-not-import-Jynlfuqc.cjs";
1
+ import { Fn as TRPCRequestInfo, Ln as AnyRouter, cr as CreateContextCallback, kn as HTTPBaseHandlerOptions, tr as inferRouterContext } from "../../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
2
  //#region src/adapters/fetch/types.d.ts
3
3
  export type FetchCreateContextFnOptions = {
4
4
  req: Request;
@@ -19,4 +19,5 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
19
19
  //#region src/adapters/fetch/fetchRequestHandler.d.ts
20
20
  export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
21
21
  //#endregion
22
+
22
23
  //# sourceMappingURL=index.d.cts.map
@@ -1,4 +1,4 @@
1
- import { $n as inferRouterContext, Dn as HTTPBaseHandlerOptions, Fn as AnyRouter, Nn as TRPCRequestInfo, or as CreateContextCallback } from "../../unstable-core-do-not-import-JE3NCpqt.mjs";
1
+ import { Fn as TRPCRequestInfo, Ln as AnyRouter, cr as CreateContextCallback, kn as HTTPBaseHandlerOptions, tr as inferRouterContext } from "../../unstable-core-do-not-import-DElJf3aU.mjs";
2
2
  //#region src/adapters/fetch/types.d.ts
3
3
  export type FetchCreateContextFnOptions = {
4
4
  req: Request;
@@ -19,4 +19,5 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHand
19
19
  //#region src/adapters/fetch/fetchRequestHandler.d.ts
20
20
  export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
21
21
  //#endregion
22
+
22
23
  //# sourceMappingURL=index.d.mts.map
@@ -1,5 +1,5 @@
1
- import { n as _objectSpread2 } from "../../getErrorShape-BziUKLM_.mjs";
2
- import { t as resolveResponse } from "../../resolveResponse-CrB_9MSD.mjs";
1
+ import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
2
+ import { t as resolveResponse } from "../../resolveResponse-DH5L33sC.mjs";
3
3
  //#region src/adapters/fetch/fetchRequestHandler.ts
4
4
  const trimSlashes = (path) => {
5
5
  path = path.startsWith("/") ? path.slice(1) : path;
@@ -50,4 +50,5 @@ async function fetchRequestHandler(opts) {
50
50
  //#endregion
51
51
  export { fetchRequestHandler };
52
52
 
53
+
53
54
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../rolldown-runtime-VH7oDXx4.cjs");
3
- const require_getErrorShape = require("../getErrorShape-CVxLwJgN.cjs");
4
- const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-D2tFgl_z.cjs");
2
+ const require_rolldown_runtime = require("../rolldown-runtime-CFW-PwTP.cjs");
3
+ const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
4
+ const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-Dj-8tGhf.cjs");
5
5
  const require_unstable_core_do_not_import = require("../unstable-core-do-not-import.cjs");
6
6
  let next_navigation = require("next/navigation");
7
7
  next_navigation = require_rolldown_runtime.__toESM(next_navigation, 1);
@@ -156,3 +156,4 @@ exports.experimental_nextAppDirCaller = nextAppDirCaller;
156
156
  exports.experimental_notFound = notFound;
157
157
  exports.experimental_redirect = redirect;
158
158
  exports.rethrowNextErrors = rethrowNextErrors;
159
+
@@ -1,4 +1,4 @@
1
- import { $ as ErrorHandlerOptions, Xr as TRPCError, bi as Simplify, hi as MaybePromise, or as CreateContextCallback, pt as CallerOverride } from "../unstable-core-do-not-import-Jynlfuqc.cjs";
1
+ import { cr as CreateContextCallback, ei as TRPCError, ht as CallerOverride, tt as ErrorHandlerOptions, wi as Simplify, yi as MaybePromise } from "../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
2
  import { RedirectType, notFound as notFound$1 } from "next/navigation";
3
3
  //#region src/adapters/next-app-dir/nextAppDirCaller.d.ts
4
4
  /**
@@ -46,4 +46,5 @@ declare const notFound: typeof notFound$1;
46
46
  export declare const rethrowNextErrors: (error: TRPCError) => void;
47
47
  //#endregion
48
48
  export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect };
49
+
49
50
  //# sourceMappingURL=next-app-dir.d.cts.map
@@ -1,4 +1,4 @@
1
- import { $ as ErrorHandlerOptions, Xr as TRPCError, bi as Simplify, hi as MaybePromise, or as CreateContextCallback, pt as CallerOverride } from "../unstable-core-do-not-import-JE3NCpqt.mjs";
1
+ import { cr as CreateContextCallback, ei as TRPCError, ht as CallerOverride, tt as ErrorHandlerOptions, wi as Simplify, yi as MaybePromise } from "../unstable-core-do-not-import-DElJf3aU.mjs";
2
2
  import { RedirectType, notFound as notFound$1 } from "next/navigation";
3
3
  //#region src/adapters/next-app-dir/nextAppDirCaller.d.ts
4
4
  /**
@@ -46,4 +46,5 @@ declare const notFound: typeof notFound$1;
46
46
  export declare const rethrowNextErrors: (error: TRPCError) => void;
47
47
  //#endregion
48
48
  export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect };
49
+
49
50
  //# sourceMappingURL=next-app-dir.d.mts.map
@@ -1,5 +1,5 @@
1
- import { r as _defineProperty } from "../getErrorShape-BziUKLM_.mjs";
2
- import { b as getTRPCErrorFromUnknown, v as TRPCError } from "../asyncGeneratorDelegate-mPyp1u6d.mjs";
1
+ import { r as _defineProperty } from "../getErrorShape-zlj81BiC.mjs";
2
+ import { b as getTRPCErrorFromUnknown, v as TRPCError } from "../asyncGeneratorDelegate-FcEJT04i.mjs";
3
3
  import { formDataToObject } from "../unstable-core-do-not-import.mjs";
4
4
  import * as nextNavigation from "next/navigation";
5
5
  //#region src/adapters/next-app-dir/redirect.ts
@@ -151,4 +151,5 @@ const notFound = () => {
151
151
  //#endregion
152
152
  export { nextAppDirCaller as experimental_nextAppDirCaller, notFound as experimental_notFound, redirect as experimental_redirect, rethrowNextErrors };
153
153
 
154
+
154
155
  //# sourceMappingURL=next-app-dir.mjs.map
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_codes = require("../codes-BwD4QurF.cjs");
3
- const require_getErrorShape = require("../getErrorShape-CVxLwJgN.cjs");
4
- const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-D2tFgl_z.cjs");
5
- const require_node_http = require("../node-http-Bti3aBT6.cjs");
2
+ const require_codes = require("../codes-HK4UsP07.cjs");
3
+ const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
4
+ const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-Dj-8tGhf.cjs");
5
+ const require_node_http = require("../node-http-BZ0HlzkC.cjs");
6
6
  //#region src/adapters/next.ts
7
7
  function createNextApiHandler(opts) {
8
8
  return async (req, res) => {
@@ -30,3 +30,4 @@ function createNextApiHandler(opts) {
30
30
  }
31
31
  //#endregion
32
32
  exports.createNextApiHandler = createNextApiHandler;
33
+
@@ -1,9 +1,10 @@
1
- import { Fn as AnyRouter } from "../unstable-core-do-not-import-Jynlfuqc.cjs";
2
- import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BzKrDvzg.cjs";
1
+ import { Ln as AnyRouter } from "../unstable-core-do-not-import-BkTO4Ekx.cjs";
2
+ import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-D7foMQMh.cjs";
3
3
  import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
4
4
  //#region src/adapters/next.d.ts
5
5
  export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest$1, NextApiResponse$1>;
6
6
  export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
7
7
  //#endregion
8
8
  export type { NextApiHandler, NextApiRequest, NextApiResponse };
9
+
9
10
  //# sourceMappingURL=next.d.cts.map
@@ -1,9 +1,10 @@
1
- import { Fn as AnyRouter } from "../unstable-core-do-not-import-JE3NCpqt.mjs";
2
- import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BDZDS1SD.mjs";
1
+ import { Ln as AnyRouter } from "../unstable-core-do-not-import-DElJf3aU.mjs";
2
+ import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-DPj2-I1U.mjs";
3
3
  import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
4
4
  //#region src/adapters/next.d.ts
5
5
  export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest$1, NextApiResponse$1>;
6
6
  export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
7
7
  //#endregion
8
8
  export type { NextApiHandler, NextApiRequest, NextApiResponse };
9
+
9
10
  //# sourceMappingURL=next.d.mts.map
@@ -1,7 +1,7 @@
1
- import { m as run } from "../codes-D6C_OiJy.mjs";
2
- import { n as _objectSpread2 } from "../getErrorShape-BziUKLM_.mjs";
3
- import { v as TRPCError } from "../asyncGeneratorDelegate-mPyp1u6d.mjs";
4
- import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-B_z10Yky.mjs";
1
+ import { m as run } from "../codes-C9N0z0an.mjs";
2
+ import { n as _objectSpread2 } from "../getErrorShape-zlj81BiC.mjs";
3
+ import { v as TRPCError } from "../asyncGeneratorDelegate-FcEJT04i.mjs";
4
+ import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-B5jkpWn7.mjs";
5
5
  //#region src/adapters/next.ts
6
6
  function createNextApiHandler(opts) {
7
7
  return async (req, res) => {
@@ -30,4 +30,5 @@ function createNextApiHandler(opts) {
30
30
  //#endregion
31
31
  export { createNextApiHandler };
32
32
 
33
+
33
34
  //# sourceMappingURL=next.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"next.mjs","names":[],"sources":["../../src/adapters/next.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n// @trpc/server\nimport type { AnyRouter } from '../@trpc/server';\n// @trpc/server\nimport { TRPCError } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<\n NextApiRequest,\n NextApiResponse\n>;\n\n/**\n * Preventing \"TypeScript where it's tough not to get \"The inferred type of 'xxxx' cannot be named without a reference to [...]\"\n */\nexport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n\nexport function createNextApiHandler<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>,\n): NextApiHandler {\n return async (req, res) => {\n let path = '';\n\n await run(async () => {\n path = run(() => {\n if (typeof req.query['trpc'] === 'string') {\n return req.query['trpc'];\n }\n if (Array.isArray(req.query['trpc'])) {\n return req.query['trpc'].join('/');\n }\n throw new TRPCError({\n message:\n 'Query \"trpc\" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',\n code: 'INTERNAL_SERVER_ERROR',\n });\n });\n\n await nodeHTTPRequestHandler({\n ...(opts as any),\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;;AAgCA,SAAgB,qBACd,MACgB;CAChB,OAAO,OAAO,KAAK,QAAQ;EACzB,IAAI,OAAO;EAEX,MAAM,IAAI,YAAY;GACpB,OAAO,UAAU;IACf,IAAI,OAAO,IAAI,MAAM,YAAY,UAC/B,OAAO,IAAI,MAAM;IAEnB,IAAI,MAAM,QAAQ,IAAI,MAAM,OAAO,GACjC,OAAO,IAAI,MAAM,OAAO,CAAC,KAAK,GAAG;IAEnC,MAAM,IAAI,UAAU;KAClB,SACE;KACF,MAAM;IACR,CAAC;GACH,CAAC;GAED,MAAM,uBAAA,eAAA,eAAA,CAAA,GACA,IAAA,GAAA,CAAA,GAAA;IACJ;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"next.mjs","names":[],"sources":["../../src/adapters/next.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n// @trpc/server\nimport type { AnyRouter } from '../@trpc/server';\n// @trpc/server\nimport { TRPCError } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<\n NextApiRequest,\n NextApiResponse\n>;\n\n/**\n * Preventing \"TypeScript where it's tough not to get \"The inferred type of 'xxxx' cannot be named without a reference to [...]\"\n */\nexport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n\nexport function createNextApiHandler<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>,\n): NextApiHandler {\n return async (req, res) => {\n let path = '';\n\n await run(async () => {\n path = run(() => {\n if (typeof req.query['trpc'] === 'string') {\n return req.query['trpc'];\n }\n if (Array.isArray(req.query['trpc'])) {\n return req.query['trpc'].join('/');\n }\n throw new TRPCError({\n message:\n 'Query \"trpc\" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',\n code: 'INTERNAL_SERVER_ERROR',\n });\n });\n\n await nodeHTTPRequestHandler({\n ...opts,\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;;AAgCA,SAAgB,qBACd,MACgB;CAChB,OAAO,OAAO,KAAK,QAAQ;EACzB,IAAI,OAAO;EAEX,MAAM,IAAI,YAAY;GACpB,OAAO,UAAU;IACf,IAAI,OAAO,IAAI,MAAM,YAAY,UAC/B,OAAO,IAAI,MAAM;IAEnB,IAAI,MAAM,QAAQ,IAAI,MAAM,OAAO,GACjC,OAAO,IAAI,MAAM,OAAO,CAAC,KAAK,GAAG;IAEnC,MAAM,IAAI,UAAU;KAClB,SACE;KACF,MAAM;IACR,CAAC;GACH,CAAC;GAED,MAAM,uBAAA,eAAA,eAAA,CAAA,GACD,IAAA,GAAA,CAAA,GAAA;IACH;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}