@trpc/server 11.0.0-alpha-tmp.233 → 11.0.0-alpha-tmp-v11-trpc-sveltekit.191
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.
- package/README.md +4 -4
- package/dist/{unstableDoNotImportThis.d.ts → @trpc-core-unstable-do-not-import-this-please.d.ts} +1 -1
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +2 -0
- package/dist/@trpc-server/http.d.ts.map +1 -0
- package/dist/@trpc-server.d.ts +45 -0
- package/dist/@trpc-server.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +12 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +20 -0
- package/dist/adapters/aws-lambda/index.mjs +20 -0
- package/dist/adapters/aws-lambda/utils.d.ts +14 -5
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/express.d.ts +12 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -2
- package/dist/adapters/express.mjs +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +4 -4
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +14 -4
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +11 -2
- package/dist/adapters/fastify/index.mjs +11 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +12 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/index.js +10 -0
- package/dist/adapters/fetch/index.mjs +10 -0
- package/dist/adapters/fetch/types.d.ts +14 -4
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +12 -2
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +12 -2
- package/dist/adapters/next.mjs +12 -2
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +3 -3
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +2 -2
- package/dist/adapters/node-http/content-type/form-data/index.mjs +2 -2
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +2 -2
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +2 -1
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +2 -2
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +2 -2
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/index.js +2 -1
- package/dist/adapters/node-http/content-type/json/index.mjs +2 -1
- package/dist/adapters/node-http/index.js +2 -2
- package/dist/adapters/node-http/index.mjs +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts +3 -3
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +12 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/types.d.ts +17 -6
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +12 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +2 -2
- package/dist/adapters/standalone.mjs +2 -2
- package/dist/adapters/ws.d.ts +10 -9
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +7 -3
- package/dist/adapters/ws.mjs +7 -3
- package/dist/bundle-analysis.json +80 -80
- package/dist/{contentType-3194ed5f.mjs → contentType-72ed9df5.mjs} +1 -0
- package/dist/{contentType-8c16408e.js → contentType-d9d22104.js} +1 -0
- package/dist/http.d.ts +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts +1 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -8
- package/dist/index.mjs +1 -1
- package/dist/{nodeHTTPRequestHandler-36974696.mjs → nodeHTTPRequestHandler-0223fac5.mjs} +10 -0
- package/dist/{nodeHTTPRequestHandler-30028c9a.js → nodeHTTPRequestHandler-83441c73.js} +10 -0
- package/package.json +4 -20
- package/src/@trpc-server/http.ts +2 -0
- package/src/@trpc-server.ts +71 -0
- package/src/adapters/aws-lambda/index.ts +20 -5
- package/src/adapters/aws-lambda/utils.ts +22 -6
- package/src/adapters/express.ts +14 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +16 -6
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +17 -5
- package/src/adapters/fetch/fetchRequestHandler.ts +15 -5
- package/src/adapters/fetch/types.ts +19 -4
- package/src/adapters/next.ts +16 -3
- package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +3 -2
- package/src/adapters/node-http/content-type/form-data/index.ts +7 -9
- package/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts +3 -2
- package/src/adapters/node-http/content-type/form-data/streamSlice.ts +2 -1
- package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +2 -2
- package/src/adapters/node-http/content-type/json/getPostBody.ts +4 -3
- package/src/adapters/node-http/internals/contentType.ts +5 -3
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +16 -6
- package/src/adapters/node-http/types.ts +23 -6
- package/src/adapters/standalone.ts +14 -3
- package/src/adapters/ws.ts +29 -22
- package/src/http.ts +1 -2
- package/src/index.ts +1 -34
- package/dist/unstableDoNotImportThis.d.ts.map +0 -1
- /package/dist/{nodeHTTPRequestHandler-640c1f60.js → nodeHTTPRequestHandler-aa0dce4e.js} +0 -0
- /package/src/{unstableDoNotImportThis.ts → @trpc-core-unstable-do-not-import-this-please.ts} +0 -0
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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
|
+
*/
|
|
3
11
|
import type {
|
|
4
12
|
APIGatewayProxyEvent,
|
|
5
13
|
APIGatewayProxyEventV2,
|
|
@@ -7,8 +15,16 @@ import type {
|
|
|
7
15
|
APIGatewayProxyStructuredResultV2,
|
|
8
16
|
Context as APIGWContext,
|
|
9
17
|
} from 'aws-lambda';
|
|
10
|
-
import {
|
|
11
|
-
|
|
18
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server'; // import @trpc/server
|
|
19
|
+
|
|
20
|
+
// @trpc/server
|
|
21
|
+
import { TRPCError } from '../../@trpc-server';
|
|
22
|
+
import type {
|
|
23
|
+
HTTPHeaders,
|
|
24
|
+
OnErrorFunction,
|
|
25
|
+
ResponseMetaFn,
|
|
26
|
+
TRPCRequestInfo,
|
|
27
|
+
} from '../../http';
|
|
12
28
|
|
|
13
29
|
export type APIGatewayEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
14
30
|
export type APIGatewayResult =
|
|
@@ -45,13 +61,13 @@ export type AWSLambdaOptions<
|
|
|
45
61
|
} & (
|
|
46
62
|
| {
|
|
47
63
|
/**
|
|
48
|
-
* @link https://trpc.io/docs/context
|
|
64
|
+
* @link https://trpc.io/docs/v11/context
|
|
49
65
|
**/
|
|
50
66
|
createContext: AWSLambdaCreateContextFn<TRouter, TEvent>;
|
|
51
67
|
}
|
|
52
68
|
| {
|
|
53
69
|
/**
|
|
54
|
-
* @link https://trpc.io/docs/context
|
|
70
|
+
* @link https://trpc.io/docs/v11/context
|
|
55
71
|
**/
|
|
56
72
|
createContext?: AWSLambdaCreateContextFn<TRouter, TEvent>;
|
|
57
73
|
}
|
package/src/adapters/express.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
2
11
|
import type * as express from 'express';
|
|
3
|
-
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
14
|
+
import type {
|
|
4
15
|
NodeHTTPCreateContextFnOptions,
|
|
5
16
|
NodeHTTPHandlerOptions,
|
|
6
|
-
nodeHTTPRequestHandler,
|
|
7
17
|
} from './node-http';
|
|
18
|
+
import { nodeHTTPRequestHandler } from './node-http';
|
|
8
19
|
|
|
9
20
|
export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<
|
|
10
21
|
express.Request,
|
|
@@ -1,16 +1,26 @@
|
|
|
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
|
+
*/
|
|
1
11
|
import { Readable } from 'node:stream';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
12
|
+
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
13
|
+
// @trpc/server
|
|
14
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
15
|
+
import type {
|
|
6
16
|
HTTPBaseHandlerOptions,
|
|
7
17
|
HTTPRequest,
|
|
8
18
|
HTTPResponse,
|
|
9
19
|
ResolveHTTPRequestOptionsContextFn,
|
|
10
|
-
resolveHTTPResponse,
|
|
11
20
|
ResponseChunk,
|
|
12
21
|
} from '../../http';
|
|
13
|
-
import {
|
|
22
|
+
import { getBatchStreamFormatter, resolveHTTPResponse } from '../../http';
|
|
23
|
+
import type { NodeHTTPCreateContextOption } from '../node-http';
|
|
14
24
|
|
|
15
25
|
export type FastifyHandlerOptions<
|
|
16
26
|
TRouter extends AnyRouter,
|
|
@@ -1,9 +1,21 @@
|
|
|
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
|
+
*/
|
|
1
11
|
/// <reference types="@fastify/websocket" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
12
|
+
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
13
|
+
import type { FastifyHandlerOptions } from '.';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
16
|
+
import type { NodeHTTPCreateContextFnOptions } from '../node-http';
|
|
17
|
+
import type { WSSHandlerOptions } from '../ws';
|
|
18
|
+
import { applyWSSHandler } from '../ws';
|
|
7
19
|
import { fastifyRequestHandler } from './fastifyRequestHandler';
|
|
8
20
|
|
|
9
21
|
export interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
+
// @trpc/server
|
|
12
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
13
|
+
import type {
|
|
4
14
|
HTTPRequest,
|
|
5
15
|
HTTPResponse,
|
|
6
16
|
ResolveHTTPRequestOptionsContextFn,
|
|
7
|
-
resolveHTTPResponse,
|
|
8
17
|
ResponseChunk,
|
|
9
18
|
} from '../../http';
|
|
10
|
-
import {
|
|
19
|
+
import { getBatchStreamFormatter, resolveHTTPResponse } from '../../http';
|
|
20
|
+
import type { FetchHandlerOptions } from './types';
|
|
11
21
|
|
|
12
22
|
export type FetchHandlerRequestOptions<TRouter extends AnyRouter> =
|
|
13
23
|
FetchHandlerOptions<TRouter> & {
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
// @trpc/server
|
|
12
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server';
|
|
13
|
+
// @trpc/server/http
|
|
14
|
+
import type {
|
|
15
|
+
HTTPBaseHandlerOptions,
|
|
16
|
+
TRPCRequestInfo,
|
|
17
|
+
} from '../../@trpc-server/http';
|
|
3
18
|
|
|
4
19
|
export type FetchCreateContextFnOptions = {
|
|
5
20
|
req: Request;
|
|
@@ -15,13 +30,13 @@ export type FetchCreateContextOption<TRouter extends AnyRouter> =
|
|
|
15
30
|
unknown extends inferRouterContext<TRouter>
|
|
16
31
|
? {
|
|
17
32
|
/**
|
|
18
|
-
* @link https://trpc.io/docs/context
|
|
33
|
+
* @link https://trpc.io/docs/v11/context
|
|
19
34
|
**/
|
|
20
35
|
createContext?: FetchCreateContextFn<TRouter>;
|
|
21
36
|
}
|
|
22
37
|
: {
|
|
23
38
|
/**
|
|
24
|
-
* @link https://trpc.io/docs/context
|
|
39
|
+
* @link https://trpc.io/docs/v11/context
|
|
25
40
|
**/
|
|
26
41
|
createContext: FetchCreateContextFn<TRouter>;
|
|
27
42
|
};
|
package/src/adapters/next.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
2
11
|
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
3
|
-
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import { getErrorShape, TRPCError } from '../@trpc-server';
|
|
16
|
+
import type {
|
|
4
17
|
NodeHTTPCreateContextFnOptions,
|
|
5
18
|
NodeHTTPHandlerOptions,
|
|
6
|
-
nodeHTTPRequestHandler,
|
|
7
19
|
} from './node-http';
|
|
20
|
+
import { nodeHTTPRequestHandler } from './node-http';
|
|
8
21
|
|
|
9
22
|
export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<
|
|
10
23
|
NextApiRequest,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-node/upload/fileUploadHandler.ts
|
|
12
12
|
*/
|
|
13
13
|
import { randomBytes } from 'node:crypto';
|
|
14
14
|
import { createReadStream, createWriteStream, statSync } from 'node:fs';
|
|
@@ -18,7 +18,8 @@ import { basename, dirname, extname, resolve as resolvePath } from 'node:path';
|
|
|
18
18
|
import { finished, Readable } from 'node:stream';
|
|
19
19
|
import { promisify } from 'node:util';
|
|
20
20
|
import { streamSlice } from './streamSlice';
|
|
21
|
-
import {
|
|
21
|
+
import type { UploadHandler } from './uploadHandler';
|
|
22
|
+
import { MaxPartSizeExceededError } from './uploadHandler';
|
|
22
23
|
|
|
23
24
|
export async function readableStreamToString(
|
|
24
25
|
stream: ReadableStream<Uint8Array>,
|
|
@@ -6,22 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/formData.ts
|
|
10
10
|
*/
|
|
11
11
|
import * as fs from 'fs/promises';
|
|
12
12
|
import { Readable } from 'node:stream';
|
|
13
|
-
import { CombinedDataTransformer } from '@trpc/core';
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
14
|
// @ts-ignore the type definitions for this package are borked
|
|
16
15
|
import { streamMultipart } from '@web3-storage/multipart-parser';
|
|
16
|
+
// @trpc/server
|
|
17
|
+
import type { CombinedDataTransformer } from '../../../../@trpc-server';
|
|
17
18
|
import { createNodeHTTPContentTypeHandler } from '../../internals/contentType';
|
|
18
|
-
import { NodeHTTPRequest } from '../../types';
|
|
19
|
+
import type { NodeHTTPRequest } from '../../types';
|
|
19
20
|
import { NodeOnDiskFile } from './fileUploadHandler';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
UploadHandler,
|
|
23
|
-
UploadHandlerPart,
|
|
24
|
-
} from './uploadHandler';
|
|
21
|
+
import type { UploadHandler, UploadHandlerPart } from './uploadHandler';
|
|
22
|
+
import { MaxBodySizeExceededError } from './uploadHandler';
|
|
25
23
|
|
|
26
24
|
const utfTextDecoder = new TextDecoder('utf-8');
|
|
27
25
|
|
|
@@ -33,7 +31,7 @@ const utfTextDecoder = new TextDecoder('utf-8');
|
|
|
33
31
|
* @param uploadHandler A function that handles file uploads and returns a value to be used in the request body. If uploaded to disk, the returned value is a NodeOnDiskFile. If uploaded to memory, the returned value is a File.
|
|
34
32
|
* @param maxBodySize The maximum size of the request body in bytes. Defaults to Infinity.
|
|
35
33
|
*
|
|
36
|
-
* @
|
|
34
|
+
* @link https://remix.run/utils/parse-multipart-form-data
|
|
37
35
|
*/
|
|
38
36
|
async function parseMultipartFormData(
|
|
39
37
|
request: NodeHTTPRequest,
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/upload/memoryUploadHandler.ts
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import type { UploadHandler } from './uploadHandler';
|
|
12
|
+
import { MaxPartSizeExceededError } from './uploadHandler';
|
|
12
13
|
|
|
13
14
|
export type MemoryUploadHandlerFilterArgs = {
|
|
14
15
|
filename?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NodeOnDiskFile } from './fileUploadHandler';
|
|
1
|
+
import type { NodeOnDiskFile } from './fileUploadHandler';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/formData.ts
|
|
5
5
|
*/
|
|
6
6
|
export type UploadHandlerPart = {
|
|
7
7
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
// @trpc/server
|
|
2
|
+
import { TRPCError } from '../../../../@trpc-server';
|
|
3
|
+
import type { BodyResult } from '../../../../http';
|
|
4
|
+
import type { NodeHTTPRequest } from '../../types';
|
|
4
5
|
|
|
5
6
|
export async function getPostBody(opts: {
|
|
6
7
|
req: NodeHTTPRequest;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
// @trpc/server
|
|
2
|
+
import type { AnyRouter } from '../../../@trpc-server';
|
|
3
|
+
// @trpc/server/http
|
|
4
|
+
import type { BaseContentTypeHandler } from '../../../@trpc-server/http';
|
|
5
|
+
import type {
|
|
4
6
|
NodeHTTPRequest,
|
|
5
7
|
NodeHTTPRequestHandlerOptions,
|
|
6
8
|
NodeHTTPResponse,
|
|
@@ -1,16 +1,26 @@
|
|
|
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
|
+
*/
|
|
1
11
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
14
|
+
import type {
|
|
5
15
|
HTTPRequest,
|
|
6
16
|
HTTPResponse,
|
|
7
17
|
ResolveHTTPRequestOptionsContextFn,
|
|
8
|
-
resolveHTTPResponse,
|
|
9
18
|
ResponseChunk,
|
|
10
19
|
} from '../../http';
|
|
20
|
+
import { getBatchStreamFormatter, resolveHTTPResponse } from '../../http';
|
|
11
21
|
import { nodeHTTPJSONContentTypeHandler } from './content-type/json';
|
|
12
|
-
import { NodeHTTPContentTypeHandler } from './internals/contentType';
|
|
13
|
-
import {
|
|
22
|
+
import type { NodeHTTPContentTypeHandler } from './internals/contentType';
|
|
23
|
+
import type {
|
|
14
24
|
NodeHTTPRequest,
|
|
15
25
|
NodeHTTPRequestHandlerOptions,
|
|
16
26
|
NodeHTTPResponse,
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 { IncomingMessage, ServerResponse } from 'http';
|
|
12
|
+
// eslint-disable-next-line no-restricted-imports
|
|
13
|
+
import type { MaybePromise } from '@trpc/core';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server';
|
|
16
|
+
// @trpc/server/http
|
|
17
|
+
import type {
|
|
18
|
+
HTTPBaseHandlerOptions,
|
|
19
|
+
TRPCRequestInfo,
|
|
20
|
+
} from '../../@trpc-server/http';
|
|
21
|
+
import type { NodeHTTPContentTypeHandler } from './internals/contentType';
|
|
5
22
|
|
|
6
23
|
interface ParsedQs {
|
|
7
24
|
[key: string]: ParsedQs | ParsedQs[] | string[] | string | undefined;
|
|
@@ -30,13 +47,13 @@ export type NodeHTTPCreateContextOption<
|
|
|
30
47
|
> = object extends inferRouterContext<TRouter>
|
|
31
48
|
? {
|
|
32
49
|
/**
|
|
33
|
-
* @link https://trpc.io/docs/context
|
|
50
|
+
* @link https://trpc.io/docs/v11/context
|
|
34
51
|
**/
|
|
35
52
|
createContext?: NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>;
|
|
36
53
|
}
|
|
37
54
|
: {
|
|
38
55
|
/**
|
|
39
|
-
* @link https://trpc.io/docs/context
|
|
56
|
+
* @link https://trpc.io/docs/v11/context
|
|
40
57
|
**/
|
|
41
58
|
createContext: NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>;
|
|
42
59
|
};
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
3
|
+
*
|
|
4
|
+
* 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
|
+
*/
|
|
1
11
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
12
|
import http from 'http';
|
|
3
|
-
|
|
4
|
-
import {
|
|
13
|
+
// @trpc/server
|
|
14
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
15
|
+
import type {
|
|
5
16
|
NodeHTTPCreateContextFnOptions,
|
|
6
17
|
NodeHTTPHandlerOptions,
|
|
7
|
-
nodeHTTPRequestHandler,
|
|
8
18
|
} from './node-http';
|
|
19
|
+
import { nodeHTTPRequestHandler } from './node-http';
|
|
9
20
|
|
|
10
21
|
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> =
|
|
11
22
|
NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
package/src/adapters/ws.ts
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { IncomingMessage } from 'http';
|
|
1
|
+
import type { IncomingMessage } from 'http';
|
|
2
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
|
+
import type { MaybePromise } from '@trpc/core';
|
|
4
|
+
import type { BaseHandlerOptions } from '@trpc/core/http';
|
|
5
|
+
import type { Unsubscribable } from '@trpc/core/observable';
|
|
6
|
+
import { isObservable } from '@trpc/core/observable';
|
|
7
|
+
import type {
|
|
8
|
+
JSONRPC2,
|
|
9
|
+
TRPCClientOutgoingMessage,
|
|
10
|
+
TRPCReconnectNotification,
|
|
11
|
+
TRPCResponseMessage,
|
|
12
|
+
} from '@trpc/core/rpc';
|
|
13
|
+
import { parseTRPCMessage } from '@trpc/core/rpc';
|
|
14
|
+
import type ws from 'ws';
|
|
15
|
+
import type { AnyRouter, inferRouterContext } from '../@trpc-server';
|
|
2
16
|
import {
|
|
3
|
-
AnyRouter,
|
|
4
17
|
callProcedure,
|
|
5
18
|
getErrorShape,
|
|
6
19
|
getTRPCErrorFromUnknown,
|
|
7
|
-
inferRouterContext,
|
|
8
|
-
MaybePromise,
|
|
9
20
|
transformTRPCResponse,
|
|
10
21
|
TRPCError,
|
|
11
|
-
} from '
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
TRPCResponseMessage,
|
|
20
|
-
} from '@trpc/core/rpc';
|
|
21
|
-
import { WebSocket, WebSocketServer } from 'ws';
|
|
22
|
-
import { NodeHTTPCreateContextFnOptions } from './node-http';
|
|
22
|
+
} from '../@trpc-server';
|
|
23
|
+
import type { NodeHTTPCreateContextFnOptions } from './node-http';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Importing ws causes a build error
|
|
27
|
+
* @link https://github.com/trpc/trpc/pull/5279
|
|
28
|
+
*/
|
|
29
|
+
const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
23
30
|
|
|
24
31
|
/**
|
|
25
32
|
* @public
|
|
26
33
|
*/
|
|
27
34
|
export type CreateWSSContextFnOptions = Omit<
|
|
28
|
-
NodeHTTPCreateContextFnOptions<IncomingMessage, WebSocket>,
|
|
35
|
+
NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>,
|
|
29
36
|
'info'
|
|
30
37
|
>;
|
|
31
38
|
|
|
@@ -46,17 +53,17 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
|
|
|
46
53
|
(object extends inferRouterContext<TRouter>
|
|
47
54
|
? {
|
|
48
55
|
/**
|
|
49
|
-
* @link https://trpc.io/docs/context
|
|
56
|
+
* @link https://trpc.io/docs/v11/context
|
|
50
57
|
**/
|
|
51
58
|
createContext?: CreateWSSContextFn<TRouter>;
|
|
52
59
|
}
|
|
53
60
|
: {
|
|
54
61
|
/**
|
|
55
|
-
* @link https://trpc.io/docs/context
|
|
62
|
+
* @link https://trpc.io/docs/v11/context
|
|
56
63
|
**/
|
|
57
64
|
createContext: CreateWSSContextFn<TRouter>;
|
|
58
65
|
}) & {
|
|
59
|
-
wss: WebSocketServer;
|
|
66
|
+
wss: ws.WebSocketServer;
|
|
60
67
|
process?: NodeJS.Process;
|
|
61
68
|
};
|
|
62
69
|
|
|
@@ -184,7 +191,7 @@ export function applyWSSHandler<TRouter extends AnyRouter>(
|
|
|
184
191
|
},
|
|
185
192
|
});
|
|
186
193
|
/* istanbul ignore next -- @preserve */
|
|
187
|
-
if (client.readyState !==
|
|
194
|
+
if (client.readyState !== WEBSOCKET_OPEN) {
|
|
188
195
|
// if the client got disconnected whilst initializing the subscription
|
|
189
196
|
// no need to send stopped message if the client is disconnected
|
|
190
197
|
sub.unsubscribe();
|
|
@@ -319,7 +326,7 @@ export function applyWSSHandler<TRouter extends AnyRouter>(
|
|
|
319
326
|
};
|
|
320
327
|
const data = JSON.stringify(response);
|
|
321
328
|
for (const client of wss.clients) {
|
|
322
|
-
if (client.readyState ===
|
|
329
|
+
if (client.readyState === WEBSOCKET_OPEN) {
|
|
323
330
|
client.send(data);
|
|
324
331
|
}
|
|
325
332
|
}
|
package/src/http.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export * from '@trpc/core/http';
|
|
1
|
+
export * from './@trpc-server/http';
|
package/src/index.ts
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
TRPCError,
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated use `experimental_trpcMiddleware` instead
|
|
5
|
-
*/
|
|
6
|
-
experimental_standaloneMiddleware,
|
|
7
|
-
experimental_standaloneMiddleware as experimental_trpcMiddleware,
|
|
8
|
-
initTRPC,
|
|
9
|
-
type inferProcedureInput,
|
|
10
|
-
type inferProcedureOutput,
|
|
11
|
-
type inferRouterError,
|
|
12
|
-
type inferRouterInputs,
|
|
13
|
-
type inferRouterOutputs,
|
|
14
|
-
type AnyProcedure as AnyTRPCProcedure,
|
|
15
|
-
type AnyRouter as AnyTRPCRouter,
|
|
16
|
-
} from './unstableDoNotImportThis';
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated use `AnyTRPCProcedure` instead
|
|
21
|
-
*/
|
|
22
|
-
AnyProcedure,
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated use `AnyTRPCRouter` instead
|
|
25
|
-
*/
|
|
26
|
-
AnyRouter,
|
|
27
|
-
} from '@trpc/core';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated
|
|
31
|
-
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
32
|
-
*/
|
|
33
|
-
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
|
|
34
|
-
Awaited<ReturnType<TFunction>>;
|
|
1
|
+
export * from './@trpc-server';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unstableDoNotImportThis.d.ts","sourceRoot":"","sources":["../src/unstableDoNotImportThis.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC"}
|
|
File without changes
|
/package/src/{unstableDoNotImportThis.ts → @trpc-core-unstable-do-not-import-this-please.ts}
RENAMED
|
File without changes
|