@trpc/server 11.0.0-alpha-tmp-export-from-main.221 → 11.0.0-alpha-tmp-export-from-main.222

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 (136) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +68 -0
  2. package/dist/adapters/aws-lambda/index.d.ts +54 -6
  3. package/dist/adapters/aws-lambda/index.js +110 -20
  4. package/dist/adapters/aws-lambda/index.mjs +94 -4
  5. package/dist/adapters/express.d.mts +19 -0
  6. package/dist/adapters/express.d.ts +9 -6
  7. package/dist/adapters/express.js +3 -3
  8. package/dist/adapters/express.mjs +1 -1
  9. package/dist/adapters/fastify/index.d.mts +33 -0
  10. package/dist/adapters/fastify/index.d.ts +33 -3
  11. package/dist/adapters/fastify/index.js +124 -5
  12. package/dist/adapters/fastify/index.mjs +125 -2
  13. package/dist/adapters/fetch/index.d.mts +51 -0
  14. package/dist/adapters/fetch/index.d.ts +51 -3
  15. package/dist/adapters/fetch/index.js +115 -4
  16. package/dist/adapters/fetch/index.mjs +116 -1
  17. package/dist/adapters/next.d.mts +21 -0
  18. package/dist/adapters/next.d.ts +11 -7
  19. package/dist/adapters/next.js +6 -6
  20. package/dist/adapters/next.mjs +2 -2
  21. package/dist/adapters/node-http/content-type/form-data/index.d.mts +219 -0
  22. package/dist/adapters/node-http/content-type/form-data/index.d.ts +201 -10
  23. package/dist/adapters/node-http/content-type/form-data/index.js +662 -23
  24. package/dist/adapters/node-http/content-type/form-data/index.mjs +646 -10
  25. package/dist/adapters/node-http/{types.d.ts → content-type/json/index.d.mts} +21 -15
  26. package/dist/adapters/node-http/content-type/json/index.d.ts +89 -2
  27. package/dist/adapters/node-http/content-type/json/index.js +48 -7
  28. package/dist/adapters/node-http/content-type/json/index.mjs +44 -3
  29. package/dist/adapters/node-http/index.d.mts +100 -0
  30. package/dist/adapters/node-http/index.d.ts +100 -3
  31. package/dist/adapters/node-http/index.js +106 -4
  32. package/dist/adapters/node-http/index.mjs +107 -1
  33. package/dist/adapters/standalone.d.mts +21 -0
  34. package/dist/adapters/standalone.d.ts +11 -9
  35. package/dist/adapters/standalone.js +9 -5
  36. package/dist/adapters/standalone.mjs +2 -2
  37. package/dist/adapters/ws.d.mts +36 -0
  38. package/dist/adapters/ws.d.ts +12 -13
  39. package/dist/adapters/ws.js +30 -28
  40. package/dist/adapters/ws.mjs +12 -10
  41. package/dist/http.d.mts +1 -0
  42. package/dist/http.d.ts +1 -7
  43. package/dist/http.js +7 -7
  44. package/dist/http.mjs +1 -1
  45. package/dist/index.d.mts +9 -0
  46. package/dist/index.d.ts +5 -65
  47. package/dist/index.js +809 -46
  48. package/dist/index.mjs +798 -1
  49. package/dist/observable.d.mts +1 -0
  50. package/dist/observable.d.ts +1 -3
  51. package/dist/observable.js +8 -8
  52. package/dist/observable.mjs +1 -1
  53. package/dist/rpc.d.mts +1 -0
  54. package/dist/rpc.d.ts +1 -3
  55. package/dist/rpc.js +5 -5
  56. package/dist/rpc.mjs +1 -1
  57. package/dist/shared.d.mts +1 -0
  58. package/dist/shared.d.ts +1 -26
  59. package/dist/shared.js +4 -4
  60. package/dist/shared.mjs +1 -1
  61. package/dist/unstableDontImportMe.d.mts +1 -0
  62. package/dist/unstableDontImportMe.d.ts +1 -10
  63. package/dist/unstableDontImportMe.js +1549 -142
  64. package/dist/unstableDontImportMe.mjs +1514 -1
  65. package/package.json +6 -4
  66. package/dist/@trpc-server/http.d.ts +0 -2
  67. package/dist/@trpc-server/http.d.ts.map +0 -1
  68. package/dist/adapters/aws-lambda/index.d.ts.map +0 -1
  69. package/dist/adapters/aws-lambda/utils.d.ts +0 -48
  70. package/dist/adapters/aws-lambda/utils.d.ts.map +0 -1
  71. package/dist/adapters/aws-lambda/utils.js +0 -100
  72. package/dist/adapters/aws-lambda/utils.mjs +0 -93
  73. package/dist/adapters/express.d.ts.map +0 -1
  74. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +0 -13
  75. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +0 -1
  76. package/dist/adapters/fastify/fastifyRequestHandler.js +0 -81
  77. package/dist/adapters/fastify/fastifyRequestHandler.mjs +0 -79
  78. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +0 -22
  79. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +0 -1
  80. package/dist/adapters/fastify/fastifyTRPCPlugin.js +0 -51
  81. package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +0 -49
  82. package/dist/adapters/fastify/index.d.ts.map +0 -1
  83. package/dist/adapters/fetch/fetchRequestHandler.d.ts +0 -18
  84. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +0 -1
  85. package/dist/adapters/fetch/fetchRequestHandler.js +0 -118
  86. package/dist/adapters/fetch/fetchRequestHandler.mjs +0 -116
  87. package/dist/adapters/fetch/index.d.ts.map +0 -1
  88. package/dist/adapters/fetch/types.d.ts +0 -31
  89. package/dist/adapters/fetch/types.d.ts.map +0 -1
  90. package/dist/adapters/next.d.ts.map +0 -1
  91. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +0 -70
  92. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +0 -1
  93. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +0 -161
  94. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +0 -157
  95. package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +0 -1
  96. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +0 -31
  97. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +0 -1
  98. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +0 -29
  99. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +0 -27
  100. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +0 -16
  101. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +0 -1
  102. package/dist/adapters/node-http/content-type/form-data/streamSlice.js +0 -46
  103. package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +0 -44
  104. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +0 -45
  105. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +0 -1
  106. package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +0 -30
  107. package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +0 -26
  108. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +0 -7
  109. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +0 -1
  110. package/dist/adapters/node-http/content-type/json/getPostBody.js +0 -42
  111. package/dist/adapters/node-http/content-type/json/getPostBody.mjs +0 -40
  112. package/dist/adapters/node-http/content-type/json/index.d.ts.map +0 -1
  113. package/dist/adapters/node-http/index.d.ts.map +0 -1
  114. package/dist/adapters/node-http/internals/contentType.d.ts +0 -9
  115. package/dist/adapters/node-http/internals/contentType.d.ts.map +0 -1
  116. package/dist/adapters/node-http/internals/contentType.js +0 -8
  117. package/dist/adapters/node-http/internals/contentType.mjs +0 -6
  118. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +0 -14
  119. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
  120. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +0 -109
  121. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +0 -107
  122. package/dist/adapters/node-http/types.d.ts.map +0 -1
  123. package/dist/adapters/standalone.d.ts.map +0 -1
  124. package/dist/adapters/ws.d.ts.map +0 -1
  125. package/dist/http.d.ts.map +0 -1
  126. package/dist/index.d.ts.map +0 -1
  127. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.js +0 -203
  128. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.mjs +0 -201
  129. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.js +0 -167
  130. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.mjs +0 -163
  131. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.js +0 -35
  132. package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.mjs +0 -30
  133. package/dist/observable.d.ts.map +0 -1
  134. package/dist/rpc.d.ts.map +0 -1
  135. package/dist/shared.d.ts.map +0 -1
  136. package/dist/unstableDontImportMe.d.ts.map +0 -1
@@ -1,31 +0,0 @@
1
- /**
2
- * Copyright 2021 Remix Software Inc.
3
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6
- */
7
- /**
8
- * @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/upload/memoryUploadHandler.ts
9
- */
10
- import type { UploadHandler } from './uploadHandler';
11
- export type MemoryUploadHandlerFilterArgs = {
12
- filename?: string;
13
- contentType: string;
14
- name: string;
15
- };
16
- export type MemoryUploadHandlerOptions = {
17
- /**
18
- * The maximum upload size allowed. If the size is exceeded an error will be thrown.
19
- * Defaults to 3000000B (3MB).
20
- */
21
- maxPartSize?: number;
22
- /**
23
- *
24
- * @param filename
25
- * @param mimetype
26
- * @param encoding
27
- */
28
- filter?(args: MemoryUploadHandlerFilterArgs): Promise<boolean> | boolean;
29
- };
30
- export declare function createMemoryUploadHandler({ filter, maxPartSize, }?: MemoryUploadHandlerOptions): UploadHandler;
31
- //# sourceMappingURL=memoryUploadHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryUploadHandler.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC1E,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,WAAqB,GACtB,GAAE,0BAA+B,GAAG,aAAa,CAkBjD"}
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- var uploadHandler = require('./uploadHandler.js');
4
-
5
- function createMemoryUploadHandler({ filter , maxPartSize =3000000 } = {}) {
6
- return async ({ filename , contentType , name , data })=>{
7
- if (filter && !await filter({
8
- filename,
9
- contentType,
10
- name
11
- })) {
12
- return undefined;
13
- }
14
- let size = 0;
15
- const chunks = [];
16
- for await (const chunk of data){
17
- size += chunk.byteLength;
18
- if (size > maxPartSize) {
19
- throw new uploadHandler.MaxPartSizeExceededError(name, maxPartSize);
20
- }
21
- chunks.push(chunk);
22
- }
23
- return new File(chunks, filename, {
24
- type: contentType
25
- });
26
- };
27
- }
28
-
29
- exports.createMemoryUploadHandler = createMemoryUploadHandler;
@@ -1,27 +0,0 @@
1
- import { MaxPartSizeExceededError } from './uploadHandler.mjs';
2
-
3
- function createMemoryUploadHandler({ filter , maxPartSize =3000000 } = {}) {
4
- return async ({ filename , contentType , name , data })=>{
5
- if (filter && !await filter({
6
- filename,
7
- contentType,
8
- name
9
- })) {
10
- return undefined;
11
- }
12
- let size = 0;
13
- const chunks = [];
14
- for await (const chunk of data){
15
- size += chunk.byteLength;
16
- if (size > maxPartSize) {
17
- throw new MaxPartSizeExceededError(name, maxPartSize);
18
- }
19
- chunks.push(chunk);
20
- }
21
- return new File(chunks, filename, {
22
- type: contentType
23
- });
24
- };
25
- }
26
-
27
- export { createMemoryUploadHandler };
@@ -1,16 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { TransformCallback } from 'node:stream';
4
- import { Transform } from 'node:stream';
5
- declare class SliceStream extends Transform {
6
- private startIndex;
7
- private endIndex;
8
- private indexOffset;
9
- private emitUp;
10
- private emitDown;
11
- constructor(startIndex?: number, endIndex?: number);
12
- _transform(chunk: any, _: BufferEncoding, done: TransformCallback): void;
13
- }
14
- export declare function streamSlice(startIndex?: number, endIndex?: number): SliceStream;
15
- export {};
16
- //# sourceMappingURL=streamSlice.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streamSlice.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/streamSlice.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,cAAM,WAAY,SAAQ,SAAS;IAKrB,OAAO,CAAC,UAAU;IAAM,OAAO,CAAC,QAAQ;IAJpD,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;gBAEL,UAAU,SAAI,EAAU,QAAQ,SAAW;IAItD,UAAU,CACjB,KAAK,EAAE,GAAG,EACV,CAAC,EAAE,cAAc,EACjB,IAAI,EAAE,iBAAiB,GACtB,IAAI;CAmCR;AAED,wBAAgB,WAAW,CAAC,UAAU,SAAI,EAAE,QAAQ,SAAW,GAAG,WAAW,CAE5E"}
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- var node_stream = require('node:stream');
4
-
5
- class SliceStream extends node_stream.Transform {
6
- _transform(chunk, _, done) {
7
- this.indexOffset += chunk.length;
8
- if (!this.emitUp && this.indexOffset >= this.startIndex) {
9
- this.emitUp = true;
10
- const start = chunk.length - (this.indexOffset - this.startIndex);
11
- if (this.indexOffset > this.endIndex) {
12
- const end = chunk.length - (this.indexOffset - this.endIndex);
13
- this.emitDown = true;
14
- this.push(chunk.slice(start, end));
15
- } else {
16
- this.push(chunk.slice(start, chunk.length));
17
- }
18
- done();
19
- return;
20
- }
21
- if (this.emitUp && !this.emitDown) {
22
- if (this.indexOffset >= this.endIndex) {
23
- this.emitDown = true;
24
- this.push(chunk.slice(0, chunk.length - (this.indexOffset - this.endIndex)));
25
- } else {
26
- this.push(chunk);
27
- }
28
- done();
29
- return;
30
- }
31
- done();
32
- }
33
- constructor(startIndex = 0, endIndex = Infinity){
34
- super();
35
- this.startIndex = startIndex;
36
- this.endIndex = endIndex;
37
- this.indexOffset = 0;
38
- this.emitUp = false;
39
- this.emitDown = false;
40
- }
41
- }
42
- function streamSlice(startIndex = 0, endIndex = Infinity) {
43
- return new SliceStream(startIndex, endIndex);
44
- }
45
-
46
- exports.streamSlice = streamSlice;
@@ -1,44 +0,0 @@
1
- import { Transform } from 'node:stream';
2
-
3
- class SliceStream extends Transform {
4
- _transform(chunk, _, done) {
5
- this.indexOffset += chunk.length;
6
- if (!this.emitUp && this.indexOffset >= this.startIndex) {
7
- this.emitUp = true;
8
- const start = chunk.length - (this.indexOffset - this.startIndex);
9
- if (this.indexOffset > this.endIndex) {
10
- const end = chunk.length - (this.indexOffset - this.endIndex);
11
- this.emitDown = true;
12
- this.push(chunk.slice(start, end));
13
- } else {
14
- this.push(chunk.slice(start, chunk.length));
15
- }
16
- done();
17
- return;
18
- }
19
- if (this.emitUp && !this.emitDown) {
20
- if (this.indexOffset >= this.endIndex) {
21
- this.emitDown = true;
22
- this.push(chunk.slice(0, chunk.length - (this.indexOffset - this.endIndex)));
23
- } else {
24
- this.push(chunk);
25
- }
26
- done();
27
- return;
28
- }
29
- done();
30
- }
31
- constructor(startIndex = 0, endIndex = Infinity){
32
- super();
33
- this.startIndex = startIndex;
34
- this.endIndex = endIndex;
35
- this.indexOffset = 0;
36
- this.emitUp = false;
37
- this.emitDown = false;
38
- }
39
- }
40
- function streamSlice(startIndex = 0, endIndex = Infinity) {
41
- return new SliceStream(startIndex, endIndex);
42
- }
43
-
44
- export { streamSlice };
@@ -1,45 +0,0 @@
1
- import type { NodeOnDiskFile } from './fileUploadHandler';
2
- /**
3
- * @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/formData.ts
4
- */
5
- export type UploadHandlerPart = {
6
- name: string;
7
- filename?: string;
8
- contentType: string;
9
- data: AsyncIterable<Uint8Array>;
10
- };
11
- export type UploadHandler = (part: Required<UploadHandlerPart>) => Promise<File | NodeOnDiskFile | null | undefined>;
12
- export declare function composeUploadHandlers(...handlers: UploadHandler[]): UploadHandler;
13
- export declare class MaxPartSizeExceededError extends Error {
14
- field: string;
15
- maxBytes: number;
16
- constructor(field: string, maxBytes: number);
17
- }
18
- export declare class MaxBodySizeExceededError extends Error {
19
- maxBytes: number;
20
- constructor(maxBytes: number);
21
- }
22
- export type MemoryUploadHandlerFilterArgs = {
23
- filename?: string;
24
- contentType: string;
25
- name: string;
26
- };
27
- export type MemoryUploadHandlerOptions = {
28
- /**
29
- * The maximum upload size allowed. If the size is exceeded an error will be thrown.
30
- * Defaults to 3000000B (3MB).
31
- */
32
- maxPartSize?: number;
33
- /**
34
- *
35
- * @param filename
36
- * @param mimetype
37
- * @param encoding
38
- */
39
- filter?(args: MemoryUploadHandlerFilterArgs): Promise<boolean> | boolean;
40
- };
41
- /**
42
- * @see
43
- */
44
- export declare function createMemoryUploadHandler({ filter, maxPartSize, }?: MemoryUploadHandlerOptions): UploadHandler;
45
- //# sourceMappingURL=uploadHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadHandler.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/uploadHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,KAC9B,OAAO,CAAC,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEvD,wBAAgB,qBAAqB,CACnC,GAAG,QAAQ,EAAE,aAAa,EAAE,GAC3B,aAAa,CAWf;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAC9B,KAAK,EAAE,MAAM;IAAS,QAAQ,EAAE,MAAM;gBAAtC,KAAK,EAAE,MAAM,EAAS,QAAQ,EAAE,MAAM;CAG1D;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAC9B,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAGpC;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC1E,CAAC;AAEF;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,WAAqB,GACtB,GAAE,0BAA+B,GAAG,aAAa,CAkBjD"}
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- function composeUploadHandlers(...handlers) {
4
- return async (part)=>{
5
- for (const handler of handlers){
6
- const value = await handler(part);
7
- if (typeof value !== 'undefined' && value !== null) {
8
- return value;
9
- }
10
- }
11
- return undefined;
12
- };
13
- }
14
- class MaxPartSizeExceededError extends Error {
15
- constructor(field, maxBytes){
16
- super(`Field "${field}" exceeded upload size of ${maxBytes} bytes.`);
17
- this.field = field;
18
- this.maxBytes = maxBytes;
19
- }
20
- }
21
- class MaxBodySizeExceededError extends Error {
22
- constructor(maxBytes){
23
- super(`Body exceeded upload size of ${maxBytes} bytes.`);
24
- this.maxBytes = maxBytes;
25
- }
26
- }
27
-
28
- exports.MaxBodySizeExceededError = MaxBodySizeExceededError;
29
- exports.MaxPartSizeExceededError = MaxPartSizeExceededError;
30
- exports.composeUploadHandlers = composeUploadHandlers;
@@ -1,26 +0,0 @@
1
- function composeUploadHandlers(...handlers) {
2
- return async (part)=>{
3
- for (const handler of handlers){
4
- const value = await handler(part);
5
- if (typeof value !== 'undefined' && value !== null) {
6
- return value;
7
- }
8
- }
9
- return undefined;
10
- };
11
- }
12
- class MaxPartSizeExceededError extends Error {
13
- constructor(field, maxBytes){
14
- super(`Field "${field}" exceeded upload size of ${maxBytes} bytes.`);
15
- this.field = field;
16
- this.maxBytes = maxBytes;
17
- }
18
- }
19
- class MaxBodySizeExceededError extends Error {
20
- constructor(maxBytes){
21
- super(`Body exceeded upload size of ${maxBytes} bytes.`);
22
- this.maxBytes = maxBytes;
23
- }
24
- }
25
-
26
- export { MaxBodySizeExceededError, MaxPartSizeExceededError, composeUploadHandlers };
@@ -1,7 +0,0 @@
1
- import type { BodyResult } from '../../../../http';
2
- import type { NodeHTTPRequest } from '../../types';
3
- export declare function getPostBody(opts: {
4
- req: NodeHTTPRequest;
5
- maxBodySize?: number;
6
- }): Promise<BodyResult>;
7
- //# sourceMappingURL=getPostBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAiCtB"}
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@trpc/core');
4
-
5
- // @trpc/server
6
- async function getPostBody(opts) {
7
- const { req , maxBodySize =Infinity } = opts;
8
- return new Promise((resolve)=>{
9
- if ('body' in req) {
10
- resolve({
11
- ok: true,
12
- data: req.body,
13
- // If the request headers specifies a content-type, we assume that the body has been preprocessed
14
- preprocessed: !!req.headers['content-type']?.startsWith('application/json')
15
- });
16
- return;
17
- }
18
- let body = '';
19
- let hasBody = false;
20
- req.on('data', function(data) {
21
- body += data;
22
- hasBody = true;
23
- if (body.length > maxBodySize) {
24
- resolve({
25
- ok: false,
26
- error: new core.TRPCError({
27
- code: 'PAYLOAD_TOO_LARGE'
28
- })
29
- });
30
- }
31
- });
32
- req.on('end', ()=>{
33
- resolve({
34
- ok: true,
35
- data: hasBody ? body : undefined,
36
- preprocessed: false
37
- });
38
- });
39
- });
40
- }
41
-
42
- exports.getPostBody = getPostBody;
@@ -1,40 +0,0 @@
1
- import { TRPCError } from '@trpc/core';
2
-
3
- // @trpc/server
4
- async function getPostBody(opts) {
5
- const { req , maxBodySize =Infinity } = opts;
6
- return new Promise((resolve)=>{
7
- if ('body' in req) {
8
- resolve({
9
- ok: true,
10
- data: req.body,
11
- // If the request headers specifies a content-type, we assume that the body has been preprocessed
12
- preprocessed: !!req.headers['content-type']?.startsWith('application/json')
13
- });
14
- return;
15
- }
16
- let body = '';
17
- let hasBody = false;
18
- req.on('data', function(data) {
19
- body += data;
20
- hasBody = true;
21
- if (body.length > maxBodySize) {
22
- resolve({
23
- ok: false,
24
- error: new TRPCError({
25
- code: 'PAYLOAD_TOO_LARGE'
26
- })
27
- });
28
- }
29
- });
30
- req.on('end', ()=>{
31
- resolve({
32
- ok: true,
33
- data: hasBody ? body : undefined,
34
- preprocessed: false
35
- });
36
- });
37
- });
38
- }
39
-
40
- export { getPostBody };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,8BAA8B,mMAMzC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { AnyRouter } from '../../..';
2
- import type { BaseContentTypeHandler } from '../../../@trpc-server/http';
3
- import type { NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse } from '../types';
4
- export interface NodeHTTPContentTypeHandler<TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> extends BaseContentTypeHandler<NodeHTTPRequestHandlerOptions<AnyRouter, TRequest, TResponse> & {
5
- query: URLSearchParams;
6
- }> {
7
- }
8
- export declare function createNodeHTTPContentTypeHandler(contentTypeHandler: NodeHTTPContentTypeHandler<NodeHTTPRequest, NodeHTTPResponse>): <TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>() => NodeHTTPContentTypeHandler<TRequest, TResponse>;
9
- //# sourceMappingURL=contentType.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node-http/internals/contentType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,0BAA0B,CACzC,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,CAClC,SAAQ,sBAAsB,CAC5B,6BAA6B,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IAC9D,KAAK,EAAE,eAAe,CAAC;CACxB,CACF;CAAG;AAEN,wBAAgB,gCAAgC,CAC9C,kBAAkB,EAAE,0BAA0B,CAC5C,eAAe,EACf,gBAAgB,CACjB,+HAOF"}
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- // @trpc/server
4
- function createNodeHTTPContentTypeHandler(contentTypeHandler) {
5
- return ()=>contentTypeHandler;
6
- }
7
-
8
- exports.createNodeHTTPContentTypeHandler = createNodeHTTPContentTypeHandler;
@@ -1,6 +0,0 @@
1
- // @trpc/server
2
- function createNodeHTTPContentTypeHandler(contentTypeHandler) {
3
- return ()=>contentTypeHandler;
4
- }
5
-
6
- export { createNodeHTTPContentTypeHandler };
@@ -1,14 +0,0 @@
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
- * Do **not** import from `@trpc/core`
5
- * @example
6
- * ```ts
7
- * import type { AnyTRPCRouter } from '@trpc/server'
8
- * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
9
- * ```
10
- */
11
- import type { AnyRouter } from '../..';
12
- import type { NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse } from './types';
13
- export declare function nodeHTTPRequestHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<void>;
14
- //# sourceMappingURL=nodeHTTPRequestHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBA4HlE"}
@@ -1,109 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@trpc/core');
4
- var index = require('./content-type/json/index.js');
5
-
6
- /**
7
- * 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`
8
- *
9
- * Do **not** import from `@trpc/core`
10
- * @example
11
- * ```ts
12
- * import type { AnyTRPCRouter } from '@trpc/server'
13
- * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
14
- * ```
15
- */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ // @trpc/server
16
- const defaultJSONContentTypeHandler = index.nodeHTTPJSONContentTypeHandler();
17
- async function nodeHTTPRequestHandler(opts) {
18
- const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
19
- return handleViaMiddleware(opts.req, opts.res, async (err)=>{
20
- if (err) throw err;
21
- //
22
- // Build tRPC dependencies
23
- const createContext = async (innerOpts)=>{
24
- return await opts.createContext?.({
25
- ...opts,
26
- ...innerOpts
27
- });
28
- };
29
- const query = opts.req.query ? new URLSearchParams(opts.req.query) : new URLSearchParams(opts.req.url.split('?')[1]);
30
- const jsonContentTypeHandler = defaultJSONContentTypeHandler;
31
- const contentTypeHandlers = opts.experimental_contentTypeHandlers ?? [
32
- jsonContentTypeHandler
33
- ];
34
- const contentTypeHandler = contentTypeHandlers.find((handler)=>handler.isMatch({
35
- ...opts,
36
- query
37
- })) ?? // fallback to json
38
- jsonContentTypeHandler;
39
- const bodyResult = await contentTypeHandler.getBody({
40
- ...opts,
41
- query
42
- });
43
- const req = {
44
- method: opts.req.method,
45
- headers: opts.req.headers,
46
- query,
47
- body: bodyResult.ok ? bodyResult.data : undefined
48
- };
49
- let isStream = false;
50
- let formatter;
51
- const unstable_onHead = (head, isStreaming)=>{
52
- if ('status' in head && (!opts.res.statusCode || opts.res.statusCode === 200)) {
53
- opts.res.statusCode = head.status;
54
- }
55
- for (const [key, value] of Object.entries(head.headers ?? {})){
56
- /* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
57
- continue;
58
- }
59
- opts.res.setHeader(key, value);
60
- }
61
- if (isStreaming) {
62
- opts.res.setHeader('Transfer-Encoding', 'chunked');
63
- const vary = opts.res.getHeader('Vary');
64
- opts.res.setHeader('Vary', vary ? 'trpc-batch-mode, ' + vary : 'trpc-batch-mode');
65
- isStream = true;
66
- formatter = core.getBatchStreamFormatter();
67
- opts.res.flushHeaders();
68
- }
69
- };
70
- const unstable_onChunk = ([index, string])=>{
71
- if (index === -1) {
72
- /**
73
- * Full response, no streaming. This can happen
74
- * - if the response is an error
75
- * - if response is empty (HEAD request)
76
- */ opts.res.end(string);
77
- } else {
78
- opts.res.write(formatter(index, string));
79
- opts.res.flush?.();
80
- }
81
- };
82
- await core.resolveHTTPResponse({
83
- batching: opts.batching,
84
- responseMeta: opts.responseMeta,
85
- path: opts.path,
86
- createContext,
87
- router: opts.router,
88
- req,
89
- error: bodyResult.ok ? null : bodyResult.error,
90
- preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
91
- onError (o) {
92
- opts?.onError?.({
93
- ...o,
94
- req: opts.req
95
- });
96
- },
97
- contentTypeHandler,
98
- unstable_onHead,
99
- unstable_onChunk
100
- });
101
- if (isStream) {
102
- opts.res.write(formatter.end());
103
- opts.res.end();
104
- }
105
- return opts.res;
106
- });
107
- }
108
-
109
- exports.nodeHTTPRequestHandler = nodeHTTPRequestHandler;