@trpc/server 11.0.0-alpha-tmp-subscription-connection-state.488 → 11.0.0-alpha-tmp-12-06-react.665
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/dist/@trpc/server/http.d.ts +1 -1
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/@trpc/server/index.d.ts +5 -1
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.js +2 -2
- package/dist/adapters/aws-lambda/getPlanner.mjs +2 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +2 -0
- package/dist/adapters/aws-lambda/index.mjs +2 -0
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +27 -7
- package/dist/adapters/express.mjs +27 -7
- package/dist/adapters/fastify/fastifyRequestHandler.js +3 -1
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +3 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +9 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +10 -3
- package/dist/adapters/fetch/fetchRequestHandler.js +9 -8
- package/dist/adapters/fetch/fetchRequestHandler.mjs +9 -8
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +10 -5
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +10 -5
- package/dist/adapters/next-app-dir/notFound.js +2 -0
- package/dist/adapters/next-app-dir/notFound.mjs +2 -0
- package/dist/adapters/next-app-dir/redirect.js +16 -1
- package/dist/adapters/next-app-dir/redirect.mjs +16 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +4 -3
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +4 -3
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +23 -30
- package/dist/adapters/next.mjs +24 -31
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +2 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +83 -40
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +83 -41
- package/dist/adapters/node-http/index.js +2 -0
- package/dist/adapters/node-http/index.mjs +2 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +7 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +70 -58
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +70 -59
- package/dist/adapters/node-http/writeResponse.d.ts +18 -0
- package/dist/adapters/node-http/writeResponse.d.ts.map +1 -0
- package/dist/adapters/node-http/writeResponse.js +82 -0
- package/dist/adapters/node-http/writeResponse.mjs +79 -0
- package/dist/adapters/standalone.d.ts +5 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +25 -13
- package/dist/adapters/standalone.mjs +26 -14
- package/dist/adapters/ws.d.ts +14 -4
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +236 -90
- package/dist/adapters/ws.mjs +237 -92
- package/dist/bundle-analysis.json +411 -294
- package/dist/http.js +2 -4
- package/dist/http.mjs +2 -2
- package/dist/index.js +6 -2
- package/dist/index.mjs +3 -1
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.1_rollup@4.27.4_tslib@2.8.1_typescript@5.7.2/node_modules/tslib/tslib.es6.js +73 -0
- package/dist/observable/behaviorSubject.d.ts +15 -0
- package/dist/observable/behaviorSubject.d.ts.map +1 -0
- package/dist/observable/behaviorSubject.js +40 -0
- package/dist/observable/behaviorSubject.mjs +38 -0
- package/dist/observable/index.d.ts +3 -3
- package/dist/observable/index.d.ts.map +1 -1
- package/dist/observable/index.js +5 -0
- package/dist/observable/index.mjs +3 -2
- package/dist/observable/observable.d.ts +2 -1
- package/dist/observable/observable.d.ts.map +1 -1
- package/dist/observable/observable.js +31 -8
- package/dist/observable/observable.mjs +31 -8
- package/dist/observable/operators.d.ts +2 -0
- package/dist/observable/operators.d.ts.map +1 -1
- package/dist/observable/operators.js +35 -0
- package/dist/observable/operators.mjs +34 -1
- package/dist/rpc.js +2 -0
- package/dist/rpc.mjs +2 -0
- package/dist/shared.js +2 -0
- package/dist/shared.mjs +2 -0
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +2 -2
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +1 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +1 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +16 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +16 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +1 -1
- package/dist/unstable-core-do-not-import/error/formatter.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +2 -2
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +2 -2
- package/dist/unstable-core-do-not-import/http/contentType.js +3 -3
- package/dist/unstable-core-do-not-import/http/contentType.mjs +3 -3
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +6 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +28 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +25 -1
- package/dist/unstable-core-do-not-import/http/isAbortError.d.ts +4 -0
- package/dist/unstable-core-do-not-import/http/isAbortError.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/isAbortError.js +9 -0
- package/dist/unstable-core-do-not-import/http/isAbortError.mjs +7 -0
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +187 -92
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +189 -94
- package/dist/unstable-core-do-not-import/http/types.d.ts +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +11 -11
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +11 -11
- package/dist/unstable-core-do-not-import/initTRPC.mjs +11 -11
- package/dist/unstable-core-do-not-import/middleware.d.ts +2 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/middleware.js +2 -2
- package/dist/unstable-core-do-not-import/middleware.mjs +2 -2
- package/dist/unstable-core-do-not-import/parser.d.ts +5 -1
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/parser.js +4 -0
- package/dist/unstable-core-do-not-import/parser.mjs +4 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts +8 -2
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +32 -13
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +33 -39
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +33 -39
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +17 -17
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +4 -3
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.js +6 -5
- package/dist/unstable-core-do-not-import/router.mjs +6 -5
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +2 -9
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +11 -6
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +7 -3
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +7 -3
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +31 -16
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +440 -318
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +440 -318
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +63 -41
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +300 -119
- package/dist/unstable-core-do-not-import/stream/sse.mjs +302 -119
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts +31 -0
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts +31 -0
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/tracked.js +29 -0
- package/dist/unstable-core-do-not-import/stream/tracked.mjs +25 -0
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +17 -0
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +171 -0
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +167 -0
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts +0 -11
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.js +0 -29
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +1 -29
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts +17 -0
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/disposable.js +44 -0
- package/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +41 -0
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts +8 -0
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.js +25 -0
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.mjs +23 -0
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts +5 -0
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.js +26 -0
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.mjs +23 -0
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts +7 -0
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/withPing.js +130 -0
- package/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +127 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +2 -4
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/transformer.js +1 -1
- package/dist/unstable-core-do-not-import/transformer.mjs +1 -1
- package/dist/unstable-core-do-not-import/types.d.ts +26 -3
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +15 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +49 -1
- package/dist/unstable-core-do-not-import/utils.mjs +45 -2
- package/dist/unstable-core-do-not-import.d.ts +4 -2
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +18 -9
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/vendor/unpromise/index.d.ts +3 -0
- package/dist/vendor/unpromise/index.d.ts.map +1 -0
- package/dist/vendor/unpromise/types.d.ts +28 -0
- package/dist/vendor/unpromise/types.d.ts.map +1 -0
- package/dist/vendor/unpromise/unpromise.d.ts +121 -0
- package/dist/vendor/unpromise/unpromise.d.ts.map +1 -0
- package/dist/vendor/unpromise/unpromise.js +292 -0
- package/dist/vendor/unpromise/unpromise.mjs +289 -0
- package/package.json +20 -17
- package/src/@trpc/server/http.ts +0 -2
- package/src/@trpc/server/index.ts +6 -0
- package/src/adapters/aws-lambda/getPlanner.ts +2 -2
- package/src/adapters/aws-lambda/index.ts +5 -6
- package/src/adapters/express.ts +21 -9
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +16 -5
- package/src/adapters/fetch/fetchRequestHandler.ts +2 -2
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +3 -0
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +3 -2
- package/src/adapters/next.ts +29 -34
- package/src/adapters/node-http/incomingMessageToRequest.ts +110 -40
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +85 -63
- package/src/adapters/node-http/writeResponse.ts +94 -0
- package/src/adapters/standalone.ts +35 -18
- package/src/adapters/ws.ts +152 -62
- package/src/observable/behaviorSubject.ts +55 -0
- package/src/observable/index.ts +22 -3
- package/src/observable/observable.ts +32 -14
- package/src/observable/operators.ts +47 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +4 -4
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +6 -6
- package/src/unstable-core-do-not-import/clientish/serialize.ts +5 -5
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +37 -4
- package/src/unstable-core-do-not-import/http/isAbortError.ts +7 -0
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +192 -85
- package/src/unstable-core-do-not-import/http/types.ts +1 -1
- package/src/unstable-core-do-not-import/initTRPC.ts +14 -20
- package/src/unstable-core-do-not-import/middleware.ts +5 -4
- package/src/unstable-core-do-not-import/parser.ts +17 -6
- package/src/unstable-core-do-not-import/procedure.ts +17 -2
- package/src/unstable-core-do-not-import/procedureBuilder.ts +138 -123
- package/src/unstable-core-do-not-import/rootConfig.ts +20 -17
- package/src/unstable-core-do-not-import/router.ts +15 -16
- package/src/unstable-core-do-not-import/rpc/codes.ts +2 -10
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +18 -7
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +5 -1
- package/src/unstable-core-do-not-import/stream/jsonl.ts +293 -294
- package/src/unstable-core-do-not-import/stream/sse.ts +349 -191
- package/src/unstable-core-do-not-import/stream/sse.types.ts +44 -0
- package/src/unstable-core-do-not-import/stream/tracked.ts +49 -0
- package/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts +89 -0
- package/src/unstable-core-do-not-import/stream/utils/createDeferred.ts +0 -36
- package/src/unstable-core-do-not-import/stream/utils/disposable.ts +52 -0
- package/src/unstable-core-do-not-import/stream/utils/readableStreamFrom.ts +28 -0
- package/src/unstable-core-do-not-import/stream/utils/timerResource.ts +29 -0
- package/src/unstable-core-do-not-import/stream/utils/withPing.ts +47 -0
- package/src/unstable-core-do-not-import/transformer.ts +1 -1
- package/src/unstable-core-do-not-import/types.ts +35 -10
- package/src/unstable-core-do-not-import/utils.ts +56 -1
- package/src/unstable-core-do-not-import.ts +4 -2
- package/src/vendor/unpromise/ATTRIBUTION.txt +1 -0
- package/src/vendor/unpromise/LICENSE +20 -0
- package/src/vendor/unpromise/index.ts +7 -0
- package/src/vendor/unpromise/types.ts +55 -0
- package/src/vendor/unpromise/unpromise.ts +380 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +0 -32
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +0 -30
- package/dist/unstable-core-do-not-import/http/toURL.d.ts +0 -2
- package/dist/unstable-core-do-not-import/http/toURL.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/toURL.js +0 -8
- package/dist/unstable-core-do-not-import/http/toURL.mjs +0 -6
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts +0 -10
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.js +0 -31
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.mjs +0 -29
- package/dist/unstable-core-do-not-import/stream/utils/createServer.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/createServer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/types.js +0 -11
- package/dist/unstable-core-do-not-import/types.mjs +0 -9
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/toURL.ts +0 -7
- package/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts +0 -31
- package/src/unstable-core-do-not-import/stream/utils/createServer.ts +0 -44
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { isObservable, observableToAsyncIterable } from '../../observable/observable.mjs';
|
|
2
2
|
import { getErrorShape } from '../error/getErrorShape.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { getTRPCErrorFromUnknown, TRPCError } from '../error/TRPCError.mjs';
|
|
4
4
|
import { jsonlStreamProducer, isPromise } from '../stream/jsonl.mjs';
|
|
5
5
|
import { sseStreamProducer, sseHeaders } from '../stream/sse.mjs';
|
|
6
6
|
import { transformTRPCResponse } from '../transformer.mjs';
|
|
7
|
-
import { isAsyncIterable, isObject } from '../utils.mjs';
|
|
7
|
+
import { run, isAsyncIterable, isObject } from '../utils.mjs';
|
|
8
8
|
import { getRequestInfo } from './contentType.mjs';
|
|
9
9
|
import { getHTTPStatusCode } from './getHTTPStatusCode.mjs';
|
|
10
10
|
|
|
11
|
+
function errorToAsyncIterable(err) {
|
|
12
|
+
return run(async function*() {
|
|
13
|
+
throw err;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
11
16
|
const TYPE_ACCEPTED_METHOD_MAP = {
|
|
12
17
|
mutation: [
|
|
13
18
|
'POST'
|
|
@@ -34,7 +39,7 @@ const TYPE_ACCEPTED_METHOD_MAP_WITH_METHOD_OVERRIDE = {
|
|
|
34
39
|
]
|
|
35
40
|
};
|
|
36
41
|
function initResponse(initOpts) {
|
|
37
|
-
const { ctx
|
|
42
|
+
const { ctx, info, responseMeta, untransformedJSON, errors = [], headers } = initOpts;
|
|
38
43
|
let status = untransformedJSON ? getHTTPStatusCode(untransformedJSON) : 200;
|
|
39
44
|
const eagerGeneration = !untransformedJSON;
|
|
40
45
|
const data = eagerGeneration ? [] : Array.isArray(untransformedJSON) ? untransformedJSON : [
|
|
@@ -57,13 +62,13 @@ function initResponse(initOpts) {
|
|
|
57
62
|
} else {
|
|
58
63
|
/**
|
|
59
64
|
* @deprecated, delete in v12
|
|
60
|
-
*/ for (const [
|
|
61
|
-
if (Array.isArray(
|
|
62
|
-
for (const v of
|
|
63
|
-
headers.append(
|
|
65
|
+
*/ for (const [key, value] of Object.entries(meta.headers)){
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
for (const v of value){
|
|
68
|
+
headers.append(key, v);
|
|
64
69
|
}
|
|
65
|
-
} else if (typeof
|
|
66
|
-
headers.set(
|
|
70
|
+
} else if (typeof value === 'string') {
|
|
71
|
+
headers.set(key, value);
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
}
|
|
@@ -76,7 +81,7 @@ function initResponse(initOpts) {
|
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
83
|
function caughtErrorToData(cause, errorOpts) {
|
|
79
|
-
const { router
|
|
84
|
+
const { router, req, onError } = errorOpts.opts;
|
|
80
85
|
const error = getTRPCErrorFromUnknown(cause);
|
|
81
86
|
onError?.({
|
|
82
87
|
error,
|
|
@@ -118,7 +123,7 @@ function caughtErrorToData(cause, errorOpts) {
|
|
|
118
123
|
return Object.values(v).some(isPromise) || Object.values(v).some(isAsyncIterable);
|
|
119
124
|
}
|
|
120
125
|
async function resolveResponse(opts) {
|
|
121
|
-
const { router
|
|
126
|
+
const { router, req } = opts;
|
|
122
127
|
const headers = new Headers([
|
|
123
128
|
[
|
|
124
129
|
'vary',
|
|
@@ -135,28 +140,72 @@ async function resolveResponse(opts) {
|
|
|
135
140
|
}
|
|
136
141
|
const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
|
|
137
142
|
const allowMethodOverride = (opts.allowMethodOverride ?? false) && req.method === 'POST';
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
const infoTuple = run(()=>{
|
|
144
|
+
try {
|
|
145
|
+
return [
|
|
146
|
+
undefined,
|
|
147
|
+
getRequestInfo({
|
|
148
|
+
req,
|
|
149
|
+
path: decodeURIComponent(opts.path),
|
|
150
|
+
router,
|
|
151
|
+
searchParams: url.searchParams,
|
|
152
|
+
headers: opts.req.headers
|
|
153
|
+
})
|
|
154
|
+
];
|
|
155
|
+
} catch (cause) {
|
|
156
|
+
return [
|
|
157
|
+
getTRPCErrorFromUnknown(cause),
|
|
158
|
+
undefined
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
const ctxManager = run(()=>{
|
|
163
|
+
let result = undefined;
|
|
164
|
+
return {
|
|
165
|
+
valueOrUndefined: ()=>{
|
|
166
|
+
if (!result) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
return result[1];
|
|
170
|
+
},
|
|
171
|
+
value: ()=>{
|
|
172
|
+
const [err, ctx] = result;
|
|
173
|
+
if (err) {
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
return ctx;
|
|
177
|
+
},
|
|
178
|
+
create: async (info)=>{
|
|
179
|
+
if (result) {
|
|
180
|
+
throw new Error('This should only be called once - report a bug in tRPC');
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const ctx = await opts.createContext({
|
|
184
|
+
info
|
|
185
|
+
});
|
|
186
|
+
result = [
|
|
187
|
+
undefined,
|
|
188
|
+
ctx
|
|
189
|
+
];
|
|
190
|
+
} catch (cause) {
|
|
191
|
+
result = [
|
|
192
|
+
getTRPCErrorFromUnknown(cause),
|
|
193
|
+
undefined
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
});
|
|
140
199
|
const methodMapper = allowMethodOverride ? TYPE_ACCEPTED_METHOD_MAP_WITH_METHOD_OVERRIDE : TYPE_ACCEPTED_METHOD_MAP;
|
|
141
200
|
/**
|
|
142
201
|
* @deprecated
|
|
143
202
|
*/ const isStreamCall = req.headers.get('trpc-accept') === 'application/jsonl';
|
|
144
|
-
const experimentalIterablesAndDeferreds =
|
|
145
|
-
const experimentalSSE =
|
|
203
|
+
const experimentalIterablesAndDeferreds = config.iterablesAndDeferreds ?? true;
|
|
204
|
+
const experimentalSSE = config.sse?.enabled ?? true;
|
|
146
205
|
try {
|
|
147
|
-
info =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
router,
|
|
151
|
-
searchParams: url.searchParams,
|
|
152
|
-
headers: opts.req.headers
|
|
153
|
-
});
|
|
154
|
-
// we create context early so that error handlers may access context information
|
|
155
|
-
ctx = await opts.createContext({
|
|
156
|
-
info
|
|
157
|
-
});
|
|
158
|
-
if (opts.error) {
|
|
159
|
-
throw opts.error;
|
|
206
|
+
const [infoError, info] = infoTuple;
|
|
207
|
+
if (infoError) {
|
|
208
|
+
throw infoError;
|
|
160
209
|
}
|
|
161
210
|
if (info.isBatchCall && !allowBatching) {
|
|
162
211
|
throw new TRPCError({
|
|
@@ -170,9 +219,13 @@ async function resolveResponse(opts) {
|
|
|
170
219
|
code: 'BAD_REQUEST'
|
|
171
220
|
});
|
|
172
221
|
}
|
|
222
|
+
await ctxManager.create(info);
|
|
173
223
|
const rpcCalls = info.calls.map(async (call)=>{
|
|
174
224
|
const proc = call.procedure;
|
|
175
225
|
try {
|
|
226
|
+
if (opts.error) {
|
|
227
|
+
throw opts.error;
|
|
228
|
+
}
|
|
176
229
|
if (!proc) {
|
|
177
230
|
throw new TRPCError({
|
|
178
231
|
code: 'NOT_FOUND',
|
|
@@ -185,20 +238,26 @@ async function resolveResponse(opts) {
|
|
|
185
238
|
message: `Unsupported ${req.method}-request to ${proc._def.type} procedure at path "${call.path}"`
|
|
186
239
|
});
|
|
187
240
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
241
|
+
if (proc._def.type === 'subscription') {
|
|
242
|
+
/* istanbul ignore if -- @preserve */ if (info.isBatchCall) {
|
|
243
|
+
throw new TRPCError({
|
|
244
|
+
code: 'BAD_REQUEST',
|
|
245
|
+
message: `Cannot batch subscription calls`
|
|
246
|
+
});
|
|
247
|
+
}
|
|
193
248
|
}
|
|
194
249
|
const data = await proc({
|
|
195
250
|
path: call.path,
|
|
196
251
|
getRawInput: call.getRawInput,
|
|
197
|
-
ctx,
|
|
198
|
-
type: proc._def.type
|
|
252
|
+
ctx: ctxManager.value(),
|
|
253
|
+
type: proc._def.type,
|
|
254
|
+
signal: opts.req.signal
|
|
199
255
|
});
|
|
200
256
|
return [
|
|
201
|
-
|
|
257
|
+
undefined,
|
|
258
|
+
{
|
|
259
|
+
data
|
|
260
|
+
}
|
|
202
261
|
];
|
|
203
262
|
} catch (cause) {
|
|
204
263
|
const error = getTRPCErrorFromUnknown(cause);
|
|
@@ -207,20 +266,20 @@ async function resolveResponse(opts) {
|
|
|
207
266
|
error,
|
|
208
267
|
path: call.path,
|
|
209
268
|
input,
|
|
210
|
-
ctx,
|
|
269
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
211
270
|
type: call.procedure?._def.type ?? 'unknown',
|
|
212
271
|
req: opts.req
|
|
213
272
|
});
|
|
214
273
|
return [
|
|
215
|
-
|
|
216
|
-
|
|
274
|
+
error,
|
|
275
|
+
undefined
|
|
217
276
|
];
|
|
218
277
|
}
|
|
219
278
|
});
|
|
220
279
|
// ----------- response handlers -----------
|
|
221
280
|
if (!info.isBatchCall) {
|
|
222
281
|
const [call] = info.calls;
|
|
223
|
-
const [
|
|
282
|
+
const [error, result] = await rpcCalls[0];
|
|
224
283
|
switch(info.type){
|
|
225
284
|
case 'unknown':
|
|
226
285
|
case 'mutation':
|
|
@@ -228,7 +287,7 @@ async function resolveResponse(opts) {
|
|
|
228
287
|
{
|
|
229
288
|
// httpLink
|
|
230
289
|
headers.set('content-type', 'application/json');
|
|
231
|
-
if (isDataStream(data)) {
|
|
290
|
+
if (isDataStream(result?.data)) {
|
|
232
291
|
throw new TRPCError({
|
|
233
292
|
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
234
293
|
message: 'Cannot use stream-like response in non-streaming request - use httpBatchStreamLink'
|
|
@@ -237,7 +296,7 @@ async function resolveResponse(opts) {
|
|
|
237
296
|
const res = error ? {
|
|
238
297
|
error: getErrorShape({
|
|
239
298
|
config,
|
|
240
|
-
ctx,
|
|
299
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
241
300
|
error,
|
|
242
301
|
input: call.result(),
|
|
243
302
|
path: call.path,
|
|
@@ -245,11 +304,11 @@ async function resolveResponse(opts) {
|
|
|
245
304
|
})
|
|
246
305
|
} : {
|
|
247
306
|
result: {
|
|
248
|
-
data
|
|
307
|
+
data: result.data
|
|
249
308
|
}
|
|
250
309
|
};
|
|
251
310
|
const headResponse = initResponse({
|
|
252
|
-
ctx,
|
|
311
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
253
312
|
info,
|
|
254
313
|
responseMeta: opts.responseMeta,
|
|
255
314
|
errors: error ? [
|
|
@@ -268,29 +327,58 @@ async function resolveResponse(opts) {
|
|
|
268
327
|
case 'subscription':
|
|
269
328
|
{
|
|
270
329
|
// httpSubscriptionLink
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
330
|
+
const iterable = run(()=>{
|
|
331
|
+
if (error) {
|
|
332
|
+
return errorToAsyncIterable(error);
|
|
333
|
+
}
|
|
334
|
+
if (!experimentalSSE) {
|
|
335
|
+
return errorToAsyncIterable(new TRPCError({
|
|
336
|
+
code: 'METHOD_NOT_SUPPORTED',
|
|
337
|
+
message: 'Missing experimental flag "sseSubscriptions"'
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
if (!isObservable(result.data) && !isAsyncIterable(result.data)) {
|
|
341
|
+
return errorToAsyncIterable(new TRPCError({
|
|
342
|
+
message: `Subscription ${call.path} did not return an observable or a AsyncGenerator`,
|
|
343
|
+
code: 'INTERNAL_SERVER_ERROR'
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
const dataAsIterable = isObservable(result.data) ? observableToAsyncIterable(result.data, opts.req.signal) : result.data;
|
|
347
|
+
return dataAsIterable;
|
|
348
|
+
});
|
|
284
349
|
const stream = sseStreamProducer({
|
|
285
|
-
...
|
|
286
|
-
data:
|
|
287
|
-
serialize: (v)=>config.transformer.output.serialize(v)
|
|
350
|
+
...config.sse,
|
|
351
|
+
data: iterable,
|
|
352
|
+
serialize: (v)=>config.transformer.output.serialize(v),
|
|
353
|
+
formatError (errorOpts) {
|
|
354
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
355
|
+
const input = call?.result();
|
|
356
|
+
const path = call?.path;
|
|
357
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
358
|
+
opts.onError?.({
|
|
359
|
+
error,
|
|
360
|
+
path,
|
|
361
|
+
input,
|
|
362
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
363
|
+
req: opts.req,
|
|
364
|
+
type
|
|
365
|
+
});
|
|
366
|
+
const shape = getErrorShape({
|
|
367
|
+
config,
|
|
368
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
369
|
+
error,
|
|
370
|
+
input,
|
|
371
|
+
path,
|
|
372
|
+
type
|
|
373
|
+
});
|
|
374
|
+
return shape;
|
|
375
|
+
}
|
|
288
376
|
});
|
|
289
377
|
for (const [key, value] of Object.entries(sseHeaders)){
|
|
290
378
|
headers.set(key, value);
|
|
291
379
|
}
|
|
292
|
-
const
|
|
293
|
-
ctx,
|
|
380
|
+
const headResponse = initResponse({
|
|
381
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
294
382
|
info,
|
|
295
383
|
responseMeta: opts.responseMeta,
|
|
296
384
|
errors: [],
|
|
@@ -299,7 +387,7 @@ async function resolveResponse(opts) {
|
|
|
299
387
|
});
|
|
300
388
|
return new Response(stream, {
|
|
301
389
|
headers,
|
|
302
|
-
status:
|
|
390
|
+
status: headResponse.status
|
|
303
391
|
});
|
|
304
392
|
}
|
|
305
393
|
}
|
|
@@ -309,15 +397,15 @@ async function resolveResponse(opts) {
|
|
|
309
397
|
// httpBatchStreamLink
|
|
310
398
|
headers.set('content-type', 'application/json');
|
|
311
399
|
headers.set('transfer-encoding', 'chunked');
|
|
312
|
-
const
|
|
313
|
-
ctx,
|
|
400
|
+
const headResponse = initResponse({
|
|
401
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
314
402
|
info,
|
|
315
403
|
responseMeta: opts.responseMeta,
|
|
316
404
|
errors: [],
|
|
317
405
|
headers,
|
|
318
406
|
untransformedJSON: null
|
|
319
407
|
});
|
|
320
|
-
const
|
|
408
|
+
const stream = jsonlStreamProducer({
|
|
321
409
|
/**
|
|
322
410
|
* Example structure for `maxDepth: 4`:
|
|
323
411
|
* {
|
|
@@ -332,13 +420,13 @@ async function resolveResponse(opts) {
|
|
|
332
420
|
* }
|
|
333
421
|
*/ maxDepth: experimentalIterablesAndDeferreds ? 4 : 3,
|
|
334
422
|
data: rpcCalls.map(async (res)=>{
|
|
335
|
-
const [
|
|
423
|
+
const [error, result] = await res;
|
|
336
424
|
const call = info.calls[0];
|
|
337
425
|
if (error) {
|
|
338
426
|
return {
|
|
339
427
|
error: getErrorShape({
|
|
340
428
|
config,
|
|
341
|
-
ctx,
|
|
429
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
342
430
|
error,
|
|
343
431
|
input: call.result(),
|
|
344
432
|
path: call.path,
|
|
@@ -349,10 +437,10 @@ async function resolveResponse(opts) {
|
|
|
349
437
|
/**
|
|
350
438
|
* Not very pretty, but we need to wrap nested data in promises
|
|
351
439
|
* Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
|
|
352
|
-
*/ const
|
|
440
|
+
*/ const iterable = isObservable(result.data) ? observableToAsyncIterable(result.data, opts.req.signal) : Promise.resolve(result.data);
|
|
353
441
|
return {
|
|
354
442
|
result: Promise.resolve({
|
|
355
|
-
data
|
|
443
|
+
data: iterable
|
|
356
444
|
})
|
|
357
445
|
};
|
|
358
446
|
}),
|
|
@@ -362,27 +450,32 @@ async function resolveResponse(opts) {
|
|
|
362
450
|
error: getTRPCErrorFromUnknown(cause),
|
|
363
451
|
path: undefined,
|
|
364
452
|
input: undefined,
|
|
365
|
-
ctx,
|
|
453
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
366
454
|
req: opts.req,
|
|
367
455
|
type: info?.type ?? 'unknown'
|
|
368
456
|
});
|
|
369
457
|
},
|
|
370
458
|
formatError (errorOpts) {
|
|
371
459
|
const call = info?.calls[errorOpts.path[0]];
|
|
460
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
461
|
+
const input = call?.result();
|
|
462
|
+
const path = call?.path;
|
|
463
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
464
|
+
// no need to call `onError` here as it will be propagated through the stream itself
|
|
372
465
|
const shape = getErrorShape({
|
|
373
466
|
config,
|
|
374
|
-
ctx,
|
|
375
|
-
error
|
|
376
|
-
input
|
|
377
|
-
path
|
|
378
|
-
type
|
|
467
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
468
|
+
error,
|
|
469
|
+
input,
|
|
470
|
+
path,
|
|
471
|
+
type
|
|
379
472
|
});
|
|
380
473
|
return shape;
|
|
381
474
|
}
|
|
382
475
|
});
|
|
383
|
-
return new Response(
|
|
476
|
+
return new Response(stream, {
|
|
384
477
|
headers,
|
|
385
|
-
status:
|
|
478
|
+
status: headResponse.status
|
|
386
479
|
});
|
|
387
480
|
}
|
|
388
481
|
// httpBatchLink
|
|
@@ -393,28 +486,28 @@ async function resolveResponse(opts) {
|
|
|
393
486
|
* - return a complete HTTPResponse
|
|
394
487
|
*/ headers.set('content-type', 'application/json');
|
|
395
488
|
const results = (await Promise.all(rpcCalls)).map((res)=>{
|
|
396
|
-
const [
|
|
489
|
+
const [error, result] = res;
|
|
397
490
|
if (error) {
|
|
398
491
|
return res;
|
|
399
492
|
}
|
|
400
|
-
if (isDataStream(data)) {
|
|
493
|
+
if (isDataStream(result.data)) {
|
|
401
494
|
return [
|
|
402
|
-
null,
|
|
403
495
|
new TRPCError({
|
|
404
496
|
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
405
497
|
message: 'Cannot use stream-like response in non-streaming request - use httpBatchStreamLink'
|
|
406
|
-
})
|
|
498
|
+
}),
|
|
499
|
+
undefined
|
|
407
500
|
];
|
|
408
501
|
}
|
|
409
502
|
return res;
|
|
410
503
|
});
|
|
411
|
-
const resultAsRPCResponse = results.map(([
|
|
504
|
+
const resultAsRPCResponse = results.map(([error, result], index)=>{
|
|
412
505
|
const call = info.calls[index];
|
|
413
506
|
if (error) {
|
|
414
507
|
return {
|
|
415
508
|
error: getErrorShape({
|
|
416
509
|
config,
|
|
417
|
-
ctx,
|
|
510
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
418
511
|
error,
|
|
419
512
|
input: call.result(),
|
|
420
513
|
path: call.path,
|
|
@@ -424,13 +517,13 @@ async function resolveResponse(opts) {
|
|
|
424
517
|
}
|
|
425
518
|
return {
|
|
426
519
|
result: {
|
|
427
|
-
data
|
|
520
|
+
data: result.data
|
|
428
521
|
}
|
|
429
522
|
};
|
|
430
523
|
});
|
|
431
|
-
const errors = results.map(([
|
|
432
|
-
const
|
|
433
|
-
ctx,
|
|
524
|
+
const errors = results.map(([error])=>error).filter(Boolean);
|
|
525
|
+
const headResponse = initResponse({
|
|
526
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
434
527
|
info,
|
|
435
528
|
responseMeta: opts.responseMeta,
|
|
436
529
|
untransformedJSON: resultAsRPCResponse,
|
|
@@ -438,10 +531,12 @@ async function resolveResponse(opts) {
|
|
|
438
531
|
headers
|
|
439
532
|
});
|
|
440
533
|
return new Response(JSON.stringify(transformTRPCResponse(config, resultAsRPCResponse)), {
|
|
441
|
-
status:
|
|
534
|
+
status: headResponse.status,
|
|
442
535
|
headers
|
|
443
536
|
});
|
|
444
537
|
} catch (cause) {
|
|
538
|
+
const [_infoError, info] = infoTuple;
|
|
539
|
+
const ctx = ctxManager.valueOrUndefined();
|
|
445
540
|
// we get here if
|
|
446
541
|
// - batching is called when it's not enabled
|
|
447
542
|
// - `createContext()` throws
|
|
@@ -449,23 +544,23 @@ async function resolveResponse(opts) {
|
|
|
449
544
|
// - post body is too large
|
|
450
545
|
// - input deserialization fails
|
|
451
546
|
// - `errorFormatter` return value is malformed
|
|
452
|
-
const { error
|
|
547
|
+
const { error, untransformedJSON, body } = caughtErrorToData(cause, {
|
|
453
548
|
opts,
|
|
454
|
-
ctx,
|
|
549
|
+
ctx: ctxManager.valueOrUndefined(),
|
|
455
550
|
type: info?.type ?? 'unknown'
|
|
456
551
|
});
|
|
457
|
-
const
|
|
552
|
+
const headResponse = initResponse({
|
|
458
553
|
ctx,
|
|
459
554
|
info,
|
|
460
555
|
responseMeta: opts.responseMeta,
|
|
461
556
|
untransformedJSON,
|
|
462
557
|
errors: [
|
|
463
|
-
|
|
558
|
+
error
|
|
464
559
|
],
|
|
465
560
|
headers
|
|
466
561
|
});
|
|
467
562
|
return new Response(body, {
|
|
468
|
-
status:
|
|
563
|
+
status: headResponse.status,
|
|
469
564
|
headers
|
|
470
565
|
});
|
|
471
566
|
}
|
|
@@ -37,7 +37,7 @@ export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> ext
|
|
|
37
37
|
/**
|
|
38
38
|
* Add handler to be called before response is sent to the user
|
|
39
39
|
* Useful for setting cache headers
|
|
40
|
-
* @
|
|
40
|
+
* @see https://trpc.io/docs/v11/caching
|
|
41
41
|
*/
|
|
42
42
|
responseMeta?: ResponseMetaFn<TRouter>;
|
|
43
43
|
}
|
|
@@ -12,7 +12,7 @@ interface RuntimeConfigOptions<TContext extends object, TMeta extends object> ex
|
|
|
12
12
|
}>, '$types' | 'transformer'>> {
|
|
13
13
|
/**
|
|
14
14
|
* Use a data transformer
|
|
15
|
-
* @
|
|
15
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
16
16
|
*/
|
|
17
17
|
transformer?: DataTransformerOptions;
|
|
18
18
|
}
|
|
@@ -20,19 +20,19 @@ type ContextCallback = (...args: any[]) => object | Promise<object>;
|
|
|
20
20
|
declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
21
21
|
/**
|
|
22
22
|
* Add a context shape as a generic to the root object
|
|
23
|
-
* @
|
|
23
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
24
24
|
*/
|
|
25
25
|
context<TNewContext extends object | ContextCallback>(): TRPCBuilder<TNewContext extends ContextCallback ? Unwrap<TNewContext> : TNewContext, TMeta>;
|
|
26
26
|
/**
|
|
27
27
|
* Add a meta shape as a generic to the root object
|
|
28
|
-
* @
|
|
28
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
29
29
|
*/
|
|
30
30
|
meta<TNewMeta extends object>(): TRPCBuilder<TContext, TNewMeta>;
|
|
31
31
|
/**
|
|
32
32
|
* Create the root object
|
|
33
|
-
* @
|
|
33
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
34
34
|
*/
|
|
35
|
-
create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(opts?: ValidateShape<TOptions, RuntimeConfigOptions<TContext, TMeta>>
|
|
35
|
+
create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(opts?: ValidateShape<TOptions, RuntimeConfigOptions<TContext, TMeta>>): {
|
|
36
36
|
/**
|
|
37
37
|
* Your router config
|
|
38
38
|
* @internal
|
|
@@ -45,17 +45,17 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
45
45
|
}>;
|
|
46
46
|
/**
|
|
47
47
|
* Builder object for creating procedures
|
|
48
|
-
* @
|
|
48
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
49
49
|
*/
|
|
50
50
|
procedure: import("./procedureBuilder").ProcedureBuilder<TContext, TMeta, object, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, false>;
|
|
51
51
|
/**
|
|
52
52
|
* Create reusable middlewares
|
|
53
|
-
* @
|
|
53
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
54
54
|
*/
|
|
55
55
|
middleware: <$ContextOverrides>(fn: import("./middleware").MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, unknown>) => import("./middleware").MiddlewareBuilder<TContext, TMeta, $ContextOverrides, unknown>;
|
|
56
56
|
/**
|
|
57
57
|
* Create a router
|
|
58
|
-
* @
|
|
58
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
59
59
|
*/
|
|
60
60
|
router: {
|
|
61
61
|
<TInput extends import("./router").RouterRecord>(input: TInput): import("./router").BuiltRouter<{
|
|
@@ -73,12 +73,12 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Merge Routers
|
|
76
|
-
* @
|
|
76
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
77
77
|
*/
|
|
78
78
|
mergeRouters: typeof mergeRouters;
|
|
79
79
|
/**
|
|
80
80
|
* Create a server-side caller for a router
|
|
81
|
-
* @
|
|
81
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
82
82
|
*/
|
|
83
83
|
createCallerFactory: <TRecord extends import("./router").RouterRecord>(router: Pick<import("./router").Router<{
|
|
84
84
|
ctx: TContext;
|
|
@@ -95,7 +95,7 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
98
|
-
* @
|
|
98
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
99
99
|
*/
|
|
100
100
|
export declare const initTRPC: TRPCBuilder<object, object>;
|
|
101
101
|
export type { TRPCBuilder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initTRPC.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/initTRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAGL,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErD,KAAK,wBAAwB,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"initTRPC.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/initTRPC.ts"],"names":[],"mappings":"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"}
|