@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.239 → 11.0.0-alpha-tmp-export-from-main.219
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 +2 -0
- package/dist/@trpc-server/http.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +2 -1
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +4 -6
- package/dist/adapters/aws-lambda/index.mjs +2 -4
- package/dist/adapters/aws-lambda/utils.d.ts +3 -2
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +4 -5
- package/dist/adapters/aws-lambda/utils.mjs +2 -3
- package/dist/adapters/express.d.ts +2 -1
- 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 +3 -6
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +1 -4
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +2 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +4 -6
- package/dist/adapters/fetch/fetchRequestHandler.mjs +2 -4
- package/dist/adapters/fetch/types.d.ts +3 -2
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +3 -1
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +4 -6
- package/dist/adapters/next.mjs +2 -4
- 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 +2 -4
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +1 -3
- package/dist/adapters/node-http/content-type/json/index.js +2 -4
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
- 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 +2 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +4 -6
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -4
- package/dist/adapters/node-http/types.d.ts +4 -3
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +2 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +0 -1
- package/dist/adapters/standalone.mjs +0 -1
- package/dist/adapters/ws.d.ts +2 -3
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -33
- package/dist/adapters/ws.mjs +1 -8
- package/dist/http.d.ts +6 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -11
- package/dist/http.mjs +1 -6
- package/dist/index.d.ts +68 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -18
- package/dist/index.mjs +1 -8
- package/dist/observable.d.ts +3 -0
- package/dist/observable.d.ts.map +1 -0
- package/dist/observable.js +30 -0
- package/dist/observable.mjs +1 -0
- package/dist/rpc.d.ts +2 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -6
- package/dist/rpc.mjs +1 -3
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +9 -6
- package/dist/shared.mjs +1 -4
- package/dist/unstableDontImportMe.d.ts +10 -0
- package/dist/unstableDontImportMe.d.ts.map +1 -0
- package/dist/unstableDontImportMe.js +142 -0
- package/dist/unstableDontImportMe.mjs +1 -0
- package/package.json +135 -52
- package/src/@trpc-server/http.ts +2 -0
- package/src/adapters/aws-lambda/index.ts +5 -4
- package/src/adapters/aws-lambda/utils.ts +4 -3
- package/src/adapters/express.ts +3 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +4 -6
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +2 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +4 -6
- package/src/adapters/fetch/types.ts +3 -2
- package/src/adapters/next.ts +4 -2
- 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 +4 -6
- package/src/adapters/node-http/types.ts +5 -4
- package/src/adapters/standalone.ts +2 -2
- package/src/adapters/ws.ts +13 -14
- package/src/http.ts +26 -1
- package/src/index.ts +105 -1
- package/src/observable.ts +16 -0
- package/src/rpc.ts +26 -1
- package/src/shared.ts +1 -1
- package/src/unstableDontImportMe.ts +146 -0
- package/unstableDontImportMe/index.d.ts +1 -0
- package/unstableDontImportMe/index.js +1 -0
- package/dist/@trpc/server/http.d.ts +0 -7
- package/dist/@trpc/server/http.d.ts.map +0 -1
- package/dist/@trpc/server/index.d.ts +0 -69
- package/dist/@trpc/server/index.d.ts.map +0 -1
- package/dist/@trpc/server/rpc.d.ts +0 -3
- package/dist/@trpc/server/rpc.d.ts.map +0 -1
- package/dist/bundle-analysis.json +0 -757
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -13
- package/dist/observable/index.mjs +0 -2
- package/dist/observable/observable.d.ts +0 -13
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/observable.js +0 -126
- package/dist/observable/observable.mjs +0 -122
- package/dist/observable/operators.d.ts +0 -8
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/operators.js +0 -103
- package/dist/observable/operators.mjs +0 -99
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.js +0 -52
- package/dist/unstable-core-do-not-import/createProxy.mjs +0 -49
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +0 -67
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +0 -63
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +0 -7
- package/dist/unstable-core-do-not-import/error/formatter.mjs +0 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +0 -31
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +0 -29
- 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/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +0 -54
- package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -52
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +0 -51
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +0 -48
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +0 -295
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +0 -293
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -37
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -48
- package/dist/unstable-core-do-not-import/index.mjs +0 -16
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +0 -95
- package/dist/unstable-core-do-not-import/initTRPC.mjs +0 -93
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.js +0 -95
- package/dist/unstable-core-do-not-import/middleware.mjs +0 -89
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.js +0 -37
- package/dist/unstable-core-do-not-import/parser.mjs +0 -35
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.js +0 -9
- package/dist/unstable-core-do-not-import/procedure.mjs +0 -7
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -176
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +0 -173
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.js +0 -8
- package/dist/unstable-core-do-not-import/rootConfig.mjs +0 -6
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.js +0 -156
- package/dist/unstable-core-do-not-import/router.mjs +0 -151
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.js +0 -38
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +0 -35
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +0 -59
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +0 -57
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.js +0 -107
- package/dist/unstable-core-do-not-import/transformer.mjs +0 -102
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -27
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.js +0 -44
- package/dist/unstable-core-do-not-import/utils.mjs +0 -39
- package/src/@trpc/server/http.ts +0 -26
- package/src/@trpc/server/index.ts +0 -105
- package/src/@trpc/server/rpc.ts +0 -26
- package/src/observable/index.ts +0 -10
- package/src/observable/observable.ts +0 -158
- package/src/observable/operators.ts +0 -119
- package/src/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -110
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -59
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
TRPCError,
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated use `experimental_trpcMiddleware` instead
|
|
5
|
-
*/
|
|
6
|
-
experimental_standaloneMiddleware,
|
|
7
|
-
experimental_standaloneMiddleware as experimental_trpcMiddleware,
|
|
8
|
-
initTRPC,
|
|
9
|
-
// --- FIXME a bunch of these exports are only useful for plugins - move them somewhere else? ----
|
|
10
|
-
callProcedure as callTRPCProcedure,
|
|
11
|
-
getTRPCErrorFromUnknown,
|
|
12
|
-
transformTRPCResponse,
|
|
13
|
-
createFlatProxy as createTRPCFlatProxy,
|
|
14
|
-
type inferProcedureInput,
|
|
15
|
-
type inferProcedureOutput,
|
|
16
|
-
type inferRouterError,
|
|
17
|
-
type inferRouterInputs,
|
|
18
|
-
type inferRouterOutputs,
|
|
19
|
-
type inferRouterContext,
|
|
20
|
-
type inferTransformedProcedureOutput,
|
|
21
|
-
type inferTransformedSubscriptionOutput,
|
|
22
|
-
type AnyProcedure as AnyTRPCProcedure,
|
|
23
|
-
type AnyRouter as AnyTRPCRouter,
|
|
24
|
-
type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction,
|
|
25
|
-
type CombinedDataTransformer as TRPCCombinedDataTransformer,
|
|
26
|
-
type ProcedureType as TRPCProcedureType,
|
|
27
|
-
type AnyMutationProcedure as AnyTRPCMutationProcedure,
|
|
28
|
-
type AnyQueryProcedure as AnyTRPCQueryProcedure,
|
|
29
|
-
type ProcedureRouterRecord as TRPCProcedureRouterRecord,
|
|
30
|
-
type ProcedureArgs as TRPCProcedureArgs,
|
|
31
|
-
type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure,
|
|
32
|
-
} from '../../unstable-core-do-not-import';
|
|
33
|
-
|
|
34
|
-
export type {
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated use `AnyTRPCProcedure` instead
|
|
37
|
-
*/
|
|
38
|
-
AnyProcedure,
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated use `AnyTRPCRouter` instead
|
|
41
|
-
*/
|
|
42
|
-
AnyRouter,
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use `AnyTRPCMiddlewareFunction` instead
|
|
45
|
-
*/
|
|
46
|
-
AnyMiddlewareFunction,
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated use `TRPCCombinedDataTransformer` instead
|
|
49
|
-
*/
|
|
50
|
-
CombinedDataTransformer,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated This is a utility type will be removed in v12
|
|
54
|
-
*/
|
|
55
|
-
Dict,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated This is a utility type will be removed in v12
|
|
59
|
-
*/
|
|
60
|
-
DeepPartial,
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated use `TRPCProcedureType` instead
|
|
63
|
-
*/
|
|
64
|
-
ProcedureType,
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated use `AnyTRPCMutationProcedure` instead
|
|
67
|
-
*/
|
|
68
|
-
AnyMutationProcedure,
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated use `AnyTRPCQueryProcedure` instead
|
|
72
|
-
*/
|
|
73
|
-
AnyQueryProcedure,
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated use `TRPCProcedureRouterRecord` instead
|
|
76
|
-
*/
|
|
77
|
-
ProcedureRouterRecord,
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated use `TRPCProcedureArgs` instead
|
|
80
|
-
*/
|
|
81
|
-
ProcedureArgs,
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated use `AnyTRPCSubscriptionProcedure` instead
|
|
84
|
-
*/
|
|
85
|
-
AnySubscriptionProcedure,
|
|
86
|
-
} from '../../unstable-core-do-not-import';
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated use `getTRPCErrorShape` instead
|
|
91
|
-
*/
|
|
92
|
-
getErrorShape,
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated use `callTRPCProcedure` instead
|
|
96
|
-
*/
|
|
97
|
-
callProcedure,
|
|
98
|
-
} from '../../unstable-core-do-not-import';
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated
|
|
102
|
-
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
103
|
-
*/
|
|
104
|
-
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
|
|
105
|
-
Awaited<ReturnType<TFunction>>;
|
package/src/@trpc/server/rpc.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Note: this should likely be moved to a sort of `@trpc/plugin` package
|
|
2
|
-
export type {
|
|
3
|
-
JSONRPC2,
|
|
4
|
-
TRPCClientIncomingMessage,
|
|
5
|
-
TRPCClientIncomingRequest,
|
|
6
|
-
TRPCClientOutgoingMessage,
|
|
7
|
-
TRPCClientOutgoingRequest,
|
|
8
|
-
TRPCErrorResponse,
|
|
9
|
-
TRPCErrorShape,
|
|
10
|
-
TRPCReconnectNotification,
|
|
11
|
-
TRPCRequest,
|
|
12
|
-
TRPCRequestMessage,
|
|
13
|
-
TRPCResponse,
|
|
14
|
-
TRPCResponseMessage,
|
|
15
|
-
TRPCResult,
|
|
16
|
-
TRPCResultMessage,
|
|
17
|
-
TRPCSubscriptionStopNotification,
|
|
18
|
-
TRPCSuccessResponse,
|
|
19
|
-
TRPC_ERROR_CODE_KEY,
|
|
20
|
-
TRPC_ERROR_CODE_NUMBER,
|
|
21
|
-
} from '../../unstable-core-do-not-import';
|
|
22
|
-
export {
|
|
23
|
-
TRPC_ERROR_CODES_BY_KEY,
|
|
24
|
-
TRPC_ERROR_CODES_BY_NUMBER,
|
|
25
|
-
parseTRPCMessage,
|
|
26
|
-
} from '../../unstable-core-do-not-import';
|
package/src/observable/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type { inferObservableValue } from './observable';
|
|
2
|
-
export { isObservable, observable, observableToPromise } from './observable';
|
|
3
|
-
export { map, share, tap } from './operators';
|
|
4
|
-
export type {
|
|
5
|
-
Observable,
|
|
6
|
-
Observer,
|
|
7
|
-
TeardownLogic,
|
|
8
|
-
Unsubscribable,
|
|
9
|
-
UnsubscribeFn,
|
|
10
|
-
} from './types';
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Observable,
|
|
3
|
-
Observer,
|
|
4
|
-
OperatorFunction,
|
|
5
|
-
TeardownLogic,
|
|
6
|
-
UnaryFunction,
|
|
7
|
-
} from './types';
|
|
8
|
-
|
|
9
|
-
function identity<TType>(x: TType): TType {
|
|
10
|
-
return x;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** @public */
|
|
14
|
-
export type inferObservableValue<TObservable> = TObservable extends Observable<
|
|
15
|
-
infer TValue,
|
|
16
|
-
unknown
|
|
17
|
-
>
|
|
18
|
-
? TValue
|
|
19
|
-
: never;
|
|
20
|
-
|
|
21
|
-
/** @public */
|
|
22
|
-
export function isObservable(x: unknown): x is Observable<unknown, unknown> {
|
|
23
|
-
return typeof x === 'object' && x !== null && 'subscribe' in x;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @public */
|
|
27
|
-
export function observable<TValue, TError = unknown>(
|
|
28
|
-
subscribe: (observer: Observer<TValue, TError>) => TeardownLogic,
|
|
29
|
-
): Observable<TValue, TError> {
|
|
30
|
-
const self: Observable<TValue, TError> = {
|
|
31
|
-
subscribe(observer) {
|
|
32
|
-
let teardownRef: TeardownLogic | null = null;
|
|
33
|
-
let isDone = false;
|
|
34
|
-
let unsubscribed = false;
|
|
35
|
-
let teardownImmediately = false;
|
|
36
|
-
function unsubscribe() {
|
|
37
|
-
if (teardownRef === null) {
|
|
38
|
-
teardownImmediately = true;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (unsubscribed) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
unsubscribed = true;
|
|
45
|
-
|
|
46
|
-
if (typeof teardownRef === 'function') {
|
|
47
|
-
teardownRef();
|
|
48
|
-
} else if (teardownRef) {
|
|
49
|
-
teardownRef.unsubscribe();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
teardownRef = subscribe({
|
|
53
|
-
next(value) {
|
|
54
|
-
if (isDone) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
observer.next?.(value);
|
|
58
|
-
},
|
|
59
|
-
error(err) {
|
|
60
|
-
if (isDone) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
isDone = true;
|
|
64
|
-
observer.error?.(err);
|
|
65
|
-
unsubscribe();
|
|
66
|
-
},
|
|
67
|
-
complete() {
|
|
68
|
-
if (isDone) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
isDone = true;
|
|
72
|
-
observer.complete?.();
|
|
73
|
-
unsubscribe();
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
if (teardownImmediately) {
|
|
77
|
-
unsubscribe();
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
unsubscribe,
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
pipe(
|
|
84
|
-
...operations: OperatorFunction<any, any, any, any>[]
|
|
85
|
-
): Observable<any, any> {
|
|
86
|
-
return pipeFromArray(operations)(self) as any;
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
return self;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function pipeFromArray<TSource, TReturn>(
|
|
93
|
-
fns: UnaryFunction<TSource, TReturn>[],
|
|
94
|
-
): UnaryFunction<TSource, TReturn> {
|
|
95
|
-
if (fns.length === 0) {
|
|
96
|
-
return identity as UnaryFunction<any, any>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (fns.length === 1) {
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
-
return fns[0]!;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return function piped(input: TSource): TReturn {
|
|
105
|
-
return fns.reduce(
|
|
106
|
-
(prev: any, fn: UnaryFunction<TSource, TReturn>) => fn(prev),
|
|
107
|
-
input as any,
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
class ObservableAbortError extends Error {
|
|
113
|
-
constructor(message: string) {
|
|
114
|
-
super(message);
|
|
115
|
-
this.name = 'ObservableAbortError';
|
|
116
|
-
Object.setPrototypeOf(this, ObservableAbortError.prototype);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** @internal */
|
|
121
|
-
export function observableToPromise<TValue>(
|
|
122
|
-
observable: Observable<TValue, unknown>,
|
|
123
|
-
) {
|
|
124
|
-
let abort: () => void;
|
|
125
|
-
const promise = new Promise<TValue>((resolve, reject) => {
|
|
126
|
-
let isDone = false;
|
|
127
|
-
function onDone() {
|
|
128
|
-
if (isDone) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
isDone = true;
|
|
132
|
-
reject(new ObservableAbortError('This operation was aborted.'));
|
|
133
|
-
obs$.unsubscribe();
|
|
134
|
-
}
|
|
135
|
-
const obs$ = observable.subscribe({
|
|
136
|
-
next(data) {
|
|
137
|
-
isDone = true;
|
|
138
|
-
resolve(data);
|
|
139
|
-
onDone();
|
|
140
|
-
},
|
|
141
|
-
error(data) {
|
|
142
|
-
isDone = true;
|
|
143
|
-
reject(data);
|
|
144
|
-
onDone();
|
|
145
|
-
},
|
|
146
|
-
complete() {
|
|
147
|
-
isDone = true;
|
|
148
|
-
onDone();
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
abort = onDone;
|
|
152
|
-
});
|
|
153
|
-
return {
|
|
154
|
-
promise,
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
156
|
-
abort: abort!,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MonoTypeOperatorFunction,
|
|
3
|
-
Observer,
|
|
4
|
-
OperatorFunction,
|
|
5
|
-
Unsubscribable,
|
|
6
|
-
} from './types';
|
|
7
|
-
|
|
8
|
-
export function map<TValueBefore, TError, TValueAfter>(
|
|
9
|
-
project: (value: TValueBefore, index: number) => TValueAfter,
|
|
10
|
-
): OperatorFunction<TValueBefore, TError, TValueAfter, TError> {
|
|
11
|
-
return (originalObserver) => {
|
|
12
|
-
return {
|
|
13
|
-
subscribe(observer) {
|
|
14
|
-
let index = 0;
|
|
15
|
-
const subscription = originalObserver.subscribe({
|
|
16
|
-
next(value) {
|
|
17
|
-
observer.next?.(project(value, index++));
|
|
18
|
-
},
|
|
19
|
-
error(error) {
|
|
20
|
-
observer.error?.(error);
|
|
21
|
-
},
|
|
22
|
-
complete() {
|
|
23
|
-
observer.complete?.();
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return subscription;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ShareConfig {}
|
|
33
|
-
export function share<TValue, TError>(
|
|
34
|
-
_opts?: ShareConfig,
|
|
35
|
-
): MonoTypeOperatorFunction<TValue, TError> {
|
|
36
|
-
return (originalObserver) => {
|
|
37
|
-
let refCount = 0;
|
|
38
|
-
|
|
39
|
-
let subscription: Unsubscribable | null = null;
|
|
40
|
-
const observers: Partial<Observer<TValue, TError>>[] = [];
|
|
41
|
-
|
|
42
|
-
function startIfNeeded() {
|
|
43
|
-
if (subscription) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
subscription = originalObserver.subscribe({
|
|
47
|
-
next(value) {
|
|
48
|
-
for (const observer of observers) {
|
|
49
|
-
observer.next?.(value);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
error(error) {
|
|
53
|
-
for (const observer of observers) {
|
|
54
|
-
observer.error?.(error);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
complete() {
|
|
58
|
-
for (const observer of observers) {
|
|
59
|
-
observer.complete?.();
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function resetIfNeeded() {
|
|
65
|
-
// "resetOnRefCountZero"
|
|
66
|
-
if (refCount === 0 && subscription) {
|
|
67
|
-
const _sub = subscription;
|
|
68
|
-
subscription = null;
|
|
69
|
-
_sub.unsubscribe();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
subscribe(observer) {
|
|
75
|
-
refCount++;
|
|
76
|
-
|
|
77
|
-
observers.push(observer);
|
|
78
|
-
startIfNeeded();
|
|
79
|
-
return {
|
|
80
|
-
unsubscribe() {
|
|
81
|
-
refCount--;
|
|
82
|
-
resetIfNeeded();
|
|
83
|
-
|
|
84
|
-
const index = observers.findIndex((v) => v === observer);
|
|
85
|
-
|
|
86
|
-
if (index > -1) {
|
|
87
|
-
observers.splice(index, 1);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function tap<TValue, TError>(
|
|
97
|
-
observer: Partial<Observer<TValue, TError>>,
|
|
98
|
-
): MonoTypeOperatorFunction<TValue, TError> {
|
|
99
|
-
return (originalObserver) => {
|
|
100
|
-
return {
|
|
101
|
-
subscribe(observer2) {
|
|
102
|
-
return originalObserver.subscribe({
|
|
103
|
-
next(v) {
|
|
104
|
-
observer.next?.(v);
|
|
105
|
-
observer2.next?.(v);
|
|
106
|
-
},
|
|
107
|
-
error(v) {
|
|
108
|
-
observer.error?.(v);
|
|
109
|
-
observer2.error?.(v);
|
|
110
|
-
},
|
|
111
|
-
complete() {
|
|
112
|
-
observer.complete?.();
|
|
113
|
-
observer2.complete?.();
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
}
|
package/src/observable/types.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export interface Unsubscribable {
|
|
2
|
-
unsubscribe(): void;
|
|
3
|
-
}
|
|
4
|
-
export type UnsubscribeFn = () => void;
|
|
5
|
-
interface Subscribable<TValue, TError> {
|
|
6
|
-
subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
|
|
7
|
-
}
|
|
8
|
-
export interface Observable<TValue, TError>
|
|
9
|
-
extends Subscribable<TValue, TError> {
|
|
10
|
-
pipe(): Observable<TValue, TError>;
|
|
11
|
-
pipe<TValue1, TError1>(
|
|
12
|
-
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
13
|
-
): Observable<TValue1, TError1>;
|
|
14
|
-
pipe<TValue1, TError1, TValue2, TError2>(
|
|
15
|
-
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
16
|
-
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
17
|
-
): Observable<TValue2, TError2>;
|
|
18
|
-
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(
|
|
19
|
-
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
20
|
-
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
21
|
-
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
22
|
-
): Observable<TValue2, TError2>;
|
|
23
|
-
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(
|
|
24
|
-
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
25
|
-
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
26
|
-
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
27
|
-
op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,
|
|
28
|
-
): Observable<TValue2, TError2>;
|
|
29
|
-
pipe<
|
|
30
|
-
TValue1,
|
|
31
|
-
TError1,
|
|
32
|
-
TValue2,
|
|
33
|
-
TError2,
|
|
34
|
-
TValue3,
|
|
35
|
-
TError3,
|
|
36
|
-
TValue4,
|
|
37
|
-
TError4,
|
|
38
|
-
TValue5,
|
|
39
|
-
TError5,
|
|
40
|
-
>(
|
|
41
|
-
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
42
|
-
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
43
|
-
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
44
|
-
op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,
|
|
45
|
-
op5: OperatorFunction<TValue4, TError4, TValue5, TError5>,
|
|
46
|
-
): Observable<TValue2, TError2>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface Observer<TValue, TError> {
|
|
50
|
-
next: (value: TValue) => void;
|
|
51
|
-
error: (err: TError) => void;
|
|
52
|
-
complete: () => void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type TeardownLogic =
|
|
56
|
-
// | SubscriptionLike
|
|
57
|
-
Unsubscribable | UnsubscribeFn | void;
|
|
58
|
-
|
|
59
|
-
export type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
60
|
-
|
|
61
|
-
export type OperatorFunction<
|
|
62
|
-
TValueBefore,
|
|
63
|
-
TErrorBefore,
|
|
64
|
-
TValueAfter,
|
|
65
|
-
TErrorAfter,
|
|
66
|
-
> = UnaryFunction<
|
|
67
|
-
Subscribable<TValueBefore, TErrorBefore>,
|
|
68
|
-
Subscribable<TValueAfter, TErrorAfter>
|
|
69
|
-
>;
|
|
70
|
-
|
|
71
|
-
export type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<
|
|
72
|
-
TValue,
|
|
73
|
-
TError,
|
|
74
|
-
TValue,
|
|
75
|
-
TError
|
|
76
|
-
>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AnyRootConfig } from './rootConfig';
|
|
2
|
-
import type { AnyRouter } from './router';
|
|
3
|
-
|
|
4
|
-
export type TRPCInferrable = AnyRouter | AnyRootConfig;
|
|
5
|
-
export type inferConfig<TInferrable extends TRPCInferrable> =
|
|
6
|
-
TInferrable extends AnyRouter ? TInferrable['_def']['_config'] : TInferrable;
|
|
7
|
-
|
|
8
|
-
export type inferErrorShape<TInferrable extends TRPCInferrable> =
|
|
9
|
-
inferConfig<TInferrable>['$types']['errorShape'];
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
interface ProxyCallbackOptions {
|
|
2
|
-
path: string[];
|
|
3
|
-
args: unknown[];
|
|
4
|
-
}
|
|
5
|
-
type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
6
|
-
|
|
7
|
-
const noop = () => {
|
|
8
|
-
// noop
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
function createInnerProxy(callback: ProxyCallback, path: string[]) {
|
|
12
|
-
const proxy: unknown = new Proxy(noop, {
|
|
13
|
-
get(_obj, key) {
|
|
14
|
-
if (typeof key !== 'string' || key === 'then') {
|
|
15
|
-
// special case for if the proxy is accidentally treated
|
|
16
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return createInnerProxy(callback, [...path, key]);
|
|
20
|
-
},
|
|
21
|
-
apply(_1, _2, args) {
|
|
22
|
-
const isApply = path[path.length - 1] === 'apply';
|
|
23
|
-
return callback({
|
|
24
|
-
args: isApply ? (args.length >= 2 ? args[1] : []) : args,
|
|
25
|
-
path: isApply ? path.slice(0, -1) : path,
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return proxy;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Creates a proxy that calls the callback with the path and arguments
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
export const createRecursiveProxy = (callback: ProxyCallback) =>
|
|
39
|
-
createInnerProxy(callback, []);
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export const createFlatProxy = <TFaux>(
|
|
47
|
-
callback: (path: string & keyof TFaux) => any,
|
|
48
|
-
): TFaux => {
|
|
49
|
-
return new Proxy(noop, {
|
|
50
|
-
get(_obj, name) {
|
|
51
|
-
if (typeof name !== 'string' || name === 'then') {
|
|
52
|
-
// special case for if the proxy is accidentally treated
|
|
53
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
return callback(name as any);
|
|
57
|
-
},
|
|
58
|
-
}) as TFaux;
|
|
59
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';
|
|
2
|
-
import { isObject } from '../utils';
|
|
3
|
-
|
|
4
|
-
class UnknownCauseError extends Error {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}
|
|
7
|
-
export function getCauseFromUnknown(cause: unknown): Error | undefined {
|
|
8
|
-
if (cause instanceof Error) {
|
|
9
|
-
return cause;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const type = typeof cause;
|
|
13
|
-
if (type === 'undefined' || type === 'function' || cause === null) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Primitive types just get wrapped in an error
|
|
18
|
-
if (type !== 'object') {
|
|
19
|
-
return new Error(String(cause));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// If it's an object, we'll create a synthetic error
|
|
23
|
-
if (isObject(cause)) {
|
|
24
|
-
const err = new UnknownCauseError();
|
|
25
|
-
for (const key in cause) {
|
|
26
|
-
err[key] = cause[key];
|
|
27
|
-
}
|
|
28
|
-
return err;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function getTRPCErrorFromUnknown(cause: unknown): TRPCError {
|
|
35
|
-
if (cause instanceof TRPCError) {
|
|
36
|
-
return cause;
|
|
37
|
-
}
|
|
38
|
-
if (cause instanceof Error && cause.name === 'TRPCError') {
|
|
39
|
-
// https://github.com/trpc/trpc/pull/4848
|
|
40
|
-
return cause as TRPCError;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const trpcError = new TRPCError({
|
|
44
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
45
|
-
cause,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Inherit stack from error
|
|
49
|
-
if (cause instanceof Error && cause.stack) {
|
|
50
|
-
trpcError.stack = cause.stack;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return trpcError;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class TRPCError extends Error {
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
-
// @ts-ignore override doesn't work in all environments due to "This member cannot have an 'override' modifier because it is not declared in the base class 'Error'"
|
|
59
|
-
public override readonly cause?: Error;
|
|
60
|
-
public readonly code;
|
|
61
|
-
|
|
62
|
-
constructor(opts: {
|
|
63
|
-
message?: string;
|
|
64
|
-
code: TRPC_ERROR_CODE_KEY;
|
|
65
|
-
cause?: unknown;
|
|
66
|
-
}) {
|
|
67
|
-
const cause = getCauseFromUnknown(opts.cause);
|
|
68
|
-
const message = opts.message ?? cause?.message ?? opts.code;
|
|
69
|
-
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
71
|
-
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
72
|
-
super(message, { cause });
|
|
73
|
-
|
|
74
|
-
this.code = opts.code;
|
|
75
|
-
this.name = 'TRPCError';
|
|
76
|
-
|
|
77
|
-
if (!this.cause) {
|
|
78
|
-
// < ES2022 / < Node 16.9.0 compatability
|
|
79
|
-
this.cause = cause;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { ProcedureType } from '../procedure';
|
|
2
|
-
import type {
|
|
3
|
-
TRPC_ERROR_CODE_KEY,
|
|
4
|
-
TRPC_ERROR_CODE_NUMBER,
|
|
5
|
-
TRPCErrorShape,
|
|
6
|
-
} from '../rpc';
|
|
7
|
-
import type { TRPCError } from './TRPCError';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export type ErrorFormatter<
|
|
13
|
-
TContext,
|
|
14
|
-
TShape extends TRPCErrorShape<number>,
|
|
15
|
-
> = (args: {
|
|
16
|
-
error: TRPCError;
|
|
17
|
-
type: ProcedureType | 'unknown';
|
|
18
|
-
path: string | undefined;
|
|
19
|
-
input: unknown;
|
|
20
|
-
ctx: TContext | undefined;
|
|
21
|
-
shape: DefaultErrorShape;
|
|
22
|
-
}) => TShape;
|
|
23
|
-
|
|
24
|
-
export type ErrorFormatterShape<TType> = TType extends ErrorFormatter<
|
|
25
|
-
any,
|
|
26
|
-
infer TShape
|
|
27
|
-
>
|
|
28
|
-
? TShape
|
|
29
|
-
: DefaultErrorShape;
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export type DefaultErrorData = {
|
|
34
|
-
code: TRPC_ERROR_CODE_KEY;
|
|
35
|
-
httpStatus: number;
|
|
36
|
-
path?: string;
|
|
37
|
-
stack?: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
export interface DefaultErrorShape
|
|
44
|
-
extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER, DefaultErrorData> {
|
|
45
|
-
message: string;
|
|
46
|
-
code: TRPC_ERROR_CODE_NUMBER;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const defaultFormatter: ErrorFormatter<any, any> = ({ shape }) => {
|
|
50
|
-
return shape;
|
|
51
|
-
};
|