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

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 (162) hide show
  1. package/dist/@trpc/server/http.d.ts +0 -1
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/@trpc/server/index.d.ts +2 -1
  4. package/dist/@trpc/server/index.d.ts.map +1 -1
  5. package/dist/adapters/aws-lambda/content-type/json/index.d.ts +10 -0
  6. package/dist/adapters/aws-lambda/content-type/json/index.d.ts.map +1 -0
  7. package/dist/adapters/aws-lambda/content-type/json/index.js +62 -0
  8. package/dist/adapters/aws-lambda/content-type/json/index.mjs +60 -0
  9. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  10. package/dist/adapters/aws-lambda/index.js +19 -9
  11. package/dist/adapters/aws-lambda/index.mjs +19 -9
  12. package/dist/adapters/aws-lambda/utils.d.ts +3 -12
  13. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  14. package/dist/adapters/aws-lambda/utils.js +12 -1
  15. package/dist/adapters/aws-lambda/utils.mjs +12 -2
  16. package/dist/adapters/content-handlers/concurrentCache.d.ts +7 -0
  17. package/dist/adapters/content-handlers/concurrentCache.d.ts.map +1 -0
  18. package/dist/adapters/content-handlers/concurrentCache.js +17 -0
  19. package/dist/adapters/content-handlers/concurrentCache.mjs +15 -0
  20. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts +10 -0
  21. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +1 -0
  22. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +33 -0
  23. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +31 -0
  24. package/dist/adapters/express.d.ts.map +1 -1
  25. package/dist/adapters/express.js +0 -1
  26. package/dist/adapters/express.mjs +0 -1
  27. package/dist/adapters/fastify/content-type/json/index.d.ts +8 -0
  28. package/dist/adapters/fastify/content-type/json/index.d.ts.map +1 -0
  29. package/dist/adapters/fastify/content-type/json/index.js +62 -0
  30. package/dist/adapters/fastify/content-type/json/index.mjs +60 -0
  31. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +1 -9
  32. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  33. package/dist/adapters/fastify/fastifyRequestHandler.js +10 -2
  34. package/dist/adapters/fastify/fastifyRequestHandler.mjs +10 -2
  35. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
  36. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  37. package/dist/adapters/fastify/types.d.ts +11 -0
  38. package/dist/adapters/fastify/types.d.ts.map +1 -0
  39. package/dist/adapters/fetch/content-type/json/index.d.ts +9 -0
  40. package/dist/adapters/fetch/content-type/json/index.d.ts.map +1 -0
  41. package/dist/adapters/fetch/content-type/json/index.js +55 -0
  42. package/dist/adapters/fetch/content-type/json/index.mjs +53 -0
  43. package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -5
  44. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  45. package/dist/adapters/fetch/fetchRequestHandler.js +16 -2
  46. package/dist/adapters/fetch/fetchRequestHandler.mjs +16 -2
  47. package/dist/adapters/fetch/types.d.ts +9 -12
  48. package/dist/adapters/fetch/types.d.ts.map +1 -1
  49. package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +2 -7
  50. package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
  51. package/dist/adapters/next.d.ts.map +1 -1
  52. package/dist/adapters/next.js +0 -1
  53. package/dist/adapters/next.mjs +0 -1
  54. package/dist/adapters/node-http/content-type/form-data/index.d.ts +4 -25
  55. package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
  56. package/dist/adapters/node-http/content-type/form-data/index.js +25 -128
  57. package/dist/adapters/node-http/content-type/form-data/index.mjs +25 -103
  58. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  59. package/dist/adapters/node-http/content-type/json/getPostBody.js +4 -12
  60. package/dist/adapters/node-http/content-type/json/getPostBody.mjs +4 -12
  61. package/dist/adapters/node-http/content-type/json/index.d.ts +4 -1
  62. package/dist/adapters/node-http/content-type/json/index.d.ts.map +1 -1
  63. package/dist/adapters/node-http/content-type/json/index.js +62 -10
  64. package/dist/adapters/node-http/content-type/json/index.mjs +62 -10
  65. package/dist/adapters/node-http/content-type/octet/index.d.ts +5 -0
  66. package/dist/adapters/node-http/content-type/octet/index.d.ts.map +1 -0
  67. package/dist/adapters/node-http/content-type/octet/index.js +19 -0
  68. package/dist/adapters/node-http/content-type/octet/index.mjs +17 -0
  69. package/dist/adapters/node-http/content-type/types.d.ts +8 -0
  70. package/dist/adapters/node-http/content-type/types.d.ts.map +1 -0
  71. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  72. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +19 -21
  73. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +20 -22
  74. package/dist/adapters/node-http/types.d.ts +8 -19
  75. package/dist/adapters/node-http/types.d.ts.map +1 -1
  76. package/dist/adapters/standalone.d.ts.map +1 -1
  77. package/dist/adapters/standalone.js +0 -1
  78. package/dist/adapters/standalone.mjs +0 -1
  79. package/dist/adapters/ws.d.ts +2 -12
  80. package/dist/adapters/ws.d.ts.map +1 -1
  81. package/dist/bundle-analysis.json +241 -230
  82. package/dist/http.js +0 -2
  83. package/dist/http.mjs +0 -1
  84. package/dist/index.js +2 -0
  85. package/dist/index.mjs +1 -0
  86. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts +16 -0
  87. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts.map +1 -0
  88. package/dist/unstable-core-do-not-import/contentTypeParsers.js +23 -0
  89. package/dist/unstable-core-do-not-import/contentTypeParsers.mjs +21 -0
  90. package/dist/unstable-core-do-not-import/http/contentType.d.ts +7 -15
  91. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  92. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -1
  93. package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -1
  94. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +5 -5
  95. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -1
  96. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +26 -20
  97. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +26 -20
  98. package/dist/unstable-core-do-not-import/http/types.d.ts +0 -2
  99. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  100. package/dist/unstable-core-do-not-import/rootConfig.d.ts +21 -0
  101. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
  102. package/dist/unstable-core-do-not-import.js +0 -2
  103. package/dist/unstable-core-do-not-import.mjs +0 -1
  104. package/package.json +6 -7
  105. package/src/@trpc/server/http.ts +0 -1
  106. package/src/@trpc/server/index.ts +4 -0
  107. package/src/adapters/aws-lambda/content-type/json/index.ts +108 -0
  108. package/src/adapters/aws-lambda/index.ts +24 -9
  109. package/src/adapters/aws-lambda/utils.ts +21 -15
  110. package/src/adapters/content-handlers/concurrentCache.ts +16 -0
  111. package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +45 -0
  112. package/src/adapters/express.ts +1 -6
  113. package/src/adapters/fastify/content-type/json/index.ts +106 -0
  114. package/src/adapters/fastify/fastifyRequestHandler.ts +15 -21
  115. package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
  116. package/src/adapters/fastify/types.ts +22 -0
  117. package/src/adapters/fetch/content-type/json/index.ts +90 -0
  118. package/src/adapters/fetch/fetchRequestHandler.ts +22 -10
  119. package/src/adapters/fetch/types.ts +22 -15
  120. package/src/adapters/next-app-dir/nextAppDirCaller.ts +2 -9
  121. package/src/adapters/next.ts +1 -6
  122. package/src/adapters/node-http/content-type/form-data/index.ts +33 -159
  123. package/src/adapters/node-http/content-type/json/getPostBody.ts +9 -18
  124. package/src/adapters/node-http/content-type/json/index.ts +98 -9
  125. package/src/adapters/node-http/content-type/octet/index.ts +27 -0
  126. package/src/adapters/node-http/{internals/contentType.ts → content-type/types.ts} +2 -14
  127. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +22 -35
  128. package/src/adapters/node-http/types.ts +46 -46
  129. package/src/adapters/standalone.ts +1 -2
  130. package/src/adapters/ws.ts +9 -14
  131. package/src/unstable-core-do-not-import/contentTypeParsers.ts +37 -0
  132. package/src/unstable-core-do-not-import/http/contentType.ts +10 -85
  133. package/src/unstable-core-do-not-import/http/index.ts +0 -1
  134. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +30 -27
  135. package/src/unstable-core-do-not-import/http/types.ts +0 -2
  136. package/src/unstable-core-do-not-import/rootConfig.ts +31 -0
  137. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +0 -73
  138. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +0 -1
  139. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +0 -161
  140. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +0 -157
  141. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +0 -31
  142. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +0 -1
  143. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +0 -29
  144. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +0 -27
  145. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +0 -16
  146. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +0 -1
  147. package/dist/adapters/node-http/content-type/form-data/streamSlice.js +0 -46
  148. package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +0 -44
  149. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +0 -45
  150. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +0 -1
  151. package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +0 -30
  152. package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +0 -26
  153. package/dist/adapters/node-http/internals/contentType.d.ts +0 -9
  154. package/dist/adapters/node-http/internals/contentType.d.ts.map +0 -1
  155. package/dist/adapters/node-http/internals/contentType.js +0 -8
  156. package/dist/adapters/node-http/internals/contentType.mjs +0 -6
  157. package/dist/unstable-core-do-not-import/http/contentType.js +0 -54
  158. package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -52
  159. package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +0 -277
  160. package/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts +0 -56
  161. package/src/adapters/node-http/content-type/form-data/streamSlice.ts +0 -56
  162. package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +0 -89
package/dist/http.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
4
4
  var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
5
5
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
6
- var contentType = require('./unstable-core-do-not-import/http/contentType.js');
7
6
  var toURL = require('./unstable-core-do-not-import/http/toURL.js');
8
7
  require('./unstable-core-do-not-import/rootConfig.js');
9
8
 
@@ -13,5 +12,4 @@ exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
13
12
  exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
14
13
  exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
15
14
  exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
16
- exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
17
15
  exports.toURL = toURL.toURL;
package/dist/http.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
2
2
  export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
3
3
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
4
- export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
5
4
  export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
6
5
  import './unstable-core-do-not-import/rootConfig.mjs';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ var transformer = require('./unstable-core-do-not-import/transformer.js');
8
8
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
9
9
  var middleware = require('./unstable-core-do-not-import/middleware.js');
10
10
  require('./unstable-core-do-not-import/rootConfig.js');
11
+ var contentTypeParsers = require('./unstable-core-do-not-import/contentTypeParsers.js');
11
12
 
12
13
 
13
14
 
@@ -21,3 +22,4 @@ exports.transformTRPCResponse = transformer.transformTRPCResponse;
21
22
  exports.initTRPC = initTRPC.initTRPC;
22
23
  exports.experimental_standaloneMiddleware = middleware.experimental_standaloneMiddleware;
23
24
  exports.experimental_trpcMiddleware = middleware.experimental_standaloneMiddleware;
25
+ exports.parseOctetInput = contentTypeParsers.parseOctetInput;
package/dist/index.mjs CHANGED
@@ -6,3 +6,4 @@ export { transformTRPCResponse } from './unstable-core-do-not-import/transformer
6
6
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
7
7
  export { experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware } from './unstable-core-do-not-import/middleware.mjs';
8
8
  import './unstable-core-do-not-import/rootConfig.mjs';
9
+ export { parseOctetInput } from './unstable-core-do-not-import/contentTypeParsers.mjs';
@@ -0,0 +1,16 @@
1
+ import type { ParserZodEsque } from './parser';
2
+ export type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {
3
+ parse: (input: unknown) => TOutput;
4
+ };
5
+ /**
6
+ * File is only available from Node19+ but it always extends Blob so we can use that as a type until we eventually drop Node18
7
+ */
8
+ interface FileLike extends Blob {
9
+ readonly name: string;
10
+ }
11
+ /**
12
+ * When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
13
+ */
14
+ export declare function parseOctetInput<TInput extends Blob | Uint8Array | FileLike>(): UtilityParser<TInput, ReadableStream>;
15
+ export {};
16
+ //# sourceMappingURL=contentTypeParsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentTypeParsers.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/contentTypeParsers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,aAAa,CAAC,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC7E,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACpC,CAAC;AAIF;;GAEG;AACH,UAAU,QAAS,SAAQ,IAAI;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,SAAS,IAAI,GAAG,UAAU,GAAG,QAAQ,KACxC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,CAezC"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var TRPCError = require('./error/TRPCError.js');
4
+
5
+ /**
6
+ * When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
7
+ */ function parseOctetInput() {
8
+ return {
9
+ _input: null,
10
+ _output: null,
11
+ parse (input) {
12
+ if (input instanceof ReadableStream) {
13
+ return input;
14
+ }
15
+ throw new TRPCError.TRPCError({
16
+ code: 'INTERNAL_SERVER_ERROR',
17
+ cause: `Parsed input was expected to be a ReadableStream but was: ${typeof input}`
18
+ });
19
+ }
20
+ };
21
+ }
22
+
23
+ exports.parseOctetInput = parseOctetInput;
@@ -0,0 +1,21 @@
1
+ import { TRPCError } from './error/TRPCError.mjs';
2
+
3
+ /**
4
+ * When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
5
+ */ function parseOctetInput() {
6
+ return {
7
+ _input: null,
8
+ _output: null,
9
+ parse (input) {
10
+ if (input instanceof ReadableStream) {
11
+ return input;
12
+ }
13
+ throw new TRPCError({
14
+ code: 'INTERNAL_SERVER_ERROR',
15
+ cause: `Parsed input was expected to be a ReadableStream but was: ${typeof input}`
16
+ });
17
+ }
18
+ };
19
+ }
20
+
21
+ export { parseOctetInput };
@@ -1,13 +1,4 @@
1
- import { TRPCError } from '../error/TRPCError';
2
- import type { AnyRouter } from '../router';
3
- import type { MaybePromise } from '../types';
4
- import type { HTTPRequest } from './types';
5
- type GetInputs = (opts: {
6
- req: HTTPRequest;
7
- isBatchCall: boolean;
8
- router: AnyRouter;
9
- preprocessedBody: boolean;
10
- }) => MaybePromise<Record<number, unknown>>;
1
+ import type { TRPCError } from '../error/TRPCError';
11
2
  export type BodyResult = {
12
3
  ok: true;
13
4
  data: unknown;
@@ -20,10 +11,11 @@ export type BodyResult = {
20
11
  error: TRPCError;
21
12
  };
22
13
  export type BaseContentTypeHandler<TOptions> = {
23
- isMatch(opts: TOptions): boolean;
24
- getBody: (opts: TOptions) => MaybePromise<BodyResult>;
25
- getInputs: GetInputs;
14
+ name: string;
15
+ isMatch(headers: Headers): boolean;
16
+ getInputs: (opts: TOptions, info: {
17
+ isBatchCall: boolean;
18
+ batch: number;
19
+ }) => Promise<unknown>;
26
20
  };
27
- export declare const getJsonContentTypeInputs: GetInputs;
28
- export {};
29
21
  //# sourceMappingURL=contentType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS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CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,sBAAsB,CAAC,QAAQ,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC,SAAS,EAAE,CACT,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,KACE,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB,CAAC"}
@@ -7,6 +7,5 @@ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPReque
7
7
  HTTPErrorHandler as OnErrorFunction, HTTPErrorHandler, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from './types';
8
8
  export { getBatchStreamFormatter } from './batchStreamFormatter';
9
9
  export type { BaseContentTypeHandler, BodyResult } from './contentType';
10
- export { getJsonContentTypeInputs } from './contentType';
11
10
  export { toURL } from './toURL';
12
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY;AACZ;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,gBAAgB,EAChB,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY;AACZ;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,gBAAgB,EAChB,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { TRPCError } from '../error/TRPCError';
2
2
  import type { AnyRouter } from '../router';
3
- import type { Maybe } from '../types';
4
- import type { BaseContentTypeHandler } from './contentType';
5
3
  import type { HTTPBaseHandlerOptions, HTTPRequest, HTTPResponse, ResolveHTTPRequestOptionsContextFn, ResponseChunk } from './types';
6
4
  interface ResolveHTTPRequestOptions<TRouter extends AnyRouter, TRequest extends HTTPRequest> extends HTTPBaseHandlerOptions<TRouter, TRequest> {
7
5
  createContext: ResolveHTTPRequestOptionsContextFn<TRouter>;
8
6
  req: TRequest;
9
7
  path: string;
10
- error?: Maybe<TRPCError>;
11
- contentTypeHandler?: BaseContentTypeHandler<any>;
12
- preprocessedBody?: boolean;
8
+ getInput: (opts: {
9
+ isBatchCall: boolean;
10
+ batch: number;
11
+ }) => Promise<unknown>;
12
+ error?: TRPCError;
13
13
  /**
14
14
  * Called as soon as the response head is known.
15
15
  * When streaming, headers will have been generated
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHTTPResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,KAAK,EACV,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACZ,kCAAkC,EAClC,aAAa,EAEd,MAAM,SAAS,CAAC;AAoBjB,UAAU,yBAAyB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,CAC5B,SAAQ,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACzB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,eAAe,EAAE,CACf,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EACxC,WAAW,EAAE,OAAO,KACjB,IAAI,CAAC;IACV;;;;;;;;OAQG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AA4GD;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB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BAAgB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AA4GD;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,IAAI,CACR,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5C,kBAAkB,GAAG,iBAAiB,CACvC,GACA,OAAO,CAAC,YAAY,CAAC,CAAC;AACzB;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -4,16 +4,12 @@ var getErrorShape = require('../error/getErrorShape.js');
4
4
  var TRPCError = require('../error/TRPCError.js');
5
5
  var router = require('../router.js');
6
6
  var transformer = require('../transformer.js');
7
- var contentType = require('./contentType.js');
8
7
  var getHTTPStatusCode = require('./getHTTPStatusCode.js');
9
8
 
10
9
  const HTTP_METHOD_PROCEDURE_TYPE_MAP = {
11
10
  GET: 'query',
12
11
  POST: 'mutation'
13
12
  };
14
- const fallbackContentTypeHandler = {
15
- getInputs: contentType.getJsonContentTypeInputs
16
- };
17
13
  function initResponse(initOpts) {
18
14
  const { ctx , paths , type , responseMeta , untransformedJSON , errors =[] , } = initOpts;
19
15
  let status = untransformedJSON ? getHTTPStatusCode.getHTTPStatusCode(untransformedJSON) : 200;
@@ -87,7 +83,6 @@ async function resolveHTTPResponse(opts) {
87
83
  ]);
88
84
  return headResponse;
89
85
  }
90
- const contentTypeHandler = opts.contentTypeHandler ?? fallbackContentTypeHandler;
91
86
  const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
92
87
  const allowMethodOverride = opts.allowMethodOverride ?? false;
93
88
  const type = HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? 'unknown';
@@ -96,9 +91,6 @@ async function resolveHTTPResponse(opts) {
96
91
  const isBatchCall = !!req.query.get('batch');
97
92
  const isStreamCall = isBatchCall && unstable_onHead && unstable_onChunk && req.headers['trpc-batch-mode'] === 'stream';
98
93
  try {
99
- if (opts.error) {
100
- throw opts.error;
101
- }
102
94
  if (isBatchCall && !allowBatching) {
103
95
  throw new TRPCError.TRPCError({
104
96
  code: 'BAD_REQUEST',
@@ -117,21 +109,14 @@ async function resolveHTTPResponse(opts) {
117
109
  code: 'METHOD_NOT_SUPPORTED'
118
110
  });
119
111
  }
120
- const inputs = await contentTypeHandler.getInputs({
121
- isBatchCall,
122
- req,
123
- router: router$1,
124
- preprocessedBody: opts.preprocessedBody ?? false
125
- });
126
112
  paths = isBatchCall ? decodeURIComponent(opts.path).split(',') : [
127
113
  opts.path
128
114
  ];
129
115
  const info = {
130
116
  isBatchCall,
131
- calls: paths.map((path, idx)=>({
117
+ calls: paths.map((path)=>({
132
118
  path,
133
- type,
134
- input: inputs[idx] ?? undefined
119
+ type
135
120
  }))
136
121
  };
137
122
  ctx = await opts.createContext({
@@ -139,12 +124,23 @@ async function resolveHTTPResponse(opts) {
139
124
  });
140
125
  const errors = [];
141
126
  const promises = paths.map(async (path, index)=>{
142
- const input = inputs[index];
127
+ async function getRawInput() {
128
+ return await opts.getInput({
129
+ isBatchCall,
130
+ batch: index
131
+ });
132
+ }
143
133
  try {
134
+ if (opts.error) {
135
+ // sometimes an error may be generated above this function in the stack
136
+ // for instance a 405 error if the method is not supported
137
+ // But we need to handle it here to ensure the error is formatted correctly
138
+ throw opts.error;
139
+ }
144
140
  const data = await router.callProcedure({
145
141
  procedures: opts.router._def.procedures,
146
142
  path,
147
- getRawInput: async ()=>input,
143
+ getRawInput: getRawInput,
148
144
  ctx,
149
145
  type,
150
146
  allowMethodOverride
@@ -157,6 +153,13 @@ async function resolveHTTPResponse(opts) {
157
153
  } catch (cause) {
158
154
  const error = TRPCError.getTRPCErrorFromUnknown(cause);
159
155
  errors.push(error);
156
+ let input;
157
+ try {
158
+ input = await getRawInput();
159
+ } catch (e) {
160
+ // if `getRawInput` fails, we can't include the input in the error
161
+ input = undefined;
162
+ }
160
163
  opts.onError?.({
161
164
  error,
162
165
  path,
@@ -238,7 +241,10 @@ async function resolveHTTPResponse(opts) {
238
241
  ]);
239
242
  } catch (cause) {
240
243
  const path = paths[index];
241
- const input = inputs[index];
244
+ const input = await opts.getInput({
245
+ isBatchCall,
246
+ batch: index
247
+ });
242
248
  const { body: body2 } = caughtErrorToData(cause, {
243
249
  opts,
244
250
  ctx,
@@ -2,16 +2,12 @@ import { getErrorShape } from '../error/getErrorShape.mjs';
2
2
  import { TRPCError, getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
3
3
  import { callProcedure } from '../router.mjs';
4
4
  import { transformTRPCResponse } from '../transformer.mjs';
5
- import { getJsonContentTypeInputs } from './contentType.mjs';
6
5
  import { getHTTPStatusCode } from './getHTTPStatusCode.mjs';
7
6
 
8
7
  const HTTP_METHOD_PROCEDURE_TYPE_MAP = {
9
8
  GET: 'query',
10
9
  POST: 'mutation'
11
10
  };
12
- const fallbackContentTypeHandler = {
13
- getInputs: getJsonContentTypeInputs
14
- };
15
11
  function initResponse(initOpts) {
16
12
  const { ctx , paths , type , responseMeta , untransformedJSON , errors =[] , } = initOpts;
17
13
  let status = untransformedJSON ? getHTTPStatusCode(untransformedJSON) : 200;
@@ -85,7 +81,6 @@ async function resolveHTTPResponse(opts) {
85
81
  ]);
86
82
  return headResponse;
87
83
  }
88
- const contentTypeHandler = opts.contentTypeHandler ?? fallbackContentTypeHandler;
89
84
  const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
90
85
  const allowMethodOverride = opts.allowMethodOverride ?? false;
91
86
  const type = HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? 'unknown';
@@ -94,9 +89,6 @@ async function resolveHTTPResponse(opts) {
94
89
  const isBatchCall = !!req.query.get('batch');
95
90
  const isStreamCall = isBatchCall && unstable_onHead && unstable_onChunk && req.headers['trpc-batch-mode'] === 'stream';
96
91
  try {
97
- if (opts.error) {
98
- throw opts.error;
99
- }
100
92
  if (isBatchCall && !allowBatching) {
101
93
  throw new TRPCError({
102
94
  code: 'BAD_REQUEST',
@@ -115,21 +107,14 @@ async function resolveHTTPResponse(opts) {
115
107
  code: 'METHOD_NOT_SUPPORTED'
116
108
  });
117
109
  }
118
- const inputs = await contentTypeHandler.getInputs({
119
- isBatchCall,
120
- req,
121
- router,
122
- preprocessedBody: opts.preprocessedBody ?? false
123
- });
124
110
  paths = isBatchCall ? decodeURIComponent(opts.path).split(',') : [
125
111
  opts.path
126
112
  ];
127
113
  const info = {
128
114
  isBatchCall,
129
- calls: paths.map((path, idx)=>({
115
+ calls: paths.map((path)=>({
130
116
  path,
131
- type,
132
- input: inputs[idx] ?? undefined
117
+ type
133
118
  }))
134
119
  };
135
120
  ctx = await opts.createContext({
@@ -137,12 +122,23 @@ async function resolveHTTPResponse(opts) {
137
122
  });
138
123
  const errors = [];
139
124
  const promises = paths.map(async (path, index)=>{
140
- const input = inputs[index];
125
+ async function getRawInput() {
126
+ return await opts.getInput({
127
+ isBatchCall,
128
+ batch: index
129
+ });
130
+ }
141
131
  try {
132
+ if (opts.error) {
133
+ // sometimes an error may be generated above this function in the stack
134
+ // for instance a 405 error if the method is not supported
135
+ // But we need to handle it here to ensure the error is formatted correctly
136
+ throw opts.error;
137
+ }
142
138
  const data = await callProcedure({
143
139
  procedures: opts.router._def.procedures,
144
140
  path,
145
- getRawInput: async ()=>input,
141
+ getRawInput: getRawInput,
146
142
  ctx,
147
143
  type,
148
144
  allowMethodOverride
@@ -155,6 +151,13 @@ async function resolveHTTPResponse(opts) {
155
151
  } catch (cause) {
156
152
  const error = getTRPCErrorFromUnknown(cause);
157
153
  errors.push(error);
154
+ let input;
155
+ try {
156
+ input = await getRawInput();
157
+ } catch (e) {
158
+ // if `getRawInput` fails, we can't include the input in the error
159
+ input = undefined;
160
+ }
158
161
  opts.onError?.({
159
162
  error,
160
163
  path,
@@ -236,7 +239,10 @@ async function resolveHTTPResponse(opts) {
236
239
  ]);
237
240
  } catch (cause) {
238
241
  const path = paths[index];
239
- const input = inputs[index];
242
+ const input = await opts.getInput({
243
+ isBatchCall,
244
+ batch: index
245
+ });
240
246
  const { body: body2 } = caughtErrorToData(cause, {
241
247
  opts,
242
248
  ctx,
@@ -37,7 +37,6 @@ export interface HTTPRequest {
37
37
  method: string;
38
38
  query: URLSearchParams;
39
39
  headers: HTTPHeaders;
40
- body: unknown;
41
40
  }
42
41
  /**
43
42
  * Base interface for anything using HTTP
@@ -53,7 +52,6 @@ export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> ext
53
52
  /** @internal */
54
53
  export type ProcedureCall = {
55
54
  type: ProcedureType;
56
- input?: unknown;
57
55
  path: string;
58
56
  };
59
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EA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CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kCAAkC,CAAC,OAAO,SAAS,SAAS,IACtE,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE5E,UAAU,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,CACnE,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxD,GAAG,EAAE,QAAQ,CAAC;CACf;AACD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,IAAI,CAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAC7C,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -64,4 +64,25 @@ export type AnyRootTypes = CreateRootTypes<{
64
64
  errorShape: any;
65
65
  transformer: any;
66
66
  }>;
67
+ type PartialIf<TCondition extends boolean, TType> = TCondition extends true ? Partial<TType> : TType;
68
+ /**
69
+ * Adds a `createContext` option with a given callback function
70
+ * If context is the default value, then the `createContext` option is optional
71
+ */
72
+ export type CreateContextCallback<TContext, TFunction extends (...args: any[]) => any> = PartialIf<object extends TContext ? true : false, {
73
+ /**
74
+ * @link https://trpc.io/docs/v11/context
75
+ **/
76
+ createContext: TFunction;
77
+ }>;
78
+ /**
79
+ * @internal
80
+ */
81
+ export type WrapCreateContext<TFunction extends (...args: any[]) => any> = {
82
+ /**
83
+ * @link https://trpc.io/docs/v11/context
84
+ **/
85
+ createContext?: TFunction;
86
+ };
87
+ export {};
67
88
  //# sourceMappingURL=rootConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootConfig.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/rootConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAMmB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,SAAS;IAClD;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,uBAAuB,CAAC;IACrC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACpE;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC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AAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,SAAS,IAAI,SAAS,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IACzC,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,GAAG,CAAC;IACV,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,KAAK,SAAS,CAAC,UAAU,SAAS,OAAO,EAAE,KAAK,IAAI,UAAU,SAAS,IAAI,GACvE,OAAO,CAAC,KAAK,CAAC,GACd,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAC/B,QAAQ,EACR,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACvC,SAAS,CACX,MAAM,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,EACtC;IACE;;QAEI;IACJ,aAAa,EAAE,SAAS,CAAC;CAC1B,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI;IACzE;;QAEI;IACJ,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B,CAAC"}
@@ -7,7 +7,6 @@ var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
7
7
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
8
8
  var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
9
9
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
10
- var contentType = require('./unstable-core-do-not-import/http/contentType.js');
11
10
  var toURL = require('./unstable-core-do-not-import/http/toURL.js');
12
11
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
13
12
  var middleware = require('./unstable-core-do-not-import/middleware.js');
@@ -35,7 +34,6 @@ exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
35
34
  exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
36
35
  exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
37
36
  exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
38
- exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
39
37
  exports.toURL = toURL.toURL;
40
38
  exports.initTRPC = initTRPC.initTRPC;
41
39
  exports.createInputMiddleware = middleware.createInputMiddleware;
@@ -5,7 +5,6 @@ export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown } from './unsta
5
5
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
6
6
  export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
7
7
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
8
- export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
9
8
  export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
10
9
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
11
10
  export { createInputMiddleware, createMiddlewareFactory, createOutputMiddleware, experimental_standaloneMiddleware, middlewareMarker } from './unstable-core-do-not-import/middleware.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.354+ab11f2310",
3
+ "version": "11.0.0-rc.361+5ad570aa5",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -132,10 +132,9 @@
132
132
  "@types/express": "^4.17.17",
133
133
  "@types/hash-sum": "^1.0.0",
134
134
  "@types/node": "^20.10.0",
135
- "@types/react": "^18.2.33",
136
- "@types/react-dom": "^18.2.14",
135
+ "@types/react": "^18.3.0",
136
+ "@types/react-dom": "^18.3.0",
137
137
  "@types/ws": "^8.2.0",
138
- "@web3-storage/multipart-parser": "^1.0.0",
139
138
  "devalue": "^5.0.0",
140
139
  "eslint": "^8.56.0",
141
140
  "express": "^4.17.1",
@@ -144,8 +143,8 @@
144
143
  "hash-sum": "^2.0.0",
145
144
  "myzod": "^1.3.1",
146
145
  "next": "^14.1.4",
147
- "react": "^18.2.0",
148
- "react-dom": "^18.2.0",
146
+ "react": "^18.3.0",
147
+ "react-dom": "^18.3.0",
149
148
  "rollup": "^4.9.5",
150
149
  "superjson": "^1.12.4",
151
150
  "superstruct": "^1.0.0",
@@ -160,5 +159,5 @@
160
159
  "funding": [
161
160
  "https://trpc.io/sponsor"
162
161
  ],
163
- "gitHead": "ab11f23106d3bc29a3207f52a8bff8806d074267"
162
+ "gitHead": "5ad570aa5e1d8951e31900d4c2ee8c1766235e6d"
164
163
  }
@@ -23,5 +23,4 @@ export type {
23
23
  BaseContentTypeHandler,
24
24
  BodyResult,
25
25
  } from '../../unstable-core-do-not-import';
26
- export { getJsonContentTypeInputs } from '../../unstable-core-do-not-import';
27
26
  export { toURL } from '../../unstable-core-do-not-import';
@@ -32,6 +32,8 @@ export {
32
32
  type RouterRecord as TRPCRouterRecord,
33
33
  type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure,
34
34
  type ProcedureOptions as TRPCProcedureOptions,
35
+ type CreateContextCallback,
36
+ type WrapCreateContext,
35
37
  type MutationProcedure as TRPCMutationProcedure,
36
38
  type QueryProcedure as TRPCQueryProcedure,
37
39
  type SubscriptionProcedure as TRPCSubscriptionProcedure,
@@ -102,3 +104,5 @@ export {
102
104
  */
103
105
  export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
104
106
  Awaited<ReturnType<TFunction>>;
107
+
108
+ export { parseOctetInput } from '../../unstable-core-do-not-import/contentTypeParsers';