@trpc/server 11.0.0-rc.601 → 11.0.0-rc.607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +1 -0
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +1 -0
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +2 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +2 -1
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -0
- package/dist/adapters/ws.mjs +1 -0
- package/dist/bundle-analysis.json +93 -93
- package/dist/observable/observable.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/transformer.js +1 -1
- package/dist/unstable-core-do-not-import/transformer.mjs +1 -1
- package/dist/unstable-core-do-not-import/types.d.ts +3 -3
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -1
- package/dist/vendor/unpromise/types.d.ts +3 -3
- package/dist/vendor/unpromise/types.d.ts.map +1 -1
- package/dist/vendor/unpromise/unpromise.d.ts +5 -5
- package/dist/vendor/unpromise/unpromise.d.ts.map +1 -1
- package/dist/vendor/unpromise/unpromise.js +4 -2
- package/dist/vendor/unpromise/unpromise.mjs +4 -2
- package/package.json +6 -6
- package/src/adapters/aws-lambda/getPlanner.ts +2 -2
- package/src/adapters/aws-lambda/index.ts +5 -6
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +8 -3
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +1 -0
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +2 -1
- package/src/adapters/ws.ts +2 -1
- package/src/observable/observable.ts +2 -6
- package/src/unstable-core-do-not-import/clientish/inference.ts +4 -4
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +6 -6
- package/src/unstable-core-do-not-import/clientish/serialize.ts +3 -3
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +2 -2
- package/src/unstable-core-do-not-import/initTRPC.ts +3 -9
- package/src/unstable-core-do-not-import/middleware.ts +3 -3
- package/src/unstable-core-do-not-import/parser.ts +5 -5
- package/src/unstable-core-do-not-import/procedureBuilder.ts +50 -52
- package/src/unstable-core-do-not-import/router.ts +6 -7
- package/src/unstable-core-do-not-import/stream/sse.ts +2 -2
- package/src/unstable-core-do-not-import/stream/tracked.ts +2 -5
- package/src/unstable-core-do-not-import/transformer.ts +1 -1
- package/src/unstable-core-do-not-import/types.ts +11 -13
- package/src/vendor/unpromise/types.ts +4 -4
- package/src/vendor/unpromise/unpromise.ts +14 -12
|
@@ -37,24 +37,21 @@ import { mergeWithoutOverrides } from './utils';
|
|
|
37
37
|
type IntersectIfDefined<TType, TWith> = TType extends UnsetMarker
|
|
38
38
|
? TWith
|
|
39
39
|
: TWith extends UnsetMarker
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
? TType
|
|
41
|
+
: Simplify<TType & TWith>;
|
|
42
|
+
|
|
43
43
|
type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker
|
|
44
44
|
? TFallback
|
|
45
45
|
: TValue;
|
|
46
46
|
|
|
47
|
-
type inferAsyncIterator<TOutput> =
|
|
48
|
-
infer $Yield,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
next: $Next;
|
|
56
|
-
}
|
|
57
|
-
: never;
|
|
47
|
+
type inferAsyncIterator<TOutput> =
|
|
48
|
+
TOutput extends AsyncIterator<infer $Yield, infer $Return, infer $Next>
|
|
49
|
+
? {
|
|
50
|
+
yield: $Yield;
|
|
51
|
+
return: $Return;
|
|
52
|
+
next: $Next;
|
|
53
|
+
}
|
|
54
|
+
: never;
|
|
58
55
|
type inferSubscriptionOutput<TOutput> = TOutput extends AsyncGenerator
|
|
59
56
|
? AsyncGenerator<
|
|
60
57
|
inferTrackedOutput<inferAsyncIterator<TOutput>['yield']>,
|
|
@@ -146,35 +143,36 @@ export type AnyProcedureBuilder = ProcedureBuilder<
|
|
|
146
143
|
*/
|
|
147
144
|
export type inferProcedureBuilderResolverOptions<
|
|
148
145
|
TProcedureBuilder extends AnyProcedureBuilder,
|
|
149
|
-
> =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
146
|
+
> =
|
|
147
|
+
TProcedureBuilder extends ProcedureBuilder<
|
|
148
|
+
infer TContext,
|
|
149
|
+
infer TMeta,
|
|
150
|
+
infer TContextOverrides,
|
|
151
|
+
infer _TInputIn,
|
|
152
|
+
infer TInputOut,
|
|
153
|
+
infer _TOutputIn,
|
|
154
|
+
infer _TOutputOut,
|
|
155
|
+
infer _TCaller
|
|
156
|
+
>
|
|
157
|
+
? ProcedureResolverOptions<
|
|
158
|
+
TContext,
|
|
159
|
+
TMeta,
|
|
160
|
+
TContextOverrides,
|
|
161
|
+
TInputOut extends UnsetMarker
|
|
162
|
+
? // 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
|
|
163
|
+
unknown
|
|
164
|
+
: TInputOut extends object
|
|
165
|
+
? Simplify<
|
|
166
|
+
TInputOut & {
|
|
167
|
+
/**
|
|
168
|
+
* Extra input params might have been added by a `.input()` further down the chain
|
|
169
|
+
*/
|
|
170
|
+
[keyAddedByInputCallFurtherDown: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
>
|
|
173
|
+
: TInputOut
|
|
174
|
+
>
|
|
175
|
+
: never;
|
|
178
176
|
|
|
179
177
|
export interface ProcedureBuilder<
|
|
180
178
|
TContext,
|
|
@@ -194,14 +192,14 @@ export interface ProcedureBuilder<
|
|
|
194
192
|
schema: TInputOut extends UnsetMarker
|
|
195
193
|
? $Parser
|
|
196
194
|
: inferParser<$Parser>['out'] extends Record<string, unknown> | undefined
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
195
|
+
? TInputOut extends Record<string, unknown> | undefined
|
|
196
|
+
? undefined extends inferParser<$Parser>['out'] // if current is optional the previous must be too
|
|
197
|
+
? undefined extends TInputOut
|
|
198
|
+
? $Parser
|
|
199
|
+
: TypeError<'Cannot chain an optional parser to a required parser'>
|
|
200
|
+
: $Parser
|
|
201
|
+
: TypeError<'All input parsers did not resolve to an object'>
|
|
202
|
+
: TypeError<'All input parsers did not resolve to an object'>,
|
|
205
203
|
): ProcedureBuilder<
|
|
206
204
|
TContext,
|
|
207
205
|
TMeta,
|
|
@@ -430,7 +428,7 @@ function createNewBuilder(
|
|
|
430
428
|
...mergeWithoutOverrides(def1, rest),
|
|
431
429
|
inputs: [...def1.inputs, ...(inputs ?? [])],
|
|
432
430
|
middlewares: [...def1.middlewares, ...middlewares],
|
|
433
|
-
meta: def1.meta && meta ? { ...def1.meta, ...meta } : meta ?? def1.meta,
|
|
431
|
+
meta: def1.meta && meta ? { ...def1.meta, ...meta } : (meta ?? def1.meta),
|
|
434
432
|
});
|
|
435
433
|
}
|
|
436
434
|
|
|
@@ -36,8 +36,8 @@ export type DecorateRouterRecord<TRecord extends RouterRecord> = {
|
|
|
36
36
|
[TKey in keyof TRecord]: TRecord[TKey] extends AnyProcedure
|
|
37
37
|
? DecorateProcedure<TRecord[TKey]>
|
|
38
38
|
: TRecord[TKey] extends RouterRecord
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
? DecorateRouterRecord<TRecord[TKey]>
|
|
40
|
+
: never;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -146,10 +146,10 @@ export type DecorateCreateRouterOptions<
|
|
|
146
146
|
? $Value extends AnyProcedure
|
|
147
147
|
? $Value
|
|
148
148
|
: $Value extends Router<any, infer TRecord>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
? TRecord
|
|
150
|
+
: $Value extends CreateRouterOptions
|
|
151
|
+
? DecorateCreateRouterOptions<$Value>
|
|
152
|
+
: never
|
|
153
153
|
: never;
|
|
154
154
|
};
|
|
155
155
|
|
|
@@ -318,7 +318,6 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
318
318
|
type MergeRouters<
|
|
319
319
|
TRouters extends AnyRouter[],
|
|
320
320
|
TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
322
321
|
TRecord extends RouterRecord = {},
|
|
323
322
|
> = TRouters extends [
|
|
324
323
|
infer Head extends AnyRouter,
|
|
@@ -112,7 +112,7 @@ export function sseStreamProducer<TValue = unknown>(
|
|
|
112
112
|
// declared inside, they would not be freed until the next value is present.
|
|
113
113
|
let value: null | TIteratorValue;
|
|
114
114
|
let chunk: null | SSEvent;
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
for await (value of iterable) {
|
|
117
117
|
if (value === PING_SYM) {
|
|
118
118
|
stream.controller.enqueue({ comment: 'ping' });
|
|
@@ -127,7 +127,7 @@ export function sseStreamProducer<TValue = unknown>(
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
stream.controller.enqueue(chunk);
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
// free up references for garbage collection
|
|
132
132
|
value = null;
|
|
133
133
|
chunk = null;
|
|
@@ -45,8 +45,5 @@ export function tracked<TData>(
|
|
|
45
45
|
return [id as TrackedId, data, trackedSymbol];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export type inferTrackedOutput<TData> =
|
|
49
|
-
infer $Data
|
|
50
|
-
>
|
|
51
|
-
? TrackedData<$Data>
|
|
52
|
-
: TData;
|
|
48
|
+
export type inferTrackedOutput<TData> =
|
|
49
|
+
TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;
|
|
@@ -175,7 +175,7 @@ export function transformResult<TRouter extends AnyRouter, TOutput>(
|
|
|
175
175
|
try {
|
|
176
176
|
// Use the data transformers on the JSON-response
|
|
177
177
|
result = transformResultInner(response, transformer);
|
|
178
|
-
} catch
|
|
178
|
+
} catch {
|
|
179
179
|
throw new TransformResultError();
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -83,8 +83,8 @@ export type WithoutIndexSignature<TObj> = {
|
|
|
83
83
|
[K in keyof TObj as string extends K
|
|
84
84
|
? never
|
|
85
85
|
: number extends K
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
? never
|
|
87
|
+
: K]: TObj[K];
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -101,14 +101,13 @@ export type Overwrite<TType, TWith> = TWith extends any
|
|
|
101
101
|
| keyof WithoutIndexSignature<TWith>]: K extends keyof TWith
|
|
102
102
|
? TWith[K]
|
|
103
103
|
: K extends keyof TType
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
? TType[K]
|
|
105
|
+
: never;
|
|
106
106
|
} & (string extends keyof TWith // Handle cases with an index signature
|
|
107
107
|
? { [key: string]: TWith[string] }
|
|
108
108
|
: number extends keyof TWith
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{})
|
|
109
|
+
? { [key: number]: TWith[number] }
|
|
110
|
+
: {})
|
|
112
111
|
: TWith
|
|
113
112
|
: never;
|
|
114
113
|
|
|
@@ -168,10 +167,10 @@ export type ProtectedIntersection<TType, TWith> = keyof TType &
|
|
|
168
167
|
*/
|
|
169
168
|
export type GetRawInputFn = () => Promise<unknown>;
|
|
170
169
|
|
|
171
|
-
const
|
|
172
|
-
export type ErrorSymbol = typeof
|
|
170
|
+
const _errorSymbol = Symbol();
|
|
171
|
+
export type ErrorSymbol = typeof _errorSymbol;
|
|
173
172
|
export type TypeError<TMessage extends string> = TMessage & {
|
|
174
|
-
_: typeof
|
|
173
|
+
_: typeof _errorSymbol;
|
|
175
174
|
};
|
|
176
175
|
export type ValueOf<TObj> = TObj[keyof TObj];
|
|
177
176
|
|
|
@@ -179,6 +178,5 @@ export type ValueOf<TObj> = TObj[keyof TObj];
|
|
|
179
178
|
* @internal
|
|
180
179
|
* Infers the type of the value yielded by an async iterable
|
|
181
180
|
*/
|
|
182
|
-
export type inferAsyncIterableYield<T> =
|
|
183
|
-
? U
|
|
184
|
-
: T;
|
|
181
|
+
export type inferAsyncIterableYield<T> =
|
|
182
|
+
T extends AsyncIterable<infer U> ? U : T;
|
|
@@ -18,22 +18,22 @@ export interface ProxyPromise<T> extends Promise<T> {
|
|
|
18
18
|
onfulfilled?:
|
|
19
19
|
| ((value: T) => TResult1 | PromiseLike<TResult1>)
|
|
20
20
|
| null
|
|
21
|
-
|
|
21
|
+
,
|
|
22
22
|
onrejected?:
|
|
23
23
|
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
|
|
24
24
|
| null
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
) => SubscribedPromise<TResult1 | TResult2>;
|
|
27
27
|
|
|
28
28
|
catch: <TResult = never>(
|
|
29
29
|
onrejected?:
|
|
30
30
|
| ((reason: any) => TResult | PromiseLike<TResult>)
|
|
31
31
|
| null
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
) => SubscribedPromise<T | TResult>;
|
|
34
34
|
|
|
35
35
|
finally: (
|
|
36
|
-
onfinally?: (() => void) | null
|
|
36
|
+
onfinally?: (() => void) | null
|
|
37
37
|
) => SubscribedPromise<T>;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
PromiseExecutor,
|
|
@@ -20,7 +20,9 @@ const subscribableCache = new WeakMap<
|
|
|
20
20
|
/** A NOOP function allowing a consistent interface for settled
|
|
21
21
|
* SubscribedPromises (settled promises are not subscribed - they resolve
|
|
22
22
|
* immediately). */
|
|
23
|
-
const NOOP = () => {
|
|
23
|
+
const NOOP = () => {
|
|
24
|
+
// noop
|
|
25
|
+
};
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
|
|
@@ -181,11 +183,11 @@ export class Unpromise<T> implements ProxyPromise<T> {
|
|
|
181
183
|
onfulfilled?:
|
|
182
184
|
| ((value: T) => TResult1 | PromiseLike<TResult1>)
|
|
183
185
|
| null
|
|
184
|
-
|
|
186
|
+
,
|
|
185
187
|
onrejected?:
|
|
186
188
|
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
|
|
187
189
|
| null
|
|
188
|
-
|
|
190
|
+
|
|
189
191
|
): SubscribedPromise<TResult1 | TResult2> {
|
|
190
192
|
const subscribed = this.subscribe();
|
|
191
193
|
const { unsubscribe } = subscribed;
|
|
@@ -198,7 +200,7 @@ export class Unpromise<T> implements ProxyPromise<T> {
|
|
|
198
200
|
onrejected?:
|
|
199
201
|
| ((reason: any) => TResult | PromiseLike<TResult>)
|
|
200
202
|
| null
|
|
201
|
-
|
|
203
|
+
|
|
202
204
|
): SubscribedPromise<T | TResult> {
|
|
203
205
|
const subscribed = this.subscribe();
|
|
204
206
|
const { unsubscribe } = subscribed;
|
|
@@ -207,7 +209,7 @@ export class Unpromise<T> implements ProxyPromise<T> {
|
|
|
207
209
|
});
|
|
208
210
|
}
|
|
209
211
|
|
|
210
|
-
finally(onfinally?: (() => void) | null
|
|
212
|
+
finally(onfinally?: (() => void) | null ): SubscribedPromise<T> {
|
|
211
213
|
const subscribed = this.subscribe();
|
|
212
214
|
const { unsubscribe } = subscribed;
|
|
213
215
|
return Object.assign(subscribed.finally(onfinally), {
|
|
@@ -312,8 +314,8 @@ export class Unpromise<T> implements ProxyPromise<T> {
|
|
|
312
314
|
* }
|
|
313
315
|
* ```
|
|
314
316
|
* */
|
|
315
|
-
static async raceReferences<
|
|
316
|
-
promises: readonly
|
|
317
|
+
static async raceReferences<TPromise extends Promise<unknown>>(
|
|
318
|
+
promises: readonly TPromise[]
|
|
317
319
|
) {
|
|
318
320
|
// map each promise to an eventual 1-tuple containing itself
|
|
319
321
|
const selfPromises = promises.map(resolveSelfTuple);
|
|
@@ -336,9 +338,9 @@ export class Unpromise<T> implements ProxyPromise<T> {
|
|
|
336
338
|
* may be ambiguous and therefore hard to identify as the winner of a race).
|
|
337
339
|
* You can call unsubscribe on the Promise to mitigate memory leaks.
|
|
338
340
|
* */
|
|
339
|
-
export function resolveSelfTuple<
|
|
340
|
-
promise:
|
|
341
|
-
): SubscribedPromise<readonly [
|
|
341
|
+
export function resolveSelfTuple<TPromise extends Promise<unknown>>(
|
|
342
|
+
promise: TPromise
|
|
343
|
+
): SubscribedPromise<readonly [TPromise]> {
|
|
342
344
|
return Unpromise.proxy(promise).then(() => [promise] as const);
|
|
343
345
|
}
|
|
344
346
|
|