@trpc/server 11.23.0 → 11.23.1-canary.14.507382d73
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/adapters/aws-lambda/index.cjs +12 -2
- package/dist/adapters/aws-lambda/index.d.cts +24 -1
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +24 -1
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +12 -2
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +8 -3
- package/dist/adapters/express.d.cts +12 -2
- package/dist/adapters/express.d.cts.map +1 -1
- package/dist/adapters/express.d.mts +12 -2
- package/dist/adapters/express.d.mts.map +1 -1
- package/dist/adapters/express.mjs +8 -3
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +20 -4
- package/dist/adapters/fastify/index.d.cts +38 -4
- package/dist/adapters/fastify/index.d.cts.map +1 -1
- package/dist/adapters/fastify/index.d.mts +38 -4
- package/dist/adapters/fastify/index.d.mts.map +1 -1
- package/dist/adapters/fastify/index.mjs +20 -4
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +13 -2
- package/dist/adapters/fetch/index.d.cts +26 -1
- package/dist/adapters/fetch/index.d.cts.map +1 -1
- package/dist/adapters/fetch/index.d.mts +26 -1
- package/dist/adapters/fetch/index.d.mts.map +1 -1
- package/dist/adapters/fetch/index.mjs +13 -2
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +19 -9
- package/dist/adapters/next-app-dir.d.cts +21 -11
- package/dist/adapters/next-app-dir.d.cts.map +1 -1
- package/dist/adapters/next-app-dir.d.mts +21 -11
- package/dist/adapters/next-app-dir.d.mts.map +1 -1
- package/dist/adapters/next-app-dir.mjs +19 -9
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +10 -4
- package/dist/adapters/next.d.cts +13 -2
- package/dist/adapters/next.d.cts.map +1 -1
- package/dist/adapters/next.d.mts +13 -2
- package/dist/adapters/next.d.mts.map +1 -1
- package/dist/adapters/next.mjs +10 -4
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +1 -1
- package/dist/adapters/node-http/index.d.cts +1 -1
- package/dist/adapters/node-http/index.d.mts +1 -1
- package/dist/adapters/node-http/index.mjs +1 -1
- package/dist/adapters/standalone.cjs +19 -3
- package/dist/adapters/standalone.d.cts +32 -6
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +32 -6
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +19 -3
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +1 -1
- package/dist/adapters/ws.d.cts +2 -2
- package/dist/adapters/ws.d.mts +2 -2
- package/dist/adapters/ws.mjs +1 -1
- package/dist/{asyncGeneratorDelegate-FcEJT04i.mjs → asyncGeneratorDelegate-Bl41FGB5.mjs} +41 -8
- package/dist/asyncGeneratorDelegate-Bl41FGB5.mjs.map +1 -0
- package/dist/{asyncGeneratorDelegate-Dj-8tGhf.cjs → asyncGeneratorDelegate-CPV0O1Hn.cjs} +40 -7
- package/dist/{codes-HK4UsP07.cjs → codes-Be-DrYMh.cjs} +8 -4
- package/dist/{codes-C9N0z0an.mjs → codes-nbrm_zWY.mjs} +9 -5
- package/dist/codes-nbrm_zWY.mjs.map +1 -0
- package/dist/{contentTypeParsers-B1e2ZNvN.cjs → contentTypeParsers-BTdoZrqN.cjs} +12 -0
- package/dist/contentTypeParsers-D1EBkFFY.mjs +26 -0
- package/dist/contentTypeParsers-D1EBkFFY.mjs.map +1 -0
- package/dist/{getErrorShape-hncV8cPE.cjs → getErrorShape-8t0oLscZ.cjs} +16 -5
- package/dist/{getErrorShape-zlj81BiC.mjs → getErrorShape-B6z8u8q0.mjs} +17 -6
- package/dist/getErrorShape-B6z8u8q0.mjs.map +1 -0
- package/dist/http.cjs +3 -3
- package/dist/http.d.cts +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +3 -3
- package/dist/{index-BI3Qi_F-.d.cts → index-BGYvuCEh.d.cts} +68 -8
- package/dist/index-BGYvuCEh.d.cts.map +1 -0
- package/dist/{index-BI3Qi_F-.d.mts → index-BGYvuCEh.d.mts} +68 -8
- package/dist/index-BGYvuCEh.d.mts.map +1 -0
- package/dist/{index-Tpw5OCTF.d.cts → index-CTfJHk7_.d.cts} +41 -29
- package/dist/index-CTfJHk7_.d.cts.map +1 -0
- package/dist/{index-CtkOmZzm.d.mts → index-DD2oXVyh.d.mts} +41 -29
- package/dist/index-DD2oXVyh.d.mts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{initTRPC-RMeQIy9H.mjs → initTRPC-JhlmAV6P.mjs} +31 -22
- package/dist/initTRPC-JhlmAV6P.mjs.map +1 -0
- package/dist/{initTRPC-DP-s8c4t.cjs → initTRPC-jn7uHFOx.cjs} +30 -21
- package/dist/{node-http-X8RiQEuH.cjs → node-http-CCpTZ1zd.cjs} +13 -6
- package/dist/{node-http-ChhZEv1k.mjs → node-http-DTcc6qM4.mjs} +14 -7
- package/dist/node-http-DTcc6qM4.mjs.map +1 -0
- package/dist/observable/index.cjs +2 -2
- package/dist/observable/index.d.cts +1 -1
- package/dist/observable/index.d.mts +1 -1
- package/dist/observable/index.mjs +2 -2
- package/dist/{observable-C-LvH26G.cjs → observable-B8nn0anr.cjs} +27 -4
- package/dist/{observable-yEyhfXUI.mjs → observable-CdPmrXKY.mjs} +28 -5
- package/dist/observable-CdPmrXKY.mjs.map +1 -0
- package/dist/{observable-CkXWrCsV.mjs → observable-F1Nt_3e4.mjs} +16 -4
- package/dist/observable-F1Nt_3e4.mjs.map +1 -0
- package/dist/{observable-xBsJ11Ns.cjs → observable-N4F1yT7s.cjs} +15 -3
- package/dist/{parseTRPCMessage-CJ4DJVBp.mjs → parseTRPCMessage-BO1-cCsX.mjs} +7 -3
- package/dist/parseTRPCMessage-BO1-cCsX.mjs.map +1 -0
- package/dist/{parseTRPCMessage-CPEfSSFx.cjs → parseTRPCMessage-BsPr5reh.cjs} +6 -2
- package/dist/{resolveResponse-DksrxZ2k.mjs → resolveResponse-B2MQmLSr.mjs} +17 -5
- package/dist/resolveResponse-B2MQmLSr.mjs.map +1 -0
- package/dist/{resolveResponse-CoGjFxK0.cjs → resolveResponse-BQcrvKyB.cjs} +16 -4
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.d.cts +1 -1
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +2 -2
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/{unstable-core-do-not-import-B8epiErP.d.cts → unstable-core-do-not-import-DYnAWlN7.d.cts} +517 -161
- package/dist/unstable-core-do-not-import-DYnAWlN7.d.cts.map +1 -0
- package/dist/{unstable-core-do-not-import-Dbo98mkh.d.mts → unstable-core-do-not-import-hC2_7K-s.d.mts} +517 -161
- package/dist/unstable-core-do-not-import-hC2_7K-s.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +7 -7
- package/dist/unstable-core-do-not-import.d.cts +1 -1
- package/dist/unstable-core-do-not-import.d.mts +1 -1
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{ws-BYfo-HED.mjs → ws-B9v4J-4P.mjs} +30 -11
- package/dist/ws-B9v4J-4P.mjs.map +1 -0
- package/dist/ws-DVHbmgfC.d.mts +95 -0
- package/dist/ws-DVHbmgfC.d.mts.map +1 -0
- package/dist/ws-JzZs-0Zd.d.cts +95 -0
- package/dist/ws-JzZs-0Zd.d.cts.map +1 -0
- package/dist/{ws-7qWW7Uec.cjs → ws-_SClUVOu.cjs} +29 -10
- package/package.json +2 -2
- package/skills/adapter-aws-lambda/SKILL.md +1 -1
- package/skills/adapter-express/SKILL.md +1 -1
- package/skills/adapter-fastify/SKILL.md +1 -1
- package/skills/adapter-fetch/SKILL.md +1 -1
- package/skills/adapter-standalone/SKILL.md +1 -1
- package/skills/auth/SKILL.md +1 -1
- package/skills/caching/SKILL.md +2 -2
- package/skills/error-handling/SKILL.md +1 -1
- package/skills/middlewares/SKILL.md +1 -1
- package/skills/non-json-content-types/SKILL.md +13 -4
- package/skills/server-setup/SKILL.md +1 -1
- package/skills/server-side-calls/SKILL.md +1 -1
- package/skills/service-oriented-architecture/SKILL.md +1 -1
- package/skills/subscriptions/SKILL.md +1 -1
- package/skills/trpc-router/SKILL.md +1 -1
- package/skills/validators/SKILL.md +1 -1
- package/src/@trpc/server/index.ts +2 -2
- package/src/adapters/aws-lambda/index.ts +23 -0
- package/src/adapters/express.ts +10 -0
- package/src/adapters/fastify/fastifyRequestHandler.ts +5 -0
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +30 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +11 -0
- package/src/adapters/fetch/types.ts +14 -0
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +8 -4
- package/src/adapters/next-app-dir/notFound.ts +3 -1
- package/src/adapters/next-app-dir/redirect.ts +6 -4
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +5 -1
- package/src/adapters/next.ts +13 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +6 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +3 -1
- package/src/adapters/node-http/types.ts +30 -25
- package/src/adapters/standalone.ts +30 -4
- package/src/adapters/ws.ts +42 -8
- package/src/adapters/wsEncoder.ts +5 -6
- package/src/observable/behaviorSubject.ts +6 -2
- package/src/observable/observable.ts +31 -5
- package/src/observable/operators.ts +12 -0
- package/src/observable/types.ts +18 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +22 -1
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +5 -2
- package/src/unstable-core-do-not-import/createProxy.ts +4 -4
- package/src/unstable-core-do-not-import/error/TRPCError.ts +19 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +15 -2
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +2 -0
- package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +15 -2
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +9 -0
- package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +8 -0
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +4 -0
- package/src/unstable-core-do-not-import/http/types.ts +55 -27
- package/src/unstable-core-do-not-import/initTRPC.ts +51 -27
- package/src/unstable-core-do-not-import/middleware.ts +25 -5
- package/src/unstable-core-do-not-import/procedure.ts +28 -2
- package/src/unstable-core-do-not-import/procedureBuilder.ts +56 -35
- package/src/unstable-core-do-not-import/rootConfig.ts +28 -19
- package/src/unstable-core-do-not-import/router.ts +71 -11
- package/src/unstable-core-do-not-import/rpc/codes.ts +13 -5
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +45 -9
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +5 -1
- package/src/unstable-core-do-not-import/stream/tracked.ts +17 -5
- package/src/unstable-core-do-not-import/transformer.ts +12 -1
- package/src/unstable-core-do-not-import/types.ts +2 -0
- package/src/unstable-core-do-not-import/utils.ts +4 -1
- package/dist/asyncGeneratorDelegate-FcEJT04i.mjs.map +0 -1
- package/dist/codes-C9N0z0an.mjs.map +0 -1
- package/dist/contentTypeParsers-Bb-9hUEf.mjs +0 -14
- package/dist/contentTypeParsers-Bb-9hUEf.mjs.map +0 -1
- package/dist/getErrorShape-zlj81BiC.mjs.map +0 -1
- package/dist/index-BI3Qi_F-.d.cts.map +0 -1
- package/dist/index-BI3Qi_F-.d.mts.map +0 -1
- package/dist/index-CtkOmZzm.d.mts.map +0 -1
- package/dist/index-Tpw5OCTF.d.cts.map +0 -1
- package/dist/initTRPC-RMeQIy9H.mjs.map +0 -1
- package/dist/node-http-ChhZEv1k.mjs.map +0 -1
- package/dist/observable-CkXWrCsV.mjs.map +0 -1
- package/dist/observable-yEyhfXUI.mjs.map +0 -1
- package/dist/parseTRPCMessage-CJ4DJVBp.mjs.map +0 -1
- package/dist/resolveResponse-DksrxZ2k.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-B8epiErP.d.cts.map +0 -1
- package/dist/unstable-core-do-not-import-Dbo98mkh.d.mts.map +0 -1
- package/dist/ws-BYfo-HED.mjs.map +0 -1
- package/dist/ws-DD1ukLuC.d.cts +0 -61
- package/dist/ws-DD1ukLuC.d.cts.map +0 -1
- package/dist/ws-DT37N43e.d.mts +0 -61
- package/dist/ws-DT37N43e.d.mts.map +0 -1
|
@@ -20,6 +20,9 @@ import {
|
|
|
20
20
|
mergeWithoutOverrides,
|
|
21
21
|
} from './utils';
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The procedures and sub-routers of a router, by name.
|
|
25
|
+
*/
|
|
23
26
|
export interface RouterRecord {
|
|
24
27
|
[key: string]: AnyProcedure | RouterRecord;
|
|
25
28
|
}
|
|
@@ -35,6 +38,8 @@ type DecorateProcedure<TProcedure extends AnyProcedure> = (
|
|
|
35
38
|
>;
|
|
36
39
|
|
|
37
40
|
/**
|
|
41
|
+
* A router's record with every procedure turned into a function, as a
|
|
42
|
+
* caller has it.
|
|
38
43
|
* @internal
|
|
39
44
|
*/
|
|
40
45
|
export type DecorateRouterRecord<TRecord extends RouterRecord> = {
|
|
@@ -48,28 +53,31 @@ export type DecorateRouterRecord<TRecord extends RouterRecord> = {
|
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
/**
|
|
56
|
+
* Called when a procedure called through a caller throws.
|
|
51
57
|
* @internal
|
|
52
58
|
*/
|
|
53
|
-
|
|
54
59
|
export type RouterCallerErrorHandler<TContext> = (
|
|
55
60
|
opts: ErrorHandlerOptions<TContext>,
|
|
56
61
|
) => void;
|
|
57
62
|
|
|
58
63
|
/**
|
|
64
|
+
* Creates a caller from a context, or from a function that returns one.
|
|
65
|
+
* A function is called on each procedure call, so cache it (for example
|
|
66
|
+
* with `React.cache`).
|
|
59
67
|
* @internal
|
|
60
68
|
*/
|
|
61
69
|
export type RouterCaller<
|
|
62
70
|
TRoot extends AnyRootTypes,
|
|
63
71
|
TRecord extends RouterRecord,
|
|
64
72
|
> = (
|
|
65
|
-
/**
|
|
66
|
-
* @note
|
|
67
|
-
* If passing a function, we recommend it's a cached function
|
|
68
|
-
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
69
|
-
*/
|
|
70
73
|
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),
|
|
71
74
|
options?: {
|
|
75
|
+
/** Called when a procedure throws, before the error is rethrown. */
|
|
72
76
|
onError?: RouterCallerErrorHandler<TRoot['ctx']>;
|
|
77
|
+
/**
|
|
78
|
+
* Passed to middleware and resolvers as `signal`. It doesn't stop a
|
|
79
|
+
* call by itself; the resolver has to check it.
|
|
80
|
+
*/
|
|
73
81
|
signal?: AbortSignal;
|
|
74
82
|
},
|
|
75
83
|
) => DecorateRouterRecord<TRecord>;
|
|
@@ -80,6 +88,7 @@ export type RouterCaller<
|
|
|
80
88
|
const lazyMarker = 'lazyMarker' as 'lazyMarker' & {
|
|
81
89
|
__brand: 'lazyMarker';
|
|
82
90
|
};
|
|
91
|
+
/** A router that `lazy()` loads on its first call. */
|
|
83
92
|
export type Lazy<TAny> = (() => Promise<TAny>) & { [lazyMarker]: true };
|
|
84
93
|
|
|
85
94
|
type LazyLoader<TAny> = {
|
|
@@ -101,7 +110,15 @@ function once<T>(fn: () => T): () => T {
|
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
/**
|
|
104
|
-
*
|
|
113
|
+
* Loads a router on its first call instead of at startup, which can make
|
|
114
|
+
* cold starts faster. Pass a function that imports the router, or a module
|
|
115
|
+
* whose only export is the router.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const appRouter = router({
|
|
119
|
+
* slow: lazy(() => import('./slow.js').then((m) => m.slowRouter)),
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
105
122
|
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
106
123
|
*/
|
|
107
124
|
export function lazy<TRouter extends AnyRouter>(
|
|
@@ -141,6 +158,7 @@ function isLazy<TAny>(input: unknown): input is Lazy<TAny> {
|
|
|
141
158
|
}
|
|
142
159
|
|
|
143
160
|
/**
|
|
161
|
+
* A router's definition: its config and procedures.
|
|
144
162
|
* @internal
|
|
145
163
|
*/
|
|
146
164
|
export interface RouterDef<
|
|
@@ -155,37 +173,62 @@ export interface RouterDef<
|
|
|
155
173
|
lazy: Record<string, LazyLoader<AnyRouter>>;
|
|
156
174
|
}
|
|
157
175
|
|
|
176
|
+
/**
|
|
177
|
+
* A router: procedures and sub-routers under one root config.
|
|
178
|
+
* @see https://trpc.io/docs/server/routers
|
|
179
|
+
*/
|
|
158
180
|
export interface Router<
|
|
159
181
|
TRoot extends AnyRootTypes,
|
|
160
182
|
TRecord extends RouterRecord,
|
|
161
183
|
> {
|
|
162
184
|
_def: RouterDef<TRoot, TRecord>;
|
|
163
185
|
/**
|
|
164
|
-
*
|
|
186
|
+
* Creates a caller, which calls the router's procedures directly on the
|
|
187
|
+
* server, from a context.
|
|
188
|
+
* @see https://trpc.io/docs/server/server-side-calls#routercreatecaller
|
|
165
189
|
*/
|
|
166
190
|
createCaller: RouterCaller<TRoot, TRecord>;
|
|
167
191
|
}
|
|
168
192
|
|
|
193
|
+
/**
|
|
194
|
+
* A router as `t.router()` returns it, with its procedures and sub-routers
|
|
195
|
+
* as properties.
|
|
196
|
+
*/
|
|
169
197
|
export type BuiltRouter<
|
|
170
198
|
TRoot extends AnyRootTypes,
|
|
171
199
|
TRecord extends RouterRecord,
|
|
172
200
|
> = Router<TRoot, TRecord> & TRecord;
|
|
173
201
|
|
|
202
|
+
/**
|
|
203
|
+
* The type of `t.router()`.
|
|
204
|
+
* @see https://trpc.io/docs/server/routers
|
|
205
|
+
*/
|
|
174
206
|
export interface RouterBuilder<TRoot extends AnyRootTypes> {
|
|
175
207
|
<TIn extends CreateRouterOptions>(
|
|
176
208
|
_: TIn,
|
|
177
209
|
): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;
|
|
178
210
|
}
|
|
179
211
|
|
|
212
|
+
/** Any router, for use in generic constraints. */
|
|
180
213
|
export type AnyRouter = Router<any, any>;
|
|
181
214
|
|
|
215
|
+
/** A router's root types: its context, metadata, error shape and transformer. */
|
|
182
216
|
export type inferRouterRootTypes<TRouter extends AnyRouter> =
|
|
183
217
|
TRouter['_def']['_config']['$types'];
|
|
184
218
|
|
|
219
|
+
/** The type of a router's context. */
|
|
185
220
|
export type inferRouterContext<TRouter extends AnyRouter> =
|
|
186
221
|
inferRouterRootTypes<TRouter>['ctx'];
|
|
222
|
+
/**
|
|
223
|
+
* The shape of a router's errors, as its error formatter returns them.
|
|
224
|
+
* @see https://trpc.io/docs/server/error-formatting
|
|
225
|
+
*/
|
|
187
226
|
export type inferRouterError<TRouter extends AnyRouter> =
|
|
188
227
|
inferRouterRootTypes<TRouter>['errorShape'];
|
|
228
|
+
/**
|
|
229
|
+
* The type of a router's metadata.
|
|
230
|
+
* @see https://trpc.io/docs/server/metadata
|
|
231
|
+
*/
|
|
189
232
|
export type inferRouterMeta<TRouter extends AnyRouter> =
|
|
190
233
|
inferRouterRootTypes<TRouter>['meta'];
|
|
191
234
|
|
|
@@ -222,7 +265,11 @@ const reservedWords = [
|
|
|
222
265
|
'apply',
|
|
223
266
|
];
|
|
224
267
|
|
|
225
|
-
/**
|
|
268
|
+
/**
|
|
269
|
+
* What `t.router()` takes: procedures, routers, lazy routers and nested
|
|
270
|
+
* objects of them, by name.
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
226
273
|
export type CreateRouterOptions = {
|
|
227
274
|
[key: string]:
|
|
228
275
|
| AnyProcedure
|
|
@@ -231,7 +278,10 @@ export type CreateRouterOptions = {
|
|
|
231
278
|
| Lazy<AnyRouter>;
|
|
232
279
|
};
|
|
233
280
|
|
|
234
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* The record of the router `t.router()` builds from its options.
|
|
283
|
+
* @internal
|
|
284
|
+
*/
|
|
235
285
|
export type DecorateCreateRouterOptions<
|
|
236
286
|
TRouterOptions extends CreateRouterOptions,
|
|
237
287
|
> = {
|
|
@@ -407,6 +457,8 @@ export async function getProcedureAtPath(
|
|
|
407
457
|
}
|
|
408
458
|
|
|
409
459
|
/**
|
|
460
|
+
* Calls the procedure at `path`, throwing `NOT_FOUND` if there's none of
|
|
461
|
+
* that type.
|
|
410
462
|
* @internal
|
|
411
463
|
*/
|
|
412
464
|
export async function callProcedure(
|
|
@@ -443,6 +495,11 @@ export async function callProcedure(
|
|
|
443
495
|
return proc(opts);
|
|
444
496
|
}
|
|
445
497
|
|
|
498
|
+
/**
|
|
499
|
+
* The type of `t.createCallerFactory()`: takes a router and returns its
|
|
500
|
+
* `createCaller`.
|
|
501
|
+
* @see https://trpc.io/docs/server/server-side-calls#create-caller
|
|
502
|
+
*/
|
|
446
503
|
export interface RouterCallerFactory<TRoot extends AnyRootTypes> {
|
|
447
504
|
<TRecord extends RouterRecord>(
|
|
448
505
|
router: Pick<Router<TRoot, TRecord>, '_def'>,
|
|
@@ -506,7 +563,10 @@ export function createCallerFactory<
|
|
|
506
563
|
};
|
|
507
564
|
}
|
|
508
565
|
|
|
509
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* The router `t.mergeRouters()` returns.
|
|
568
|
+
* @internal
|
|
569
|
+
*/
|
|
510
570
|
export type MergeRouters<
|
|
511
571
|
TRouters extends AnyRouter[],
|
|
512
572
|
TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],
|
|
@@ -3,10 +3,10 @@ import type { InvertKeyValue, ValueOf } from '../types';
|
|
|
3
3
|
// reference: https://www.jsonrpc.org/specification
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* JSON-RPC 2.0
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes
|
|
7
|
+
* use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending
|
|
8
|
+
* in the digits of the matching HTTP status.
|
|
9
|
+
* @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes
|
|
10
10
|
*/
|
|
11
11
|
export const TRPC_ERROR_CODES_BY_KEY = {
|
|
12
12
|
/**
|
|
@@ -43,7 +43,10 @@ export const TRPC_ERROR_CODES_BY_KEY = {
|
|
|
43
43
|
CLIENT_CLOSED_REQUEST: -32099, // 499
|
|
44
44
|
} as const;
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The tRPC error code of each JSON-RPC 2.0 error code.
|
|
48
|
+
* @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes
|
|
49
|
+
*/
|
|
47
50
|
export const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<
|
|
48
51
|
typeof TRPC_ERROR_CODES_BY_KEY
|
|
49
52
|
> = {
|
|
@@ -66,7 +69,12 @@ export const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<
|
|
|
66
69
|
[-32099]: 'CLIENT_CLOSED_REQUEST',
|
|
67
70
|
};
|
|
68
71
|
|
|
72
|
+
/** A JSON-RPC 2.0 error code tRPC sends, such as `-32004`. */
|
|
69
73
|
export type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
|
|
74
|
+
/**
|
|
75
|
+
* A tRPC error code, such as `'NOT_FOUND'`.
|
|
76
|
+
* @see https://trpc.io/docs/server/error-handling#error-codes
|
|
77
|
+
*/
|
|
70
78
|
export type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
|
71
79
|
|
|
72
80
|
/**
|
|
@@ -4,16 +4,20 @@ import type { ProcedureType } from '../procedure';
|
|
|
4
4
|
import type { TRPC_ERROR_CODE_NUMBER } from './codes';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The error object of an error response: a JSON-RPC code, a message and
|
|
8
|
+
* any `data` the error formatter adds.
|
|
9
|
+
* @see https://trpc.io/docs/rpc#error-response
|
|
8
10
|
*/
|
|
9
11
|
export interface TRPCErrorShape<TData extends object = object> {
|
|
10
12
|
code: TRPC_ERROR_CODE_NUMBER;
|
|
11
13
|
message: string;
|
|
14
|
+
/** Extra details, such as the tRPC code and HTTP status. */
|
|
12
15
|
data: TData;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
|
-
* JSON-RPC 2.0
|
|
19
|
+
* Types for the JSON-RPC 2.0 messages tRPC's envelopes build on.
|
|
20
|
+
* @see https://www.jsonrpc.org/specification
|
|
17
21
|
*/
|
|
18
22
|
export namespace JSONRPC2 {
|
|
19
23
|
export type RequestId = number | string | null;
|
|
@@ -52,6 +56,7 @@ export namespace JSONRPC2 {
|
|
|
52
56
|
|
|
53
57
|
/////////////////////////// HTTP envelopes ///////////////////////
|
|
54
58
|
|
|
59
|
+
/** A call to a procedure. */
|
|
55
60
|
export interface TRPCRequest extends JSONRPC2.Request<
|
|
56
61
|
ProcedureType,
|
|
57
62
|
{
|
|
@@ -64,6 +69,7 @@ export interface TRPCRequest extends JSONRPC2.Request<
|
|
|
64
69
|
}
|
|
65
70
|
> {}
|
|
66
71
|
|
|
72
|
+
/** The `result` of a successful response. */
|
|
67
73
|
export interface TRPCResult<TData = unknown> {
|
|
68
74
|
data: TData;
|
|
69
75
|
type?: 'data';
|
|
@@ -73,14 +79,26 @@ export interface TRPCResult<TData = unknown> {
|
|
|
73
79
|
id?: string;
|
|
74
80
|
}
|
|
75
81
|
|
|
82
|
+
/**
|
|
83
|
+
* A successful response.
|
|
84
|
+
* @see https://trpc.io/docs/rpc#successful-response
|
|
85
|
+
*/
|
|
76
86
|
export interface TRPCSuccessResponse<TData> extends JSONRPC2.ResultResponse<
|
|
77
87
|
TRPCResult<TData>
|
|
78
88
|
> {}
|
|
79
89
|
|
|
90
|
+
/**
|
|
91
|
+
* An error response.
|
|
92
|
+
* @see https://trpc.io/docs/rpc#error-response
|
|
93
|
+
*/
|
|
80
94
|
export interface TRPCErrorResponse<
|
|
81
95
|
TError extends TRPCErrorShape = TRPCErrorShape,
|
|
82
96
|
> extends JSONRPC2.ErrorResponse<TError> {}
|
|
83
97
|
|
|
98
|
+
/**
|
|
99
|
+
* A response to a call: a success or an error.
|
|
100
|
+
* @see https://trpc.io/docs/rpc#http-response-specification
|
|
101
|
+
*/
|
|
84
102
|
export type TRPCResponse<
|
|
85
103
|
TData = unknown,
|
|
86
104
|
TError extends TRPCErrorShape = TRPCErrorShape,
|
|
@@ -88,35 +106,50 @@ export type TRPCResponse<
|
|
|
88
106
|
|
|
89
107
|
/////////////////////////// WebSocket envelopes ///////////////////////
|
|
90
108
|
|
|
109
|
+
/**
|
|
110
|
+
* A call to a procedure over WebSockets, with the id its responses carry.
|
|
111
|
+
* @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
|
|
112
|
+
*/
|
|
91
113
|
export type TRPCRequestMessage = TRPCRequest & {
|
|
92
114
|
id: JSONRPC2.RequestId;
|
|
93
115
|
};
|
|
94
116
|
|
|
95
117
|
/**
|
|
96
|
-
* The client
|
|
118
|
+
* The client asks the server to stop a subscription.
|
|
119
|
+
* @see https://trpc.io/docs/server/websockets#to-cancel-a-subscription-call-subscriptionstop
|
|
97
120
|
*/
|
|
98
121
|
export interface TRPCSubscriptionStopNotification extends JSONRPC2.BaseRequest<'subscription.stop'> {
|
|
99
122
|
id: null;
|
|
100
123
|
}
|
|
101
124
|
|
|
102
125
|
/**
|
|
103
|
-
* The
|
|
126
|
+
* The notifications a WebSocket client sends.
|
|
104
127
|
*/
|
|
105
128
|
export type TRPCClientOutgoingRequest = TRPCSubscriptionStopNotification;
|
|
106
129
|
|
|
107
130
|
/**
|
|
108
|
-
*
|
|
131
|
+
* Any message a WebSocket client sends.
|
|
132
|
+
* @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
|
|
109
133
|
*/
|
|
110
134
|
export type TRPCClientOutgoingMessage =
|
|
111
135
|
| TRPCRequestMessage
|
|
112
136
|
| (JSONRPC2.BaseRequest<'subscription.stop'> & { id: JSONRPC2.RequestId });
|
|
113
137
|
|
|
138
|
+
/**
|
|
139
|
+
* A result sent over WebSockets: data, or a subscription's `started` or
|
|
140
|
+
* `stopped` event.
|
|
141
|
+
* @see https://trpc.io/docs/server/websockets#subscription-response-shape
|
|
142
|
+
*/
|
|
114
143
|
export interface TRPCResultMessage<TData> extends JSONRPC2.ResultResponse<
|
|
115
144
|
| { type: 'started'; data?: never }
|
|
116
145
|
| { type: 'stopped'; data?: never }
|
|
117
146
|
| TRPCResult<TData>
|
|
118
147
|
> {}
|
|
119
148
|
|
|
149
|
+
/**
|
|
150
|
+
* A response sent over WebSockets, with the id of the call it answers.
|
|
151
|
+
* @see https://trpc.io/docs/server/websockets#response
|
|
152
|
+
*/
|
|
120
153
|
export type TRPCResponseMessage<
|
|
121
154
|
TData = unknown,
|
|
122
155
|
TError extends TRPCErrorShape = TRPCErrorShape,
|
|
@@ -126,19 +159,21 @@ export type TRPCResponseMessage<
|
|
|
126
159
|
);
|
|
127
160
|
|
|
128
161
|
/**
|
|
129
|
-
* The server
|
|
162
|
+
* The server asks the client to reconnect, for example before a restart.
|
|
163
|
+
* @see https://trpc.io/docs/server/websockets#notifications-from-server-to-client
|
|
130
164
|
*/
|
|
131
165
|
export interface TRPCReconnectNotification extends JSONRPC2.BaseRequest<'reconnect'> {
|
|
132
166
|
id: JSONRPC2.RequestId;
|
|
133
167
|
}
|
|
134
168
|
|
|
135
169
|
/**
|
|
136
|
-
* The
|
|
170
|
+
* The notifications a WebSocket client receives.
|
|
137
171
|
*/
|
|
138
172
|
export type TRPCClientIncomingRequest = TRPCReconnectNotification;
|
|
139
173
|
|
|
140
174
|
/**
|
|
141
|
-
*
|
|
175
|
+
* Any message a WebSocket client receives.
|
|
176
|
+
* @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
|
|
142
177
|
*/
|
|
143
178
|
export type TRPCClientIncomingMessage<
|
|
144
179
|
TResult = unknown,
|
|
@@ -146,7 +181,8 @@ export type TRPCClientIncomingMessage<
|
|
|
146
181
|
> = TRPCClientIncomingRequest | TRPCResponseMessage<TResult, TError>;
|
|
147
182
|
|
|
148
183
|
/**
|
|
149
|
-
* The
|
|
184
|
+
* The connection params a WebSocket client sends as its first message.
|
|
185
|
+
* @see https://trpc.io/docs/server/websockets#connection-params
|
|
150
186
|
*/
|
|
151
187
|
export interface TRPCConnectionParamsMessage extends JSONRPC2.BaseRequest<'connectionParams'> {
|
|
152
188
|
data: TRPCRequestInfo['connectionParams'];
|
|
@@ -46,7 +46,11 @@ function assertIsJSONRPC2OrUndefined(
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Checks that a message a WebSocket client sent is a valid tRPC message,
|
|
51
|
+
* and deserializes its input. Throws if it isn't.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
50
54
|
export function parseTRPCMessage(
|
|
51
55
|
obj: unknown,
|
|
52
56
|
transformer: CombinedDataTransformer,
|
|
@@ -3,26 +3,30 @@ const trackedSymbol = Symbol();
|
|
|
3
3
|
type TrackedId = string & {
|
|
4
4
|
__brand: 'TrackedId';
|
|
5
5
|
};
|
|
6
|
+
/** An event wrapped by `tracked()`, with its id. */
|
|
6
7
|
export type TrackedEnvelope<TData> = [TrackedId, TData, typeof trackedSymbol];
|
|
7
8
|
|
|
9
|
+
/** A tracked event as the client gets it. */
|
|
8
10
|
export interface TrackedData<TData> {
|
|
9
11
|
/**
|
|
10
|
-
* The id
|
|
12
|
+
* The event's id, which the client sends back as `lastEventId` when it
|
|
13
|
+
* reconnects.
|
|
11
14
|
*/
|
|
12
15
|
id: string;
|
|
13
16
|
/**
|
|
14
|
-
* The data
|
|
17
|
+
* The event's data.
|
|
15
18
|
*/
|
|
16
19
|
data: TData;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @deprecated
|
|
22
|
+
* Wraps an event with an id, so a client can resume from it.
|
|
23
|
+
* @deprecated Use `tracked(id, data)` instead.
|
|
21
24
|
*/
|
|
22
25
|
export function sse<TData>(event: { id: string; data: TData }) {
|
|
23
26
|
return tracked(event.id, event.data);
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
/** Whether a value was made by `tracked()`. */
|
|
26
30
|
export function isTrackedEnvelope<TData>(
|
|
27
31
|
value: unknown,
|
|
28
32
|
): value is TrackedEnvelope<TData> {
|
|
@@ -30,7 +34,14 @@ export function isTrackedEnvelope<TData>(
|
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
*
|
|
37
|
+
* Gives a subscription event an id. When the connection drops, the client
|
|
38
|
+
* reconnects with the last id it got, as `input.lastEventId`, so the
|
|
39
|
+
* subscription can resume from there. The id can't be empty.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* yield tracked(post.id, post);
|
|
43
|
+
* ```
|
|
44
|
+
* @see https://trpc.io/docs/server/subscriptions#tracked
|
|
34
45
|
*/
|
|
35
46
|
export function tracked<TData>(
|
|
36
47
|
id: string,
|
|
@@ -45,5 +56,6 @@ export function tracked<TData>(
|
|
|
45
56
|
return [id as TrackedId, data, trackedSymbol];
|
|
46
57
|
}
|
|
47
58
|
|
|
59
|
+
/** The type a client gets for an event, unwrapping `tracked()` events. */
|
|
48
60
|
export type inferTrackedOutput<TData> =
|
|
49
61
|
TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;
|
|
@@ -8,6 +8,9 @@ import type {
|
|
|
8
8
|
import { isObject } from './utils';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
+
* A transformer that serializes and deserializes data the same way in
|
|
12
|
+
* both directions, such as `superjson`.
|
|
13
|
+
* @see https://trpc.io/docs/server/data-transformers#datatransformer-interface
|
|
11
14
|
* @public
|
|
12
15
|
*/
|
|
13
16
|
export interface DataTransformer {
|
|
@@ -38,6 +41,8 @@ interface OutputDataTransformer extends DataTransformer {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
44
|
+
* A transformer with one serializer for inputs and another for outputs.
|
|
45
|
+
* @see https://trpc.io/docs/server/data-transformers#different-transformers-for-upload-and-download
|
|
41
46
|
* @public
|
|
42
47
|
*/
|
|
43
48
|
export interface CombinedDataTransformer {
|
|
@@ -52,6 +57,8 @@ export interface CombinedDataTransformer {
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
/**
|
|
60
|
+
* The half of a combined transformer the client uses: serializing inputs
|
|
61
|
+
* and deserializing outputs.
|
|
55
62
|
* @public
|
|
56
63
|
*/
|
|
57
64
|
export type CombinedDataTransformerClient = {
|
|
@@ -60,6 +67,9 @@ export type CombinedDataTransformerClient = {
|
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
/**
|
|
70
|
+
* A transformer: one for both directions, or separate ones for inputs and
|
|
71
|
+
* outputs.
|
|
72
|
+
* @see https://trpc.io/docs/server/data-transformers
|
|
63
73
|
* @public
|
|
64
74
|
*/
|
|
65
75
|
export type DataTransformerOptions = CombinedDataTransformer | DataTransformer;
|
|
@@ -108,7 +118,8 @@ function transformTRPCResponseItem<
|
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
|
-
*
|
|
121
|
+
* Serializes a response, or a list of them, with the router's output
|
|
122
|
+
* transformer. Meant for custom adapters.
|
|
112
123
|
**/
|
|
113
124
|
export function transformTRPCResponse<
|
|
114
125
|
TResponse extends
|
|
@@ -18,11 +18,13 @@ export type Simplify<TType> = TType extends any[] | Date
|
|
|
18
18
|
: { [K in keyof TType]: TType[K] };
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
+
* An object with string keys whose values may be `undefined`.
|
|
21
22
|
* @public
|
|
22
23
|
*/
|
|
23
24
|
export type Dict<TType> = Record<string, TType | undefined>;
|
|
24
25
|
|
|
25
26
|
/**
|
|
27
|
+
* A value, or a promise of one.
|
|
26
28
|
* @public
|
|
27
29
|
*/
|
|
28
30
|
export type MaybePromise<TType> = Promise<TType> | TType;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asyncGeneratorDelegate-FcEJT04i.mjs","names":[],"sources":["../src/unstable-core-do-not-import/error/TRPCError.ts","../src/unstable-core-do-not-import/transformer.ts","../src/unstable-core-do-not-import/router.ts","../src/unstable-core-do-not-import/stream/tracked.ts"],"sourcesContent":["import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';\nimport { isObject } from '../utils';\n\nclass UnknownCauseError extends Error {\n [key: string]: unknown;\n\n constructor(cause: object) {\n super(getMessage(cause));\n Object.assign(this, cause);\n\n if (isErrorLike(cause)) {\n if (typeof cause.name === 'string') this.name = cause.name;\n if (typeof cause.stack === 'string') this.stack = cause.stack;\n }\n }\n}\n\nfunction getMessage(cause: object) {\n if ('message' in cause) return String(cause.message);\n\n return undefined;\n}\n\n/**\n * Errors from another realm (e.g. `node:vm`, iframes) fail `instanceof Error`\n * but still carry the `[object Error]` brand.\n */\nfunction isErrorLike(value: unknown): value is Error {\n return (\n value instanceof Error ||\n Object.prototype.toString.call(value) === '[object Error]'\n );\n}\n\nexport function getCauseFromUnknown(cause: unknown): Error | undefined {\n if (cause instanceof Error) {\n return cause;\n }\n\n const type = typeof cause;\n if (type === 'undefined' || type === 'function' || cause === null) {\n return undefined;\n }\n\n // Primitive types just get wrapped in an error\n if (type !== 'object') {\n // oxlint-disable-next-line typescript/no-base-to-string\n return new Error(String(cause));\n }\n\n // If it's an object, we'll create a synthetic error\n if (isObject(cause)) {\n return new UnknownCauseError(cause);\n }\n\n return undefined;\n}\n\nexport function getTRPCErrorFromUnknown(cause: unknown): TRPCError {\n if (cause instanceof TRPCError) {\n return cause;\n }\n if (cause instanceof Error && cause.name === 'TRPCError') {\n // https://github.com/trpc/trpc/pull/4848\n return cause as TRPCError;\n }\n\n const trpcError = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n cause,\n });\n\n // Inherit stack from error\n if (isErrorLike(cause) && cause.stack) {\n trpcError.stack = cause.stack;\n }\n\n return trpcError;\n}\n\nexport class TRPCError extends Error {\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @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'\"\n public override readonly cause?: Error;\n public readonly code;\n\n constructor(opts: {\n message?: string;\n code: TRPC_ERROR_CODE_KEY;\n cause?: unknown;\n }) {\n const cause = getCauseFromUnknown(opts.cause);\n const message = opts.message ?? cause?.message ?? opts.code;\n\n // oxlint-disable-next-line typescript/ban-ts-comment\n // @ts-ignore https://github.com/tc39/proposal-error-cause\n super(message, { cause });\n\n this.code = opts.code;\n this.name = 'TRPCError';\n this.cause ??= cause;\n }\n}\n","import type { AnyRootTypes, RootConfig } from './rootConfig';\nimport type { AnyRouter, inferRouterError } from './router';\nimport type {\n TRPCResponse,\n TRPCResponseMessage,\n TRPCResultMessage,\n} from './rpc';\nimport { isObject } from './utils';\n\n/**\n * @public\n */\nexport interface DataTransformer {\n serialize(object: any): any;\n deserialize(object: any): any;\n}\n\ninterface InputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the client** before sending the data to the server.\n */\n serialize(object: any): any;\n /**\n * This function runs **on the server** to transform the data before it is passed to the resolver\n */\n deserialize(object: any): any;\n}\n\ninterface OutputDataTransformer extends DataTransformer {\n /**\n * This function runs **on the server** before sending the data to the client.\n */\n serialize(object: any): any;\n /**\n * This function runs **only on the client** to transform the data sent from the server.\n */\n deserialize(object: any): any;\n}\n\n/**\n * @public\n */\nexport interface CombinedDataTransformer {\n /**\n * Specify how the data sent from the client to the server should be transformed.\n */\n input: InputDataTransformer;\n /**\n * Specify how the data sent from the server to the client should be transformed.\n */\n output: OutputDataTransformer;\n}\n\n/**\n * @public\n */\nexport type CombinedDataTransformerClient = {\n input: Pick<CombinedDataTransformer['input'], 'serialize'>;\n output: Pick<CombinedDataTransformer['output'], 'deserialize'>;\n};\n\n/**\n * @public\n */\nexport type DataTransformerOptions = CombinedDataTransformer | DataTransformer;\n\n/**\n * @internal\n */\nexport function getDataTransformer(\n transformer: DataTransformerOptions,\n): CombinedDataTransformer {\n if ('input' in transformer) {\n return transformer;\n }\n return { input: transformer, output: transformer };\n}\n\n/**\n * @internal\n */\nexport const defaultTransformer: CombinedDataTransformer = {\n input: { serialize: (obj) => obj, deserialize: (obj) => obj },\n output: { serialize: (obj) => obj, deserialize: (obj) => obj },\n};\n\nfunction transformTRPCResponseItem<\n TResponseItem extends TRPCResponse | TRPCResponseMessage,\n>(config: RootConfig<AnyRootTypes>, item: TResponseItem): TResponseItem {\n if ('error' in item) {\n return {\n ...item,\n error: config.transformer.output.serialize(item.error),\n };\n }\n\n if ('data' in item.result) {\n return {\n ...item,\n result: {\n ...item.result,\n data: config.transformer.output.serialize(item.result.data),\n },\n };\n }\n\n return item;\n}\n\n/**\n * Takes a unserialized `TRPCResponse` and serializes it with the router's transformers\n **/\nexport function transformTRPCResponse<\n TResponse extends\n | TRPCResponse\n | TRPCResponse[]\n | TRPCResponseMessage\n | TRPCResponseMessage[],\n>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse) {\n return Array.isArray(itemOrItems)\n ? itemOrItems.map((item) => transformTRPCResponseItem(config, item))\n : transformTRPCResponseItem(config, itemOrItems);\n}\n\n// FIXME:\n// - the generics here are probably unnecessary\n// - the RPC-spec could probably be simplified to combine HTTP + WS\n/** @internal */\nfunction transformResultInner<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n) {\n if ('error' in response) {\n const error = transformer.deserialize(\n response.error,\n ) as inferRouterError<TRouter>;\n return {\n ok: false,\n error: {\n ...response,\n error,\n },\n } as const;\n }\n\n const result = {\n ...response.result,\n ...((!response.result.type || response.result.type === 'data') && {\n type: 'data',\n data: transformer.deserialize(response.result.data),\n }),\n } as TRPCResultMessage<TOutput>['result'];\n return { ok: true, result } as const;\n}\n\nclass TransformResultError extends Error {\n constructor() {\n super('Unable to transform response from server');\n }\n}\n\n/**\n * Transforms and validates that the result is a valid TRPCResponse\n * @internal\n */\nexport function transformResult<TRouter extends AnyRouter, TOutput>(\n response:\n | TRPCResponse<TOutput, inferRouterError<TRouter>>\n | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>,\n transformer: DataTransformer,\n): ReturnType<typeof transformResultInner> {\n let result: ReturnType<typeof transformResultInner>;\n try {\n // Use the data transformers on the JSON-response\n result = transformResultInner(response, transformer);\n } catch {\n throw new TransformResultError();\n }\n\n // check that output of the transformers is a valid TRPCResponse\n if (\n !result.ok &&\n (!isObject(result.error.error) ||\n typeof result.error.error['code'] !== 'number')\n ) {\n throw new TransformResultError();\n }\n if (result.ok && !isObject(result.result)) {\n throw new TransformResultError();\n }\n return result;\n}\n","import type { Observable } from '../observable';\nimport { createRecursiveProxy } from './createProxy';\nimport { defaultFormatter } from './error/formatter';\nimport { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';\nimport type {\n AnyProcedure,\n ErrorHandlerOptions,\n inferProcedureInput,\n inferProcedureOutput,\n LegacyObservableSubscriptionProcedure,\n} from './procedure';\nimport type { ProcedureCallOptions } from './procedureBuilder';\nimport type { AnyRootTypes, RootConfig } from './rootConfig';\nimport { defaultTransformer } from './transformer';\nimport type { MaybePromise, ValueOf } from './types';\nimport {\n emptyObject,\n isFunction,\n isObject,\n mergeWithoutOverrides,\n} from './utils';\n\nexport interface RouterRecord {\n [key: string]: AnyProcedure | RouterRecord;\n}\n\ntype DecorateProcedure<TProcedure extends AnyProcedure> = (\n input: inferProcedureInput<TProcedure>,\n) => Promise<\n TProcedure['_def']['type'] extends 'subscription'\n ? TProcedure extends LegacyObservableSubscriptionProcedure<any>\n ? Observable<inferProcedureOutput<TProcedure>, TRPCError>\n : inferProcedureOutput<TProcedure>\n : inferProcedureOutput<TProcedure>\n>;\n\n/**\n * @internal\n */\nexport type DecorateRouterRecord<TRecord extends RouterRecord> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<$Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<$Value>\n : never\n : never;\n};\n\n/**\n * @internal\n */\n\nexport type RouterCallerErrorHandler<TContext> = (\n opts: ErrorHandlerOptions<TContext>,\n) => void;\n\n/**\n * @internal\n */\nexport type RouterCaller<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = (\n /**\n * @note\n * If passing a function, we recommend it's a cached function\n * e.g. wrapped in `React.cache` to avoid unnecessary computations\n */\n ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),\n options?: {\n onError?: RouterCallerErrorHandler<TRoot['ctx']>;\n signal?: AbortSignal;\n },\n) => DecorateRouterRecord<TRecord>;\n\n/**\n * @internal\n */\nconst lazyMarker = 'lazyMarker' as 'lazyMarker' & {\n __brand: 'lazyMarker';\n};\nexport type Lazy<TAny> = (() => Promise<TAny>) & { [lazyMarker]: true };\n\ntype LazyLoader<TAny> = {\n load: () => Promise<void>;\n ref: Lazy<TAny>;\n path: readonly string[];\n key: string;\n};\n\nfunction once<T>(fn: () => T): () => T {\n const uncalled = Symbol();\n let result: T | typeof uncalled = uncalled;\n return (): T => {\n if (result === uncalled) {\n result = fn();\n }\n return result;\n };\n}\n\n/**\n * Lazy load a router\n * @see https://trpc.io/docs/server/merging-routers#lazy-load\n */\nexport function lazy<TRouter extends AnyRouter>(\n importRouter: () => Promise<\n | TRouter\n | {\n [key: string]: TRouter;\n }\n >,\n): Lazy<NoInfer<TRouter>> {\n async function resolve(): Promise<TRouter> {\n const mod = await importRouter();\n\n // if the module is a router, return it\n if (isRouter(mod)) {\n return mod;\n }\n\n const routers = Object.values(mod);\n\n if (routers.length !== 1 || !isRouter(routers[0])) {\n throw new Error(\n \"Invalid router module - either define exactly 1 export or return the router directly.\\nExample: `lazy(() => import('./slow.js').then((m) => m.slowRouter))`\",\n );\n }\n\n return routers[0];\n }\n\n (resolve as Lazy<NoInfer<TRouter>>)[lazyMarker] = true as const;\n\n return resolve as Lazy<NoInfer<TRouter>>;\n}\n\nfunction isLazy<TAny>(input: unknown): input is Lazy<TAny> {\n return typeof input === 'function' && lazyMarker in input;\n}\n\n/**\n * @internal\n */\nexport interface RouterDef<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _config: RootConfig<TRoot>;\n router: true;\n procedure?: never;\n procedures: TRecord;\n record: TRecord;\n lazy: Record<string, LazyLoader<AnyRouter>>;\n}\n\nexport interface Router<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> {\n _def: RouterDef<TRoot, TRecord>;\n /**\n * @see https://trpc.io/docs/v11/server/server-side-calls\n */\n createCaller: RouterCaller<TRoot, TRecord>;\n}\n\nexport type BuiltRouter<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = Router<TRoot, TRecord> & TRecord;\n\nexport interface RouterBuilder<TRoot extends AnyRootTypes> {\n <TIn extends CreateRouterOptions>(\n _: TIn,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;\n}\n\nexport type AnyRouter = Router<any, any>;\n\nexport type inferRouterRootTypes<TRouter extends AnyRouter> =\n TRouter['_def']['_config']['$types'];\n\nexport type inferRouterContext<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['ctx'];\nexport type inferRouterError<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['errorShape'];\nexport type inferRouterMeta<TRouter extends AnyRouter> =\n inferRouterRootTypes<TRouter>['meta'];\n\nfunction isRouter(value: unknown): value is AnyRouter {\n return (\n isObject(value) && isObject(value['_def']) && 'router' in value['_def']\n );\n}\n\nconst emptyRouter = {\n _ctx: null as any,\n _errorShape: null as any,\n _meta: null as any,\n queries: {},\n mutations: {},\n subscriptions: {},\n errorFormatter: defaultFormatter,\n transformer: defaultTransformer,\n};\n\n/**\n * Reserved words that can't be used as router or procedure names\n */\nconst reservedWords = [\n /**\n * Then is a reserved word because otherwise we can't return a promise that returns a Proxy\n * since JS will think that `.then` is something that exists\n */\n 'then',\n /**\n * `fn.call()` and `fn.apply()` are reserved words because otherwise we can't call a function using `.call` or `.apply`\n */\n 'call',\n 'apply',\n];\n\n/** @internal */\nexport type CreateRouterOptions = {\n [key: string]:\n | AnyProcedure\n | AnyRouter\n | CreateRouterOptions\n | Lazy<AnyRouter>;\n};\n\n/** @internal */\nexport type DecorateCreateRouterOptions<\n TRouterOptions extends CreateRouterOptions,\n> = {\n [K in keyof TRouterOptions]: TRouterOptions[K] extends infer $Value\n ? $Value extends AnyProcedure\n ? $Value\n : $Value extends Router<any, infer TRecord>\n ? TRecord\n : $Value extends Lazy<Router<any, infer TRecord>>\n ? TRecord\n : $Value extends CreateRouterOptions\n ? DecorateCreateRouterOptions<$Value>\n : never\n : never;\n};\n\nfunction getRouterInput(router: AnyRouter) {\n const input = Object.assign(\n emptyObject<CreateRouterOptions>(),\n router._def.record,\n );\n\n for (const loader of Object.values(router._def.lazy)) {\n let record = input;\n for (const key of loader.path) {\n record = record[key] = Object.assign(\n emptyObject<CreateRouterOptions>(),\n record[key],\n );\n }\n record[loader.key] = loader.ref;\n }\n\n return input;\n}\n\n/**\n * @internal\n */\nexport function createRouterFactory<TRoot extends AnyRootTypes>(\n config: RootConfig<TRoot>,\n) {\n function createRouterInner<TInput extends CreateRouterOptions>(\n input: TInput,\n ): BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>> {\n const reservedWordsUsed = new Set(\n Object.keys(input).filter((v) => reservedWords.includes(v)),\n );\n if (reservedWordsUsed.size > 0) {\n throw new Error(\n 'Reserved words used in `router({})` call: ' +\n Array.from(reservedWordsUsed).join(', '),\n );\n }\n\n const procedures: Record<string, AnyProcedure> = emptyObject();\n const lazy: Record<string, LazyLoader<AnyRouter>> = emptyObject();\n\n function createLazyLoader(opts: {\n ref: Lazy<AnyRouter>;\n path: readonly string[];\n key: string;\n aggregate: RouterRecord;\n }): LazyLoader<AnyRouter> {\n return {\n ref: opts.ref,\n path: opts.path,\n key: opts.key,\n load: once(async () => {\n const router = await opts.ref();\n const lazyPath = [...opts.path, opts.key];\n const lazyKey = lazyPath.join('.');\n\n opts.aggregate[opts.key] = step(getRouterInput(router), lazyPath);\n\n delete lazy[lazyKey];\n }),\n };\n }\n\n function step(from: CreateRouterOptions, path: readonly string[] = []) {\n const aggregate: RouterRecord = emptyObject();\n for (const [key, item] of Object.entries(from ?? {})) {\n if (isLazy(item)) {\n lazy[[...path, key].join('.')] = createLazyLoader({\n path,\n ref: item,\n key,\n aggregate,\n });\n continue;\n }\n if (isRouter(item)) {\n aggregate[key] = step(getRouterInput(item), [...path, key]);\n continue;\n }\n if (!isProcedure(item)) {\n // RouterRecord\n aggregate[key] = step(item, [...path, key]);\n continue;\n }\n\n const newPath = [...path, key].join('.');\n\n if (procedures[newPath]) {\n throw new Error(`Duplicate key: ${newPath}`);\n }\n\n procedures[newPath] = item;\n aggregate[key] = item;\n }\n\n return aggregate;\n }\n const record = step(input);\n\n const _def: AnyRouter['_def'] = {\n _config: config,\n router: true,\n procedures,\n lazy,\n ...emptyRouter,\n record,\n };\n\n const router: BuiltRouter<TRoot, {}> = {\n ...(record as {}),\n _def,\n createCaller: createCallerFactory<TRoot>()({\n _def,\n }),\n };\n return router as BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;\n }\n\n return createRouterInner;\n}\n\nfunction isProcedure(\n procedureOrRouter: ValueOf<CreateRouterOptions>,\n): procedureOrRouter is AnyProcedure {\n return typeof procedureOrRouter === 'function';\n}\n\n/**\n * @internal\n */\nexport async function getProcedureAtPath(\n router: Pick<Router<any, any>, '_def'>,\n path: string,\n): Promise<AnyProcedure | null> {\n const { _def } = router;\n let procedure = _def.procedures[path];\n\n while (!procedure) {\n const key = Object.keys(_def.lazy).find(\n (key) => path === key || path.startsWith(key + '.'),\n );\n // console.log(`found lazy: ${key ?? 'NOPE'} (fullPath: ${fullPath})`);\n\n if (!key) {\n return null;\n }\n // console.log('loading', key, '.......');\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const lazyRouter = _def.lazy[key]!;\n await lazyRouter.load();\n\n procedure = _def.procedures[path];\n }\n\n return procedure;\n}\n\n/**\n * @internal\n */\nexport async function callProcedure(\n opts: ProcedureCallOptions<unknown> & {\n router: AnyRouter;\n allowMethodOverride?: boolean;\n },\n) {\n const { type, path } = opts;\n const proc = await getProcedureAtPath(opts.router, path);\n if (\n !proc ||\n !isProcedure(proc) ||\n (proc._def.type !== type && !opts.allowMethodOverride)\n ) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No \"${type}\"-procedure on path \"${path}\"`,\n });\n }\n\n /* istanbul ignore if -- @preserve */\n if (\n proc._def.type !== type &&\n opts.allowMethodOverride &&\n proc._def.type === 'subscription'\n ) {\n throw new TRPCError({\n code: 'METHOD_NOT_SUPPORTED',\n message: `Method override is not supported for subscriptions`,\n });\n }\n\n return proc(opts);\n}\n\nexport interface RouterCallerFactory<TRoot extends AnyRootTypes> {\n <TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord>;\n}\n\nexport function createCallerFactory<\n TRoot extends AnyRootTypes,\n>(): RouterCallerFactory<TRoot> {\n return function createCallerInner<TRecord extends RouterRecord>(\n router: Pick<Router<TRoot, TRecord>, '_def'>,\n ): RouterCaller<TRoot, TRecord> {\n const { _def } = router;\n type Context = TRoot['ctx'];\n\n return function createCaller(ctxOrCallback, opts) {\n return createRecursiveProxy<ReturnType<RouterCaller<any, any>>>(\n async (innerOpts) => {\n const { path, args } = innerOpts;\n const fullPath = path.join('.');\n\n if (path.length === 1 && path[0] === '_def') {\n return _def;\n }\n\n const procedure = await getProcedureAtPath(router, fullPath);\n\n let ctx: Context | undefined = undefined;\n try {\n if (!procedure) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: `No procedure found on path \"${path}\"`,\n });\n }\n ctx = isFunction(ctxOrCallback)\n ? await Promise.resolve(ctxOrCallback())\n : ctxOrCallback;\n\n return await procedure({\n path: fullPath,\n getRawInput: async () => args[0],\n ctx,\n type: procedure._def.type,\n signal: opts?.signal,\n batchIndex: 0,\n });\n } catch (cause) {\n opts?.onError?.({\n ctx,\n error: getTRPCErrorFromUnknown(cause),\n input: args[0],\n path: fullPath,\n type: procedure?._def.type ?? 'unknown',\n });\n throw cause;\n }\n },\n );\n };\n };\n}\n\n/** @internal */\nexport type MergeRouters<\n TRouters extends AnyRouter[],\n TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],\n TRecord extends RouterRecord = {},\n> = TRouters extends [\n infer Head extends AnyRouter,\n ...infer Tail extends AnyRouter[],\n]\n ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord>\n : BuiltRouter<TRoot, TRecord>;\n\nexport function mergeRouters<TRouters extends AnyRouter[]>(\n ...routerList: [...TRouters]\n): MergeRouters<TRouters> {\n const record = mergeWithoutOverrides(\n {},\n ...[...new Set(routerList)].map((r) => getRouterInput(r)),\n );\n const errorFormatter = routerList.reduce(\n (currentErrorFormatter, nextRouter) => {\n if (\n nextRouter._def._config.errorFormatter &&\n nextRouter._def._config.errorFormatter !== defaultFormatter\n ) {\n if (\n currentErrorFormatter !== defaultFormatter &&\n currentErrorFormatter !== nextRouter._def._config.errorFormatter\n ) {\n throw new Error('You seem to have several error formatters');\n }\n return nextRouter._def._config.errorFormatter;\n }\n return currentErrorFormatter;\n },\n defaultFormatter,\n );\n\n const transformer = routerList.reduce((prev, current) => {\n if (\n current._def._config.transformer &&\n current._def._config.transformer !== defaultTransformer\n ) {\n if (\n prev !== defaultTransformer &&\n prev !== current._def._config.transformer\n ) {\n throw new Error('You seem to have several transformers');\n }\n return current._def._config.transformer;\n }\n return prev;\n }, defaultTransformer);\n\n const router = createRouterFactory({\n errorFormatter,\n transformer,\n isDev: routerList.every((r) => r._def._config.isDev),\n allowOutsideOfServer: routerList.every(\n (r) => r._def._config.allowOutsideOfServer,\n ),\n isServer: routerList.every((r) => r._def._config.isServer),\n $types: routerList[0]?._def._config.$types,\n sse: routerList[0]?._def._config.sse,\n })(record);\n\n return router as MergeRouters<TRouters>;\n}\n","const trackedSymbol = Symbol();\n\ntype TrackedId = string & {\n __brand: 'TrackedId';\n};\nexport type TrackedEnvelope<TData> = [TrackedId, TData, typeof trackedSymbol];\n\nexport interface TrackedData<TData> {\n /**\n * The id of the message to keep track of in case the connection gets lost\n */\n id: string;\n /**\n * The data field of the message\n */\n data: TData;\n}\n/**\n * Produce a typed server-sent event message\n * @deprecated use `tracked(id, data)` instead\n */\nexport function sse<TData>(event: { id: string; data: TData }) {\n return tracked(event.id, event.data);\n}\n\nexport function isTrackedEnvelope<TData>(\n value: unknown,\n): value is TrackedEnvelope<TData> {\n return Array.isArray(value) && value[2] === trackedSymbol;\n}\n\n/**\n * Automatically track an event so that it can be resumed from a given id if the connection is lost\n */\nexport function tracked<TData>(\n id: string,\n data: TData,\n): TrackedEnvelope<TData> {\n if (id === '') {\n // This limitation could be removed by using different SSE event names / channels for tracked event and non-tracked event\n throw new Error(\n '`id` must not be an empty string as empty string is the same as not setting the id at all',\n );\n }\n return [id as TrackedId, data, trackedSymbol];\n}\n\nexport type inferTrackedOutput<TData> =\n TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;\n"],"mappings":";;;AAGA,IAAM,oBAAN,cAAgC,MAAM;CAGpC,YAAY,OAAe;EACzB,MAAM,WAAW,KAAK,CAAC;EACvB,OAAO,OAAO,MAAM,KAAK;EAEzB,IAAI,YAAY,KAAK,GAAG;GACtB,IAAI,OAAO,MAAM,SAAS,UAAU,KAAK,OAAO,MAAM;G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AAK,QAAQ;CACnC,CAAC,CAAC,CAAC,MAES;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/jBA,MAAM,gBAAgB,OAAO;;;;;AAqB7B,SAAgB,IAAW,OAAoC;CAC7D,OAAO,QAAQ,MAAM,IAAI,MAAM,IAAI;AACrC;AAEA,SAAgB,kBACd,OACiC;CACjC,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO;AAC9C;;;;AAKA,SAAgB,QACd,IACA,MACwB;CACxB,IAAI,OAAO,IAET,MAAM,IAAI,MACR,2FACF;CAEF,OAAO;EAAC;EAAiB;EAAM;CAAa;AAC9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codes-C9N0z0an.mjs","names":[],"sources":["../src/unstable-core-do-not-import/utils.ts","../src/unstable-core-do-not-import/rpc/codes.ts"],"sourcesContent":["/** @internal */\nexport type UnsetMarker = 'unsetMarker' & {\n __brand: 'unsetMarker';\n};\n\n/**\n * Ensures there are no duplicate keys when building a procedure.\n * @internal\n */\nexport function mergeWithoutOverrides<TType extends Record<string, unknown>>(\n obj1: TType,\n ...objs: Partial<TType>[]\n): TType {\n const newObj: TType = Object.assign(emptyObject(), obj1);\n\n for (const overrides of objs) {\n for (const key in overrides) {\n if (key in newObj && newObj[key] !== overrides[key]) {\n throw new Error(`Duplicate key ${key}`);\n }\n newObj[key as keyof TType] = overrides[key] as TType[keyof TType];\n }\n }\n return newObj;\n}\n\n/**\n * Check that value is object\n * @internal\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && !Array.isArray(value) && typeof value === 'object';\n}\n\ntype AnyFn = ((...args: any[]) => unknown) & Record<keyof any, unknown>;\nexport function isFunction(fn: unknown): fn is AnyFn {\n return typeof fn === 'function';\n}\n\n/**\n * Create an object without inheriting anything from `Object.prototype`\n * @internal\n */\nexport function emptyObject<TObj extends Record<string, unknown>>(): TObj {\n return Object.create(null);\n}\n\nconst asyncIteratorsSupported =\n typeof Symbol === 'function' && !!Symbol.asyncIterator;\n\nexport function isAsyncIterable<TValue>(\n value: unknown,\n): value is AsyncIterable<TValue> {\n return (\n asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value\n );\n}\n\n/**\n * Run an IIFE\n */\nexport const run = <TValue>(fn: () => TValue): TValue => fn();\n\n// oxlint-disable-next-line typescript/no-empty-function\nexport function noop(): void {}\n\nexport function identity<T>(it: T): T {\n return it;\n}\n\n/**\n * Generic runtime assertion function. Throws, if the condition is not `true`.\n *\n * Can be used as a slightly less dangerous variant of type assertions. Code\n * mistakes would be revealed at runtime then (hopefully during testing).\n */\nexport function assert(\n condition: boolean,\n msg = 'no additional info',\n): asserts condition {\n if (!condition) {\n throw new Error(`AssertionError: ${msg}`);\n }\n}\n\nexport function assertNever(value: never): never {\n throw new Error(`AssertionError: unexpected value ${String(value)}`);\n}\n\nexport function sleep(ms = 0): Promise<void> {\n return new Promise<void>((res) => setTimeout(res, ms));\n}\n\n/**\n * Ponyfill for\n * [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).\n */\nexport function abortSignalsAnyPonyfill(signals: AbortSignal[]): AbortSignal {\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n\n const ac = new AbortController();\n\n for (const signal of signals) {\n if (signal.aborted) {\n trigger();\n break;\n }\n signal.addEventListener('abort', trigger, { once: true });\n }\n\n return ac.signal;\n\n function trigger() {\n ac.abort();\n for (const signal of signals) {\n signal.removeEventListener('abort', trigger);\n }\n }\n}\n","import type { InvertKeyValue, ValueOf } from '../types';\n\n// reference: https://www.jsonrpc.org/specification\n\n/**\n * JSON-RPC 2.0 Error codes\n *\n * `-32000` to `-32099` are reserved for implementation-defined server-errors.\n * For tRPC we're copying the last digits of HTTP 4XX errors.\n */\nexport const TRPC_ERROR_CODES_BY_KEY = {\n /**\n * Invalid JSON was received by the server.\n * An error occurred on the server while parsing the JSON text.\n */\n PARSE_ERROR: -32700,\n /**\n * The JSON sent is not a valid Request object.\n */\n BAD_REQUEST: -32600, // 400\n\n // Internal JSON-RPC error\n INTERNAL_SERVER_ERROR: -32603, // 500\n NOT_IMPLEMENTED: -32603, // 501\n BAD_GATEWAY: -32603, // 502\n SERVICE_UNAVAILABLE: -32603, // 503\n GATEWAY_TIMEOUT: -32603, // 504\n\n // Implementation specific errors\n UNAUTHORIZED: -32001, // 401\n PAYMENT_REQUIRED: -32002, // 402\n FORBIDDEN: -32003, // 403\n NOT_FOUND: -32004, // 404\n METHOD_NOT_SUPPORTED: -32005, // 405\n TIMEOUT: -32008, // 408\n CONFLICT: -32009, // 409\n PRECONDITION_FAILED: -32012, // 412\n PAYLOAD_TOO_LARGE: -32013, // 413\n UNSUPPORTED_MEDIA_TYPE: -32015, // 415\n UNPROCESSABLE_CONTENT: -32022, // 422\n PRECONDITION_REQUIRED: -32028, // 428\n TOO_MANY_REQUESTS: -32029, // 429\n CLIENT_CLOSED_REQUEST: -32099, // 499\n} as const;\n\n// pure\nexport const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<\n typeof TRPC_ERROR_CODES_BY_KEY\n> = {\n [-32700]: 'PARSE_ERROR',\n [-32600]: 'BAD_REQUEST',\n [-32603]: 'INTERNAL_SERVER_ERROR',\n [-32001]: 'UNAUTHORIZED',\n [-32002]: 'PAYMENT_REQUIRED',\n [-32003]: 'FORBIDDEN',\n [-32004]: 'NOT_FOUND',\n [-32005]: 'METHOD_NOT_SUPPORTED',\n [-32008]: 'TIMEOUT',\n [-32009]: 'CONFLICT',\n [-32012]: 'PRECONDITION_FAILED',\n [-32013]: 'PAYLOAD_TOO_LARGE',\n [-32015]: 'UNSUPPORTED_MEDIA_TYPE',\n [-32022]: 'UNPROCESSABLE_CONTENT',\n [-32028]: 'PRECONDITION_REQUIRED',\n [-32029]: 'TOO_MANY_REQUESTS',\n [-32099]: 'CLIENT_CLOSED_REQUEST',\n};\n\nexport type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;\nexport type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;\n\n/**\n * tRPC error codes that are considered retryable\n * With out of the box SSE, the client will reconnect when these errors are encountered\n */\nexport const retryableRpcCodes: TRPC_ERROR_CODE_NUMBER[] = [\n TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,\n TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,\n TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,\n TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR,\n];\n"],"mappings":";;;;;AASA,SAAgB,sBACd,MACA,GAAG,MACI;CACP,MAAM,SAAgB,OAAO,OAAO,YAAY,GAAG,IAAI;CAEvD,KAAK,MAAM,aAAa,MACtB,KAAK,MAAM,OAAO,WAAW;EAC3B,IAAI,OAAO,UAAU,OAAO,SAAS,UAAU,MAC7C,MAAM,IAAI,MAAM,iBAAiB,KAAK;EAExC,OAAO,OAAsB,UAAU;CACzC;CAEF,OAAO;AACT;;;;;AAMA,SAAgB,SAAS,OAAkD;CACzE,OAAO,CAAC,CAAC,SAAS,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,UAAU;AAC9D;AAGA,SAAgB,WAAW,IAA0B;CACnD,OAAO,OAAO,OAAO;AACvB;;;;;AAMA,SAAgB,cAA0D;CACxE,OAAO,OAAO,OAAO,IAAI;AAC3B;AAEA,MAAM,0BACJ,OAAO,WAAW,cAAc,CAAC,CAAC,OAAO;AAE3C,SAAgB,gBACd,OACgC;CAChC,OACE,2BAA2B,SAAS,KAAK,KAAK,OAAO,iBAAiB;AAE1E;;;;AAKA,MAAa,OAAe,OAA6B,GAAG;AAG5D,SAAgB,OAAa,CAAC;AAE9B,SAAgB,SAAY,IAAU;CACpC,OAA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a,oBAA8C;CACzD,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;AAC1B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/unstable-core-do-not-import/http/contentTypeParsers.ts
|
|
2
|
-
const octetInputParser = {
|
|
3
|
-
_input: null,
|
|
4
|
-
_output: null,
|
|
5
|
-
parse(input) {
|
|
6
|
-
if (input instanceof ReadableStream) return input;
|
|
7
|
-
throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
export { octetInputParser as t };
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=contentTypeParsers-Bb-9hUEf.mjs.map
|