@trpc/server 11.0.0-rc.361 → 11.0.0-rc.363

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 (178) hide show
  1. package/dist/@trpc/server/http.d.ts +7 -5
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/@trpc/server/index.d.ts +1 -2
  4. package/dist/@trpc/server/index.d.ts.map +1 -1
  5. package/dist/adapters/aws-lambda/getPlanner.d.ts +13 -0
  6. package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -0
  7. package/dist/adapters/aws-lambda/getPlanner.js +143 -0
  8. package/dist/adapters/aws-lambda/getPlanner.mjs +141 -0
  9. package/dist/adapters/aws-lambda/index.d.ts +12 -9
  10. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  11. package/dist/adapters/aws-lambda/index.js +8 -77
  12. package/dist/adapters/aws-lambda/index.mjs +9 -72
  13. package/dist/adapters/express.js +1 -0
  14. package/dist/adapters/express.mjs +1 -0
  15. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +19 -2
  16. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  17. package/dist/adapters/fastify/fastifyRequestHandler.js +22 -64
  18. package/dist/adapters/fastify/fastifyRequestHandler.mjs +22 -64
  19. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
  20. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  21. package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -0
  22. package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -0
  23. package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -2
  24. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  25. package/dist/adapters/fetch/fetchRequestHandler.js +29 -86
  26. package/dist/adapters/fetch/fetchRequestHandler.mjs +29 -86
  27. package/dist/adapters/fetch/types.d.ts +2 -2
  28. package/dist/adapters/fetch/types.d.ts.map +1 -1
  29. package/dist/adapters/next.js +1 -1
  30. package/dist/adapters/next.mjs +1 -1
  31. package/dist/adapters/node-http/incomingMessageToRequest.d.ts +18 -0
  32. package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -0
  33. package/dist/adapters/node-http/incomingMessageToRequest.js +71 -0
  34. package/dist/adapters/node-http/incomingMessageToRequest.mjs +69 -0
  35. package/dist/adapters/node-http/index.d.ts +1 -0
  36. package/dist/adapters/node-http/index.d.ts.map +1 -1
  37. package/dist/adapters/node-http/index.js +2 -0
  38. package/dist/adapters/node-http/index.mjs +1 -0
  39. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
  40. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  41. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +28 -71
  42. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +28 -71
  43. package/dist/adapters/node-http/types.d.ts +7 -8
  44. package/dist/adapters/node-http/types.d.ts.map +1 -1
  45. package/dist/adapters/ws.js +1 -1
  46. package/dist/adapters/ws.mjs +1 -1
  47. package/dist/bundle-analysis.json +174 -271
  48. package/dist/http.js +4 -2
  49. package/dist/http.mjs +2 -1
  50. package/dist/index.js +2 -4
  51. package/dist/index.mjs +1 -2
  52. package/dist/unstable-core-do-not-import/http/contentType.d.ts +8 -20
  53. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  54. package/dist/unstable-core-do-not-import/http/contentType.js +180 -0
  55. package/dist/unstable-core-do-not-import/http/contentType.mjs +178 -0
  56. package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +14 -0
  57. package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +1 -0
  58. package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +14 -0
  59. package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +12 -0
  60. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +1 -1
  61. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
  62. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +15 -0
  63. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -0
  64. package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.js → resolveResponse.js} +119 -134
  65. package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.mjs → resolveResponse.mjs} +119 -134
  66. package/dist/unstable-core-do-not-import/http/types.d.ts +25 -27
  67. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  68. package/dist/unstable-core-do-not-import/initTRPC.d.ts +1 -1
  69. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +1 -3
  70. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
  71. package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -2
  72. package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -2
  73. package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -9
  74. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
  75. package/dist/unstable-core-do-not-import/utils.d.ts +3 -0
  76. package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
  77. package/dist/unstable-core-do-not-import/utils.js +2 -0
  78. package/dist/unstable-core-do-not-import/utils.mjs +2 -1
  79. package/dist/unstable-core-do-not-import.d.ts +9 -3
  80. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  81. package/dist/unstable-core-do-not-import.js +12 -8
  82. package/dist/unstable-core-do-not-import.mjs +7 -5
  83. package/package.json +3 -13
  84. package/src/@trpc/server/http.ts +7 -12
  85. package/src/@trpc/server/index.ts +0 -3
  86. package/src/adapters/aws-lambda/getPlanner.ts +191 -0
  87. package/src/adapters/aws-lambda/index.ts +43 -107
  88. package/src/adapters/express.ts +1 -1
  89. package/src/adapters/fastify/fastifyRequestHandler.ts +43 -90
  90. package/src/adapters/fastify/fastifyTRPCPlugin.ts +4 -3
  91. package/src/adapters/fetch/fetchRequestHandler.ts +35 -111
  92. package/src/adapters/fetch/types.ts +4 -2
  93. package/src/adapters/next.ts +1 -1
  94. package/src/adapters/node-http/incomingMessageToRequest.ts +94 -0
  95. package/src/adapters/node-http/index.ts +1 -0
  96. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +31 -97
  97. package/src/adapters/node-http/types.ts +27 -37
  98. package/src/adapters/standalone.ts +1 -1
  99. package/src/unstable-core-do-not-import/http/contentType.ts +214 -22
  100. package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +29 -0
  101. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +2 -2
  102. package/src/unstable-core-do-not-import/http/resolveResponse.ts +386 -0
  103. package/src/unstable-core-do-not-import/http/types.ts +25 -30
  104. package/src/unstable-core-do-not-import/procedureBuilder.ts +2 -4
  105. package/src/unstable-core-do-not-import/rootConfig.ts +0 -10
  106. package/src/unstable-core-do-not-import/utils.ts +4 -0
  107. package/src/unstable-core-do-not-import.ts +9 -3
  108. package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
  109. package/adapters/node-http/content-type/form-data/index.js +0 -1
  110. package/adapters/node-http/content-type/json/index.d.ts +0 -1
  111. package/adapters/node-http/content-type/json/index.js +0 -1
  112. package/dist/adapters/aws-lambda/content-type/json/index.d.ts +0 -10
  113. package/dist/adapters/aws-lambda/content-type/json/index.d.ts.map +0 -1
  114. package/dist/adapters/aws-lambda/content-type/json/index.js +0 -62
  115. package/dist/adapters/aws-lambda/content-type/json/index.mjs +0 -60
  116. package/dist/adapters/aws-lambda/utils.d.ts +0 -31
  117. package/dist/adapters/aws-lambda/utils.d.ts.map +0 -1
  118. package/dist/adapters/aws-lambda/utils.js +0 -111
  119. package/dist/adapters/aws-lambda/utils.mjs +0 -103
  120. package/dist/adapters/content-handlers/concurrentCache.d.ts +0 -7
  121. package/dist/adapters/content-handlers/concurrentCache.d.ts.map +0 -1
  122. package/dist/adapters/content-handlers/concurrentCache.js +0 -17
  123. package/dist/adapters/content-handlers/concurrentCache.mjs +0 -15
  124. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts +0 -10
  125. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +0 -1
  126. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +0 -33
  127. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +0 -31
  128. package/dist/adapters/fastify/content-type/json/index.d.ts +0 -8
  129. package/dist/adapters/fastify/content-type/json/index.d.ts.map +0 -1
  130. package/dist/adapters/fastify/content-type/json/index.js +0 -62
  131. package/dist/adapters/fastify/content-type/json/index.mjs +0 -60
  132. package/dist/adapters/fastify/types.d.ts +0 -11
  133. package/dist/adapters/fastify/types.d.ts.map +0 -1
  134. package/dist/adapters/fetch/content-type/json/index.d.ts +0 -9
  135. package/dist/adapters/fetch/content-type/json/index.d.ts.map +0 -1
  136. package/dist/adapters/fetch/content-type/json/index.js +0 -55
  137. package/dist/adapters/fetch/content-type/json/index.mjs +0 -53
  138. package/dist/adapters/node-http/content-type/form-data/index.d.ts +0 -5
  139. package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +0 -1
  140. package/dist/adapters/node-http/content-type/form-data/index.js +0 -32
  141. package/dist/adapters/node-http/content-type/form-data/index.mjs +0 -30
  142. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +0 -7
  143. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +0 -1
  144. package/dist/adapters/node-http/content-type/json/getPostBody.js +0 -45
  145. package/dist/adapters/node-http/content-type/json/getPostBody.mjs +0 -43
  146. package/dist/adapters/node-http/content-type/json/index.d.ts +0 -5
  147. package/dist/adapters/node-http/content-type/json/index.d.ts.map +0 -1
  148. package/dist/adapters/node-http/content-type/json/index.js +0 -68
  149. package/dist/adapters/node-http/content-type/json/index.mjs +0 -66
  150. package/dist/adapters/node-http/content-type/octet/index.d.ts +0 -5
  151. package/dist/adapters/node-http/content-type/octet/index.d.ts.map +0 -1
  152. package/dist/adapters/node-http/content-type/octet/index.js +0 -19
  153. package/dist/adapters/node-http/content-type/octet/index.mjs +0 -17
  154. package/dist/adapters/node-http/content-type/types.d.ts +0 -8
  155. package/dist/adapters/node-http/content-type/types.d.ts.map +0 -1
  156. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts +0 -16
  157. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts.map +0 -1
  158. package/dist/unstable-core-do-not-import/contentTypeParsers.js +0 -23
  159. package/dist/unstable-core-do-not-import/contentTypeParsers.mjs +0 -21
  160. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -11
  161. package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
  162. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
  163. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
  164. package/src/adapters/aws-lambda/content-type/json/index.ts +0 -108
  165. package/src/adapters/aws-lambda/utils.ts +0 -170
  166. package/src/adapters/content-handlers/concurrentCache.ts +0 -16
  167. package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +0 -45
  168. package/src/adapters/fastify/content-type/json/index.ts +0 -106
  169. package/src/adapters/fastify/types.ts +0 -22
  170. package/src/adapters/fetch/content-type/json/index.ts +0 -90
  171. package/src/adapters/node-http/content-type/form-data/index.ts +0 -37
  172. package/src/adapters/node-http/content-type/json/getPostBody.ts +0 -49
  173. package/src/adapters/node-http/content-type/json/index.ts +0 -100
  174. package/src/adapters/node-http/content-type/octet/index.ts +0 -27
  175. package/src/adapters/node-http/content-type/types.ts +0 -19
  176. package/src/unstable-core-do-not-import/contentTypeParsers.ts +0 -37
  177. package/src/unstable-core-do-not-import/http/index.ts +0 -28
  178. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -461
@@ -1,7 +1,9 @@
1
- export { getHTTPStatusCode, getHTTPStatusCodeFromError, } from '../../unstable-core-do-not-import';
2
- export { resolveHTTPResponse } from '../../unstable-core-do-not-import';
3
- export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse, OnErrorFunction, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from '../../unstable-core-do-not-import';
1
+ export { getHTTPStatusCode, getHTTPStatusCodeFromError, resolveResponse, } from '../../unstable-core-do-not-import';
2
+ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPErrorHandler,
3
+ /**
4
+ * @deprecated Use `HTTPErrorHandler` instead
5
+ */
6
+ HTTPErrorHandler as OnErrorFunction, ResolveHTTPRequestOptionsContextFn, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from '../../unstable-core-do-not-import';
4
7
  export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
5
- export type { BaseContentTypeHandler, BodyResult, } from '../../unstable-core-do-not-import';
6
- export { toURL } from '../../unstable-core-do-not-import';
8
+ export { octetInputParser, toURL } from '../../unstable-core-do-not-import';
7
9
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,YAAY,EACV,sBAAsB,EACtB,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB;AAChB;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,kCAAkC,EAClC,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC"}
@@ -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 WrapCreateContext, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, } from '../../unstable-core-do-not-import';
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, } from '../../unstable-core-do-not-import';
6
6
  export type {
7
7
  /**
8
8
  * @deprecated use `AnyTRPCProcedure` instead
@@ -58,5 +58,4 @@ callProcedure, } from '../../unstable-core-do-not-import';
58
58
  * Use `Awaited<ReturnType<typeof myFunction>>` instead
59
59
  */
60
60
  export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> = Awaited<ReturnType<TFunction>>;
61
- export { parseOctetInput } from '../../unstable-core-do-not-import/contentTypeParsers';
62
61
  //# sourceMappingURL=index.d.ts.map
@@ -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,iCAAi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AAyB,EACvD,KAAK,WAAW,GACjB,MAAM,mCAAmC,CAAC;AAE3C,YAAY;AACV;;GAEG;AACH,YAAY;AACZ;;GAEG;AACH,SAAS;AACT;;GAEG;AACH,qBAAqB;AACrB;;GAEG;AACH,uBAAuB;AAEvB;;GAEG;AACH,IAAI;AAEJ;;GAEG;AACH,WAAW;AACX;;GAEG;AACH,aAAa;AACb;;GAEG;AACH,oBAAoB;AAEpB;;GAEG;AACH,iBAAiB;AACjB;;GAEG;AACH,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO;AACL;;GAEG;AACH,aAAa;AAEb;;GAEG;AACH,aAAa,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACxE,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
2
+ export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
3
+ export type APIGatewayResult = APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;
4
+ /** 1:1 mapping of v1 or v2 input events, deduces which is which.
5
+ * @internal
6
+ **/
7
+ export type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent ? APIGatewayProxyResult : TEvent extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
8
+ export declare function getPlanner<TEvent extends LambdaEvent>(event: TEvent): {
9
+ path: string;
10
+ request: Request;
11
+ toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;
12
+ };
13
+ //# sourceMappingURL=getPlanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACrC,iCAAiC,GACjC,KAAK,CAAC;AA0HV,wBAAgB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,KAAK,EAAE,MAAM;;;;EAoCnE"}
@@ -0,0 +1,143 @@
1
+ 'use strict';
2
+
3
+ function determinePayloadFormat(event) {
4
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
5
+ // According to AWS support, version is is extracted from the version property in the event.
6
+ // If there is no version property, then the version is implied as 1.0
7
+ const unknownEvent = event;
8
+ if (typeof unknownEvent.version === 'undefined') {
9
+ return '1.0';
10
+ } else {
11
+ return unknownEvent.version;
12
+ }
13
+ }
14
+ const v1Processor = {
15
+ // same as getPath above
16
+ getTRPCPath: (event)=>{
17
+ if (!event.pathParameters) {
18
+ // Then this event was not triggered by a resource denoted with {proxy+}
19
+ return event.path.split('/').pop() ?? '';
20
+ }
21
+ const matches = event.resource.matchAll(/\{(.*?)\}/g);
22
+ for (const match of matches){
23
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
+ const group = match[1];
25
+ if (group.includes('+') && event.pathParameters) {
26
+ return event.pathParameters[group.replace('+', '')] ?? '';
27
+ }
28
+ }
29
+ return event.path.slice(1);
30
+ },
31
+ url (event) {
32
+ const hostname = event.requestContext.domainName ?? event.headers['host'] ?? event.multiValueHeaders?.['host']?.[0] ?? 'localhost';
33
+ const searchParams = new URLSearchParams();
34
+ for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
35
+ if (value !== undefined) {
36
+ searchParams.append(key, value);
37
+ }
38
+ }
39
+ const qs = searchParams.toString();
40
+ return {
41
+ hostname,
42
+ pathname: event.path,
43
+ search: qs && `?${qs}`
44
+ };
45
+ },
46
+ getHeaders: (event)=>{
47
+ const headers = new Headers();
48
+ for (const [key, value] of Object.entries(event.headers ?? {})){
49
+ if (value !== undefined) {
50
+ headers.append(key, value);
51
+ }
52
+ }
53
+ for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})){
54
+ if (values) {
55
+ values.forEach((v)=>headers.append(k, v));
56
+ }
57
+ }
58
+ return headers;
59
+ },
60
+ getMethod: (event)=>event.httpMethod,
61
+ toResult: async (response)=>{
62
+ const result = {
63
+ statusCode: response.status,
64
+ body: await response.text(),
65
+ headers: Object.fromEntries(response.headers.entries())
66
+ };
67
+ return result;
68
+ }
69
+ };
70
+ const v2Processor = {
71
+ getTRPCPath: (event)=>{
72
+ const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
73
+ for (const match of matches){
74
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
+ const group = match[1];
76
+ if (group.includes('+') && event.pathParameters) {
77
+ return event.pathParameters[group.replace('+', '')] ?? '';
78
+ }
79
+ }
80
+ return event.rawPath.slice(1);
81
+ },
82
+ url (event) {
83
+ return {
84
+ hostname: event.requestContext.domainName,
85
+ pathname: event.rawPath,
86
+ search: event.rawQueryString && `?${event.rawQueryString}`
87
+ };
88
+ },
89
+ getHeaders: (event)=>{
90
+ const headers = new Headers();
91
+ for (const [key, value] of Object.entries(event.headers ?? {})){
92
+ if (value !== undefined) {
93
+ headers.append(key, value);
94
+ }
95
+ }
96
+ if (event.cookies) {
97
+ headers.append('cookie', event.cookies.join('; '));
98
+ }
99
+ return headers;
100
+ },
101
+ getMethod: (event)=>event.requestContext.http.method,
102
+ toResult: async (response)=>{
103
+ const result = {
104
+ statusCode: response.status,
105
+ body: await response.text(),
106
+ headers: Object.fromEntries(response.headers.entries())
107
+ };
108
+ return result;
109
+ }
110
+ };
111
+ function getPlanner(event) {
112
+ const version = determinePayloadFormat(event);
113
+ let processor;
114
+ switch(version){
115
+ case '1.0':
116
+ processor = v1Processor;
117
+ break;
118
+ case '2.0':
119
+ processor = v2Processor;
120
+ break;
121
+ default:
122
+ throw new Error(`Unsupported version: ${version}`);
123
+ }
124
+ const urlParts = processor.url(event);
125
+ const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;
126
+ const init = {
127
+ headers: processor.getHeaders(event),
128
+ method: processor.getMethod(event),
129
+ // @ts-expect-error this is fine
130
+ duplex: 'half'
131
+ };
132
+ if (event.body) {
133
+ init.body = event.isBase64Encoded ? Buffer.from(event.body, 'base64') : event.body;
134
+ }
135
+ const request = new Request(url, init);
136
+ return {
137
+ path: processor.getTRPCPath(event),
138
+ request,
139
+ toResult: processor.toResult
140
+ };
141
+ }
142
+
143
+ exports.getPlanner = getPlanner;
@@ -0,0 +1,141 @@
1
+ function determinePayloadFormat(event) {
2
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
3
+ // According to AWS support, version is is extracted from the version property in the event.
4
+ // If there is no version property, then the version is implied as 1.0
5
+ const unknownEvent = event;
6
+ if (typeof unknownEvent.version === 'undefined') {
7
+ return '1.0';
8
+ } else {
9
+ return unknownEvent.version;
10
+ }
11
+ }
12
+ const v1Processor = {
13
+ // same as getPath above
14
+ getTRPCPath: (event)=>{
15
+ if (!event.pathParameters) {
16
+ // Then this event was not triggered by a resource denoted with {proxy+}
17
+ return event.path.split('/').pop() ?? '';
18
+ }
19
+ const matches = event.resource.matchAll(/\{(.*?)\}/g);
20
+ for (const match of matches){
21
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
+ const group = match[1];
23
+ if (group.includes('+') && event.pathParameters) {
24
+ return event.pathParameters[group.replace('+', '')] ?? '';
25
+ }
26
+ }
27
+ return event.path.slice(1);
28
+ },
29
+ url (event) {
30
+ const hostname = event.requestContext.domainName ?? event.headers['host'] ?? event.multiValueHeaders?.['host']?.[0] ?? 'localhost';
31
+ const searchParams = new URLSearchParams();
32
+ for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
33
+ if (value !== undefined) {
34
+ searchParams.append(key, value);
35
+ }
36
+ }
37
+ const qs = searchParams.toString();
38
+ return {
39
+ hostname,
40
+ pathname: event.path,
41
+ search: qs && `?${qs}`
42
+ };
43
+ },
44
+ getHeaders: (event)=>{
45
+ const headers = new Headers();
46
+ for (const [key, value] of Object.entries(event.headers ?? {})){
47
+ if (value !== undefined) {
48
+ headers.append(key, value);
49
+ }
50
+ }
51
+ for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})){
52
+ if (values) {
53
+ values.forEach((v)=>headers.append(k, v));
54
+ }
55
+ }
56
+ return headers;
57
+ },
58
+ getMethod: (event)=>event.httpMethod,
59
+ toResult: async (response)=>{
60
+ const result = {
61
+ statusCode: response.status,
62
+ body: await response.text(),
63
+ headers: Object.fromEntries(response.headers.entries())
64
+ };
65
+ return result;
66
+ }
67
+ };
68
+ const v2Processor = {
69
+ getTRPCPath: (event)=>{
70
+ const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
71
+ for (const match of matches){
72
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
73
+ const group = match[1];
74
+ if (group.includes('+') && event.pathParameters) {
75
+ return event.pathParameters[group.replace('+', '')] ?? '';
76
+ }
77
+ }
78
+ return event.rawPath.slice(1);
79
+ },
80
+ url (event) {
81
+ return {
82
+ hostname: event.requestContext.domainName,
83
+ pathname: event.rawPath,
84
+ search: event.rawQueryString && `?${event.rawQueryString}`
85
+ };
86
+ },
87
+ getHeaders: (event)=>{
88
+ const headers = new Headers();
89
+ for (const [key, value] of Object.entries(event.headers ?? {})){
90
+ if (value !== undefined) {
91
+ headers.append(key, value);
92
+ }
93
+ }
94
+ if (event.cookies) {
95
+ headers.append('cookie', event.cookies.join('; '));
96
+ }
97
+ return headers;
98
+ },
99
+ getMethod: (event)=>event.requestContext.http.method,
100
+ toResult: async (response)=>{
101
+ const result = {
102
+ statusCode: response.status,
103
+ body: await response.text(),
104
+ headers: Object.fromEntries(response.headers.entries())
105
+ };
106
+ return result;
107
+ }
108
+ };
109
+ function getPlanner(event) {
110
+ const version = determinePayloadFormat(event);
111
+ let processor;
112
+ switch(version){
113
+ case '1.0':
114
+ processor = v1Processor;
115
+ break;
116
+ case '2.0':
117
+ processor = v2Processor;
118
+ break;
119
+ default:
120
+ throw new Error(`Unsupported version: ${version}`);
121
+ }
122
+ const urlParts = processor.url(event);
123
+ const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;
124
+ const init = {
125
+ headers: processor.getHeaders(event),
126
+ method: processor.getMethod(event),
127
+ // @ts-expect-error this is fine
128
+ duplex: 'half'
129
+ };
130
+ if (event.body) {
131
+ init.body = event.isBase64Encoded ? Buffer.from(event.body, 'base64') : event.body;
132
+ }
133
+ const request = new Request(url, init);
134
+ return {
135
+ path: processor.getTRPCPath(event),
136
+ request,
137
+ toResult: processor.toResult
138
+ };
139
+ }
140
+
141
+ export { getPlanner };
@@ -7,13 +7,16 @@
7
7
  * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
8
8
  * ```
9
9
  */
10
- import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context as APIGWContext } from 'aws-lambda';
11
- import type { AnyRouter } from '../../@trpc/server';
12
- import type { APIGatewayEvent, AWSLambdaOptions } from './utils';
13
- export * from './utils';
14
- /** 1:1 mapping of v1 or v2 input events, deduces which is which.
15
- * @internal
16
- **/
17
- type inferAPIGWReturn<TType> = TType extends APIGatewayProxyEvent ? APIGatewayProxyResult : TType extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
18
- export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends APIGatewayEvent, TResult extends inferAPIGWReturn<TEvent>>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: APIGWContext) => Promise<TResult>;
10
+ import type { Context as APIGWContext } from 'aws-lambda';
11
+ import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../../@trpc/server';
12
+ import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
13
+ import type { inferAPIGWReturn, LambdaEvent } from './getPlanner';
14
+ export type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
15
+ event: TEvent;
16
+ context: APIGWContext;
17
+ info: TRPCRequestInfo;
18
+ };
19
+ export type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
20
+ export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({ event, context, info, }: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
21
+ export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>>;
19
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EACjC,OAAO,IAAI,YAAY,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAWpD,OAAO,KAAK,EACV,eAAe,EAEf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAUjB,cAAc,SAAS,CAAC;AA6CxB;;IAEI;AACJ,KAAK,gBAA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W,IACxB,CAAC,EACH,KAAK,EACL,OAAO,EACP,IAAI,GACL,EAAE,6BAA6B,CAAC,MAAM,CAAC,KACpC,kBAAkB,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEzC,wBAAgB,uBAAuB,CACrC,OAAO,SAAS,SAAS,EACzB,MAAM,SAAS,WAAW,EAE1B,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,GACtC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CA0B7E"}
@@ -1,60 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
4
- var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
3
+ var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
5
4
  require('../../unstable-core-do-not-import/rootConfig.js');
6
- var selectContentHandlerOrUnsupportedMediaType = require('../content-handlers/selectContentHandlerOrUnsupportedMediaType.js');
7
- var index = require('./content-type/json/index.js');
8
- var utils = require('./utils.js');
5
+ var getPlanner = require('./getPlanner.js');
9
6
 
10
- /**
11
- * 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`
12
- *
13
- * @example
14
- * ```ts
15
- * import type { AnyTRPCRouter } from '@trpc/server'
16
- * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
17
- * ```
18
- */ // @trpc/server
19
- function lambdaEventToHTTPRequest(event) {
20
- const query = new URLSearchParams();
21
- for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
22
- if (typeof value !== 'undefined') {
23
- query.append(key, value);
24
- }
25
- }
26
- return {
27
- method: utils.getHTTPMethod(event),
28
- query: query,
29
- headers: event.headers
30
- };
31
- }
32
- function tRPCOutputToAPIGatewayOutput(event, response) {
33
- if (utils.isPayloadV1(event)) {
34
- const resp = {
35
- statusCode: response.status,
36
- body: response.body ?? '',
37
- headers: utils.transformHeaders(response.headers ?? {})
38
- };
39
- return resp;
40
- } else if (utils.isPayloadV2(event)) {
41
- const resp1 = {
42
- statusCode: response.status,
43
- body: response.body ?? undefined,
44
- headers: utils.transformHeaders(response.headers ?? {})
45
- };
46
- return resp1;
47
- } else {
48
- throw new TRPCError.TRPCError({
49
- code: 'INTERNAL_SERVER_ERROR',
50
- message: utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
51
- });
52
- }
53
- }
54
7
  function awsLambdaRequestHandler(opts) {
55
8
  return async (event, context)=>{
56
- const req = lambdaEventToHTTPRequest(event);
57
- const path = utils.getPath(event);
9
+ const planner = getPlanner.getPlanner(event);
58
10
  const createContext = async (innerOpts)=>{
59
11
  return await opts.createContext?.({
60
12
  event,
@@ -62,26 +14,12 @@ function awsLambdaRequestHandler(opts) {
62
14
  ...innerOpts
63
15
  });
64
16
  };
65
- const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType.selectContentHandlerOrUnsupportedMediaType([
66
- index.getLambdaHTTPJSONContentTypeHandler()
67
- ], {
68
- ...opts,
69
- event,
70
- req
71
- });
72
- const response = await resolveHTTPResponse.resolveHTTPResponse({
17
+ const response = await resolveResponse.resolveResponse({
73
18
  ...opts,
74
19
  createContext,
75
- req,
76
- path,
77
- error: unsupportedMediaTypeError,
78
- async getInput (info) {
79
- return await contentTypeHandler?.getInputs({
80
- ...opts,
81
- event,
82
- req
83
- }, info);
84
- },
20
+ req: planner.request,
21
+ path: planner.path,
22
+ error: null,
85
23
  onError (o) {
86
24
  opts?.onError?.({
87
25
  ...o,
@@ -89,15 +27,8 @@ function awsLambdaRequestHandler(opts) {
89
27
  });
90
28
  }
91
29
  });
92
- return tRPCOutputToAPIGatewayOutput(event, response);
30
+ return await planner.toResult(response);
93
31
  };
94
32
  }
95
33
 
96
- exports.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE;
97
- exports.getHTTPMethod = utils.getHTTPMethod;
98
- exports.getPath = utils.getPath;
99
- exports.isPayloadV1 = utils.isPayloadV1;
100
- exports.isPayloadV2 = utils.isPayloadV2;
101
- exports.lambdaEventToHTTPBody = utils.lambdaEventToHTTPBody;
102
- exports.transformHeaders = utils.transformHeaders;
103
34
  exports.awsLambdaRequestHandler = awsLambdaRequestHandler;
@@ -1,59 +1,10 @@
1
- import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
2
- import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
1
+ import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
3
2
  import '../../unstable-core-do-not-import/rootConfig.mjs';
4
- import { selectContentHandlerOrUnsupportedMediaType } from '../content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs';
5
- import { getLambdaHTTPJSONContentTypeHandler } from './content-type/json/index.mjs';
6
- import { getPath, getHTTPMethod, isPayloadV1, transformHeaders, isPayloadV2, UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE } from './utils.mjs';
7
- export { lambdaEventToHTTPBody } from './utils.mjs';
3
+ import { getPlanner } from './getPlanner.mjs';
8
4
 
9
- /**
10
- * 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`
11
- *
12
- * @example
13
- * ```ts
14
- * import type { AnyTRPCRouter } from '@trpc/server'
15
- * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
16
- * ```
17
- */ // @trpc/server
18
- function lambdaEventToHTTPRequest(event) {
19
- const query = new URLSearchParams();
20
- for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
21
- if (typeof value !== 'undefined') {
22
- query.append(key, value);
23
- }
24
- }
25
- return {
26
- method: getHTTPMethod(event),
27
- query: query,
28
- headers: event.headers
29
- };
30
- }
31
- function tRPCOutputToAPIGatewayOutput(event, response) {
32
- if (isPayloadV1(event)) {
33
- const resp = {
34
- statusCode: response.status,
35
- body: response.body ?? '',
36
- headers: transformHeaders(response.headers ?? {})
37
- };
38
- return resp;
39
- } else if (isPayloadV2(event)) {
40
- const resp1 = {
41
- statusCode: response.status,
42
- body: response.body ?? undefined,
43
- headers: transformHeaders(response.headers ?? {})
44
- };
45
- return resp1;
46
- } else {
47
- throw new TRPCError({
48
- code: 'INTERNAL_SERVER_ERROR',
49
- message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
50
- });
51
- }
52
- }
53
5
  function awsLambdaRequestHandler(opts) {
54
6
  return async (event, context)=>{
55
- const req = lambdaEventToHTTPRequest(event);
56
- const path = getPath(event);
7
+ const planner = getPlanner(event);
57
8
  const createContext = async (innerOpts)=>{
58
9
  return await opts.createContext?.({
59
10
  event,
@@ -61,26 +12,12 @@ function awsLambdaRequestHandler(opts) {
61
12
  ...innerOpts
62
13
  });
63
14
  };
64
- const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType([
65
- getLambdaHTTPJSONContentTypeHandler()
66
- ], {
67
- ...opts,
68
- event,
69
- req
70
- });
71
- const response = await resolveHTTPResponse({
15
+ const response = await resolveResponse({
72
16
  ...opts,
73
17
  createContext,
74
- req,
75
- path,
76
- error: unsupportedMediaTypeError,
77
- async getInput (info) {
78
- return await contentTypeHandler?.getInputs({
79
- ...opts,
80
- event,
81
- req
82
- }, info);
83
- },
18
+ req: planner.request,
19
+ path: planner.path,
20
+ error: null,
84
21
  onError (o) {
85
22
  opts?.onError?.({
86
23
  ...o,
@@ -88,8 +25,8 @@ function awsLambdaRequestHandler(opts) {
88
25
  });
89
26
  }
90
27
  });
91
- return tRPCOutputToAPIGatewayOutput(event, response);
28
+ return await planner.toResult(response);
92
29
  };
93
30
  }
94
31
 
95
- export { UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE, awsLambdaRequestHandler, getHTTPMethod, getPath, isPayloadV1, isPayloadV2, transformHeaders };
32
+ export { awsLambdaRequestHandler };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
4
+ require('../unstable-core-do-not-import/rootConfig.js');
4
5
 
5
6
  function createExpressMiddleware(opts) {
6
7
  return async (req, res)=>{
@@ -1,4 +1,5 @@
1
1
  import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
2
+ import '../unstable-core-do-not-import/rootConfig.mjs';
2
3
 
3
4
  function createExpressMiddleware(opts) {
4
5
  return async (req, res)=>{
@@ -1,5 +1,22 @@
1
+ /**
2
+ * 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`
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import type { AnyTRPCRouter } from '@trpc/server'
7
+ * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
8
+ * ```
9
+ */
1
10
  import type { FastifyReply, FastifyRequest } from 'fastify';
2
11
  import type { AnyRouter } from '../../@trpc/server';
3
- import type { FastifyRequestHandlerOptions } from './types';
4
- export declare function fastifyRequestHandler<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<never>;
12
+ import { type HTTPBaseHandlerOptions } from '../../@trpc/server/http';
13
+ import { type NodeHTTPCreateContextOption } from '../node-http';
14
+ export type FastifyHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = HTTPBaseHandlerOptions<TRouter, TRequest> & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
15
+ type FastifyRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = FastifyHandlerOptions<TRouter, TRequest, TResponse> & {
16
+ req: TRequest;
17
+ res: TResponse;
18
+ path: string;
19
+ };
20
+ export declare function fastifyRequestHandler<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<void>;
21
+ export {};
5
22
  //# sourceMappingURL=fastifyRequestHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D,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,kBAgGjE"}
1
+ {"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,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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