@trpc/server 11.0.0-rc.544 → 11.0.0-rc.552
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/bundle-analysis.json +30 -30
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +16 -4
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +16 -4
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +15 -10
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +19 -4
- package/src/unstable-core-do-not-import/procedureBuilder.ts +28 -17
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
2
|
+
"bundleSize": 136668,
|
|
3
|
+
"bundleOrigSize": 186605,
|
|
4
4
|
"bundleReduction": 26.76,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 18439,
|
|
9
|
+
"origSize": 17070,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"resolveResponse"
|
|
12
12
|
],
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/unstable-core-do-not-import.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 13.
|
|
17
|
+
"percent": 13.49,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"/src/unstable-core-do-not-import.ts",
|
|
32
32
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 12.
|
|
34
|
+
"percent": 12.85,
|
|
35
35
|
"reduction": 4.31
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependents": [
|
|
48
48
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
49
49
|
],
|
|
50
|
-
"percent": 11.
|
|
50
|
+
"percent": 11.92,
|
|
51
51
|
"reduction": 0
|
|
52
52
|
},
|
|
53
53
|
{
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"/src/unstable-core-do-not-import.ts",
|
|
63
63
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
64
64
|
],
|
|
65
|
-
"percent": 5.
|
|
65
|
+
"percent": 5.63,
|
|
66
66
|
"reduction": 0
|
|
67
67
|
},
|
|
68
68
|
{
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"/src/unstable-core-do-not-import.ts",
|
|
81
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
82
82
|
],
|
|
83
|
-
"percent": 4.
|
|
83
|
+
"percent": 4.7,
|
|
84
84
|
"reduction": 40.18
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -97,13 +97,13 @@
|
|
|
97
97
|
"/src/unstable-core-do-not-import.ts",
|
|
98
98
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
99
99
|
],
|
|
100
|
-
"percent": 4.
|
|
100
|
+
"percent": 4.32,
|
|
101
101
|
"reduction": 15.22
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
105
105
|
"size": 5795,
|
|
106
|
-
"origSize":
|
|
106
|
+
"origSize": 16084,
|
|
107
107
|
"renderedExports": [
|
|
108
108
|
"createBuilder"
|
|
109
109
|
],
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"/src/unstable-core-do-not-import.ts",
|
|
113
113
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
114
114
|
],
|
|
115
|
-
"percent": 4.
|
|
116
|
-
"reduction": 63.
|
|
115
|
+
"percent": 4.24,
|
|
116
|
+
"reduction": 63.97
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"id": "/src/adapters/aws-lambda/getPlanner.ts",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"dependents": [
|
|
127
127
|
"/src/adapters/aws-lambda/index.ts"
|
|
128
128
|
],
|
|
129
|
-
"percent": 3.
|
|
129
|
+
"percent": 3.96,
|
|
130
130
|
"reduction": 11.38
|
|
131
131
|
},
|
|
132
132
|
{
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
147
147
|
"/src/observable/operators.ts"
|
|
148
148
|
],
|
|
149
|
-
"percent": 3.
|
|
149
|
+
"percent": 3.01,
|
|
150
150
|
"reduction": 0
|
|
151
151
|
},
|
|
152
152
|
{
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"dependents": [
|
|
161
161
|
"/src/adapters/next-app-dir.ts"
|
|
162
162
|
],
|
|
163
|
-
"percent": 2.
|
|
163
|
+
"percent": 2.36,
|
|
164
164
|
"reduction": 22.57
|
|
165
165
|
},
|
|
166
166
|
{
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"dependents": [
|
|
175
175
|
"/src/adapters/node-http/index.ts"
|
|
176
176
|
],
|
|
177
|
-
"percent": 2.
|
|
177
|
+
"percent": 2.09,
|
|
178
178
|
"reduction": 6.07
|
|
179
179
|
},
|
|
180
180
|
{
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"/src/unstable-core-do-not-import/router.ts",
|
|
211
211
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
212
212
|
],
|
|
213
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.01,
|
|
214
214
|
"reduction": 45.94
|
|
215
215
|
},
|
|
216
216
|
{
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"dependents": [
|
|
225
225
|
"/src/unstable-core-do-not-import.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 1.
|
|
227
|
+
"percent": 1.97,
|
|
228
228
|
"reduction": 40.98
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
245
245
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
246
246
|
],
|
|
247
|
-
"percent": 1.
|
|
247
|
+
"percent": 1.92,
|
|
248
248
|
"reduction": 55.78
|
|
249
249
|
},
|
|
250
250
|
{
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
"/src/unstable-core-do-not-import.ts",
|
|
261
261
|
"/src/unstable-core-do-not-import/router.ts"
|
|
262
262
|
],
|
|
263
|
-
"percent": 1.
|
|
263
|
+
"percent": 1.7,
|
|
264
264
|
"reduction": 0
|
|
265
265
|
},
|
|
266
266
|
{
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"dependents": [
|
|
275
275
|
"/src/adapters/fetch/index.ts"
|
|
276
276
|
],
|
|
277
|
-
"percent": 1.
|
|
277
|
+
"percent": 1.65,
|
|
278
278
|
"reduction": 2.17
|
|
279
279
|
},
|
|
280
280
|
{
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"dependents": [
|
|
304
304
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
305
305
|
],
|
|
306
|
-
"percent": 1.
|
|
306
|
+
"percent": 1.5,
|
|
307
307
|
"reduction": 5.79
|
|
308
308
|
},
|
|
309
309
|
{
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
"dependents": [
|
|
318
318
|
"/src/adapters/fastify/index.ts"
|
|
319
319
|
],
|
|
320
|
-
"percent": 1.
|
|
320
|
+
"percent": 1.3,
|
|
321
321
|
"reduction": 29.88
|
|
322
322
|
},
|
|
323
323
|
{
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
],
|
|
354
354
|
"removedExports": [],
|
|
355
355
|
"dependents": [],
|
|
356
|
-
"percent": 1.
|
|
356
|
+
"percent": 1.24,
|
|
357
357
|
"reduction": 19.29
|
|
358
358
|
},
|
|
359
359
|
{
|
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
396
396
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
397
397
|
],
|
|
398
|
-
"percent": 1.
|
|
398
|
+
"percent": 1.05,
|
|
399
399
|
"reduction": 16.73
|
|
400
400
|
},
|
|
401
401
|
{
|
|
@@ -539,7 +539,7 @@
|
|
|
539
539
|
"/src/unstable-core-do-not-import.ts",
|
|
540
540
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
541
541
|
],
|
|
542
|
-
"percent": 0.
|
|
542
|
+
"percent": 0.58,
|
|
543
543
|
"reduction": 44.65
|
|
544
544
|
},
|
|
545
545
|
{
|
|
@@ -567,7 +567,7 @@
|
|
|
567
567
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
568
568
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
569
569
|
],
|
|
570
|
-
"percent": 0.
|
|
570
|
+
"percent": 0.53,
|
|
571
571
|
"reduction": 20.74
|
|
572
572
|
},
|
|
573
573
|
{
|
|
@@ -636,7 +636,7 @@
|
|
|
636
636
|
],
|
|
637
637
|
"removedExports": [],
|
|
638
638
|
"dependents": [],
|
|
639
|
-
"percent": 0.
|
|
639
|
+
"percent": 0.2,
|
|
640
640
|
"reduction": 72.92
|
|
641
641
|
},
|
|
642
642
|
{
|
|
@@ -707,7 +707,7 @@
|
|
|
707
707
|
"/src/unstable-core-do-not-import.ts",
|
|
708
708
|
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts"
|
|
709
709
|
],
|
|
710
|
-
"percent": 0.
|
|
710
|
+
"percent": 0.05,
|
|
711
711
|
"reduction": 97.19
|
|
712
712
|
},
|
|
713
713
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAibnB"}
|
|
@@ -292,13 +292,25 @@ async function resolveResponse(opts) {
|
|
|
292
292
|
data: dataAsIterable,
|
|
293
293
|
serialize: (v)=>config.transformer.output.serialize(v),
|
|
294
294
|
formatError (errorOpts) {
|
|
295
|
+
const error = TRPCError.getTRPCErrorFromUnknown(errorOpts.error);
|
|
296
|
+
const input = call?.result();
|
|
297
|
+
const path = call?.path;
|
|
298
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
295
299
|
const shape = getErrorShape.getErrorShape({
|
|
296
300
|
config,
|
|
297
301
|
ctx,
|
|
298
|
-
error
|
|
299
|
-
input
|
|
300
|
-
path
|
|
301
|
-
type
|
|
302
|
+
error,
|
|
303
|
+
input,
|
|
304
|
+
path,
|
|
305
|
+
type
|
|
306
|
+
});
|
|
307
|
+
opts.onError?.({
|
|
308
|
+
error,
|
|
309
|
+
path,
|
|
310
|
+
input,
|
|
311
|
+
ctx,
|
|
312
|
+
req: opts.req,
|
|
313
|
+
type
|
|
302
314
|
});
|
|
303
315
|
return shape;
|
|
304
316
|
}
|
|
@@ -290,13 +290,25 @@ async function resolveResponse(opts) {
|
|
|
290
290
|
data: dataAsIterable,
|
|
291
291
|
serialize: (v)=>config.transformer.output.serialize(v),
|
|
292
292
|
formatError (errorOpts) {
|
|
293
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
294
|
+
const input = call?.result();
|
|
295
|
+
const path = call?.path;
|
|
296
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
293
297
|
const shape = getErrorShape({
|
|
294
298
|
config,
|
|
295
299
|
ctx,
|
|
296
|
-
error
|
|
297
|
-
input
|
|
298
|
-
path
|
|
299
|
-
type
|
|
300
|
+
error,
|
|
301
|
+
input,
|
|
302
|
+
path,
|
|
303
|
+
type
|
|
304
|
+
});
|
|
305
|
+
opts.onError?.({
|
|
306
|
+
error,
|
|
307
|
+
path,
|
|
308
|
+
input,
|
|
309
|
+
ctx,
|
|
310
|
+
req: opts.req,
|
|
311
|
+
type
|
|
300
312
|
});
|
|
301
313
|
return shape;
|
|
302
314
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { inferObservableValue } from '../observable';
|
|
1
|
+
import type { inferObservableValue, Observable } from '../observable';
|
|
2
2
|
import type { AnyMiddlewareFunction, MiddlewareBuilder, MiddlewareFunction } from './middleware';
|
|
3
3
|
import type { inferParser, Parser } from './parser';
|
|
4
4
|
import type { AnyProcedure, LegacyObservableSubscriptionProcedure, MutationProcedure, ProcedureType, QueryProcedure, SubscriptionProcedure } from './procedure';
|
|
@@ -8,13 +8,6 @@ import type { UnsetMarker } from './utils';
|
|
|
8
8
|
type IntersectIfDefined<TType, TWith> = TType extends UnsetMarker ? TWith : TWith extends UnsetMarker ? TType : Simplify<TType & TWith>;
|
|
9
9
|
type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker ? TFallback : TValue;
|
|
10
10
|
type inferSubscriptionOutput<TOutput> = TOutput extends AsyncIterable<infer $Output> ? inferTrackedOutput<$Output> : inferObservableValue<TOutput>;
|
|
11
|
-
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> = $Output extends AsyncIterable<any> ? SubscriptionProcedure<{
|
|
12
|
-
input: DefaultValue<TInputIn, void>;
|
|
13
|
-
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
14
|
-
}> : LegacyObservableSubscriptionProcedure<{
|
|
15
|
-
input: DefaultValue<TInputIn, void>;
|
|
16
|
-
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
17
|
-
}>;
|
|
18
11
|
export type CallerOverride<TContext> = (opts: {
|
|
19
12
|
args: unknown[];
|
|
20
13
|
invoke: (opts: ProcedureCallOptions<TContext>) => Promise<unknown>;
|
|
@@ -113,9 +106,21 @@ export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn,
|
|
|
113
106
|
}>;
|
|
114
107
|
/**
|
|
115
108
|
* Subscription procedure
|
|
116
|
-
* @see https://trpc.io/docs/v11/
|
|
109
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
117
110
|
*/
|
|
118
|
-
subscription<$Output
|
|
111
|
+
subscription<$Output extends AsyncGenerator<any, void, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : SubscriptionProcedure<{
|
|
112
|
+
input: DefaultValue<TInputIn, void>;
|
|
113
|
+
output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.
|
|
117
|
+
* This feature will be removed in v12 of tRPC.
|
|
118
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
119
|
+
*/
|
|
120
|
+
subscription<$Output extends Observable<any, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : LegacyObservableSubscriptionProcedure<{
|
|
121
|
+
input: DefaultValue<TInputIn, void>;
|
|
122
|
+
output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;
|
|
123
|
+
}>;
|
|
119
124
|
/**
|
|
120
125
|
* Overrides the way a procedure is invoked
|
|
121
126
|
* Do not use this unless you know what you're doing - this is an experimental API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedureBuilder.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedureBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"procedureBuilder.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedureBuilder.ts"],"names":[],"mappings":"AAAA,O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AC,KAAK,CAAC,CAAC;CAClC;AAED,KAAK,wBAAwB,GAAG,CAC9B,IAAI,EAAE,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAC/C,OAAO,CAAC,OAAO,CAAC,CAAC;AAiBtB,wBAAgB,aAAa,CAAC,QAAQ,EAAE,KAAK,EAC3C,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAC5C,gBAAgB,CACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,KAAK,CACN,CAkEA;AA6CD;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC5C,GAAG,EAAE,QAAQ,CAAC;IACd,WAAW,EAAE,aAAa,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;CACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.552+268308497",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "268308497fef646ca5e322b49d1503cd47392871"
|
|
153
153
|
}
|
|
@@ -384,18 +384,33 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
384
384
|
const dataAsIterable = isObservable(data)
|
|
385
385
|
? observableToAsyncIterable(data)
|
|
386
386
|
: data;
|
|
387
|
+
|
|
387
388
|
const stream = sseStreamProducer({
|
|
388
389
|
...config.experimental?.sseSubscriptions,
|
|
389
390
|
data: dataAsIterable,
|
|
390
391
|
serialize: (v) => config.transformer.output.serialize(v),
|
|
391
392
|
formatError(errorOpts) {
|
|
393
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
394
|
+
const input = call?.result();
|
|
395
|
+
const path = call?.path;
|
|
396
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
397
|
+
|
|
392
398
|
const shape = getErrorShape({
|
|
393
399
|
config,
|
|
394
400
|
ctx,
|
|
395
|
-
error
|
|
396
|
-
input
|
|
397
|
-
path
|
|
398
|
-
type
|
|
401
|
+
error,
|
|
402
|
+
input,
|
|
403
|
+
path,
|
|
404
|
+
type,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
opts.onError?.({
|
|
408
|
+
error,
|
|
409
|
+
path,
|
|
410
|
+
input,
|
|
411
|
+
ctx,
|
|
412
|
+
req: opts.req,
|
|
413
|
+
type,
|
|
399
414
|
});
|
|
400
415
|
|
|
401
416
|
return shape;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { inferObservableValue } from '../observable';
|
|
1
|
+
import type { inferObservableValue, Observable } from '../observable';
|
|
2
2
|
import { getTRPCErrorFromUnknown, TRPCError } from './error/TRPCError';
|
|
3
3
|
import type {
|
|
4
4
|
AnyMiddlewareFunction,
|
|
@@ -50,17 +50,6 @@ type inferSubscriptionOutput<TOutput> = TOutput extends AsyncIterable<
|
|
|
50
50
|
? inferTrackedOutput<$Output>
|
|
51
51
|
: inferObservableValue<TOutput>;
|
|
52
52
|
|
|
53
|
-
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> =
|
|
54
|
-
$Output extends AsyncIterable<any>
|
|
55
|
-
? SubscriptionProcedure<{
|
|
56
|
-
input: DefaultValue<TInputIn, void>;
|
|
57
|
-
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
58
|
-
}>
|
|
59
|
-
: LegacyObservableSubscriptionProcedure<{
|
|
60
|
-
input: DefaultValue<TInputIn, void>;
|
|
61
|
-
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
62
|
-
}>;
|
|
63
|
-
|
|
64
53
|
export type CallerOverride<TContext> = (opts: {
|
|
65
54
|
args: unknown[];
|
|
66
55
|
invoke: (opts: ProcedureCallOptions<TContext>) => Promise<unknown>;
|
|
@@ -354,9 +343,9 @@ export interface ProcedureBuilder<
|
|
|
354
343
|
|
|
355
344
|
/**
|
|
356
345
|
* Subscription procedure
|
|
357
|
-
* @see https://trpc.io/docs/v11/
|
|
346
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
358
347
|
*/
|
|
359
|
-
subscription<$Output
|
|
348
|
+
subscription<$Output extends AsyncGenerator<any, void, any>>(
|
|
360
349
|
resolver: ProcedureResolver<
|
|
361
350
|
TContext,
|
|
362
351
|
TMeta,
|
|
@@ -367,8 +356,30 @@ export interface ProcedureBuilder<
|
|
|
367
356
|
>,
|
|
368
357
|
): TCaller extends true
|
|
369
358
|
? TypeError<'Not implemented'>
|
|
370
|
-
:
|
|
371
|
-
|
|
359
|
+
: SubscriptionProcedure<{
|
|
360
|
+
input: DefaultValue<TInputIn, void>;
|
|
361
|
+
output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;
|
|
362
|
+
}>;
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.
|
|
365
|
+
* This feature will be removed in v12 of tRPC.
|
|
366
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
367
|
+
*/
|
|
368
|
+
subscription<$Output extends Observable<any, any>>(
|
|
369
|
+
resolver: ProcedureResolver<
|
|
370
|
+
TContext,
|
|
371
|
+
TMeta,
|
|
372
|
+
TContextOverrides,
|
|
373
|
+
TInputOut,
|
|
374
|
+
TOutputIn,
|
|
375
|
+
$Output
|
|
376
|
+
>,
|
|
377
|
+
): TCaller extends true
|
|
378
|
+
? TypeError<'Not implemented'>
|
|
379
|
+
: LegacyObservableSubscriptionProcedure<{
|
|
380
|
+
input: DefaultValue<TInputIn, void>;
|
|
381
|
+
output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;
|
|
382
|
+
}>;
|
|
372
383
|
/**
|
|
373
384
|
* Overrides the way a procedure is invoked
|
|
374
385
|
* Do not use this unless you know what you're doing - this is an experimental API
|
|
@@ -476,7 +487,7 @@ export function createBuilder<TContext, TMeta>(
|
|
|
476
487
|
resolver,
|
|
477
488
|
) as AnyMutationProcedure;
|
|
478
489
|
},
|
|
479
|
-
subscription(resolver) {
|
|
490
|
+
subscription(resolver: ProcedureResolver<any, any, any, any, any, any>) {
|
|
480
491
|
return createResolver({ ..._def, type: 'subscription' }, resolver) as any;
|
|
481
492
|
},
|
|
482
493
|
experimental_caller(caller) {
|