@trpc/server 11.0.0-alpha-tmp-nosideeffects.257 → 11.0.0-alpha-tmp-02-08-tmp.274
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 -0
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +2 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +2 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +2 -1
- package/dist/adapters/fetch/fetchRequestHandler.mjs +2 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +7 -3
- package/dist/adapters/standalone.mjs +7 -3
- package/dist/adapters/ws.d.ts +1 -0
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +4 -1
- package/dist/adapters/ws.mjs +4 -1
- package/dist/bundle-analysis.json +728 -0
- package/dist/http.js +2 -0
- package/dist/http.mjs +1 -0
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts +4 -4
- 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 +5 -6
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/index.d.ts +1 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/toURL.d.ts +2 -0
- package/dist/unstable-core-do-not-import/http/toURL.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/toURL.js +8 -0
- package/dist/unstable-core-do-not-import/http/toURL.mjs +6 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +4 -3
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +3 -1
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +2 -0
- package/dist/unstable-core-do-not-import.mjs +1 -0
- package/package.json +4 -4
- package/src/@trpc/server/http.ts +1 -0
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +2 -0
- package/src/adapters/fetch/fetchRequestHandler.ts +3 -1
- package/src/adapters/standalone.ts +6 -3
- package/src/adapters/ws.ts +6 -1
- package/src/unstable-core-do-not-import/clientish/inference.ts +5 -5
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +6 -12
- package/src/unstable-core-do-not-import/http/index.ts +2 -0
- package/src/unstable-core-do-not-import/http/toURL.ts +7 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +8 -4
- package/src/unstable-core-do-not-import/router.ts +6 -1
package/dist/http.js
CHANGED
|
@@ -5,6 +5,7 @@ require('./unstable-core-do-not-import/rpc/codes.js');
|
|
|
5
5
|
var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
6
6
|
var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
7
7
|
var contentType = require('./unstable-core-do-not-import/http/contentType.js');
|
|
8
|
+
var toURL = require('./unstable-core-do-not-import/http/toURL.js');
|
|
8
9
|
require('./unstable-core-do-not-import/rootConfig.js');
|
|
9
10
|
|
|
10
11
|
|
|
@@ -14,3 +15,4 @@ exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromErro
|
|
|
14
15
|
exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
|
|
15
16
|
exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
|
|
16
17
|
exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
|
|
18
|
+
exports.toURL = toURL.toURL;
|
package/dist/http.mjs
CHANGED
|
@@ -3,4 +3,5 @@ import './unstable-core-do-not-import/rpc/codes.mjs';
|
|
|
3
3
|
export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
4
4
|
export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
5
5
|
export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
|
|
6
|
+
export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
|
|
6
7
|
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { inferObservableValue } from '../../observable';
|
|
2
2
|
import type { AnyProcedure, inferProcedureInput } from '../procedure';
|
|
3
3
|
import type { AnyRouter, RouterRecord } from '../router';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AnyClientTypes, inferClientTypes, InferrableClientTypes } from './inferrable';
|
|
5
5
|
import type { Serialize } from './serialize';
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export type inferTransformedProcedureOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> =
|
|
9
|
+
export type inferTransformedProcedureOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<TProcedure['_def']['_output_out']> : TProcedure['_def']['_output_out'];
|
|
10
10
|
/** @internal */
|
|
11
|
-
export type inferTransformedSubscriptionOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> =
|
|
12
|
-
export type GetInferenceHelpers<TType extends 'input' | 'output', TRoot extends
|
|
11
|
+
export type inferTransformedSubscriptionOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<inferObservableValue<TProcedure['_def']['_output_out']>> : inferObservableValue<TProcedure['_def']['_output_out']>;
|
|
12
|
+
export type GetInferenceHelpers<TType extends 'input' | 'output', TRoot extends AnyClientTypes, TRecord extends RouterRecord> = {
|
|
13
13
|
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? GetInferenceHelpers<TType, TRoot, $Value> : $Value extends AnyProcedure ? TType extends 'input' ? inferProcedureInput<$Value> : inferTransformedProcedureOutput<TRoot, $Value> : never : never;
|
|
14
14
|
};
|
|
15
15
|
export type inferRouterInputs<TRouter extends AnyRouter> = GetInferenceHelpers<'input', TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/clientish/inference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/clientish/inference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AAEH,MAAM,MAAM,+BAA+B,CACzC,WAAW,SAAS,qBAAqB,EACzC,UAAU,SAAS,YAAY,IAC7B,gBAAgB,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,SAAS,KAAK,GAC1D,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC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CAAC,CAC1B,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AnyRootTypes } from '../rootConfig';
|
|
2
|
-
export type
|
|
2
|
+
export type AnyClientTypes = Pick<AnyRootTypes, 'errorShape' | 'transformer'>;
|
|
3
3
|
/**
|
|
4
4
|
* Result of `initTRPC.create()`
|
|
5
5
|
*/
|
|
6
6
|
type InitLike = {
|
|
7
7
|
_config: {
|
|
8
|
-
$types:
|
|
8
|
+
$types: AnyClientTypes;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -18,16 +18,15 @@ type RouterLike = {
|
|
|
18
18
|
* Result of `initTRPC.create()._config`
|
|
19
19
|
*/
|
|
20
20
|
type RootConfigLike = {
|
|
21
|
-
$types:
|
|
21
|
+
$types: AnyClientTypes;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Anything that can be inferred to the root config types needed for a TRPC client
|
|
25
25
|
*/
|
|
26
|
-
export type InferrableClientTypes = RouterLike | InitLike | RootConfigLike |
|
|
26
|
+
export type InferrableClientTypes = RouterLike | InitLike | RootConfigLike | AnyClientTypes;
|
|
27
27
|
/**
|
|
28
28
|
* Infer the root types from a InferrableClientTypes
|
|
29
29
|
*/
|
|
30
|
-
export type
|
|
31
|
-
export type inferErrorShape<TInferrable extends InferrableClientTypes> = inferRootTypes<TInferrable>['errorShape'];
|
|
30
|
+
export type inferClientTypes<TInferrable extends InferrableClientTypes> = TInferrable extends AnyClientTypes ? TInferrable : TInferrable extends RootConfigLike ? TInferrable['$types'] : TInferrable extends InitLike ? TInferrable['_config']['$types'] : TInferrable extends RouterLike ? TInferrable['_def']['_config']['$types'] : never;
|
|
32
31
|
export {};
|
|
33
32
|
//# sourceMappingURL=inferrable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inferrable.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/clientish/inferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"inferrable.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/clientish/inferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,aAAa,CAAC,CAAC;AAE9E;;GAEG;AACH,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE;QACP,MAAM,EAAE,cAAc,CAAC;KACxB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,UAAU,GACV,QAAQ,GACR,cAAc,GACd,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,qBAAqB,IACpE,WAAW,SAAS,cAAc,GAC9B,WAAW,GACX,WAAW,SAAS,cAAc,GAClC,WAAW,CAAC,QAAQ,CAAC,GACrB,WAAW,SAAS,QAAQ,GAC5B,WAAW,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAChC,WAAW,SAAS,UAAU,GAC9B,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GACxC,KAAK,CAAC"}
|
|
@@ -4,4 +4,5 @@ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPReque
|
|
|
4
4
|
export { getBatchStreamFormatter } from './batchStreamFormatter';
|
|
5
5
|
export type { BaseContentTypeHandler, BodyResult } from './contentType';
|
|
6
6
|
export { getJsonContentTypeInputs } from './contentType';
|
|
7
|
+
export { toURL } from './toURL';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toURL.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/toURL.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAMhD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { inferObservableValue } from '../observable';
|
|
1
2
|
import type { AnyMiddlewareFunction, MiddlewareBuilder, MiddlewareFunction } from './middleware';
|
|
2
3
|
import type { inferParser, Parser } from './parser';
|
|
3
4
|
import type { MutationProcedure, ProcedureType, QueryProcedure, SubscriptionProcedure } from './procedure';
|
|
@@ -30,10 +31,10 @@ interface ResolverOptions<TContext, _TMeta, TContextOverridesIn, TInputOut> {
|
|
|
30
31
|
/**
|
|
31
32
|
* A procedure resolver
|
|
32
33
|
*/
|
|
33
|
-
type ProcedureResolver<TContext, _TMeta, TContextOverrides, TInputOut,
|
|
34
|
+
type ProcedureResolver<TContext, _TMeta, TContextOverrides, TInputOut, TOutputParserIn, $Output> = (opts: {
|
|
34
35
|
ctx: Simplify<Overwrite<TContext, TContextOverrides>>;
|
|
35
36
|
input: TInputOut extends UnsetMarker ? undefined : TInputOut;
|
|
36
|
-
}) => MaybePromise<DefaultValue<
|
|
37
|
+
}) => MaybePromise<DefaultValue<TOutputParserIn, $Output>>;
|
|
37
38
|
export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut> {
|
|
38
39
|
/**
|
|
39
40
|
* Add an input parser to the procedure.
|
|
@@ -77,7 +78,7 @@ export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn,
|
|
|
77
78
|
*/
|
|
78
79
|
subscription<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): SubscriptionProcedure<{
|
|
79
80
|
input: DefaultValue<TInputIn, void>;
|
|
80
|
-
output: DefaultValue<TOutputOut,
|
|
81
|
+
output: DefaultValue<TOutputOut, inferObservableValue<$Output>>;
|
|
81
82
|
}>;
|
|
82
83
|
/**
|
|
83
84
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedureBuilder.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedureBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"procedureBuilder.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedureBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAKV,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,SAAS,CAAC;AAGjB,KAAK,kBAAkB,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,SAAS,WAAW,GAC7D,KAAK,GACL,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;AAE5B,gBAAgB;AAChB,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,KAAK,WAAW,GAAG,OAAO,WAAW,CAAC;AACtC,KAAK,YAAY,CAAC,MAAM,EAAE,SAAS,IAAI,MAAM,SAAS,WAAW,GAC7D,SAAS,GACT,MAAM,CAAC;AAEX,KAAK,mBAAmB,CAAC,KAAK,IAAI;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,CAA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,KAAK,EAC3C,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAC5C,gBAAgB,CACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,CACZ,CAuEA;AAwBD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,OAAO,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Observable } from '../observable';
|
|
2
|
+
import { TRPCError } from './error/TRPCError';
|
|
1
3
|
import type { AnyProcedure, inferProcedureInput } from './procedure';
|
|
2
4
|
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
3
5
|
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
@@ -5,7 +7,7 @@ import type { MaybePromise } from './types';
|
|
|
5
7
|
export interface RouterRecord {
|
|
6
8
|
[key: string]: AnyProcedure | RouterRecord;
|
|
7
9
|
}
|
|
8
|
-
type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['_output_out']>;
|
|
10
|
+
type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['type'] extends 'subscription' ? Observable<TProcedure['_def']['_output_out'], TRPCError> : TProcedure['_def']['_output_out']>;
|
|
9
11
|
/**
|
|
10
12
|
* @internal
|
|
11
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU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-import/http/getHTTPStatu
|
|
|
8
8
|
var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
9
9
|
var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
10
10
|
var contentType = require('./unstable-core-do-not-import/http/contentType.js');
|
|
11
|
+
var toURL = require('./unstable-core-do-not-import/http/toURL.js');
|
|
11
12
|
var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
|
|
12
13
|
var middleware = require('./unstable-core-do-not-import/middleware.js');
|
|
13
14
|
var parser = require('./unstable-core-do-not-import/parser.js');
|
|
@@ -35,6 +36,7 @@ exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromErro
|
|
|
35
36
|
exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
|
|
36
37
|
exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
|
|
37
38
|
exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
|
|
39
|
+
exports.toURL = toURL.toURL;
|
|
38
40
|
exports.initTRPC = initTRPC.initTRPC;
|
|
39
41
|
exports.createInputMiddleware = middleware.createInputMiddleware;
|
|
40
42
|
exports.createMiddlewareFactory = middleware.createMiddlewareFactory;
|
|
@@ -6,6 +6,7 @@ export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-d
|
|
|
6
6
|
export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
7
7
|
export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
8
8
|
export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
|
|
9
|
+
export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
|
|
9
10
|
export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
|
|
10
11
|
export { createInputMiddleware, createMiddlewareFactory, createOutputMiddleware, experimental_standaloneMiddleware, middlewareMarker } from './unstable-core-do-not-import/middleware.mjs';
|
|
11
12
|
export { getParseFn } from './unstable-core-do-not-import/parser.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-
|
|
3
|
+
"version": "11.0.0-alpha-tmp-02-08-tmp.274+fc6e807b1",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
"tslib": "^2.5.0",
|
|
149
149
|
"tsx": "^4.0.0",
|
|
150
150
|
"typescript": "^5.3.3",
|
|
151
|
-
"valibot": "^0.
|
|
152
|
-
"vitest": "^
|
|
151
|
+
"valibot": "^0.28.0",
|
|
152
|
+
"vitest": "^1.2.2",
|
|
153
153
|
"ws": "^8.0.0",
|
|
154
154
|
"yup": "^1.0.0",
|
|
155
155
|
"zod": "^3.0.0"
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"funding": [
|
|
158
158
|
"https://trpc.io/sponsor"
|
|
159
159
|
],
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "fc6e807b19d0b6fc726daa0a58ff5fcefcbef3d2"
|
|
161
161
|
}
|
package/src/@trpc/server/http.ts
CHANGED
|
@@ -43,6 +43,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
let prefix = opts.prefix ?? '';
|
|
46
|
+
const websocketPrefix = prefix;
|
|
46
47
|
|
|
47
48
|
// https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
|
|
48
49
|
// @ts-expect-error property 'default' does not exists on type ...
|
|
@@ -58,6 +59,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
|
|
|
58
59
|
if (opts.useWSS) {
|
|
59
60
|
applyWSSHandler<TRouter>({
|
|
60
61
|
...(opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>),
|
|
62
|
+
prefix: websocketPrefix,
|
|
61
63
|
wss: fastify.websocketServer,
|
|
62
64
|
});
|
|
63
65
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
10
|
// @trpc/server
|
|
11
|
+
|
|
11
12
|
import type { AnyRouter } from '../../@trpc/server';
|
|
12
13
|
import type {
|
|
13
14
|
HTTPRequest,
|
|
@@ -18,6 +19,7 @@ import type {
|
|
|
18
19
|
import {
|
|
19
20
|
getBatchStreamFormatter,
|
|
20
21
|
resolveHTTPResponse,
|
|
22
|
+
toURL,
|
|
21
23
|
} from '../../@trpc/server/http';
|
|
22
24
|
import type { FetchHandlerOptions } from './types';
|
|
23
25
|
|
|
@@ -45,7 +47,7 @@ export async function fetchRequestHandler<TRouter extends AnyRouter>(
|
|
|
45
47
|
return opts.createContext?.({ req: opts.req, resHeaders, ...innerOpts });
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
const url =
|
|
50
|
+
const url = toURL(opts.req.url);
|
|
49
51
|
|
|
50
52
|
const pathname = trimSlashes(url.pathname);
|
|
51
53
|
const endpoint = trimSlashes(opts.endpoint);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import http from 'http';
|
|
12
12
|
// @trpc/server
|
|
13
13
|
import type { AnyRouter } from '../@trpc/server';
|
|
14
|
+
import { toURL } from '../@trpc/server/http';
|
|
14
15
|
import type {
|
|
15
16
|
NodeHTTPCreateContextFnOptions,
|
|
16
17
|
NodeHTTPHandlerOptions,
|
|
@@ -29,9 +30,11 @@ export function createHTTPHandler<TRouter extends AnyRouter>(
|
|
|
29
30
|
opts: CreateHTTPHandlerOptions<TRouter>,
|
|
30
31
|
) {
|
|
31
32
|
return async (req: http.IncomingMessage, res: http.ServerResponse) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const url = toURL(req.url!);
|
|
34
|
+
|
|
35
|
+
// get procedure path and remove the leading slash
|
|
36
|
+
// /procedure -> procedure
|
|
37
|
+
const path = url.pathname.slice(1);
|
|
35
38
|
|
|
36
39
|
await nodeHTTPRequestHandler({
|
|
37
40
|
// FIXME: no typecasting should be needed here
|
package/src/adapters/ws.ts
CHANGED
|
@@ -66,15 +66,20 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
|
|
|
66
66
|
}) & {
|
|
67
67
|
wss: ws.WebSocketServer;
|
|
68
68
|
process?: NodeJS.Process;
|
|
69
|
+
prefix?: string;
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
export function applyWSSHandler<TRouter extends AnyRouter>(
|
|
72
73
|
opts: WSSHandlerOptions<TRouter>,
|
|
73
74
|
) {
|
|
74
|
-
const { wss, createContext, router } = opts;
|
|
75
|
+
const { wss, createContext, router, prefix } = opts;
|
|
75
76
|
|
|
76
77
|
const { transformer } = router._def._config;
|
|
77
78
|
wss.on('connection', async (client, req) => {
|
|
79
|
+
if (prefix && !req.url?.startsWith(prefix)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
const clientSubscriptions = new Map<number | string, Unsubscribable>();
|
|
79
84
|
|
|
80
85
|
function respond(untransformedJSON: TRPCResponseMessage) {
|
|
@@ -2,9 +2,9 @@ import type { inferObservableValue } from '../../observable';
|
|
|
2
2
|
import type { AnyProcedure, inferProcedureInput } from '../procedure';
|
|
3
3
|
import type { AnyRouter, RouterRecord } from '../router';
|
|
4
4
|
import type {
|
|
5
|
-
|
|
5
|
+
AnyClientTypes,
|
|
6
|
+
inferClientTypes,
|
|
6
7
|
InferrableClientTypes,
|
|
7
|
-
inferRootTypes,
|
|
8
8
|
} from './inferrable';
|
|
9
9
|
import type { Serialize } from './serialize';
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ import type { Serialize } from './serialize';
|
|
|
15
15
|
export type inferTransformedProcedureOutput<
|
|
16
16
|
TInferrable extends InferrableClientTypes,
|
|
17
17
|
TProcedure extends AnyProcedure,
|
|
18
|
-
> =
|
|
18
|
+
> = inferClientTypes<TInferrable>['transformer'] extends false
|
|
19
19
|
? Serialize<TProcedure['_def']['_output_out']>
|
|
20
20
|
: TProcedure['_def']['_output_out'];
|
|
21
21
|
/** @internal */
|
|
@@ -23,13 +23,13 @@ export type inferTransformedProcedureOutput<
|
|
|
23
23
|
export type inferTransformedSubscriptionOutput<
|
|
24
24
|
TInferrable extends InferrableClientTypes,
|
|
25
25
|
TProcedure extends AnyProcedure,
|
|
26
|
-
> =
|
|
26
|
+
> = inferClientTypes<TInferrable>['transformer'] extends false
|
|
27
27
|
? Serialize<inferObservableValue<TProcedure['_def']['_output_out']>>
|
|
28
28
|
: inferObservableValue<TProcedure['_def']['_output_out']>;
|
|
29
29
|
|
|
30
30
|
export type GetInferenceHelpers<
|
|
31
31
|
TType extends 'input' | 'output',
|
|
32
|
-
TRoot extends
|
|
32
|
+
TRoot extends AnyClientTypes,
|
|
33
33
|
TRecord extends RouterRecord,
|
|
34
34
|
> = {
|
|
35
35
|
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { AnyRootTypes } from '../rootConfig';
|
|
2
2
|
|
|
3
|
-
export type
|
|
4
|
-
AnyRootTypes,
|
|
5
|
-
'errorShape' | 'transformer'
|
|
6
|
-
>;
|
|
3
|
+
export type AnyClientTypes = Pick<AnyRootTypes, 'errorShape' | 'transformer'>;
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Result of `initTRPC.create()`
|
|
10
7
|
*/
|
|
11
8
|
type InitLike = {
|
|
12
9
|
_config: {
|
|
13
|
-
$types:
|
|
10
|
+
$types: AnyClientTypes;
|
|
14
11
|
};
|
|
15
12
|
};
|
|
16
13
|
|
|
@@ -25,7 +22,7 @@ type RouterLike = {
|
|
|
25
22
|
* Result of `initTRPC.create()._config`
|
|
26
23
|
*/
|
|
27
24
|
type RootConfigLike = {
|
|
28
|
-
$types:
|
|
25
|
+
$types: AnyClientTypes;
|
|
29
26
|
};
|
|
30
27
|
|
|
31
28
|
/**
|
|
@@ -35,13 +32,13 @@ export type InferrableClientTypes =
|
|
|
35
32
|
| RouterLike
|
|
36
33
|
| InitLike
|
|
37
34
|
| RootConfigLike
|
|
38
|
-
|
|
|
35
|
+
| AnyClientTypes;
|
|
39
36
|
|
|
40
37
|
/**
|
|
41
38
|
* Infer the root types from a InferrableClientTypes
|
|
42
39
|
*/
|
|
43
|
-
export type
|
|
44
|
-
TInferrable extends
|
|
40
|
+
export type inferClientTypes<TInferrable extends InferrableClientTypes> =
|
|
41
|
+
TInferrable extends AnyClientTypes
|
|
45
42
|
? TInferrable
|
|
46
43
|
: TInferrable extends RootConfigLike
|
|
47
44
|
? TInferrable['$types']
|
|
@@ -50,6 +47,3 @@ export type inferRootTypes<TInferrable extends InferrableClientTypes> =
|
|
|
50
47
|
: TInferrable extends RouterLike
|
|
51
48
|
? TInferrable['_def']['_config']['$types']
|
|
52
49
|
: never;
|
|
53
|
-
|
|
54
|
-
export type inferErrorShape<TInferrable extends InferrableClientTypes> =
|
|
55
|
-
inferRootTypes<TInferrable>['errorShape'];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { inferObservableValue } from '../observable';
|
|
1
2
|
import { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';
|
|
2
3
|
import type {
|
|
3
4
|
AnyMiddlewareFunction,
|
|
@@ -73,12 +74,15 @@ type ProcedureResolver<
|
|
|
73
74
|
_TMeta,
|
|
74
75
|
TContextOverrides,
|
|
75
76
|
TInputOut,
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
TOutputParserIn,
|
|
78
|
+
$Output,
|
|
78
79
|
> = (opts: {
|
|
79
80
|
ctx: Simplify<Overwrite<TContext, TContextOverrides>>;
|
|
80
81
|
input: TInputOut extends UnsetMarker ? undefined : TInputOut;
|
|
81
|
-
}) => MaybePromise<
|
|
82
|
+
}) => MaybePromise<
|
|
83
|
+
// If an output parser is defined, we need to return what the parser expects, otherwise we return the inferred type
|
|
84
|
+
DefaultValue<TOutputParserIn, $Output>
|
|
85
|
+
>;
|
|
82
86
|
|
|
83
87
|
type AnyResolver = ProcedureResolver<any, any, any, any, any, any>;
|
|
84
88
|
export interface ProcedureBuilder<
|
|
@@ -224,7 +228,7 @@ export interface ProcedureBuilder<
|
|
|
224
228
|
>,
|
|
225
229
|
): SubscriptionProcedure<{
|
|
226
230
|
input: DefaultValue<TInputIn, void>;
|
|
227
|
-
output: DefaultValue<TOutputOut,
|
|
231
|
+
output: DefaultValue<TOutputOut, inferObservableValue<$Output>>;
|
|
228
232
|
}>;
|
|
229
233
|
/**
|
|
230
234
|
* @internal
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Observable } from '../observable';
|
|
1
2
|
import { createRecursiveProxy } from './createProxy';
|
|
2
3
|
import { defaultFormatter } from './error/formatter';
|
|
3
4
|
import { TRPCError } from './error/TRPCError';
|
|
@@ -14,7 +15,11 @@ export interface RouterRecord {
|
|
|
14
15
|
|
|
15
16
|
type DecorateProcedure<TProcedure extends AnyProcedure> = (
|
|
16
17
|
input: inferProcedureInput<TProcedure>,
|
|
17
|
-
) => Promise<
|
|
18
|
+
) => Promise<
|
|
19
|
+
TProcedure['_def']['type'] extends 'subscription'
|
|
20
|
+
? Observable<TProcedure['_def']['_output_out'], TRPCError>
|
|
21
|
+
: TProcedure['_def']['_output_out']
|
|
22
|
+
>;
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* @internal
|