@trpc/server 11.0.0-alpha-tmp-export-from-main.218 → 11.0.0-alpha-tmp-export-from-main-nuke-core.239
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 +7 -0
- package/dist/@trpc/server/http.d.ts.map +1 -0
- package/dist/@trpc/server/index.d.ts +69 -0
- package/dist/@trpc/server/index.d.ts.map +1 -0
- package/dist/@trpc/server/rpc.d.ts +3 -0
- package/dist/@trpc/server/rpc.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +1 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +6 -4
- package/dist/adapters/aws-lambda/index.mjs +4 -2
- package/dist/adapters/aws-lambda/utils.d.ts +2 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +5 -4
- package/dist/adapters/aws-lambda/utils.mjs +3 -2
- package/dist/adapters/express.d.ts +1 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +6 -3
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +4 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +0 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +0 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +6 -4
- package/dist/adapters/fetch/fetchRequestHandler.mjs +4 -2
- package/dist/adapters/fetch/types.d.ts +2 -3
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +1 -3
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +6 -4
- package/dist/adapters/next.mjs +4 -2
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +4 -2
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +3 -1
- package/dist/adapters/node-http/content-type/json/index.js +4 -2
- package/dist/adapters/node-http/content-type/json/index.mjs +3 -1
- package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +6 -4
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +4 -2
- package/dist/adapters/node-http/types.d.ts +3 -4
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +1 -0
- package/dist/adapters/standalone.mjs +1 -0
- package/dist/adapters/ws.d.ts +3 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +33 -26
- package/dist/adapters/ws.mjs +8 -1
- package/dist/bundle-analysis.json +757 -0
- package/dist/http.d.ts +1 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +11 -21
- package/dist/http.mjs +6 -1
- package/dist/index.d.ts +1 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -41
- package/dist/index.mjs +8 -1
- package/dist/observable/index.d.ts +5 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/observable/index.js +13 -0
- package/dist/observable/index.mjs +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/observable/observable.js +126 -0
- package/dist/observable/observable.mjs +122 -0
- package/dist/observable/operators.d.ts +8 -0
- package/dist/observable/operators.d.ts.map +1 -0
- package/dist/observable/operators.js +103 -0
- package/dist/observable/operators.mjs +99 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/rpc.d.ts +1 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +6 -13
- package/dist/rpc.mjs +3 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +6 -9
- package/dist/shared.mjs +4 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +6 -0
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts +19 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +52 -0
- package/dist/unstable-core-do-not-import/createProxy.mjs +49 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +13 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.js +67 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +63 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +33 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/formatter.js +7 -0
- package/dist/unstable-core-do-not-import/error/formatter.mjs +5 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +15 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +31 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +29 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +24 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +32 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +30 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +29 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentType.js +54 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +52 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +5 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +51 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +48 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts +7 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +51 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +295 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +293 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts +96 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.d.ts +37 -0
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.js +48 -0
- package/dist/unstable-core-do-not-import/index.mjs +16 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +96 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/initTRPC.js +95 -0
- package/dist/unstable-core-do-not-import/initTRPC.mjs +93 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts +105 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/middleware.js +95 -0
- package/dist/unstable-core-do-not-import/middleware.mjs +89 -0
- package/dist/unstable-core-do-not-import/parser.d.ts +30 -0
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/parser.js +37 -0
- package/dist/unstable-core-do-not-import/parser.mjs +35 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts +72 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedure.js +9 -0
- package/dist/unstable-core-do-not-import/procedure.mjs +7 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +101 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.js +176 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +173 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +75 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rootConfig.js +8 -0
- package/dist/unstable-core-do-not-import/rootConfig.mjs +6 -0
- package/dist/unstable-core-do-not-import/router.d.ts +85 -0
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/router.js +156 -0
- package/dist/unstable-core-do-not-import/router.mjs +151 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +51 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/codes.js +38 -0
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +35 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +97 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +59 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +57 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts +62 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +107 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.js +107 -0
- package/dist/unstable-core-do-not-import/transformer.mjs +102 -0
- package/dist/unstable-core-do-not-import/types.d.ts +98 -0
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.d.ts +27 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.js +44 -0
- package/dist/unstable-core-do-not-import/utils.mjs +39 -0
- package/package.json +53 -125
- package/src/@trpc/server/http.ts +26 -0
- package/src/@trpc/server/index.ts +105 -0
- package/src/@trpc/server/rpc.ts +26 -0
- package/src/adapters/aws-lambda/index.ts +4 -5
- package/src/adapters/aws-lambda/utils.ts +3 -4
- package/src/adapters/express.ts +1 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +6 -4
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -2
- package/src/adapters/fetch/fetchRequestHandler.ts +6 -4
- package/src/adapters/fetch/types.ts +2 -3
- package/src/adapters/next.ts +2 -4
- package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +6 -4
- package/src/adapters/node-http/types.ts +4 -5
- package/src/adapters/standalone.ts +2 -2
- package/src/adapters/ws.ts +14 -13
- package/src/http.ts +1 -26
- package/src/index.ts +1 -105
- package/src/observable/index.ts +10 -0
- package/src/observable/observable.ts +158 -0
- package/src/observable/operators.ts +119 -0
- package/src/observable/types.ts +76 -0
- package/src/rpc.ts +1 -26
- package/src/shared.ts +1 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +9 -0
- package/src/unstable-core-do-not-import/createProxy.ts +59 -0
- package/src/unstable-core-do-not-import/error/TRPCError.ts +82 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +51 -0
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +36 -0
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +29 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +99 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +57 -0
- package/src/unstable-core-do-not-import/http/index.ts +23 -0
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +458 -0
- package/src/unstable-core-do-not-import/http/types.ts +111 -0
- package/src/unstable-core-do-not-import/index.ts +110 -0
- package/src/unstable-core-do-not-import/initTRPC.ts +206 -0
- package/src/unstable-core-do-not-import/middleware.ts +233 -0
- package/src/unstable-core-do-not-import/parser.ts +94 -0
- package/src/unstable-core-do-not-import/procedure.ts +108 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +458 -0
- package/src/unstable-core-do-not-import/rootConfig.ts +90 -0
- package/src/unstable-core-do-not-import/router.ts +370 -0
- package/src/unstable-core-do-not-import/rpc/codes.ts +44 -0
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +136 -0
- package/src/unstable-core-do-not-import/rpc/index.ts +21 -0
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +85 -0
- package/src/unstable-core-do-not-import/serialize.ts +122 -0
- package/src/unstable-core-do-not-import/transformer.ts +202 -0
- package/src/unstable-core-do-not-import/types.ts +151 -0
- package/src/unstable-core-do-not-import/utils.ts +59 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +0 -10
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +0 -1
- package/dist/@trpc-server/http.d.ts +0 -2
- package/dist/@trpc-server/http.d.ts.map +0 -1
- package/dist/observable.d.ts +0 -3
- package/dist/observable.d.ts.map +0 -1
- package/dist/observable.js +0 -30
- package/dist/observable.mjs +0 -1
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +0 -146
- package/src/@trpc-server/http.ts +0 -2
- package/src/observable.ts +0 -16
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { procedureTypes, type ProcedureType } from '../procedure';
|
|
2
|
+
import type { CombinedDataTransformer } from '../transformer';
|
|
3
|
+
import { isObject } from '../utils';
|
|
4
|
+
import type { TRPCClientOutgoingMessage } from './envelopes';
|
|
5
|
+
|
|
6
|
+
/* istanbul ignore next -- @preserve */
|
|
7
|
+
function assertIsObject(obj: unknown): asserts obj is Record<string, unknown> {
|
|
8
|
+
if (!isObject(obj)) {
|
|
9
|
+
throw new Error('Not an object');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* istanbul ignore next -- @preserve */
|
|
14
|
+
function assertIsProcedureType(obj: unknown): asserts obj is ProcedureType {
|
|
15
|
+
if (!procedureTypes.includes(obj as any)) {
|
|
16
|
+
throw new Error('Invalid procedure type');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* istanbul ignore next -- @preserve */
|
|
21
|
+
function assertIsRequestId(
|
|
22
|
+
obj: unknown,
|
|
23
|
+
): asserts obj is number | string | null {
|
|
24
|
+
if (
|
|
25
|
+
obj !== null &&
|
|
26
|
+
typeof obj === 'number' &&
|
|
27
|
+
isNaN(obj) &&
|
|
28
|
+
typeof obj !== 'string'
|
|
29
|
+
) {
|
|
30
|
+
throw new Error('Invalid request id');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* istanbul ignore next -- @preserve */
|
|
35
|
+
function assertIsString(obj: unknown): asserts obj is string {
|
|
36
|
+
if (typeof obj !== 'string') {
|
|
37
|
+
throw new Error('Invalid string');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* istanbul ignore next -- @preserve */
|
|
42
|
+
function assertIsJSONRPC2OrUndefined(
|
|
43
|
+
obj: unknown,
|
|
44
|
+
): asserts obj is '2.0' | undefined {
|
|
45
|
+
if (typeof obj !== 'undefined' && obj !== '2.0') {
|
|
46
|
+
throw new Error('Must be JSONRPC 2.0');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @public */
|
|
51
|
+
export function parseTRPCMessage(
|
|
52
|
+
obj: unknown,
|
|
53
|
+
transformer: CombinedDataTransformer,
|
|
54
|
+
): TRPCClientOutgoingMessage {
|
|
55
|
+
assertIsObject(obj);
|
|
56
|
+
|
|
57
|
+
const { id, jsonrpc, method, params } = obj;
|
|
58
|
+
assertIsRequestId(id);
|
|
59
|
+
assertIsJSONRPC2OrUndefined(jsonrpc);
|
|
60
|
+
|
|
61
|
+
if (method === 'subscription.stop') {
|
|
62
|
+
return {
|
|
63
|
+
id,
|
|
64
|
+
jsonrpc,
|
|
65
|
+
method,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
assertIsProcedureType(method);
|
|
69
|
+
assertIsObject(params);
|
|
70
|
+
const { input: rawInput, path } = params;
|
|
71
|
+
|
|
72
|
+
assertIsString(path);
|
|
73
|
+
|
|
74
|
+
const input = transformer.input.deserialize(rawInput);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
id,
|
|
78
|
+
jsonrpc,
|
|
79
|
+
method,
|
|
80
|
+
params: {
|
|
81
|
+
input,
|
|
82
|
+
path,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { Simplify, WithoutIndexSignature } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @link https://github.com/remix-run/remix/blob/2248669ed59fd716e267ea41df5d665d4781f4a9/packages/remix-server-runtime/serialize.ts
|
|
6
|
+
*/
|
|
7
|
+
type JsonPrimitive = boolean | number | string | null;
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
9
|
+
type NonJsonPrimitive = Function | symbol | undefined;
|
|
10
|
+
/*
|
|
11
|
+
* `any` is the only type that can let you equate `0` with `1`
|
|
12
|
+
* See https://stackoverflow.com/a/49928360/1490091
|
|
13
|
+
*/
|
|
14
|
+
type IsAny<T> = 0 extends T & 1 ? true : false;
|
|
15
|
+
|
|
16
|
+
// `undefined` is a weird one that's technically not valid JSON,
|
|
17
|
+
// but the return value of `JSON.parse` can be `undefined` so we
|
|
18
|
+
// support it as both a Primitive and a NonJsonPrimitive
|
|
19
|
+
type JsonReturnable = JsonPrimitive | undefined;
|
|
20
|
+
|
|
21
|
+
type IsRecord<T extends object> = keyof WithoutIndexSignature<T> extends never
|
|
22
|
+
? true
|
|
23
|
+
: false;
|
|
24
|
+
|
|
25
|
+
/* prettier-ignore */
|
|
26
|
+
export type Serialize<T> =
|
|
27
|
+
IsAny<T> extends true ? any :
|
|
28
|
+
unknown extends T ? unknown :
|
|
29
|
+
T extends JsonReturnable ? T :
|
|
30
|
+
T extends Map<any, any> | Set<any> ? object :
|
|
31
|
+
T extends NonJsonPrimitive ? never :
|
|
32
|
+
T extends { toJSON(): infer U } ? U :
|
|
33
|
+
T extends [] ? [] :
|
|
34
|
+
T extends [unknown, ...unknown[]] ? SerializeTuple<T> :
|
|
35
|
+
T extends readonly (infer U)[] ? (U extends NonJsonPrimitive ? null : Serialize<U>)[] :
|
|
36
|
+
T extends object ?
|
|
37
|
+
IsRecord<T> extends true ? Record<keyof T, Serialize<T[keyof T]>> :
|
|
38
|
+
Simplify<SerializeObject<UndefinedToOptional<T>>> :
|
|
39
|
+
never;
|
|
40
|
+
|
|
41
|
+
/** JSON serialize [tuples](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) */
|
|
42
|
+
type SerializeTuple<T extends [unknown, ...unknown[]]> = {
|
|
43
|
+
[K in keyof T]: T[K] extends NonJsonPrimitive ? null : Serialize<T[K]>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// prettier-ignore
|
|
47
|
+
type SerializeObjectKey<T extends Record<any, any>, K> =
|
|
48
|
+
// never include entries where the key is a symbol
|
|
49
|
+
K extends symbol ? never :
|
|
50
|
+
// always include entries where the value is any
|
|
51
|
+
IsAny<T[K]> extends true ? K :
|
|
52
|
+
// always include entries where the value is unknown
|
|
53
|
+
unknown extends T[K] ? K :
|
|
54
|
+
// never include entries where the value is a non-JSON primitive
|
|
55
|
+
T[K] extends NonJsonPrimitive ? never :
|
|
56
|
+
// otherwise serialize the value
|
|
57
|
+
K;
|
|
58
|
+
/**
|
|
59
|
+
* JSON serialize objects (not including arrays) and classes
|
|
60
|
+
* @internal
|
|
61
|
+
**/
|
|
62
|
+
export type SerializeObject<T extends object> = {
|
|
63
|
+
[K in keyof T as SerializeObjectKey<T, K>]: Serialize<T[K]>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Extract keys from T where the value dosen't extend undefined
|
|
68
|
+
* Note: Can't parse IndexSignature or Record types
|
|
69
|
+
*/
|
|
70
|
+
type FilterDefinedKeys<T extends object> = Exclude<
|
|
71
|
+
{
|
|
72
|
+
[K in keyof T]: undefined extends T[K] ? never : K;
|
|
73
|
+
}[keyof T],
|
|
74
|
+
undefined
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get value of exactOptionalPropertyTypes config
|
|
79
|
+
*/
|
|
80
|
+
type ExactOptionalPropertyTypes = { a?: 0 | undefined } extends {
|
|
81
|
+
a?: 0;
|
|
82
|
+
}
|
|
83
|
+
? false
|
|
84
|
+
: true;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check if T has an index signature
|
|
88
|
+
*/
|
|
89
|
+
type HasIndexSignature<T extends object> = string extends keyof T
|
|
90
|
+
? true
|
|
91
|
+
: false;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* { [key: string]: number | undefined } --> { [key: string]: number }
|
|
95
|
+
*/
|
|
96
|
+
type HandleIndexSignature<T extends object> = {
|
|
97
|
+
[K in keyof Omit<T, keyof WithoutIndexSignature<T>>]: Exclude<
|
|
98
|
+
T[K],
|
|
99
|
+
undefined
|
|
100
|
+
>;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* { a: number | undefined } --> { a?: number }
|
|
105
|
+
* Note: Can't parse IndexSignature or Record types
|
|
106
|
+
*/
|
|
107
|
+
type HandleUndefined<T extends object> = {
|
|
108
|
+
[K in keyof Omit<T, FilterDefinedKeys<T>>]?: Exclude<T[K], undefined>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Handle undefined, index signature and records
|
|
113
|
+
*/
|
|
114
|
+
type UndefinedToOptional<T extends object> =
|
|
115
|
+
// Property is not a union with `undefined`, keep as-is
|
|
116
|
+
Pick<WithoutIndexSignature<T>, FilterDefinedKeys<WithoutIndexSignature<T>>> &
|
|
117
|
+
// If following is true, don't merge undefined or optional into index signature if any in T
|
|
118
|
+
(ExactOptionalPropertyTypes extends true
|
|
119
|
+
? HandleIndexSignature<T> & HandleUndefined<WithoutIndexSignature<T>>
|
|
120
|
+
: HasIndexSignature<T> extends true
|
|
121
|
+
? HandleIndexSignature<T>
|
|
122
|
+
: HandleUndefined<T>);
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { AnyRootConfig } from './rootConfig';
|
|
2
|
+
import type { AnyRouter, inferRouterError } from './router';
|
|
3
|
+
import type {
|
|
4
|
+
TRPCResponse,
|
|
5
|
+
TRPCResponseMessage,
|
|
6
|
+
TRPCResultMessage,
|
|
7
|
+
} from './rpc';
|
|
8
|
+
import { isObject } from './utils';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface DataTransformer {
|
|
14
|
+
serialize: (object: any) => any;
|
|
15
|
+
deserialize: (object: any) => any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface InputDataTransformer extends DataTransformer {
|
|
19
|
+
/**
|
|
20
|
+
* This function runs **on the client** before sending the data to the server.
|
|
21
|
+
*/
|
|
22
|
+
serialize: (object: any) => any;
|
|
23
|
+
/**
|
|
24
|
+
* This function runs **on the server** to transform the data before it is passed to the resolver
|
|
25
|
+
*/
|
|
26
|
+
deserialize: (object: any) => any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface OutputDataTransformer extends DataTransformer {
|
|
30
|
+
/**
|
|
31
|
+
* This function runs **on the server** before sending the data to the client.
|
|
32
|
+
*/
|
|
33
|
+
serialize: (object: any) => any;
|
|
34
|
+
/**
|
|
35
|
+
* This function runs **only on the client** to transform the data sent from the server.
|
|
36
|
+
*/
|
|
37
|
+
deserialize: (object: any) => any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export interface CombinedDataTransformer {
|
|
44
|
+
/**
|
|
45
|
+
* Specify how the data sent from the client to the server should be transformed.
|
|
46
|
+
*/
|
|
47
|
+
input: InputDataTransformer;
|
|
48
|
+
/**
|
|
49
|
+
* Specify how the data sent from the server to the client should be transformed.
|
|
50
|
+
*/
|
|
51
|
+
output: OutputDataTransformer;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export type CombinedDataTransformerClient = {
|
|
58
|
+
input: Pick<CombinedDataTransformer['input'], 'serialize'>;
|
|
59
|
+
output: Pick<CombinedDataTransformer['output'], 'deserialize'>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export type DataTransformerOptions = CombinedDataTransformer | DataTransformer;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export function getDataTransformer(
|
|
71
|
+
transformer: DataTransformerOptions,
|
|
72
|
+
): CombinedDataTransformer {
|
|
73
|
+
if ('input' in transformer) {
|
|
74
|
+
return transformer;
|
|
75
|
+
}
|
|
76
|
+
return { input: transformer, output: transformer };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export type DefaultDataTransformer = CombinedDataTransformer & {
|
|
83
|
+
_default: true;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
export const defaultTransformer: DefaultDataTransformer = {
|
|
90
|
+
_default: true,
|
|
91
|
+
input: { serialize: (obj) => obj, deserialize: (obj) => obj },
|
|
92
|
+
output: { serialize: (obj) => obj, deserialize: (obj) => obj },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function transformTRPCResponseItem<
|
|
96
|
+
TResponseItem extends TRPCResponse | TRPCResponseMessage,
|
|
97
|
+
>(config: AnyRootConfig, item: TResponseItem): TResponseItem {
|
|
98
|
+
if ('error' in item) {
|
|
99
|
+
return {
|
|
100
|
+
...item,
|
|
101
|
+
error: config.transformer.output.serialize(item.error),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if ('data' in item.result) {
|
|
106
|
+
return {
|
|
107
|
+
...item,
|
|
108
|
+
result: {
|
|
109
|
+
...item.result,
|
|
110
|
+
data: config.transformer.output.serialize(item.result.data),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return item;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
120
|
+
**/
|
|
121
|
+
export function transformTRPCResponse<
|
|
122
|
+
TResponse extends
|
|
123
|
+
| TRPCResponse
|
|
124
|
+
| TRPCResponse[]
|
|
125
|
+
| TRPCResponseMessage
|
|
126
|
+
| TRPCResponseMessage[],
|
|
127
|
+
>(config: AnyRootConfig, itemOrItems: TResponse) {
|
|
128
|
+
return Array.isArray(itemOrItems)
|
|
129
|
+
? itemOrItems.map((item) => transformTRPCResponseItem(config, item))
|
|
130
|
+
: transformTRPCResponseItem(config, itemOrItems);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// FIXME:
|
|
134
|
+
// - the generics here are probably unnecessary
|
|
135
|
+
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
136
|
+
/** @internal */
|
|
137
|
+
function transformResultInner<TRouter extends AnyRouter, TOutput>(
|
|
138
|
+
response:
|
|
139
|
+
| TRPCResponse<TOutput, inferRouterError<TRouter>>
|
|
140
|
+
| TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,
|
|
141
|
+
transformer: DataTransformer,
|
|
142
|
+
) {
|
|
143
|
+
if ('error' in response) {
|
|
144
|
+
const error = transformer.deserialize(
|
|
145
|
+
response.error,
|
|
146
|
+
) as inferRouterError<TRouter>;
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
error: {
|
|
150
|
+
...response,
|
|
151
|
+
error,
|
|
152
|
+
},
|
|
153
|
+
} as const;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const result = {
|
|
157
|
+
...response.result,
|
|
158
|
+
...((!response.result.type || response.result.type === 'data') && {
|
|
159
|
+
type: 'data',
|
|
160
|
+
data: transformer.deserialize(response.result.data),
|
|
161
|
+
}),
|
|
162
|
+
} as TRPCResultMessage<TOutput>['result'];
|
|
163
|
+
return { ok: true, result } as const;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class TransformResultError extends Error {
|
|
167
|
+
constructor() {
|
|
168
|
+
super('Unable to transform response from server');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Transforms and validates that the result is a valid TRPCResponse
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export function transformResult<TRouter extends AnyRouter, TOutput>(
|
|
177
|
+
response:
|
|
178
|
+
| TRPCResponse<TOutput, inferRouterError<TRouter>>
|
|
179
|
+
| TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,
|
|
180
|
+
transformer: DataTransformer,
|
|
181
|
+
): ReturnType<typeof transformResultInner> {
|
|
182
|
+
let result: ReturnType<typeof transformResultInner>;
|
|
183
|
+
try {
|
|
184
|
+
// Use the data transformers on the JSON-response
|
|
185
|
+
result = transformResultInner(response, transformer);
|
|
186
|
+
} catch (err) {
|
|
187
|
+
throw new TransformResultError();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// check that output of the transformers is a valid TRPCResponse
|
|
191
|
+
if (
|
|
192
|
+
!result.ok &&
|
|
193
|
+
(!isObject(result.error.error) ||
|
|
194
|
+
typeof result.error.error['code'] !== 'number')
|
|
195
|
+
) {
|
|
196
|
+
throw new TransformResultError();
|
|
197
|
+
}
|
|
198
|
+
if (result.ok && !isObject(result.result)) {
|
|
199
|
+
throw new TransformResultError();
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ================================
|
|
3
|
+
* Useful utility types that doesn't have anything to do with tRPC in particular
|
|
4
|
+
* ================================
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type Maybe<TType> = TType | null | undefined;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @link https://github.com/ianstormtaylor/superstruct/blob/7973400cd04d8ad92bbdc2b6f35acbfb3c934079/src/utils.ts#L323-L325
|
|
15
|
+
*/
|
|
16
|
+
export type Simplify<TType> = TType extends any[] | Date
|
|
17
|
+
? TType
|
|
18
|
+
: { [K in keyof TType]: TType[K] };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export type Dict<TType> = Record<string, TType | undefined>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export type MaybePromise<TType> = Promise<TType> | TType;
|
|
29
|
+
|
|
30
|
+
export type FilterKeys<TObj extends object, TFilter> = {
|
|
31
|
+
[TKey in keyof TObj]: TObj[TKey] extends TFilter ? TKey : never;
|
|
32
|
+
}[keyof TObj];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export type Filter<TObj extends object, TFilter> = Pick<
|
|
38
|
+
TObj,
|
|
39
|
+
FilterKeys<TObj, TFilter>
|
|
40
|
+
>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Unwrap return type if the type is a function (sync or async), else use the type as is
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export type Unwrap<TType> = TType extends (...args: any[]) => infer R
|
|
47
|
+
? Awaited<R>
|
|
48
|
+
: TType;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Makes the object recursively optional
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export type DeepPartial<TObject> = TObject extends object
|
|
55
|
+
? {
|
|
56
|
+
[P in keyof TObject]?: DeepPartial<TObject[P]>;
|
|
57
|
+
}
|
|
58
|
+
: TObject;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Omits the key without removing a potential union
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export type DistributiveOmit<TObj, TKey extends keyof any> = TObj extends any
|
|
65
|
+
? Omit<TObj, TKey>
|
|
66
|
+
: never;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* See https://github.com/microsoft/TypeScript/issues/41966#issuecomment-758187996
|
|
70
|
+
* Fixes issues with iterating over keys of objects with index signatures.
|
|
71
|
+
* Without this, iterations over keys of objects with index signatures will lose
|
|
72
|
+
* type information about the keys and only the index signature will remain.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export type WithoutIndexSignature<TObj> = {
|
|
76
|
+
[K in keyof TObj as string extends K
|
|
77
|
+
? never
|
|
78
|
+
: number extends K
|
|
79
|
+
? never
|
|
80
|
+
: K]: TObj[K];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
* Overwrite properties in `TType` with properties in `TWith`
|
|
86
|
+
* Only overwrites properties when the type to be overwritten
|
|
87
|
+
* is an object. Otherwise it will just use the type from `TWith`.
|
|
88
|
+
*/
|
|
89
|
+
export type Overwrite<TType, TWith> = TWith extends any
|
|
90
|
+
? TType extends object
|
|
91
|
+
? {
|
|
92
|
+
[K in // Exclude index signature from keys
|
|
93
|
+
| keyof WithoutIndexSignature<TType>
|
|
94
|
+
| keyof WithoutIndexSignature<TWith>]: K extends keyof TWith
|
|
95
|
+
? TWith[K]
|
|
96
|
+
: K extends keyof TType
|
|
97
|
+
? TType[K]
|
|
98
|
+
: never;
|
|
99
|
+
} & (string extends keyof TWith // Handle cases with an index signature
|
|
100
|
+
? { [key: string]: TWith[string] }
|
|
101
|
+
: number extends keyof TWith
|
|
102
|
+
? { [key: number]: TWith[number] }
|
|
103
|
+
: // eslint-disable-next-line @typescript-eslint/ban-types
|
|
104
|
+
{})
|
|
105
|
+
: TWith
|
|
106
|
+
: never;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
export type ValidateShape<TActualShape, TExpectedShape> =
|
|
112
|
+
TActualShape extends TExpectedShape
|
|
113
|
+
? Exclude<keyof TActualShape, keyof TExpectedShape> extends never
|
|
114
|
+
? TActualShape
|
|
115
|
+
: TExpectedShape
|
|
116
|
+
: never;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export type PickFirstDefined<TType, TPick> = undefined extends TType
|
|
122
|
+
? undefined extends TPick
|
|
123
|
+
? never
|
|
124
|
+
: TPick
|
|
125
|
+
: TType;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* ================================
|
|
129
|
+
* tRPC specific types
|
|
130
|
+
* ================================
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export type IntersectionError<TKey extends string> =
|
|
137
|
+
`The property '${TKey}' in your router collides with a built-in method, rename this router or procedure on your backend.`;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export type ProtectedIntersection<TType, TWith> = keyof TType &
|
|
143
|
+
keyof TWith extends never
|
|
144
|
+
? TType & TWith
|
|
145
|
+
: IntersectionError<string & keyof TType & keyof TWith>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
* Returns the raw input type of a procedure
|
|
150
|
+
*/
|
|
151
|
+
export type GetRawInputFn = () => Promise<unknown>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
|
|
2
|
+
[K in keyof TType]: TValue extends TType[K] ? K : never;
|
|
3
|
+
}[keyof TType];
|
|
4
|
+
|
|
5
|
+
type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
|
|
6
|
+
[TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function invert<TRecord extends Record<PropertyKey, PropertyKey>>(
|
|
12
|
+
obj: TRecord,
|
|
13
|
+
): Invert<TRecord> {
|
|
14
|
+
const newObj = Object.create(null);
|
|
15
|
+
for (const key in obj) {
|
|
16
|
+
const v = obj[key];
|
|
17
|
+
newObj[v] = key;
|
|
18
|
+
}
|
|
19
|
+
return newObj;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Ensures there are no duplicate keys when building a procedure.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export function mergeWithoutOverrides<TType extends Record<string, unknown>>(
|
|
27
|
+
obj1: TType,
|
|
28
|
+
...objs: Partial<TType>[]
|
|
29
|
+
): TType {
|
|
30
|
+
const newObj: TType = Object.assign(Object.create(null), obj1);
|
|
31
|
+
|
|
32
|
+
for (const overrides of objs) {
|
|
33
|
+
for (const key in overrides) {
|
|
34
|
+
if (key in newObj && newObj[key] !== overrides[key]) {
|
|
35
|
+
throw new Error(`Duplicate key ${key}`);
|
|
36
|
+
}
|
|
37
|
+
newObj[key as keyof TType] = overrides[key] as TType[keyof TType];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return newObj;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check that value is object
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export function isObject(value: unknown): value is Record<string, unknown> {
|
|
48
|
+
return !!value && !Array.isArray(value) && typeof value === 'object';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create an object without inheriting anything from `Object.prototype`
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export function omitPrototype<TObj extends Record<string, unknown>>(
|
|
56
|
+
obj: TObj,
|
|
57
|
+
): TObj {
|
|
58
|
+
return Object.assign(Object.create(null), obj);
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/unstable-core-do-not-import';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/unstable-core-do-not-import');
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is here to make TypeScript happy and prevent _"The inferred type of 'createContext' cannot be named without a reference to [...]"_.
|
|
3
|
-
*
|
|
4
|
-
* We're basically just re-exporting everything from @trpc/core here.
|
|
5
|
-
*
|
|
6
|
-
* If you need to import anything from here, please open an issue at https://github.com/trpc/trpc/issues
|
|
7
|
-
*/
|
|
8
|
-
export type { AnyMiddlewareFunction, AnyRouter, AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRootConfig, AnyRouterDef, AnySubscriptionProcedure, BaseContentTypeHandler, BaseHandlerOptions, BodyResult, CombinedDataTransformer, CombinedDataTransformerClient, CreateRouterInner, DataTransformer, DataTransformerOptions, DeepPartial, DefaultDataTransformer, DefaultErrorData, DefaultErrorShape, Dict, DistributiveOmit, Filter, FilterKeys, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse, IntersectionError, JSONRPC2, Maybe, MaybePromise, MiddlewareBuilder, MiddlewareFunction, MutationProcedure, Observable, Observer, OnErrorFunction, Overwrite, PickFirstDefined, Procedure, ProcedureArgs, ProcedureBuilder, ProcedureCall, ProcedureOptions, ProcedureRecord, ProcedureRouterRecord, ProcedureType, ProtectedIntersection, QueryProcedure, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, RootConfig, Router, RouterCaller, Serialize, SerializeObject, Simplify, SubscriptionProcedure, TRPCClientIncomingMessage, TRPCClientIncomingRequest, TRPCClientOutgoingMessage, TRPCClientOutgoingRequest, TRPCErrorResponse, TRPCErrorShape, TRPCInferrable, TRPCReconnectNotification, TRPCRequest, TRPCRequestInfo, TRPCRequestMessage, TRPCResponse, TRPCResponseMessage, TRPCResult, TRPCResultMessage, TRPCSubscriptionStopNotification, TRPCSuccessResponse, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER, TeardownLogic, Unsubscribable, UnsubscribeFn, Unwrap, ValidateShape, WithoutIndexSignature, inferErrorShape, inferHandlerInput, inferObservableValue, inferParser, inferProcedureInput, inferProcedureOutput, inferProcedureParams, inferRouterContext, inferRouterError, inferRouterInputs, inferRouterMeta, inferRouterOutputs, inferTransformedProcedureOutput, inferTransformedSubscriptionOutput, } from '@trpc/core';
|
|
9
|
-
export { TRPCError, TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER, callProcedure, createBuilder, createFlatProxy, createInputMiddleware, createOutputMiddleware, createRecursiveProxy, createRouterFactory, experimental_standaloneMiddleware, getBatchStreamFormatter, getCauseFromUnknown, getErrorShape, getHTTPStatusCode, getHTTPStatusCodeFromError, getJsonContentTypeInputs, getTRPCErrorFromUnknown, initTRPC, isObject, isObservable, map, mergeRouters, middlewareMarker, observable, observableToPromise, parseTRPCMessage, procedureTypes, resolveHTTPResponse, share, tap, transformResult, transformTRPCResponse, unsetMarker, } from '@trpc/core';
|
|
10
|
-
//# sourceMappingURL=@trpc-core-unstable-do-not-import-this-please.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"@trpc-core-unstable-do-not-import-this-please.d.ts","sourceRoot":"","sources":["../src/@trpc-core-unstable-do-not-import-this-please.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACV,MAAM,EACN,YAAY,EACZ,SAAS,EACT,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,aAAa,EACb,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,EACjC,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,GAAG,EACH,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,eAAe,EACf,qBAAqB,EACrB,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/@trpc-server/http.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC"}
|
package/dist/observable.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export type { Observable, Observer, TeardownLogic, Unsubscribable, UnsubscribeFn, inferObservableValue, } from './@trpc-core-unstable-do-not-import-this-please';
|
|
2
|
-
export { isObservable, map, observable, observableToPromise, share, tap, } from './@trpc-core-unstable-do-not-import-this-please';
|
|
3
|
-
//# sourceMappingURL=observable.d.ts.map
|
package/dist/observable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../src/observable.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,GAAG,EACH,UAAU,EACV,mBAAmB,EACnB,KAAK,EACL,GAAG,GACJ,MAAM,iDAAiD,CAAC"}
|
package/dist/observable.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@trpc/core');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "isObservable", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return core.isObservable; }
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, "map", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return core.map; }
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "observable", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return core.observable; }
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "observableToPromise", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () { return core.observableToPromise; }
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, "share", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return core.share; }
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "tap", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return core.tap; }
|
|
30
|
-
});
|