@trpc/server 11.19.0 → 11.21.1-canary.20.10e2ef98f
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/adapters/aws-lambda/index.d.ts +1 -0
- package/adapters/aws-lambda/index.js +1 -0
- package/adapters/express/index.d.ts +1 -0
- package/adapters/express/index.js +1 -0
- package/adapters/fastify/index.d.ts +1 -0
- package/adapters/fastify/index.js +1 -0
- package/adapters/fetch/index.d.ts +1 -0
- package/adapters/fetch/index.js +1 -0
- package/adapters/next/index.d.ts +1 -0
- package/adapters/next/index.js +1 -0
- package/adapters/next-app-dir/index.d.ts +1 -0
- package/adapters/next-app-dir/index.js +1 -0
- package/adapters/node-http/content-type/form-data/index.d.ts +1 -0
- package/adapters/node-http/content-type/form-data/index.js +1 -0
- package/adapters/node-http/content-type/json/index.d.ts +1 -0
- package/adapters/node-http/content-type/json/index.js +1 -0
- package/adapters/node-http/index.d.ts +1 -0
- package/adapters/node-http/index.js +1 -0
- package/adapters/standalone/index.d.ts +1 -0
- package/adapters/standalone/index.js +1 -0
- package/adapters/ws/index.d.ts +1 -0
- package/adapters/ws/index.js +1 -0
- package/dist/adapters/aws-lambda/index.cjs +2 -2
- package/dist/adapters/aws-lambda/index.d.cts +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +1 -1
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/express.cjs +3 -3
- package/dist/adapters/express.d.cts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.mjs +3 -3
- package/dist/adapters/fastify/index.cjs +4 -4
- package/dist/adapters/fastify/index.d.cts +2 -2
- package/dist/adapters/fastify/index.d.mts +2 -2
- package/dist/adapters/fastify/index.mjs +4 -4
- package/dist/adapters/fetch/index.cjs +2 -2
- package/dist/adapters/fetch/index.d.cts +1 -1
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/next-app-dir.cjs +7 -7
- package/dist/adapters/next-app-dir.d.cts +1 -1
- package/dist/adapters/next-app-dir.d.mts +1 -1
- package/dist/adapters/next-app-dir.mjs +2 -2
- package/dist/adapters/next.cjs +5 -5
- package/dist/adapters/next.d.cts +2 -2
- package/dist/adapters/next.d.mts +2 -2
- package/dist/adapters/next.mjs +4 -4
- 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 +3 -3
- package/dist/adapters/standalone.d.cts +2 -2
- package/dist/adapters/standalone.d.mts +2 -2
- package/dist/adapters/standalone.mjs +3 -3
- 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/{tracked-BQJb0ANk.cjs → asyncGeneratorDelegate-D2tFgl_z.cjs} +167 -17
- package/dist/{tracked-D4jU_Hb3.mjs → asyncGeneratorDelegate-mPyp1u6d.mjs} +141 -9
- package/dist/asyncGeneratorDelegate-mPyp1u6d.mjs.map +1 -0
- package/dist/{codes-C6ZIq69A.cjs → codes-BwD4QurF.cjs} +9 -0
- package/dist/{codes-D5Ya6_Bi.mjs → codes-D6C_OiJy.mjs} +5 -2
- package/dist/codes-D6C_OiJy.mjs.map +1 -0
- package/dist/{getErrorShape-B0JBUs-i.mjs → getErrorShape-BziUKLM_.mjs} +52 -14
- package/dist/getErrorShape-BziUKLM_.mjs.map +1 -0
- package/dist/{getErrorShape-DeIapApr.cjs → getErrorShape-CVxLwJgN.cjs} +80 -12
- package/dist/http.cjs +2 -2
- package/dist/http.d.cts +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +2 -2
- package/dist/{index-_jAhoJQ7.d.mts → index-BDZDS1SD.d.mts} +2 -2
- package/dist/{index-BHatz_Pu.d.cts.map → index-BDZDS1SD.d.mts.map} +1 -1
- package/dist/{index-BHatz_Pu.d.cts → index-BzKrDvzg.d.cts} +2 -2
- package/dist/{index-_jAhoJQ7.d.mts.map → index-BzKrDvzg.d.cts.map} +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{initTRPC-B7UdX-c3.cjs → initTRPC-DLNeKv0z.cjs} +114 -26
- package/dist/{initTRPC-B259os3T.mjs → initTRPC-DpOypWK_.mjs} +95 -19
- package/dist/initTRPC-DpOypWK_.mjs.map +1 -0
- package/dist/{node-http-BUlb5EdB.mjs → node-http-B_z10Yky.mjs} +5 -5
- package/dist/{node-http-BUlb5EdB.mjs.map → node-http-B_z10Yky.mjs.map} +1 -1
- package/dist/{node-http-CikCqjt6.cjs → node-http-Bti3aBT6.cjs} +9 -9
- package/dist/{parseTRPCMessage-MJWDg1vX.mjs → parseTRPCMessage-CSh-CVPr.mjs} +2 -2
- package/dist/{parseTRPCMessage-MJWDg1vX.mjs.map → parseTRPCMessage-CSh-CVPr.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-BxAIUx49.cjs → parseTRPCMessage-RJS87G_t.cjs} +1 -1
- package/dist/{resolveResponse-JtMyT9TQ.mjs → resolveResponse-CrB_9MSD.mjs} +43 -179
- package/dist/resolveResponse-CrB_9MSD.mjs.map +1 -0
- package/dist/{resolveResponse-DLpzHrPG.cjs → resolveResponse-D5JAuwvU.cjs} +90 -226
- 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-BK_OKrtM.d.mts → unstable-core-do-not-import-JE3NCpqt.d.mts} +707 -636
- package/dist/unstable-core-do-not-import-JE3NCpqt.d.mts.map +1 -0
- package/dist/{unstable-core-do-not-import-B9ZnrQAU.d.cts → unstable-core-do-not-import-Jynlfuqc.d.cts} +707 -636
- package/dist/unstable-core-do-not-import-Jynlfuqc.d.cts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +30 -23
- package/dist/unstable-core-do-not-import.d.cts +2 -2
- package/dist/unstable-core-do-not-import.d.mts +2 -2
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{ws-BMSSVFiW.cjs → ws-BgBeYgGS.cjs} +22 -22
- package/dist/{ws-C7ZOJJeA.mjs → ws-CNjkWAs9.mjs} +7 -7
- package/dist/{ws-C7ZOJJeA.mjs.map → ws-CNjkWAs9.mjs.map} +1 -1
- package/http/index.d.ts +1 -0
- package/http/index.js +1 -0
- package/observable/index.d.ts +1 -0
- package/observable/index.js +1 -0
- package/package.json +14 -14
- package/rpc/index.d.ts +1 -0
- package/rpc/index.js +1 -0
- package/shared/index.d.ts +1 -0
- package/shared/index.js +1 -0
- package/src/@trpc/server/index.ts +1 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +12 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +90 -3
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +8 -17
- package/src/unstable-core-do-not-import/initTRPC.ts +10 -7
- package/src/unstable-core-do-not-import/middleware.ts +93 -2
- package/src/unstable-core-do-not-import/procedure.ts +2 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +79 -13
- package/src/unstable-core-do-not-import/rootConfig.ts +8 -0
- package/src/unstable-core-do-not-import/stream/jsonl.ts +41 -33
- package/src/unstable-core-do-not-import/utils.ts +4 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/codes-D5Ya6_Bi.mjs.map +0 -1
- package/dist/getErrorShape-B0JBUs-i.mjs.map +0 -1
- package/dist/initTRPC-B259os3T.mjs.map +0 -1
- package/dist/resolveResponse-JtMyT9TQ.mjs.map +0 -1
- package/dist/tracked-D4jU_Hb3.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-B9ZnrQAU.d.cts.map +0 -1
- package/dist/unstable-core-do-not-import-BK_OKrtM.d.mts.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { inferObservableValue, Observable } from '../observable';
|
|
2
|
+
import type { ProcedureErrorFormatter } from './error/formatter';
|
|
2
3
|
import { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';
|
|
3
4
|
import type {
|
|
4
5
|
AnyMiddlewareFunction,
|
|
@@ -7,6 +8,7 @@ import type {
|
|
|
7
8
|
MiddlewareResult,
|
|
8
9
|
} from './middleware';
|
|
9
10
|
import {
|
|
11
|
+
createErrorFormatterMiddleware,
|
|
10
12
|
createInputMiddleware,
|
|
11
13
|
createOutputMiddleware,
|
|
12
14
|
middlewareMarker,
|
|
@@ -23,6 +25,9 @@ import type {
|
|
|
23
25
|
QueryProcedure,
|
|
24
26
|
SubscriptionProcedure,
|
|
25
27
|
} from './procedure';
|
|
28
|
+
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
29
|
+
import { isDevDefault } from './rootConfig';
|
|
30
|
+
import type { TRPCErrorShape } from './rpc';
|
|
26
31
|
import type { inferTrackedOutput } from './stream/tracked';
|
|
27
32
|
import type {
|
|
28
33
|
GetRawInputFn,
|
|
@@ -44,6 +49,9 @@ type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker
|
|
|
44
49
|
? TFallback
|
|
45
50
|
: TValue;
|
|
46
51
|
|
|
52
|
+
type FoldErrorShape<TErrorShape, $Shape> =
|
|
53
|
+
Extract<$Shape, TRPCErrorShape> | TErrorShape;
|
|
54
|
+
|
|
47
55
|
type inferAsyncIterable<TOutput> =
|
|
48
56
|
TOutput extends AsyncIterable<infer $Yield, infer $Return, infer $Next>
|
|
49
57
|
? {
|
|
@@ -87,6 +95,7 @@ type ProcedureBuilderDef<TMeta> = {
|
|
|
87
95
|
subscription?: boolean;
|
|
88
96
|
type?: ProcedureType;
|
|
89
97
|
caller?: CallerOverride<unknown>;
|
|
98
|
+
config?: RootConfig<AnyRootTypes>;
|
|
90
99
|
};
|
|
91
100
|
|
|
92
101
|
type AnyProcedureBuilderDef = ProcedureBuilderDef<any>;
|
|
@@ -144,6 +153,7 @@ export type AnyProcedureBuilder = ProcedureBuilder<
|
|
|
144
153
|
any,
|
|
145
154
|
any,
|
|
146
155
|
any,
|
|
156
|
+
any,
|
|
147
157
|
any
|
|
148
158
|
>;
|
|
149
159
|
|
|
@@ -162,7 +172,8 @@ export type inferProcedureBuilderResolverOptions<
|
|
|
162
172
|
infer TInputOut,
|
|
163
173
|
infer _TOutputIn,
|
|
164
174
|
infer _TOutputOut,
|
|
165
|
-
infer _TCaller
|
|
175
|
+
infer _TCaller,
|
|
176
|
+
infer _TErrorShape
|
|
166
177
|
>
|
|
167
178
|
? ProcedureResolverOptions<
|
|
168
179
|
TContext,
|
|
@@ -193,6 +204,13 @@ export interface ProcedureBuilder<
|
|
|
193
204
|
TOutputIn,
|
|
194
205
|
TOutputOut,
|
|
195
206
|
TCaller extends boolean,
|
|
207
|
+
/**
|
|
208
|
+
* Defaults to `unknown` so that an annotation written without it falls back
|
|
209
|
+
* to the router-wide error shape rather than pinning the procedure to the
|
|
210
|
+
* default one.
|
|
211
|
+
* @see inferProcedureErrorShape
|
|
212
|
+
*/
|
|
213
|
+
TErrorShape = unknown,
|
|
196
214
|
> {
|
|
197
215
|
/**
|
|
198
216
|
* Add an input parser to the procedure.
|
|
@@ -218,7 +236,8 @@ export interface ProcedureBuilder<
|
|
|
218
236
|
IntersectIfDefined<TInputOut, inferParser<$Parser>['out']>,
|
|
219
237
|
TOutputIn,
|
|
220
238
|
TOutputOut,
|
|
221
|
-
TCaller
|
|
239
|
+
TCaller,
|
|
240
|
+
TErrorShape
|
|
222
241
|
>;
|
|
223
242
|
/**
|
|
224
243
|
* Add an output parser to the procedure.
|
|
@@ -234,7 +253,8 @@ export interface ProcedureBuilder<
|
|
|
234
253
|
TInputOut,
|
|
235
254
|
IntersectIfDefined<TOutputIn, inferParser<$Parser>['in']>,
|
|
236
255
|
IntersectIfDefined<TOutputOut, inferParser<$Parser>['out']>,
|
|
237
|
-
TCaller
|
|
256
|
+
TCaller,
|
|
257
|
+
TErrorShape
|
|
238
258
|
>;
|
|
239
259
|
/**
|
|
240
260
|
* Add a meta data to the procedure.
|
|
@@ -250,7 +270,29 @@ export interface ProcedureBuilder<
|
|
|
250
270
|
TInputOut,
|
|
251
271
|
TOutputIn,
|
|
252
272
|
TOutputOut,
|
|
253
|
-
TCaller
|
|
273
|
+
TCaller,
|
|
274
|
+
TErrorShape
|
|
275
|
+
>;
|
|
276
|
+
/**
|
|
277
|
+
* Add per procedure error formatters.
|
|
278
|
+
*
|
|
279
|
+
* An error will bubble until a `.errors()` handler returns a shape
|
|
280
|
+
* or it reaches the global errorFormatter
|
|
281
|
+
*
|
|
282
|
+
* @see https://trpc.io/docs/v11/server/error-formatting
|
|
283
|
+
*/
|
|
284
|
+
errors<$Shape extends TRPCErrorShape | undefined | void>(
|
|
285
|
+
formatter: ProcedureErrorFormatter<TContext, TContextOverrides, $Shape>,
|
|
286
|
+
): ProcedureBuilder<
|
|
287
|
+
TContext,
|
|
288
|
+
TMeta,
|
|
289
|
+
TContextOverrides,
|
|
290
|
+
TInputIn,
|
|
291
|
+
TInputOut,
|
|
292
|
+
TOutputIn,
|
|
293
|
+
TOutputOut,
|
|
294
|
+
TCaller,
|
|
295
|
+
FoldErrorShape<TErrorShape, $Shape>
|
|
254
296
|
>;
|
|
255
297
|
/**
|
|
256
298
|
* Add a middleware to the procedure.
|
|
@@ -279,7 +321,8 @@ export interface ProcedureBuilder<
|
|
|
279
321
|
TInputOut,
|
|
280
322
|
TOutputIn,
|
|
281
323
|
TOutputOut,
|
|
282
|
-
TCaller
|
|
324
|
+
TCaller,
|
|
325
|
+
TErrorShape
|
|
283
326
|
>;
|
|
284
327
|
|
|
285
328
|
/**
|
|
@@ -293,6 +336,7 @@ export interface ProcedureBuilder<
|
|
|
293
336
|
$InputOut,
|
|
294
337
|
$OutputIn,
|
|
295
338
|
$OutputOut,
|
|
339
|
+
$ErrorShape,
|
|
296
340
|
>(
|
|
297
341
|
builder: Overwrite<TContext, TContextOverrides> extends $Context
|
|
298
342
|
? TMeta extends $Meta
|
|
@@ -304,7 +348,8 @@ export interface ProcedureBuilder<
|
|
|
304
348
|
$InputOut,
|
|
305
349
|
$OutputIn,
|
|
306
350
|
$OutputOut,
|
|
307
|
-
TCaller
|
|
351
|
+
TCaller,
|
|
352
|
+
$ErrorShape
|
|
308
353
|
>
|
|
309
354
|
: TypeError<'Meta mismatch'>
|
|
310
355
|
: TypeError<'Context mismatch'>,
|
|
@@ -316,7 +361,8 @@ export interface ProcedureBuilder<
|
|
|
316
361
|
IntersectIfDefined<TInputOut, $InputOut>,
|
|
317
362
|
IntersectIfDefined<TOutputIn, $OutputIn>,
|
|
318
363
|
IntersectIfDefined<TOutputOut, $OutputOut>,
|
|
319
|
-
TCaller
|
|
364
|
+
TCaller,
|
|
365
|
+
FoldErrorShape<TErrorShape, $ErrorShape>
|
|
320
366
|
>;
|
|
321
367
|
|
|
322
368
|
/**
|
|
@@ -330,6 +376,7 @@ export interface ProcedureBuilder<
|
|
|
330
376
|
$InputOut,
|
|
331
377
|
$OutputIn,
|
|
332
378
|
$OutputOut,
|
|
379
|
+
$ErrorShape,
|
|
333
380
|
>(
|
|
334
381
|
builder: Overwrite<TContext, TContextOverrides> extends $Context
|
|
335
382
|
? TMeta extends $Meta
|
|
@@ -341,7 +388,8 @@ export interface ProcedureBuilder<
|
|
|
341
388
|
$InputOut,
|
|
342
389
|
$OutputIn,
|
|
343
390
|
$OutputOut,
|
|
344
|
-
TCaller
|
|
391
|
+
TCaller,
|
|
392
|
+
$ErrorShape
|
|
345
393
|
>
|
|
346
394
|
: TypeError<'Meta mismatch'>
|
|
347
395
|
: TypeError<'Context mismatch'>,
|
|
@@ -353,7 +401,8 @@ export interface ProcedureBuilder<
|
|
|
353
401
|
IntersectIfDefined<TInputOut, $InputOut>,
|
|
354
402
|
IntersectIfDefined<TOutputIn, $OutputIn>,
|
|
355
403
|
IntersectIfDefined<TOutputOut, $OutputOut>,
|
|
356
|
-
TCaller
|
|
404
|
+
TCaller,
|
|
405
|
+
FoldErrorShape<TErrorShape, $ErrorShape>
|
|
357
406
|
>;
|
|
358
407
|
/**
|
|
359
408
|
* Query procedure
|
|
@@ -376,6 +425,7 @@ export interface ProcedureBuilder<
|
|
|
376
425
|
input: DefaultValue<TInputIn, void>;
|
|
377
426
|
output: DefaultValue<TOutputOut, $Output>;
|
|
378
427
|
meta: TMeta;
|
|
428
|
+
errorShape: TErrorShape;
|
|
379
429
|
}>;
|
|
380
430
|
|
|
381
431
|
/**
|
|
@@ -399,6 +449,7 @@ export interface ProcedureBuilder<
|
|
|
399
449
|
input: DefaultValue<TInputIn, void>;
|
|
400
450
|
output: DefaultValue<TOutputOut, $Output>;
|
|
401
451
|
meta: TMeta;
|
|
452
|
+
errorShape: TErrorShape;
|
|
402
453
|
}>;
|
|
403
454
|
|
|
404
455
|
/**
|
|
@@ -420,6 +471,7 @@ export interface ProcedureBuilder<
|
|
|
420
471
|
input: DefaultValue<TInputIn, void>;
|
|
421
472
|
output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;
|
|
422
473
|
meta: TMeta;
|
|
474
|
+
errorShape: TErrorShape;
|
|
423
475
|
}>;
|
|
424
476
|
/**
|
|
425
477
|
* @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.
|
|
@@ -441,6 +493,7 @@ export interface ProcedureBuilder<
|
|
|
441
493
|
input: DefaultValue<TInputIn, void>;
|
|
442
494
|
output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;
|
|
443
495
|
meta: TMeta;
|
|
496
|
+
errorShape: TErrorShape;
|
|
444
497
|
}>;
|
|
445
498
|
/**
|
|
446
499
|
* Overrides the way a procedure is invoked
|
|
@@ -456,7 +509,8 @@ export interface ProcedureBuilder<
|
|
|
456
509
|
TInputOut,
|
|
457
510
|
TOutputIn,
|
|
458
511
|
TOutputOut,
|
|
459
|
-
true
|
|
512
|
+
true,
|
|
513
|
+
TErrorShape
|
|
460
514
|
>;
|
|
461
515
|
/**
|
|
462
516
|
* @internal
|
|
@@ -472,18 +526,19 @@ function createNewBuilder(
|
|
|
472
526
|
def1: AnyProcedureBuilderDef,
|
|
473
527
|
def2: Partial<AnyProcedureBuilderDef>,
|
|
474
528
|
): AnyProcedureBuilder {
|
|
475
|
-
const { middlewares = [], inputs, meta, ...rest } = def2;
|
|
529
|
+
const { middlewares = [], inputs, meta, config, ...rest } = def2;
|
|
476
530
|
|
|
477
531
|
// TODO: maybe have a fn here to warn about calls
|
|
478
532
|
return createBuilder({
|
|
479
533
|
...mergeWithoutOverrides(def1, rest),
|
|
534
|
+
config: def1.config ?? config,
|
|
480
535
|
inputs: [...def1.inputs, ...(inputs ?? [])],
|
|
481
536
|
middlewares: [...def1.middlewares, ...middlewares],
|
|
482
537
|
meta: def1.meta && meta ? { ...def1.meta, ...meta } : (meta ?? def1.meta),
|
|
483
538
|
});
|
|
484
539
|
}
|
|
485
540
|
|
|
486
|
-
export function createBuilder<TContext, TMeta>(
|
|
541
|
+
export function createBuilder<TContext, TMeta, TErrorShape = unknown>(
|
|
487
542
|
initDef: Partial<AnyProcedureBuilderDef> = {},
|
|
488
543
|
): ProcedureBuilder<
|
|
489
544
|
TContext,
|
|
@@ -493,7 +548,8 @@ export function createBuilder<TContext, TMeta>(
|
|
|
493
548
|
UnsetMarker,
|
|
494
549
|
UnsetMarker,
|
|
495
550
|
UnsetMarker,
|
|
496
|
-
false
|
|
551
|
+
false,
|
|
552
|
+
TErrorShape
|
|
497
553
|
> {
|
|
498
554
|
const _def: AnyProcedureBuilderDef = {
|
|
499
555
|
procedure: true,
|
|
@@ -523,6 +579,16 @@ export function createBuilder<TContext, TMeta>(
|
|
|
523
579
|
meta,
|
|
524
580
|
});
|
|
525
581
|
},
|
|
582
|
+
errors(formatter) {
|
|
583
|
+
return createNewBuilder(_def, {
|
|
584
|
+
middlewares: [
|
|
585
|
+
createErrorFormatterMiddleware(
|
|
586
|
+
formatter,
|
|
587
|
+
_def.config?.isDev ?? isDevDefault(),
|
|
588
|
+
),
|
|
589
|
+
],
|
|
590
|
+
});
|
|
591
|
+
},
|
|
526
592
|
use(middlewareBuilderOrFn) {
|
|
527
593
|
// Distinguish between a middleware builder and a middleware function
|
|
528
594
|
const middlewares =
|
|
@@ -25,6 +25,14 @@ export const isServerDefault: boolean =
|
|
|
25
25
|
!!globalThis.process?.env?.['JEST_WORKER_ID'] ||
|
|
26
26
|
!!globalThis.process?.env?.['VITEST_WORKER_ID'];
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The default check to see if we're in development
|
|
30
|
+
*/
|
|
31
|
+
export function isDevDefault(): boolean {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
33
|
+
return globalThis.process?.env['NODE_ENV'] !== 'production';
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
/**
|
|
29
37
|
* The tRPC root config
|
|
30
38
|
* @internal
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from '@trpc/server/vendor/is-plain-object';
|
|
2
2
|
import {
|
|
3
|
+
assertNever,
|
|
3
4
|
emptyObject,
|
|
4
5
|
isAsyncIterable,
|
|
5
6
|
isFunction,
|
|
@@ -543,45 +544,52 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
543
544
|
|
|
544
545
|
const controller = streamManager.getOrCreate(chunkId);
|
|
545
546
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
547
|
+
if (type === CHUNK_VALUE_TYPE_PROMISE) {
|
|
548
|
+
return run(async () => {
|
|
549
|
+
using reader = controller.getReaderResource();
|
|
550
|
+
|
|
551
|
+
const { done, value } = await reader.read();
|
|
552
|
+
|
|
553
|
+
if (done) {
|
|
554
|
+
throw new Error('Stream closed unexpectedly');
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const [_chunkId, status, data] = value as PromiseChunk;
|
|
558
|
+
switch (status) {
|
|
559
|
+
case PROMISE_STATUS_FULFILLED:
|
|
560
|
+
return decode(data);
|
|
561
|
+
case PROMISE_STATUS_REJECTED:
|
|
562
|
+
throw opts.formatError?.({ error: data }) ?? new AsyncError(data);
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
if (type === CHUNK_VALUE_TYPE_ASYNC_ITERABLE) {
|
|
567
|
+
return run(async function* () {
|
|
568
|
+
using reader = controller.getReaderResource();
|
|
569
|
+
|
|
570
|
+
while (true) {
|
|
571
|
+
const { done, value } = await reader.read();
|
|
572
|
+
|
|
573
|
+
if (done) {
|
|
574
|
+
throw new Error('Stream closed unexpectedly');
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const [_chunkId, status, data] = value as IterableChunk;
|
|
550
578
|
|
|
551
|
-
const { value } = await reader.read();
|
|
552
|
-
const [_chunkId, status, data] = value as PromiseChunk;
|
|
553
579
|
switch (status) {
|
|
554
|
-
case
|
|
580
|
+
case ASYNC_ITERABLE_STATUS_YIELD:
|
|
581
|
+
yield decode(data);
|
|
582
|
+
break;
|
|
583
|
+
case ASYNC_ITERABLE_STATUS_RETURN:
|
|
555
584
|
return decode(data);
|
|
556
|
-
case
|
|
585
|
+
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
557
586
|
throw opts.formatError?.({ error: data }) ?? new AsyncError(data);
|
|
558
587
|
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
case CHUNK_VALUE_TYPE_ASYNC_ITERABLE: {
|
|
562
|
-
return run(async function* () {
|
|
563
|
-
using reader = controller.getReaderResource();
|
|
564
|
-
|
|
565
|
-
while (true) {
|
|
566
|
-
const { value } = await reader.read();
|
|
567
|
-
|
|
568
|
-
const [_chunkId, status, data] = value as IterableChunk;
|
|
569
|
-
|
|
570
|
-
switch (status) {
|
|
571
|
-
case ASYNC_ITERABLE_STATUS_YIELD:
|
|
572
|
-
yield decode(data);
|
|
573
|
-
break;
|
|
574
|
-
case ASYNC_ITERABLE_STATUS_RETURN:
|
|
575
|
-
return decode(data);
|
|
576
|
-
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
577
|
-
throw (
|
|
578
|
-
opts.formatError?.({ error: data }) ?? new AsyncError(data)
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
}
|
|
588
|
+
}
|
|
589
|
+
});
|
|
584
590
|
}
|
|
591
|
+
|
|
592
|
+
assertNever(type);
|
|
585
593
|
}
|
|
586
594
|
|
|
587
595
|
function decode(value: EncodedValue): unknown {
|
|
@@ -83,6 +83,10 @@ export function assert(
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export function assertNever(value: never): never {
|
|
87
|
+
throw new Error(`AssertionError: unexpected value ${String(value)}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
86
90
|
export function sleep(ms = 0): Promise<void> {
|
|
87
91
|
return new Promise<void>((res) => setTimeout(res, ms));
|
|
88
92
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/unstable-core-do-not-import';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/unstable-core-do-not-import');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codes-D5Ya6_Bi.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// eslint-disable-next-line @typescript-eslint/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 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,I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B,mBAAmB;CACnB,uBAAuB;AACzB;AAGA,MAAa,6BAET;EACD,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;AACZ;;;;;AASA,MAAa,oBAA8C;CACzD,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;AAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getErrorShape-B0JBUs-i.mjs","names":[],"sources":["../src/unstable-core-do-not-import/createProxy.ts","../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts","../src/unstable-core-do-not-import/error/getErrorShape.ts"],"sourcesContent":["import { emptyObject } from './utils';\n\ninterface ProxyCallbackOptions {\n path: readonly string[];\n args: readonly unknown[];\n}\ntype ProxyCallback = (opts: ProxyCallbackOptions) => unknown;\n\nconst noop = () => {\n // noop\n};\n\nconst freezeIfAvailable = (obj: object) => {\n if (Object.freeze) {\n Object.freeze(obj);\n }\n};\n\nfunction createInnerProxy(\n callback: ProxyCallback,\n path: readonly string[],\n memo: Record<string, unknown>,\n) {\n const cacheKey = path.join('.');\n\n memo[cacheKey] ??= new Proxy(noop, {\n get(_obj, key) {\n if (typeof key !== 'string' || key === 'then') {\n // special case for if the proxy is accidentally treated\n // like a PromiseLike (like in `Promise.resolve(proxy)`)\n return undefined;\n }\n return createInnerProxy(callback, [...path, key], memo);\n },\n apply(_1, _2, args) {\n const lastOfPath = path[path.length - 1];\n\n // React 19 may call valueOf / toString / toJSON when coercing a proxy\n // to a primitive (e.g. during rendering or logging). Return a debug\n // string so the coercion does not recurse into the proxy. This only\n // triggers for direct calls (proxy.toString()), not for chained access\n // (proxy.toString.query()), preserving route naming freedom.\n if (\n lastOfPath === 'valueOf' ||\n lastOfPath === 'toString' ||\n lastOfPath === 'toJSON'\n ) {\n const debugPath = path.slice(0, -1).join('.');\n return `tRPC.proxy(${debugPath})`;\n }\n\n let opts = { args, path };\n // special handling for e.g. `trpc.hello.call(this, 'there')` and `trpc.hello.apply(this, ['there'])\n if (lastOfPath === 'call') {\n opts = {\n args: args.length >= 2 ? [args[1]] : [],\n path: path.slice(0, -1),\n };\n } else if (lastOfPath === 'apply') {\n opts = {\n args: args.length >= 2 ? args[1] : [],\n path: path.slice(0, -1),\n };\n }\n freezeIfAvailable(opts.args);\n freezeIfAvailable(opts.path);\n return callback(opts);\n },\n });\n\n return memo[cacheKey];\n}\n\n/**\n * Creates a proxy that calls the callback with the path and arguments\n *\n * @internal\n */\nexport const createRecursiveProxy = <TFaux = unknown>(\n callback: ProxyCallback,\n): TFaux => createInnerProxy(callback, [], emptyObject()) as TFaux;\n\n/**\n * Used in place of `new Proxy` where each handler will map 1 level deep to another value.\n *\n * @internal\n */\nexport const createFlatProxy = <TFaux>(\n callback: (path: keyof TFaux) => any,\n): TFaux => {\n return new Proxy(noop, {\n get(_obj, name) {\n if (name === 'then') {\n // special case for if the proxy is accidentally treated\n // like a PromiseLike (like in `Promise.resolve(proxy)`)\n return undefined;\n }\n return callback(name as any);\n },\n }) as TFaux;\n};\n","import type { TRPCError } from '../error/TRPCError';\nimport type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';\nimport { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc';\nimport type { InvertKeyValue, ValueOf } from '../types';\nimport { isObject } from '../utils';\n\nexport const JSONRPC2_TO_HTTP_CODE: Record<\n keyof typeof TRPC_ERROR_CODES_BY_KEY,\n number\n> = {\n PARSE_ERROR: 400,\n BAD_REQUEST: 400,\n UNAUTHORIZED: 401,\n PAYMENT_REQUIRED: 402,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n METHOD_NOT_SUPPORTED: 405,\n TIMEOUT: 408,\n CONFLICT: 409,\n PRECONDITION_FAILED: 412,\n PAYLOAD_TOO_LARGE: 413,\n UNSUPPORTED_MEDIA_TYPE: 415,\n UNPROCESSABLE_CONTENT: 422,\n PRECONDITION_REQUIRED: 428,\n TOO_MANY_REQUESTS: 429,\n CLIENT_CLOSED_REQUEST: 499,\n INTERNAL_SERVER_ERROR: 500,\n NOT_IMPLEMENTED: 501,\n BAD_GATEWAY: 502,\n SERVICE_UNAVAILABLE: 503,\n GATEWAY_TIMEOUT: 504,\n};\n\nexport const HTTP_CODE_TO_JSONRPC2: InvertKeyValue<\n typeof JSONRPC2_TO_HTTP_CODE\n> = {\n 400: 'BAD_REQUEST',\n 401: 'UNAUTHORIZED',\n 402: 'PAYMENT_REQUIRED',\n 403: 'FORBIDDEN',\n 404: 'NOT_FOUND',\n 405: 'METHOD_NOT_SUPPORTED',\n 408: 'TIMEOUT',\n 409: 'CONFLICT',\n 412: 'PRECONDITION_FAILED',\n 413: 'PAYLOAD_TOO_LARGE',\n 415: 'UNSUPPORTED_MEDIA_TYPE',\n 422: 'UNPROCESSABLE_CONTENT',\n 428: 'PRECONDITION_REQUIRED',\n 429: 'TOO_MANY_REQUESTS',\n 499: 'CLIENT_CLOSED_REQUEST',\n 500: 'INTERNAL_SERVER_ERROR',\n 501: 'NOT_IMPLEMENTED',\n 502: 'BAD_GATEWAY',\n 503: 'SERVICE_UNAVAILABLE',\n 504: 'GATEWAY_TIMEOUT',\n} as const;\n\nexport function getStatusCodeFromKey(\n code: keyof typeof TRPC_ERROR_CODES_BY_KEY,\n) {\n return JSONRPC2_TO_HTTP_CODE[code] ?? 500;\n}\n\nexport function getStatusKeyFromCode(\n code: keyof typeof HTTP_CODE_TO_JSONRPC2,\n): ValueOf<typeof HTTP_CODE_TO_JSONRPC2> {\n return HTTP_CODE_TO_JSONRPC2[code] ?? 'INTERNAL_SERVER_ERROR';\n}\n\nexport function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]) {\n const arr = Array.isArray(json) ? json : [json];\n const httpStatuses = new Set<number>(\n arr.map((res) => {\n if ('error' in res && isObject(res.error.data)) {\n if (typeof res.error.data?.['httpStatus'] === 'number') {\n return res.error.data['httpStatus'];\n }\n const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];\n return getStatusCodeFromKey(code);\n }\n return 200;\n }),\n );\n\n if (httpStatuses.size !== 1) {\n return 207;\n }\n\n const httpStatus = httpStatuses.values().next().value;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return httpStatus!;\n}\n\nexport function getHTTPStatusCodeFromError(error: TRPCError) {\n return getStatusCodeFromKey(error.code);\n}\n","import { getHTTPStatusCodeFromError } from '../http/getHTTPStatusCode';\nimport type { ProcedureType } from '../procedure';\nimport type { AnyRootTypes, RootConfig } from '../rootConfig';\nimport { TRPC_ERROR_CODES_BY_KEY } from '../rpc';\nimport type { DefaultErrorShape } from './formatter';\nimport type { TRPCError } from './TRPCError';\n\n/**\n * @internal\n */\nexport function getErrorShape<TRoot extends AnyRootTypes>(opts: {\n config: RootConfig<TRoot>;\n error: TRPCError;\n type: ProcedureType | 'unknown';\n path: string | undefined;\n input: unknown;\n ctx: TRoot['ctx'] | undefined;\n}): TRoot['errorShape'] {\n const { path, error, config } = opts;\n const { code } = opts.error;\n const shape: DefaultErrorShape = {\n message: error.message,\n code: TRPC_ERROR_CODES_BY_KEY[code],\n data: {\n code,\n httpStatus: getHTTPStatusCodeFromError(error),\n },\n };\n if (config.isDev && typeof opts.error.stack === 'string') {\n shape.data.stack = opts.error.stack;\n }\n if (typeof path === 'string') {\n shape.data.path = path;\n }\n return config.errorFormatter({ ...opts, shape });\n}\n"],"mappings":";;AAQA,MAAM,aAAa,CAEnB;AAEA,MAAM,qBAAqB,QAAgB;CACzC,IAAI,OAAO,QACT,OAAO,OAAO,GAAG;AAErB;AAEA,SAAS,iBACP,UACA,MACA,MACA;;CACA,MAAM,WAAW,KAAK,KAAK,GAAG;CAE9B,CAAA,iBAAA,KAAK,eAAA,QAAA,mBAAA,KAAA,MAAL,KAAK,YAAc,IAAI,MAAM,MAAM;EACjC,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,wBAAwB;EAC9B,MAAM;GACJ;GACA,YAAY,2BAA2B,KAAK;EAC9C;CACF;CACA,IAAI,OAAO,SAAS,OAAO,KAAK,MAAM,UAAU,UAC9C,MAAM,KAAK,QAAQ,KAAK,MAAM;CAEhC,IAAI,OAAO,SAAS,UAClB,MAAM,KAAK,OAAO;CAEpB,OAAO,OAAO,eAAA,eAAA,eAAA,CAAA,GAAoB,IAAA,GAAA,CAAA,GAAA,EAAM,MAAA,CAAM,CAAC;AACjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initTRPC-B259os3T.mjs","names":[],"sources":["../src/unstable-core-do-not-import/middleware.ts","../src/vendor/standard-schema-v1/error.ts","../src/unstable-core-do-not-import/parser.ts","../src/unstable-core-do-not-import/procedureBuilder.ts","../src/unstable-core-do-not-import/rootConfig.ts","../src/unstable-core-do-not-import/initTRPC.ts"],"sourcesContent":["import { TRPCError } from './error/TRPCError';\nimport type { ParseFn } from './parser';\nimport type { ProcedureType } from './procedure';\nimport type { GetRawInputFn, Overwrite, Simplify } from './types';\nimport { isObject } from './utils';\n\n/** @internal */\nexport const middlewareMarker = 'middlewareMarker' as 'middlewareMarker' & {\n __brand: 'middlewareMarker';\n};\ntype MiddlewareMarker = typeof middlewareMarker;\n\ninterface MiddlewareResultBase {\n /**\n * All middlewares should pass through their `next()`'s output.\n * Requiring this marker makes sure that can't be forgotten at compile-time.\n */\n readonly marker: MiddlewareMarker;\n}\n\ninterface MiddlewareOKResult<_TContextOverride> extends MiddlewareResultBase {\n ok: true;\n data: unknown;\n // this could be extended with `input`/`rawInput` later\n}\n\ninterface MiddlewareErrorResult<\n _TContextOverride,\n> extends MiddlewareResultBase {\n ok: false;\n error: TRPCError;\n}\n\n/**\n * @internal\n */\nexport type MiddlewareResult<_TContextOverride> =\n | MiddlewareErrorResult<_TContextOverride>\n | MiddlewareOKResult<_TContextOverride>;\n\n/**\n * @internal\n */\nexport interface MiddlewareBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n> {\n /**\n * Create a new builder based on the current middleware builder\n */\n unstable_pipe<$ContextOverridesOut>(\n fn:\n | MiddlewareFunction<\n TContext,\n TMeta,\n TContextOverrides,\n $ContextOverridesOut,\n TInputOut\n >\n | MiddlewareBuilder<\n Overwrite<TContext, TContextOverrides>,\n TMeta,\n $ContextOverridesOut,\n TInputOut\n >,\n ): MiddlewareBuilder<\n TContext,\n TMeta,\n Overwrite<TContextOverrides, $ContextOverridesOut>,\n TInputOut\n >;\n\n /**\n * List of middlewares within this middleware builder\n */\n _middlewares: MiddlewareFunction<\n TContext,\n TMeta,\n TContextOverrides,\n object,\n TInputOut\n >[];\n}\n\n/**\n * @internal\n */\nexport type MiddlewareFunction<\n TContext,\n TMeta,\n TContextOverridesIn,\n $ContextOverridesOut,\n TInputOut,\n> = {\n (opts: {\n ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;\n type: ProcedureType;\n path: string;\n input: TInputOut;\n getRawInput: GetRawInputFn;\n meta: TMeta | undefined;\n signal: AbortSignal | undefined;\n /**\n * The index of this call in a batch request.\n */\n batchIndex: number;\n next: {\n (): Promise<MiddlewareResult<TContextOverridesIn>>;\n <$ContextOverride>(opts: {\n ctx?: $ContextOverride;\n input?: unknown;\n }): Promise<MiddlewareResult<$ContextOverride>>;\n (opts: {\n getRawInput: GetRawInputFn;\n }): Promise<MiddlewareResult<TContextOverridesIn>>;\n };\n }): Promise<MiddlewareResult<$ContextOverridesOut>>;\n _type?: string | undefined;\n};\n\nexport type AnyMiddlewareFunction = MiddlewareFunction<any, any, any, any, any>;\nexport type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;\n/**\n * @internal\n */\nexport function createMiddlewareFactory<\n TContext,\n TMeta,\n TInputOut = unknown,\n>() {\n function createMiddlewareInner(\n middlewares: AnyMiddlewareFunction[],\n ): AnyMiddlewareBuilder {\n return {\n _middlewares: middlewares,\n unstable_pipe(middlewareBuilderOrFn) {\n const pipedMiddleware =\n '_middlewares' in middlewareBuilderOrFn\n ? middlewareBuilderOrFn._middlewares\n : [middlewareBuilderOrFn];\n\n return createMiddlewareInner([...middlewares, ...pipedMiddleware]);\n },\n };\n }\n\n function createMiddleware<$ContextOverrides>(\n fn: MiddlewareFunction<\n TContext,\n TMeta,\n object,\n $ContextOverrides,\n TInputOut\n >,\n ): MiddlewareBuilder<TContext, TMeta, $ContextOverrides, TInputOut> {\n return createMiddlewareInner([fn]);\n }\n\n return createMiddleware;\n}\n\n/**\n * Create a standalone middleware\n * @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares\n * @deprecated use `.concat()` instead\n */\nexport const experimental_standaloneMiddleware = <\n TCtx extends {\n ctx?: object;\n meta?: object;\n input?: unknown;\n },\n>() => ({\n create: createMiddlewareFactory<\n TCtx extends { ctx: infer T extends object } ? T : any,\n TCtx extends { meta: infer T extends object } ? T : object,\n TCtx extends { input: infer T } ? T : unknown\n >(),\n});\n\n/**\n * @internal\n * Please note, `trpc-openapi` uses this function.\n */\nexport function createInputMiddleware<TInput>(parse: ParseFn<TInput>) {\n const inputMiddleware: AnyMiddlewareFunction =\n async function inputValidatorMiddleware(opts) {\n let parsedInput: ReturnType<typeof parse>;\n\n const rawInput = await opts.getRawInput();\n try {\n parsedInput = await parse(rawInput);\n } catch (cause) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n cause,\n });\n }\n\n // Multiple input parsers\n const combinedInput =\n isObject(opts.input) && isObject(parsedInput)\n ? {\n ...opts.input,\n ...parsedInput,\n }\n : parsedInput;\n\n return opts.next({ input: combinedInput });\n };\n inputMiddleware._type = 'input';\n return inputMiddleware;\n}\n\n/**\n * @internal\n */\nexport function createOutputMiddleware<TOutput>(parse: ParseFn<TOutput>) {\n const outputMiddleware: AnyMiddlewareFunction =\n async function outputValidatorMiddleware({ next }) {\n const result = await next();\n if (!result.ok) {\n // pass through failures without validating\n return result;\n }\n try {\n const data = await parse(result.data);\n return {\n ...result,\n data,\n };\n } catch (cause) {\n throw new TRPCError({\n message: 'Output validation failed',\n code: 'INTERNAL_SERVER_ERROR',\n cause,\n });\n }\n };\n outputMiddleware._type = 'output';\n return outputMiddleware;\n}\n","import type { StandardSchemaV1 } from \"./spec\";\n\n/** A schema error with useful information. */\n\nexport class StandardSchemaV1Error extends Error {\n /** The schema issues. */\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;\n\n /**\n * Creates a schema error with useful information.\n *\n * @param issues The schema issues.\n */\n constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>) {\n super(issues[0]?.message);\n this.name = 'SchemaError';\n this.issues = issues;\n }\n}\n","import { StandardSchemaV1Error } from '../vendor/standard-schema-v1/error';\nimport { type StandardSchemaV1 } from '../vendor/standard-schema-v1/spec';\n\n// zod / typeschema\nexport type ParserZodEsque<TInput, TParsedInput> = {\n _input: TInput;\n _output: TParsedInput;\n};\n\nexport type ParserValibotEsque<TInput, TParsedInput> = {\n schema: {\n _types?: {\n input: TInput;\n output: TParsedInput;\n };\n };\n};\n\nexport type ParserArkTypeEsque<TInput, TParsedInput> = {\n inferIn: TInput;\n infer: TParsedInput;\n};\n\nexport type ParserStandardSchemaEsque<TInput, TParsedInput> = StandardSchemaV1<\n TInput,\n TParsedInput\n>;\n\nexport type ParserMyZodEsque<TInput> = {\n parse: (input: any) => TInput;\n};\n\nexport type ParserSuperstructEsque<TInput> = {\n create: (input: unknown) => TInput;\n};\n\nexport type ParserCustomValidatorEsque<TInput> = (\n input: unknown,\n) => Promise<TInput> | TInput;\n\nexport type ParserYupEsque<TInput> = {\n validateSync: (input: unknown) => TInput;\n};\n\nexport type ParserScaleEsque<TInput> = {\n assert(value: unknown): asserts value is TInput;\n};\n\nexport type ParserWithoutInput<TInput> =\n | ParserCustomValidatorEsque<TInput>\n | ParserMyZodEsque<TInput>\n | ParserScaleEsque<TInput>\n | ParserSuperstructEsque<TInput>\n | ParserYupEsque<TInput>;\n\nexport type ParserWithInputOutput<TInput, TParsedInput> =\n | ParserZodEsque<TInput, TParsedInput>\n | ParserValibotEsque<TInput, TParsedInput>\n | ParserArkTypeEsque<TInput, TParsedInput>\n | ParserStandardSchemaEsque<TInput, TParsedInput>;\n\nexport type Parser = ParserWithInputOutput<any, any> | ParserWithoutInput<any>;\n\nexport type inferParser<TParser extends Parser> =\n TParser extends ParserStandardSchemaEsque<infer $TIn, infer $TOut>\n ? {\n in: $TIn;\n out: $TOut;\n }\n : TParser extends ParserWithInputOutput<infer $TIn, infer $TOut>\n ? {\n in: $TIn;\n out: $TOut;\n }\n : TParser extends ParserWithoutInput<infer $InOut>\n ? {\n in: $InOut;\n out: $InOut;\n }\n : never;\n\nexport type ParseFn<TType> = (value: unknown) => Promise<TType> | TType;\n\nexport function getParseFn<TType>(procedureParser: Parser): ParseFn<TType> {\n const parser = procedureParser as any;\n const isStandardSchema = '~standard' in parser;\n\n if (typeof parser === 'function' && typeof parser.assert === 'function') {\n // ParserArkTypeEsque - arktype schemas shouldn't be called as a function because they return a union type instead of throwing\n return parser.assert.bind(parser);\n }\n\n if (typeof parser === 'function' && !isStandardSchema) {\n // ParserValibotEsque (>= v0.31.0)\n // ParserCustomValidatorEsque - note the check for standard-schema conformance - some libraries like `effect` use function schemas which are *not* a \"parse\" function.\n return parser;\n }\n\n if (typeof parser.parseAsync === 'function') {\n // ParserZodEsque\n return parser.parseAsync.bind(parser);\n }\n\n if (typeof parser.parse === 'function') {\n // ParserZodEsque\n // ParserValibotEsque (< v0.13.0)\n return parser.parse.bind(parser);\n }\n\n if (typeof parser.validateSync === 'function') {\n // ParserYupEsque\n return parser.validateSync.bind(parser);\n }\n\n if (typeof parser.create === 'function') {\n // ParserSuperstructEsque\n return parser.create.bind(parser);\n }\n\n if (typeof parser.assert === 'function') {\n // ParserScaleEsque\n return (value) => {\n parser.assert(value);\n return value as TType;\n };\n }\n\n if (isStandardSchema) {\n // StandardSchemaEsque\n return async (value) => {\n const result = await parser['~standard'].validate(value);\n if (result.issues) {\n throw new StandardSchemaV1Error(result.issues);\n }\n return result.value;\n };\n }\n\n throw new Error('Could not find a validator fn');\n}\n","import type { inferObservableValue, Observable } from '../observable';\nimport { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';\nimport type {\n AnyMiddlewareFunction,\n MiddlewareBuilder,\n MiddlewareFunction,\n MiddlewareResult,\n} from './middleware';\nimport {\n createInputMiddleware,\n createOutputMiddleware,\n middlewareMarker,\n} from './middleware';\nimport type { inferParser, Parser } from './parser';\nimport { getParseFn } from './parser';\nimport type {\n AnyMutationProcedure,\n AnyProcedure,\n AnyQueryProcedure,\n LegacyObservableSubscriptionProcedure,\n MutationProcedure,\n ProcedureType,\n QueryProcedure,\n SubscriptionProcedure,\n} from './procedure';\nimport type { inferTrackedOutput } from './stream/tracked';\nimport type {\n GetRawInputFn,\n MaybePromise,\n Overwrite,\n Simplify,\n TypeError,\n} from './types';\nimport type { UnsetMarker } from './utils';\nimport { mergeWithoutOverrides } from './utils';\n\ntype IntersectIfDefined<TType, TWith> = TType extends UnsetMarker\n ? TWith\n : TWith extends UnsetMarker\n ? TType\n : Simplify<TType & TWith>;\n\ntype DefaultValue<TValue, TFallback> = TValue extends UnsetMarker\n ? TFallback\n : TValue;\n\ntype inferAsyncIterable<TOutput> =\n TOutput extends AsyncIterable<infer $Yield, infer $Return, infer $Next>\n ? {\n yield: $Yield;\n return: $Return;\n next: $Next;\n }\n : never;\ntype inferSubscriptionOutput<TOutput> =\n TOutput extends AsyncIterable<any>\n ? AsyncIterable<\n inferTrackedOutput<inferAsyncIterable<TOutput>['yield']>,\n inferAsyncIterable<TOutput>['return'],\n inferAsyncIterable<TOutput>['next']\n >\n : TypeError<'Subscription output could not be inferred'>;\n\nexport type CallerOverride<TContext> = (opts: {\n args: unknown[];\n invoke: (opts: ProcedureCallOptions<TContext>) => Promise<unknown>;\n _def: AnyProcedure['_def'];\n}) => Promise<unknown>;\ntype ProcedureBuilderDef<TMeta> = {\n procedure: true;\n inputs: Parser[];\n output?: Parser;\n meta?: TMeta;\n resolver?: ProcedureBuilderResolver;\n middlewares: AnyMiddlewareFunction[];\n /**\n * @deprecated use `type` instead\n */\n mutation?: boolean;\n /**\n * @deprecated use `type` instead\n */\n query?: boolean;\n /**\n * @deprecated use `type` instead\n */\n subscription?: boolean;\n type?: ProcedureType;\n caller?: CallerOverride<unknown>;\n};\n\ntype AnyProcedureBuilderDef = ProcedureBuilderDef<any>;\n\n/**\n * Procedure resolver options (what the `.query()`, `.mutation()`, and `.subscription()` functions receive)\n * @internal\n */\nexport interface ProcedureResolverOptions<\n TContext,\n _TMeta,\n TContextOverridesIn,\n TInputOut,\n> {\n ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;\n input: TInputOut extends UnsetMarker ? undefined : TInputOut;\n /**\n * The AbortSignal of the request\n */\n signal: AbortSignal | undefined;\n /**\n * The path of the procedure\n */\n path: string;\n /**\n * The index of this call in a batch request.\n * Will be set when the procedure is called as part of a batch.\n */\n batchIndex?: number;\n}\n\n/**\n * A procedure resolver\n */\ntype ProcedureResolver<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n TOutputParserIn,\n $Output,\n> = (\n opts: ProcedureResolverOptions<TContext, TMeta, TContextOverrides, TInputOut>,\n) => MaybePromise<\n // If an output parser is defined, we need to return what the parser expects, otherwise we return the inferred type\n DefaultValue<TOutputParserIn, $Output>\n>;\n\ntype AnyResolver = ProcedureResolver<any, any, any, any, any, any>;\nexport type AnyProcedureBuilder = ProcedureBuilder<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>;\n\n/**\n * Infer the context type from a procedure builder\n * Useful to create common helper functions for different procedures\n */\nexport type inferProcedureBuilderResolverOptions<\n TProcedureBuilder extends AnyProcedureBuilder,\n> =\n TProcedureBuilder extends ProcedureBuilder<\n infer TContext,\n infer TMeta,\n infer TContextOverrides,\n infer _TInputIn,\n infer TInputOut,\n infer _TOutputIn,\n infer _TOutputOut,\n infer _TCaller\n >\n ? ProcedureResolverOptions<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut extends UnsetMarker\n ? // if input is not set, we don't want to infer it as `undefined` since a procedure further down the chain might have set an input\n unknown\n : TInputOut extends object\n ? Simplify<\n TInputOut & {\n /**\n * Extra input params might have been added by a `.input()` further down the chain\n */\n [keyAddedByInputCallFurtherDown: string]: unknown;\n }\n >\n : TInputOut\n >\n : never;\n\nexport interface ProcedureBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n TInputIn,\n TInputOut,\n TOutputIn,\n TOutputOut,\n TCaller extends boolean,\n> {\n /**\n * Add an input parser to the procedure.\n * @see https://trpc.io/docs/v11/server/validators\n */\n input<$Parser extends Parser>(\n schema: TInputOut extends UnsetMarker\n ? $Parser\n : inferParser<$Parser>['out'] extends Record<string, unknown> | undefined\n ? TInputOut extends Record<string, unknown> | undefined\n ? undefined extends inferParser<$Parser>['out'] // if current is optional the previous must be too\n ? undefined extends TInputOut\n ? $Parser\n : TypeError<'Cannot chain an optional parser to a required parser'>\n : $Parser\n : TypeError<'All input parsers did not resolve to an object'>\n : TypeError<'All input parsers did not resolve to an object'>,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n IntersectIfDefined<TInputIn, inferParser<$Parser>['in']>,\n IntersectIfDefined<TInputOut, inferParser<$Parser>['out']>,\n TOutputIn,\n TOutputOut,\n TCaller\n >;\n /**\n * Add an output parser to the procedure.\n * @see https://trpc.io/docs/v11/server/validators\n */\n output<$Parser extends Parser>(\n schema: $Parser,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n TInputIn,\n TInputOut,\n IntersectIfDefined<TOutputIn, inferParser<$Parser>['in']>,\n IntersectIfDefined<TOutputOut, inferParser<$Parser>['out']>,\n TCaller\n >;\n /**\n * Add a meta data to the procedure.\n * @see https://trpc.io/docs/v11/server/metadata\n */\n meta(\n meta: TMeta,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n TInputIn,\n TInputOut,\n TOutputIn,\n TOutputOut,\n TCaller\n >;\n /**\n * Add a middleware to the procedure.\n * @see https://trpc.io/docs/v11/server/middlewares\n */\n use<$ContextOverridesOut>(\n fn:\n | MiddlewareBuilder<\n Overwrite<TContext, TContextOverrides>,\n TMeta,\n $ContextOverridesOut,\n TInputOut\n >\n | MiddlewareFunction<\n TContext,\n TMeta,\n TContextOverrides,\n $ContextOverridesOut,\n TInputOut\n >,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n Overwrite<TContextOverrides, $ContextOverridesOut>,\n TInputIn,\n TInputOut,\n TOutputIn,\n TOutputOut,\n TCaller\n >;\n\n /**\n * @deprecated use {@link concat} instead\n */\n unstable_concat<\n $Context,\n $Meta,\n $ContextOverrides,\n $InputIn,\n $InputOut,\n $OutputIn,\n $OutputOut,\n >(\n builder: Overwrite<TContext, TContextOverrides> extends $Context\n ? TMeta extends $Meta\n ? ProcedureBuilder<\n $Context,\n $Meta,\n $ContextOverrides,\n $InputIn,\n $InputOut,\n $OutputIn,\n $OutputOut,\n TCaller\n >\n : TypeError<'Meta mismatch'>\n : TypeError<'Context mismatch'>,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n Overwrite<TContextOverrides, $ContextOverrides>,\n IntersectIfDefined<TInputIn, $InputIn>,\n IntersectIfDefined<TInputOut, $InputOut>,\n IntersectIfDefined<TOutputIn, $OutputIn>,\n IntersectIfDefined<TOutputOut, $OutputOut>,\n TCaller\n >;\n\n /**\n * Combine two procedure builders\n */\n concat<\n $Context,\n $Meta,\n $ContextOverrides,\n $InputIn,\n $InputOut,\n $OutputIn,\n $OutputOut,\n >(\n builder: Overwrite<TContext, TContextOverrides> extends $Context\n ? TMeta extends $Meta\n ? ProcedureBuilder<\n $Context,\n $Meta,\n $ContextOverrides,\n $InputIn,\n $InputOut,\n $OutputIn,\n $OutputOut,\n TCaller\n >\n : TypeError<'Meta mismatch'>\n : TypeError<'Context mismatch'>,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n Overwrite<TContextOverrides, $ContextOverrides>,\n IntersectIfDefined<TInputIn, $InputIn>,\n IntersectIfDefined<TInputOut, $InputOut>,\n IntersectIfDefined<TOutputIn, $OutputIn>,\n IntersectIfDefined<TOutputOut, $OutputOut>,\n TCaller\n >;\n /**\n * Query procedure\n * @see https://trpc.io/docs/v11/concepts#vocabulary\n */\n query<$Output>(\n resolver: ProcedureResolver<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n TOutputIn,\n $Output\n >,\n ): TCaller extends true\n ? (\n input: DefaultValue<TInputIn, void>,\n ) => Promise<DefaultValue<TOutputOut, $Output>>\n : QueryProcedure<{\n input: DefaultValue<TInputIn, void>;\n output: DefaultValue<TOutputOut, $Output>;\n meta: TMeta;\n }>;\n\n /**\n * Mutation procedure\n * @see https://trpc.io/docs/v11/concepts#vocabulary\n */\n mutation<$Output>(\n resolver: ProcedureResolver<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n TOutputIn,\n $Output\n >,\n ): TCaller extends true\n ? (\n input: DefaultValue<TInputIn, void>,\n ) => Promise<DefaultValue<TOutputOut, $Output>>\n : MutationProcedure<{\n input: DefaultValue<TInputIn, void>;\n output: DefaultValue<TOutputOut, $Output>;\n meta: TMeta;\n }>;\n\n /**\n * Subscription procedure\n * @see https://trpc.io/docs/v11/server/subscriptions\n */\n subscription<$Output extends AsyncIterable<any, void, any>>(\n resolver: ProcedureResolver<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n TOutputIn,\n $Output\n >,\n ): TCaller extends true\n ? TypeError<'Not implemented'>\n : SubscriptionProcedure<{\n input: DefaultValue<TInputIn, void>;\n output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;\n meta: TMeta;\n }>;\n /**\n * @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.\n * This feature will be removed in v12 of tRPC.\n * @see https://trpc.io/docs/v11/server/subscriptions\n */\n subscription<$Output extends Observable<any, any>>(\n resolver: ProcedureResolver<\n TContext,\n TMeta,\n TContextOverrides,\n TInputOut,\n TOutputIn,\n $Output\n >,\n ): TCaller extends true\n ? TypeError<'Not implemented'>\n : LegacyObservableSubscriptionProcedure<{\n input: DefaultValue<TInputIn, void>;\n output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;\n meta: TMeta;\n }>;\n /**\n * Overrides the way a procedure is invoked\n * Do not use this unless you know what you're doing - this is an experimental API\n */\n experimental_caller(\n caller: CallerOverride<TContext>,\n ): ProcedureBuilder<\n TContext,\n TMeta,\n TContextOverrides,\n TInputIn,\n TInputOut,\n TOutputIn,\n TOutputOut,\n true\n >;\n /**\n * @internal\n */\n _def: ProcedureBuilderDef<TMeta>;\n}\n\ntype ProcedureBuilderResolver = (\n opts: ProcedureResolverOptions<any, any, any, any>,\n) => Promise<unknown>;\n\nfunction createNewBuilder(\n def1: AnyProcedureBuilderDef,\n def2: Partial<AnyProcedureBuilderDef>,\n): AnyProcedureBuilder {\n const { middlewares = [], inputs, meta, ...rest } = def2;\n\n // TODO: maybe have a fn here to warn about calls\n return createBuilder({\n ...mergeWithoutOverrides(def1, rest),\n inputs: [...def1.inputs, ...(inputs ?? [])],\n middlewares: [...def1.middlewares, ...middlewares],\n meta: def1.meta && meta ? { ...def1.meta, ...meta } : (meta ?? def1.meta),\n });\n}\n\nexport function createBuilder<TContext, TMeta>(\n initDef: Partial<AnyProcedureBuilderDef> = {},\n): ProcedureBuilder<\n TContext,\n TMeta,\n object,\n UnsetMarker,\n UnsetMarker,\n UnsetMarker,\n UnsetMarker,\n false\n> {\n const _def: AnyProcedureBuilderDef = {\n procedure: true,\n inputs: [],\n middlewares: [],\n ...initDef,\n };\n\n const builder: AnyProcedureBuilder = {\n _def,\n input(input) {\n const parser = getParseFn(input as Parser);\n return createNewBuilder(_def, {\n inputs: [input as Parser],\n middlewares: [createInputMiddleware(parser)],\n });\n },\n output(output: Parser) {\n const parser = getParseFn(output);\n return createNewBuilder(_def, {\n output,\n middlewares: [createOutputMiddleware(parser)],\n });\n },\n meta(meta) {\n return createNewBuilder(_def, {\n meta,\n });\n },\n use(middlewareBuilderOrFn) {\n // Distinguish between a middleware builder and a middleware function\n const middlewares =\n '_middlewares' in middlewareBuilderOrFn\n ? middlewareBuilderOrFn._middlewares\n : [middlewareBuilderOrFn];\n\n return createNewBuilder(_def, {\n middlewares: middlewares,\n });\n },\n unstable_concat(builder) {\n return createNewBuilder(_def, (builder as AnyProcedureBuilder)._def);\n },\n concat(builder) {\n return createNewBuilder(_def, (builder as AnyProcedureBuilder)._def);\n },\n query(resolver) {\n return createResolver(\n { ..._def, type: 'query' },\n resolver,\n ) as AnyQueryProcedure;\n },\n mutation(resolver) {\n return createResolver(\n { ..._def, type: 'mutation' },\n resolver,\n ) as AnyMutationProcedure;\n },\n subscription(resolver: ProcedureResolver<any, any, any, any, any, any>) {\n return createResolver({ ..._def, type: 'subscription' }, resolver) as any;\n },\n experimental_caller(caller) {\n return createNewBuilder(_def, {\n caller,\n }) as any;\n },\n };\n\n return builder;\n}\n\nfunction createResolver(\n _defIn: AnyProcedureBuilderDef & { type: ProcedureType },\n resolver: AnyResolver,\n) {\n const finalBuilder = createNewBuilder(_defIn, {\n resolver,\n middlewares: [\n async function resolveMiddleware(opts) {\n const data = await resolver(opts);\n return {\n marker: middlewareMarker,\n ok: true,\n data,\n ctx: opts.ctx,\n } as const;\n },\n ],\n });\n const _def: AnyProcedure['_def'] = {\n ...finalBuilder._def,\n type: _defIn.type,\n experimental_caller: Boolean(finalBuilder._def.caller),\n meta: finalBuilder._def.meta,\n $types: null as any,\n };\n\n const invoke = createProcedureCaller(finalBuilder._def);\n const callerOverride = finalBuilder._def.caller;\n if (!callerOverride) {\n return invoke;\n }\n const callerWrapper = async (...args: unknown[]) => {\n return await callerOverride({\n args,\n invoke,\n _def: _def,\n });\n };\n\n callerWrapper._def = _def;\n\n return callerWrapper;\n}\n\n/**\n * @internal\n */\nexport interface ProcedureCallOptions<TContext> {\n ctx: TContext;\n getRawInput: GetRawInputFn;\n input?: unknown;\n path: string;\n type: ProcedureType;\n signal: AbortSignal | undefined;\n /**\n * The index of this call in a batch request.\n */\n batchIndex: number;\n}\n\nconst codeblock = `\nThis is a client-only function.\nIf you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls\n`.trim();\n\n// run the middlewares recursively with the resolver as the last one\nasync function callRecursive(\n index: number,\n _def: AnyProcedureBuilderDef,\n opts: ProcedureCallOptions<any>,\n): Promise<MiddlewareResult<any>> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const middleware = _def.middlewares[index]!;\n const result = await middleware({\n ...opts,\n meta: _def.meta,\n input: opts.input,\n next(_nextOpts?: any) {\n const nextOpts = _nextOpts as\n | {\n ctx?: Record<string, unknown>;\n input?: unknown;\n getRawInput?: GetRawInputFn;\n }\n | undefined;\n\n return callRecursive(index + 1, _def, {\n ...opts,\n ctx: nextOpts?.ctx ? { ...opts.ctx, ...nextOpts.ctx } : opts.ctx,\n input: nextOpts && 'input' in nextOpts ? nextOpts.input : opts.input,\n getRawInput: nextOpts?.getRawInput ?? opts.getRawInput,\n });\n },\n });\n\n return result;\n } catch (cause) {\n return {\n ok: false,\n error: getTRPCErrorFromUnknown(cause),\n marker: middlewareMarker,\n };\n }\n}\n\nfunction createProcedureCaller(_def: AnyProcedureBuilderDef): AnyProcedure {\n async function procedure(opts: ProcedureCallOptions<unknown>) {\n // is direct server-side call\n if (!opts || !('getRawInput' in opts)) {\n throw new Error(codeblock);\n }\n\n // there's always at least one \"next\" since we wrap this.resolver in a middleware\n const result = await callRecursive(0, _def, opts);\n\n if (!result) {\n throw new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message:\n 'No result from middlewares - did you forget to `return next()`?',\n });\n }\n if (!result.ok) {\n // re-throw original error\n throw result.error;\n }\n return result.data;\n }\n\n procedure._def = _def;\n procedure.procedure = true;\n procedure.meta = _def.meta;\n\n // FIXME typecast shouldn't be needed - fixittt\n return procedure as unknown as AnyProcedure;\n}\n","import type { CombinedDataTransformer } from '../unstable-core-do-not-import';\nimport type { DefaultErrorShape, ErrorFormatter } from './error/formatter';\nimport type { JSONLProducerOptions } from './stream/jsonl';\nimport type { SSEStreamProducerOptions } from './stream/sse';\n\n/**\n * The initial generics that are used in the init function\n * @internal\n */\nexport interface RootTypes {\n ctx: object;\n meta: object;\n errorShape: DefaultErrorShape;\n transformer: boolean;\n}\n\n/**\n * The default check to see if we're in a server\n */\nexport const isServerDefault: boolean =\n typeof window === 'undefined' ||\n 'Deno' in window ||\n // eslint-disable-next-line @typescript-eslint/dot-notation\n globalThis.process?.env?.['NODE_ENV'] === 'test' ||\n !!globalThis.process?.env?.['JEST_WORKER_ID'] ||\n !!globalThis.process?.env?.['VITEST_WORKER_ID'];\n\n/**\n * The tRPC root config\n * @internal\n */\nexport interface RootConfig<TTypes extends RootTypes> {\n /**\n * The types that are used in the config\n * @internal\n */\n $types: TTypes;\n /**\n * Use a data transformer\n * @see https://trpc.io/docs/v11/data-transformers\n */\n transformer: CombinedDataTransformer;\n /**\n * Use custom error formatting\n * @see https://trpc.io/docs/v11/error-formatting\n */\n errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;\n /**\n * Allow `@trpc/server` to run in non-server environments\n * @warning **Use with caution**, this should likely mainly be used within testing.\n * @default false\n */\n allowOutsideOfServer: boolean;\n /**\n * Is this a server environment?\n * @warning **Use with caution**, this should likely mainly be used within testing.\n * @default typeof window === 'undefined' || 'Deno' in window || process.env.NODE_ENV === 'test'\n */\n isServer: boolean;\n /**\n * Is this development?\n * Will be used to decide if the API should return stack traces\n * @default process.env.NODE_ENV !== 'production'\n */\n isDev: boolean;\n\n defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;\n\n /**\n * Options for server-sent events (SSE) subscriptions\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink\n */\n sse?: {\n /**\n * Enable server-sent events (SSE) subscriptions\n * @default true\n */\n enabled?: boolean;\n } & Pick<\n SSEStreamProducerOptions,\n 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'\n >;\n\n /**\n * Options for batch stream\n * @see https://trpc.io/docs/client/links/httpBatchStreamLink\n */\n jsonl?: Pick<JSONLProducerOptions, 'pingMs'>;\n experimental?: {};\n}\n\n/**\n * @internal\n */\nexport type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;\n\nexport type AnyRootTypes = CreateRootTypes<{\n ctx: any;\n meta: any;\n errorShape: any;\n transformer: any;\n}>;\n\ntype PartialIf<TCondition extends boolean, TType> = TCondition extends true\n ? Partial<TType>\n : TType;\n\n/**\n * Adds a `createContext` option with a given callback function\n * If context is the default value, then the `createContext` option is optional\n */\nexport type CreateContextCallback<\n TContext,\n TFunction extends (...args: any[]) => any,\n> = PartialIf<\n object extends TContext ? true : false,\n {\n /**\n * @see https://trpc.io/docs/v11/context\n **/\n createContext: TFunction;\n }\n>;\n","import {\n defaultFormatter,\n type DefaultErrorShape,\n type ErrorFormatter,\n} from './error/formatter';\nimport type { MiddlewareBuilder, MiddlewareFunction } from './middleware';\nimport { createMiddlewareFactory } from './middleware';\nimport type { ProcedureBuilder } from './procedureBuilder';\nimport { createBuilder } from './procedureBuilder';\nimport type { AnyRootTypes, CreateRootTypes } from './rootConfig';\nimport { isServerDefault, type RootConfig } from './rootConfig';\nimport type {\n AnyRouter,\n MergeRouters,\n RouterBuilder,\n RouterCallerFactory,\n} from './router';\nimport {\n createCallerFactory,\n createRouterFactory,\n mergeRouters,\n} from './router';\nimport type { DataTransformerOptions } from './transformer';\nimport { defaultTransformer, getDataTransformer } from './transformer';\nimport type { Unwrap, ValidateShape } from './types';\nimport type { UnsetMarker } from './utils';\n\ntype inferErrorFormatterShape<TType> =\n TType extends ErrorFormatter<any, infer TShape> ? TShape : DefaultErrorShape;\n/** @internal */\nexport interface RuntimeConfigOptions<\n TContext extends object,\n TMeta extends object,\n> extends Partial<\n Omit<\n RootConfig<{\n ctx: TContext;\n meta: TMeta;\n errorShape: any;\n transformer: any;\n }>,\n '$types' | 'transformer'\n >\n> {\n /**\n * Use a data transformer\n * @see https://trpc.io/docs/v11/data-transformers\n */\n transformer?: DataTransformerOptions;\n}\n\ntype ContextCallback = (...args: any[]) => object | Promise<object>;\n\nexport interface TRPCRootObject<\n TContext extends object,\n TMeta extends object,\n TOptions extends RuntimeConfigOptions<TContext, TMeta>,\n $Root extends AnyRootTypes = {\n ctx: TContext;\n meta: TMeta;\n errorShape: undefined extends TOptions['errorFormatter']\n ? DefaultErrorShape\n : inferErrorFormatterShape<TOptions['errorFormatter']>;\n transformer: undefined extends TOptions['transformer'] ? false : true;\n },\n> {\n /**\n * Your router config\n * @internal\n */\n _config: RootConfig<$Root>;\n\n /**\n * Builder object for creating procedures\n * @see https://trpc.io/docs/v11/server/procedures\n */\n procedure: ProcedureBuilder<\n TContext,\n TMeta,\n object,\n UnsetMarker,\n UnsetMarker,\n UnsetMarker,\n UnsetMarker,\n false\n >;\n\n /**\n * Create reusable middlewares\n * @see https://trpc.io/docs/v11/server/middlewares\n */\n middleware: <$ContextOverrides>(\n fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, unknown>,\n ) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, unknown>;\n\n /**\n * Create a router\n * @see https://trpc.io/docs/v11/server/routers\n */\n router: RouterBuilder<$Root>;\n\n /**\n * Merge Routers\n * @see https://trpc.io/docs/v11/server/merging-routers\n */\n mergeRouters: <TRouters extends AnyRouter[]>(\n ...routerList: [...TRouters]\n ) => MergeRouters<TRouters>;\n\n /**\n * Create a server-side caller for a router\n * @see https://trpc.io/docs/v11/server/server-side-calls\n */\n createCallerFactory: RouterCallerFactory<$Root>;\n}\n\nclass TRPCBuilder<TContext extends object, TMeta extends object> {\n /**\n * Add a context shape as a generic to the root object\n * @see https://trpc.io/docs/v11/server/context\n */\n context<TNewContext extends object | ContextCallback>() {\n return new TRPCBuilder<\n TNewContext extends ContextCallback ? Unwrap<TNewContext> : TNewContext,\n TMeta\n >();\n }\n\n /**\n * Add a meta shape as a generic to the root object\n * @see https://trpc.io/docs/v11/quickstart\n */\n meta<TNewMeta extends object>() {\n return new TRPCBuilder<TContext, TNewMeta>();\n }\n\n /**\n * Create the root object\n * @see https://trpc.io/docs/v11/server/routers#initialize-trpc\n */\n create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(\n opts?: ValidateShape<TOptions, RuntimeConfigOptions<TContext, TMeta>>,\n ): TRPCRootObject<TContext, TMeta, TOptions> {\n type $Root = CreateRootTypes<{\n ctx: TContext;\n meta: TMeta;\n errorShape: undefined extends TOptions['errorFormatter']\n ? DefaultErrorShape\n : inferErrorFormatterShape<TOptions['errorFormatter']>;\n transformer: undefined extends TOptions['transformer'] ? false : true;\n }>;\n\n const config: RootConfig<$Root> = {\n ...opts,\n transformer: getDataTransformer(opts?.transformer ?? defaultTransformer),\n isDev:\n opts?.isDev ??\n // eslint-disable-next-line @typescript-eslint/dot-notation\n globalThis.process?.env['NODE_ENV'] !== 'production',\n allowOutsideOfServer: opts?.allowOutsideOfServer ?? false,\n errorFormatter: opts?.errorFormatter ?? defaultFormatter,\n isServer: opts?.isServer ?? isServerDefault,\n /**\n * These are just types, they can't be used at runtime\n * @internal\n */\n $types: null as any,\n };\n\n {\n // Server check\n const isServer: boolean = opts?.isServer ?? isServerDefault;\n\n if (!isServer && opts?.allowOutsideOfServer !== true) {\n throw new Error(\n `You're trying to use @trpc/server in a non-server environment. This is not supported by default.`,\n );\n }\n }\n return {\n /**\n * Your router config\n * @internal\n */\n _config: config,\n /**\n * Builder object for creating procedures\n * @see https://trpc.io/docs/v11/server/procedures\n */\n procedure: createBuilder<$Root['ctx'], $Root['meta']>({\n meta: opts?.defaultMeta,\n }),\n /**\n * Create reusable middlewares\n * @see https://trpc.io/docs/v11/server/middlewares\n */\n middleware: createMiddlewareFactory<$Root['ctx'], $Root['meta']>(),\n /**\n * Create a router\n * @see https://trpc.io/docs/v11/server/routers\n */\n router: createRouterFactory<$Root>(config),\n /**\n * Merge Routers\n * @see https://trpc.io/docs/v11/server/merging-routers\n */\n mergeRouters,\n /**\n * Create a server-side caller for a router\n * @see https://trpc.io/docs/v11/server/server-side-calls\n */\n createCallerFactory: createCallerFactory<$Root>(),\n };\n }\n}\n\n/**\n * Builder to initialize the tRPC root object - use this exactly once per backend\n * @see https://trpc.io/docs/v11/quickstart\n */\nexport const initTRPC = new TRPCBuilder();\nexport type { TRPCBuilder };\n"],"mappings":";;;;;AAOA,MAAa,mBAAmB;;;;AAwHhC,SAAgB,0BAIZ;CACF,SAAS,sBACP,aACsB;EACtB,OAAO;GACL,cAAc;GACd,cAAc,uBAAuB;IACnC,MAAM,kBACJ,kBAAkB,wBACd,sBAAsB,eACtB,CAAC,qBAAqB;IAE5B,OAAO,sBAAsB,CAAC,GAAG,aAAa,GAAG,eAAe,CAAC;GACnE;EACF;CACF;CAEA,SAAS,iBACP,IAOkE;EAClE,OAAO,sBAAsB,CAAC,EAAE,CAAC;CACnC;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,2CAML,EACN,QAAQ,wBAIN,EACJ;;;;;AAMA,SAAgB,sBAA8B,OAAwB;CACpE,MAAM,kBACJ,eAAe,yBAAyB,MAAM;EAC5C,IAAI;EAEJ,MAAM,WAAW,MAAM,KAAK,YAAY;EACxC,IAAI;GACF,cAAc,MAAM,MAAM,QAAQ;EACpC,SAAS,OAAO;GACd,MAAM,IAAI,UAAU;IAClB,MAAM;IACN;GACF,CAAC;EACH;EAGA,MAAM,gBACJ,SAAS,KAAK,KAAK,KAAK,SAAS,WAAW,IAAA,eAAA,eAAA,CAAA,GAEnC,KAAK,KAAA,GACL,WACL,IACA;EAEN,OAAO,KAAK,KAAK,EAAE,OAAO,cAAc,CAAC;CAC3C;CACF,gBAAgB,QAAQ;CACxB,OAAO;AACT;;;;AAKA,SAAgB,uBAAgC,OAAyB;CACvE,MAAM,mBACJ,eAAe,0BAA0B,EAAE,QAAQ;EACjD,MAAM,SAAS,MAAM,KAAK;EAC1B,IAAI,CAAC,OAAO,IAEV,OAAO;EAET,IAAI;GACF,MAAM,OAAO,MAAM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