@trpc/server 11.0.0-rc.340 → 11.0.0-rc.345

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 (145) 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 +59 -0
  8. package/dist/adapters/aws-lambda/content-type/json/index.mjs +57 -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/selectContentHandlerOrUnsupportedMediaType.d.ts +4 -0
  17. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +1 -0
  18. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +22 -0
  19. package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +20 -0
  20. package/dist/adapters/express.d.ts.map +1 -1
  21. package/dist/adapters/express.js +0 -1
  22. package/dist/adapters/express.mjs +0 -1
  23. package/dist/adapters/fastify/content-type/json/index.d.ts +8 -0
  24. package/dist/adapters/fastify/content-type/json/index.d.ts.map +1 -0
  25. package/dist/adapters/fastify/content-type/json/index.js +59 -0
  26. package/dist/adapters/fastify/content-type/json/index.mjs +57 -0
  27. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +1 -9
  28. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  29. package/dist/adapters/fastify/fastifyRequestHandler.js +10 -2
  30. package/dist/adapters/fastify/fastifyRequestHandler.mjs +10 -2
  31. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
  32. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  33. package/dist/adapters/fastify/types.d.ts +11 -0
  34. package/dist/adapters/fastify/types.d.ts.map +1 -0
  35. package/dist/adapters/fetch/content-type/json/index.d.ts +9 -0
  36. package/dist/adapters/fetch/content-type/json/index.d.ts.map +1 -0
  37. package/dist/adapters/fetch/content-type/json/index.js +58 -0
  38. package/dist/adapters/fetch/content-type/json/index.mjs +56 -0
  39. package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -5
  40. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  41. package/dist/adapters/fetch/fetchRequestHandler.js +16 -2
  42. package/dist/adapters/fetch/fetchRequestHandler.mjs +16 -2
  43. package/dist/adapters/fetch/types.d.ts +9 -12
  44. package/dist/adapters/fetch/types.d.ts.map +1 -1
  45. package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +2 -7
  46. package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
  47. package/dist/adapters/next.d.ts.map +1 -1
  48. package/dist/adapters/next.js +0 -1
  49. package/dist/adapters/next.mjs +0 -1
  50. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +0 -72
  51. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +5 -76
  52. package/dist/adapters/node-http/content-type/form-data/index.d.ts +5 -19
  53. package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
  54. package/dist/adapters/node-http/content-type/form-data/index.js +14 -39
  55. package/dist/adapters/node-http/content-type/form-data/index.mjs +15 -35
  56. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +2 -2
  57. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +1 -1
  58. package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +0 -12
  59. package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +1 -12
  60. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  61. package/dist/adapters/node-http/content-type/json/getPostBody.js +4 -12
  62. package/dist/adapters/node-http/content-type/json/getPostBody.mjs +4 -12
  63. package/dist/adapters/node-http/content-type/json/index.d.ts +4 -1
  64. package/dist/adapters/node-http/content-type/json/index.d.ts.map +1 -1
  65. package/dist/adapters/node-http/content-type/json/index.js +59 -10
  66. package/dist/adapters/node-http/content-type/json/index.mjs +59 -10
  67. package/dist/adapters/node-http/content-type/octet/index.d.ts +5 -0
  68. package/dist/adapters/node-http/content-type/octet/index.d.ts.map +1 -0
  69. package/dist/adapters/node-http/content-type/octet/index.js +19 -0
  70. package/dist/adapters/node-http/content-type/octet/index.mjs +17 -0
  71. package/dist/adapters/node-http/content-type/types.d.ts +8 -0
  72. package/dist/adapters/node-http/content-type/types.d.ts.map +1 -0
  73. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  74. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +19 -21
  75. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +20 -22
  76. package/dist/adapters/node-http/types.d.ts +8 -19
  77. package/dist/adapters/node-http/types.d.ts.map +1 -1
  78. package/dist/adapters/standalone.d.ts.map +1 -1
  79. package/dist/adapters/standalone.js +0 -1
  80. package/dist/adapters/standalone.mjs +0 -1
  81. package/dist/adapters/ws.d.ts +2 -12
  82. package/dist/adapters/ws.d.ts.map +1 -1
  83. package/dist/bundle-analysis.json +266 -207
  84. package/dist/http.js +0 -2
  85. package/dist/http.mjs +0 -1
  86. package/dist/index.js +2 -0
  87. package/dist/index.mjs +1 -0
  88. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts +16 -0
  89. package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts.map +1 -0
  90. package/dist/unstable-core-do-not-import/contentTypeParsers.js +23 -0
  91. package/dist/unstable-core-do-not-import/contentTypeParsers.mjs +21 -0
  92. package/dist/unstable-core-do-not-import/http/contentType.d.ts +6 -14
  93. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  94. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -1
  95. package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -1
  96. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +5 -5
  97. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -1
  98. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +25 -22
  99. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +25 -22
  100. package/dist/unstable-core-do-not-import/http/types.d.ts +0 -2
  101. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  102. package/dist/unstable-core-do-not-import/rootConfig.d.ts +21 -0
  103. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
  104. package/dist/unstable-core-do-not-import.js +0 -2
  105. package/dist/unstable-core-do-not-import.mjs +0 -1
  106. package/package.json +3 -3
  107. package/src/@trpc/server/http.ts +0 -1
  108. package/src/@trpc/server/index.ts +7 -0
  109. package/src/adapters/aws-lambda/content-type/json/index.ts +99 -0
  110. package/src/adapters/aws-lambda/index.ts +24 -9
  111. package/src/adapters/aws-lambda/utils.ts +21 -15
  112. package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +21 -0
  113. package/src/adapters/express.ts +1 -6
  114. package/src/adapters/fastify/content-type/json/index.ts +97 -0
  115. package/src/adapters/fastify/fastifyRequestHandler.ts +15 -21
  116. package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
  117. package/src/adapters/fastify/types.ts +22 -0
  118. package/src/adapters/fetch/content-type/json/index.ts +96 -0
  119. package/src/adapters/fetch/fetchRequestHandler.ts +22 -10
  120. package/src/adapters/fetch/types.ts +22 -15
  121. package/src/adapters/next-app-dir/nextAppDirCaller.ts +2 -9
  122. package/src/adapters/next.ts +1 -6
  123. package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +7 -7
  124. package/src/adapters/node-http/content-type/form-data/index.ts +29 -51
  125. package/src/adapters/node-http/content-type/form-data/streamSlice.ts +2 -2
  126. package/src/adapters/node-http/content-type/json/getPostBody.ts +9 -18
  127. package/src/adapters/node-http/content-type/json/index.ts +85 -5
  128. package/src/adapters/node-http/content-type/octet/index.ts +29 -0
  129. package/src/adapters/node-http/{internals/contentType.ts → content-type/types.ts} +2 -14
  130. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +22 -35
  131. package/src/adapters/node-http/types.ts +46 -46
  132. package/src/adapters/standalone.ts +1 -2
  133. package/src/adapters/ws.ts +9 -14
  134. package/src/unstable-core-do-not-import/contentTypeParsers.ts +37 -0
  135. package/src/unstable-core-do-not-import/http/contentType.ts +9 -84
  136. package/src/unstable-core-do-not-import/http/index.ts +0 -1
  137. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +29 -28
  138. package/src/unstable-core-do-not-import/http/types.ts +0 -2
  139. package/src/unstable-core-do-not-import/rootConfig.ts +31 -0
  140. package/dist/adapters/node-http/internals/contentType.d.ts +0 -9
  141. package/dist/adapters/node-http/internals/contentType.d.ts.map +0 -1
  142. package/dist/adapters/node-http/internals/contentType.js +0 -8
  143. package/dist/adapters/node-http/internals/contentType.mjs +0 -6
  144. package/dist/unstable-core-do-not-import/http/contentType.js +0 -54
  145. package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -52
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> = {
14
+ name: string;
23
15
  isMatch(opts: TOptions): boolean;
24
- getBody: (opts: TOptions) => MaybePromise<BodyResult>;
25
- getInputs: GetInputs;
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,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE;IACtB,GAAG,EAAE,WAAW,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,KAAK,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5C,MAAM,MAAM,UAAU,GAClB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,sBAAsB,CAAC,QAAQ,IAAI;IAC7C,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,YAAY,CAAC,UAAU,CAAC,CAAC;IACtD,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAqCF,eAAO,MAAM,wBAAwB,EAAE,SAgCtC,CAAC"}
1
+ {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,MAAM,UAAU,GAClB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,sBAAsB,CAAC,QAAQ,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACjC,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,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"}
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;AAKnB,OAAO,KAAK,EACV,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACZ,kCAAkC,EAClC,aAAa,EAEd,MAAM,SAAS,CAAC;AAgBjB,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,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;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,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,24 @@ 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
- });
112
+ const batchesCache = {};
113
+ async function getRawInputForBatch(batch) {
114
+ if (!batchesCache.hasOwnProperty(batch)) {
115
+ batchesCache[batch] = await opts.getInput({
116
+ isBatchCall,
117
+ batch
118
+ });
119
+ }
120
+ return batchesCache[batch];
121
+ }
126
122
  paths = isBatchCall ? decodeURIComponent(opts.path).split(',') : [
127
123
  opts.path
128
124
  ];
129
125
  const info = {
130
126
  isBatchCall,
131
- calls: paths.map((path, idx)=>({
127
+ calls: paths.map((path)=>({
132
128
  path,
133
- type,
134
- input: inputs[idx] ?? undefined
129
+ type
135
130
  }))
136
131
  };
137
132
  ctx = await opts.createContext({
@@ -139,12 +134,20 @@ async function resolveHTTPResponse(opts) {
139
134
  });
140
135
  const errors = [];
141
136
  const promises = paths.map(async (path, index)=>{
142
- const input = inputs[index];
137
+ async function getRawInput() {
138
+ return await getRawInputForBatch(index);
139
+ }
143
140
  try {
141
+ if (opts.error) {
142
+ // sometimes an error may be generated above this function in the stack
143
+ // for instance a 405 error if the method is not supported
144
+ // But we need to handle it here to ensure the error is formatted correctly
145
+ throw opts.error;
146
+ }
144
147
  const data = await router.callProcedure({
145
148
  procedures: opts.router._def.procedures,
146
149
  path,
147
- getRawInput: async ()=>input,
150
+ getRawInput: getRawInput,
148
151
  ctx,
149
152
  type,
150
153
  allowMethodOverride
@@ -160,7 +163,7 @@ async function resolveHTTPResponse(opts) {
160
163
  opts.onError?.({
161
164
  error,
162
165
  path,
163
- input,
166
+ input: getRawInput(),
164
167
  ctx,
165
168
  type: type,
166
169
  req: opts.req
@@ -171,7 +174,7 @@ async function resolveHTTPResponse(opts) {
171
174
  error,
172
175
  type,
173
176
  path,
174
- input,
177
+ input: getRawInput(),
175
178
  ctx
176
179
  })
177
180
  };
@@ -238,7 +241,7 @@ 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 getRawInputForBatch(index);
242
245
  const { body: body2 } = caughtErrorToData(cause, {
243
246
  opts,
244
247
  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,24 @@ 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
- });
110
+ const batchesCache = {};
111
+ async function getRawInputForBatch(batch) {
112
+ if (!batchesCache.hasOwnProperty(batch)) {
113
+ batchesCache[batch] = await opts.getInput({
114
+ isBatchCall,
115
+ batch
116
+ });
117
+ }
118
+ return batchesCache[batch];
119
+ }
124
120
  paths = isBatchCall ? decodeURIComponent(opts.path).split(',') : [
125
121
  opts.path
126
122
  ];
127
123
  const info = {
128
124
  isBatchCall,
129
- calls: paths.map((path, idx)=>({
125
+ calls: paths.map((path)=>({
130
126
  path,
131
- type,
132
- input: inputs[idx] ?? undefined
127
+ type
133
128
  }))
134
129
  };
135
130
  ctx = await opts.createContext({
@@ -137,12 +132,20 @@ async function resolveHTTPResponse(opts) {
137
132
  });
138
133
  const errors = [];
139
134
  const promises = paths.map(async (path, index)=>{
140
- const input = inputs[index];
135
+ async function getRawInput() {
136
+ return await getRawInputForBatch(index);
137
+ }
141
138
  try {
139
+ if (opts.error) {
140
+ // sometimes an error may be generated above this function in the stack
141
+ // for instance a 405 error if the method is not supported
142
+ // But we need to handle it here to ensure the error is formatted correctly
143
+ throw opts.error;
144
+ }
142
145
  const data = await callProcedure({
143
146
  procedures: opts.router._def.procedures,
144
147
  path,
145
- getRawInput: async ()=>input,
148
+ getRawInput: getRawInput,
146
149
  ctx,
147
150
  type,
148
151
  allowMethodOverride
@@ -158,7 +161,7 @@ async function resolveHTTPResponse(opts) {
158
161
  opts.onError?.({
159
162
  error,
160
163
  path,
161
- input,
164
+ input: getRawInput(),
162
165
  ctx,
163
166
  type: type,
164
167
  req: opts.req
@@ -169,7 +172,7 @@ async function resolveHTTPResponse(opts) {
169
172
  error,
170
173
  type,
171
174
  path,
172
- input,
175
+ input: getRawInput(),
173
176
  ctx
174
177
  })
175
178
  };
@@ -236,7 +239,7 @@ 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 getRawInputForBatch(index);
240
243
  const { body: body2 } = caughtErrorToData(cause, {
241
244
  opts,
242
245
  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.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AAQ,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,C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,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.340+d1652d1bc",
3
+ "version": "11.0.0-rc.345+6e01a29cf",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -136,7 +136,7 @@
136
136
  "@types/react-dom": "^18.2.14",
137
137
  "@types/ws": "^8.2.0",
138
138
  "@web3-storage/multipart-parser": "^1.0.0",
139
- "devalue": "^4.0.0",
139
+ "devalue": "^5.0.0",
140
140
  "eslint": "^8.56.0",
141
141
  "express": "^4.17.1",
142
142
  "fastify": "^4.16.0",
@@ -160,5 +160,5 @@
160
160
  "funding": [
161
161
  "https://trpc.io/sponsor"
162
162
  ],
163
- "gitHead": "d1652d1bc0a9ff3e3d286a4bf69c116621c165f8"
163
+ "gitHead": "6e01a29cf4343cc2a303c62753df3fd70d489123"
164
164
  }
@@ -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,11 @@ 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,
37
+ type MutationProcedure as TRPCMutationProcedure,
38
+ type QueryProcedure as TRPCQueryProcedure,
39
+ type SubscriptionProcedure as TRPCSubscriptionProcedure,
35
40
  } from '../../unstable-core-do-not-import';
36
41
 
37
42
  export type {
@@ -98,3 +103,5 @@ export {
98
103
  */
99
104
  export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
100
105
  Awaited<ReturnType<TFunction>>;
106
+
107
+ export { parseOctetInput } from '../../unstable-core-do-not-import/contentTypeParsers';