@trpc/server 10.0.0-proxy-beta.0 → 10.0.0-proxy-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +3 -3
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/aws-lambda/utils.d.ts +2 -2
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/express.js +3 -3
- package/dist/adapters/express.mjs +3 -3
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/fastify/index.mjs +2 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/lambda/index.d.ts +1 -1
- package/dist/adapters/lambda/index.d.ts.map +1 -1
- package/dist/adapters/next.js +3 -3
- package/dist/adapters/next.mjs +3 -3
- package/dist/adapters/node-http/index.js +3 -3
- package/dist/adapters/node-http/index.mjs +3 -3
- package/dist/adapters/standalone.js +3 -3
- package/dist/adapters/standalone.mjs +3 -3
- package/dist/{codes-1c24d919.js → codes-731f0a7c.js} +2 -5
- package/dist/{codes-aaa7d554.mjs → codes-f164ac85.mjs} +2 -6
- package/dist/core/initTRPC.d.ts +6 -6
- package/dist/core/initTRPC.d.ts.map +1 -1
- package/dist/core/internals/config.d.ts +4 -4
- package/dist/core/internals/config.d.ts.map +1 -1
- package/dist/core/internals/getParseFn.d.ts +3 -3
- package/dist/core/internals/getParseFn.d.ts.map +1 -1
- package/dist/core/internals/mergeWithoutOverrides.d.ts +1 -1
- package/dist/core/internals/mergeWithoutOverrides.d.ts.map +1 -1
- package/dist/core/internals/omitPrototype.d.ts +1 -1
- package/dist/core/internals/omitPrototype.d.ts.map +1 -1
- package/dist/core/internals/procedureBuilder.d.ts +19 -19
- package/dist/core/internals/procedureBuilder.d.ts.map +1 -1
- package/dist/core/internals/utils.d.ts +5 -5
- package/dist/core/internals/utils.d.ts.map +1 -1
- package/dist/core/middleware.d.ts +8 -8
- package/dist/core/middleware.d.ts.map +1 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/deprecated/internals/middlewares.d.ts +3 -3
- package/dist/deprecated/internals/middlewares.d.ts.map +1 -1
- package/dist/deprecated/internals/procedure.d.ts +8 -8
- package/dist/deprecated/internals/procedure.d.ts.map +1 -1
- package/dist/deprecated/interop.d.ts +2 -2
- package/dist/deprecated/interop.d.ts.map +1 -1
- package/dist/deprecated/router.d.ts +1 -1
- package/dist/deprecated/router.d.ts.map +1 -1
- package/dist/error/formatter.d.ts +1 -1
- package/dist/error/formatter.d.ts.map +1 -1
- package/dist/http/internals/getHTTPStatusCode.d.ts +1 -1
- package/dist/http/internals/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +4 -4
- package/dist/internals/invert.d.ts +6 -6
- package/dist/internals/invert.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-7295e689.js → nodeHTTPRequestHandler-e4b36284.js} +1 -1
- package/dist/{nodeHTTPRequestHandler-e4a030ab.mjs → nodeHTTPRequestHandler-f84d898b.mjs} +1 -1
- package/dist/observable/internals/identity.d.ts +1 -1
- package/dist/observable/internals/identity.d.ts.map +1 -1
- package/dist/observable/internals/pipe.d.ts +1 -1
- package/dist/observable/internals/pipe.d.ts.map +1 -1
- package/dist/observable/types.d.ts +6 -6
- package/dist/observable/types.d.ts.map +1 -1
- package/dist/{resolveHTTPResponse-9a70b9b2.js → resolveHTTPResponse-f80439bb.js} +4 -13
- package/dist/{resolveHTTPResponse-3955937e.mjs → resolveHTTPResponse-fa4e77dd.mjs} +3 -12
- package/dist/{router-fee6849a.js → router-244a949f.js} +3 -2
- package/dist/{router-4f222389.mjs → router-b5b89d55.mjs} +3 -2
- package/dist/rpc/codes.d.ts +1 -1
- package/dist/rpc/codes.d.ts.map +1 -1
- package/dist/rpc/index.js +1 -1
- package/dist/rpc/index.mjs +1 -1
- package/dist/types.d.ts +15 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/adapters/aws-lambda/index.ts +2 -2
- package/src/adapters/aws-lambda/utils.ts +2 -2
- package/src/adapters/lambda/index.ts +2 -2
- package/src/core/initTRPC.ts +3 -3
- package/src/core/internals/config.ts +4 -4
- package/src/core/internals/getParseFn.ts +5 -5
- package/src/core/internals/mergeWithoutOverrides.ts +6 -6
- package/src/core/internals/omitPrototype.ts +4 -4
- package/src/core/internals/procedureBuilder.ts +32 -30
- package/src/core/internals/utils.ts +9 -9
- package/src/core/middleware.ts +6 -6
- package/src/core/types.ts +2 -2
- package/src/deprecated/internals/middlewares.ts +3 -1
- package/src/deprecated/internals/procedure.ts +18 -15
- package/src/deprecated/interop.ts +6 -2
- package/src/deprecated/router.ts +5 -2
- package/src/error/formatter.ts +4 -1
- package/src/http/internals/getHTTPStatusCode.ts +1 -1
- package/src/internals/invert.ts +8 -8
- package/src/observable/internals/identity.ts +1 -1
- package/src/observable/internals/pipe.ts +5 -5
- package/src/observable/types.ts +37 -26
- package/src/rpc/codes.ts +2 -2
- package/src/types.ts +23 -16
- package/dist/rpc/internals/invert.d.ts +0 -18
- package/dist/rpc/internals/invert.d.ts.map +0 -1
- package/src/rpc/internals/invert.ts +0 -27
package/src/internals/invert.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
type KeyFromValue<
|
|
2
|
-
[K in keyof
|
|
3
|
-
}[keyof
|
|
1
|
+
type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
|
|
2
|
+
[K in keyof TType]: TValue extends TType[K] ? K : never;
|
|
3
|
+
}[keyof TType];
|
|
4
4
|
|
|
5
|
-
type Invert<
|
|
6
|
-
[
|
|
5
|
+
type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
|
|
6
|
+
[TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export function invert<
|
|
10
|
-
obj:
|
|
11
|
-
): Invert<
|
|
9
|
+
export function invert<TRecord extends Record<PropertyKey, PropertyKey>>(
|
|
10
|
+
obj: TRecord,
|
|
11
|
+
): Invert<TRecord> {
|
|
12
12
|
const newObj = Object.create(null) as any;
|
|
13
13
|
for (const key in obj) {
|
|
14
14
|
const v = obj[key];
|
|
@@ -2,9 +2,9 @@ import { UnaryFunction } from '../types';
|
|
|
2
2
|
import { identity } from './identity';
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
5
|
-
export function pipeFromArray<
|
|
6
|
-
fns: Array<UnaryFunction<
|
|
7
|
-
): UnaryFunction<
|
|
5
|
+
export function pipeFromArray<TSource, TReturn>(
|
|
6
|
+
fns: Array<UnaryFunction<TSource, TReturn>>,
|
|
7
|
+
): UnaryFunction<TSource, TReturn> {
|
|
8
8
|
if (fns.length === 0) {
|
|
9
9
|
return identity as UnaryFunction<any, any>;
|
|
10
10
|
}
|
|
@@ -14,9 +14,9 @@ export function pipeFromArray<T, R>(
|
|
|
14
14
|
return fns[0]!;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return function piped(input:
|
|
17
|
+
return function piped(input: TSource): TReturn {
|
|
18
18
|
return fns.reduce(
|
|
19
|
-
(prev: any, fn: UnaryFunction<
|
|
19
|
+
(prev: any, fn: UnaryFunction<TSource, TReturn>) => fn(prev),
|
|
20
20
|
input as any,
|
|
21
21
|
);
|
|
22
22
|
};
|
package/src/observable/types.ts
CHANGED
|
@@ -8,31 +8,42 @@ export interface Subscribable<TValue, TError> {
|
|
|
8
8
|
export interface Observable<TValue, TError>
|
|
9
9
|
extends Subscribable<TValue, TError> {
|
|
10
10
|
pipe(): Observable<TValue, TError>;
|
|
11
|
-
pipe<
|
|
12
|
-
op1: OperatorFunction<TValue, TError,
|
|
13
|
-
): Observable<
|
|
14
|
-
pipe<
|
|
15
|
-
op1: OperatorFunction<TValue, TError,
|
|
16
|
-
op2: OperatorFunction<
|
|
17
|
-
): Observable<
|
|
18
|
-
pipe<
|
|
19
|
-
op1: OperatorFunction<TValue, TError,
|
|
20
|
-
op2: OperatorFunction<
|
|
21
|
-
op3: OperatorFunction<
|
|
22
|
-
): Observable<
|
|
23
|
-
pipe<
|
|
24
|
-
op1: OperatorFunction<TValue, TError,
|
|
25
|
-
op2: OperatorFunction<
|
|
26
|
-
op3: OperatorFunction<
|
|
27
|
-
op4: OperatorFunction<
|
|
28
|
-
): Observable<
|
|
29
|
-
pipe<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
pipe<TValue1, TError1>(
|
|
12
|
+
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
13
|
+
): Observable<TValue1, TError1>;
|
|
14
|
+
pipe<TValue1, TError1, TValue2, TError2>(
|
|
15
|
+
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
16
|
+
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
17
|
+
): Observable<TValue2, TError2>;
|
|
18
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(
|
|
19
|
+
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
20
|
+
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
21
|
+
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
22
|
+
): Observable<TValue2, TError2>;
|
|
23
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(
|
|
24
|
+
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
25
|
+
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
26
|
+
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
27
|
+
op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,
|
|
28
|
+
): Observable<TValue2, TError2>;
|
|
29
|
+
pipe<
|
|
30
|
+
TValue1,
|
|
31
|
+
TError1,
|
|
32
|
+
TValue2,
|
|
33
|
+
TError2,
|
|
34
|
+
TValue3,
|
|
35
|
+
TError3,
|
|
36
|
+
TValue4,
|
|
37
|
+
TError4,
|
|
38
|
+
TValue5,
|
|
39
|
+
TError5,
|
|
40
|
+
>(
|
|
41
|
+
op1: OperatorFunction<TValue, TError, TValue1, TError1>,
|
|
42
|
+
op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,
|
|
43
|
+
op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,
|
|
44
|
+
op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,
|
|
45
|
+
op5: OperatorFunction<TValue4, TError4, TValue5, TError5>,
|
|
46
|
+
): Observable<TValue2, TError2>;
|
|
36
47
|
}
|
|
37
48
|
export interface SubscriptionLike extends Unsubscribable {
|
|
38
49
|
unsubscribe(): void;
|
|
@@ -49,7 +60,7 @@ export type TeardownLogic =
|
|
|
49
60
|
// | SubscriptionLike
|
|
50
61
|
Unsubscribable | UnsubscribeFn | void;
|
|
51
62
|
|
|
52
|
-
export type UnaryFunction<
|
|
63
|
+
export type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
53
64
|
|
|
54
65
|
export type OperatorFunction<
|
|
55
66
|
TValueBefore,
|
package/src/rpc/codes.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { invert } from '
|
|
1
|
+
import { invert } from '../internals/invert';
|
|
2
2
|
|
|
3
3
|
// reference: https://www.jsonrpc.org/specification
|
|
4
4
|
|
|
@@ -35,7 +35,7 @@ export const TRPC_ERROR_CODES_BY_KEY = {
|
|
|
35
35
|
} as const;
|
|
36
36
|
|
|
37
37
|
export const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
|
|
38
|
-
type ValueOf<
|
|
38
|
+
type ValueOf<TObj> = TObj[keyof TObj];
|
|
39
39
|
|
|
40
40
|
export type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
|
|
41
41
|
export type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
package/src/types.ts
CHANGED
|
@@ -3,43 +3,45 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
export type identity<
|
|
6
|
+
export type identity<TType> = TType;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export type FlatOverwrite<
|
|
12
|
-
[TKey in keyof
|
|
13
|
-
?
|
|
14
|
-
: TKey extends keyof
|
|
15
|
-
?
|
|
11
|
+
export type FlatOverwrite<TType, TWith> = identity<{
|
|
12
|
+
[TKey in keyof TWith | keyof TType]: TKey extends keyof TWith
|
|
13
|
+
? TWith[TKey]
|
|
14
|
+
: TKey extends keyof TType
|
|
15
|
+
? TType[TKey]
|
|
16
16
|
: never;
|
|
17
17
|
}>;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
export type Maybe<
|
|
22
|
+
export type Maybe<TType> = TType | undefined | null;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
|
-
export type ThenArg<
|
|
27
|
+
export type ThenArg<TType> = TType extends PromiseLike<infer U>
|
|
28
|
+
? ThenArg<U>
|
|
29
|
+
: TType;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* @internal
|
|
31
33
|
*/
|
|
32
|
-
export type Simplify<
|
|
34
|
+
export type Simplify<TType> = { [KeyType in keyof TType]: TType[KeyType] };
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* @public
|
|
36
38
|
*/
|
|
37
|
-
export type Dict<
|
|
39
|
+
export type Dict<TType> = Record<string, TType | undefined>;
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* @public
|
|
41
43
|
*/
|
|
42
|
-
export type MaybePromise<
|
|
44
|
+
export type MaybePromise<TType> = TType | Promise<TType>;
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* @internal
|
|
@@ -47,7 +49,9 @@ export type MaybePromise<T> = T | Promise<T>;
|
|
|
47
49
|
* Creates a "lower-priority" type inference.
|
|
48
50
|
* https://github.com/microsoft/TypeScript/issues/14829#issuecomment-322267089
|
|
49
51
|
*/
|
|
50
|
-
export type InferLast<
|
|
52
|
+
export type InferLast<TType> = TType & {
|
|
53
|
+
[KeyType in keyof TType]: TType[KeyType];
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
57
|
* @public
|
|
@@ -55,11 +59,14 @@ export type InferLast<T> = T & { [K in keyof T]: T[K] };
|
|
|
55
59
|
export type inferAsyncReturnType<TFunction extends (...args: any) => any> =
|
|
56
60
|
ThenArg<ReturnType<TFunction>>;
|
|
57
61
|
|
|
58
|
-
type FilterKeys<
|
|
59
|
-
[TKey in keyof
|
|
60
|
-
}[keyof
|
|
62
|
+
type FilterKeys<TObj extends object, TFilter> = {
|
|
63
|
+
[TKey in keyof TObj]: TObj[TKey] extends TFilter ? TKey : never;
|
|
64
|
+
}[keyof TObj];
|
|
61
65
|
|
|
62
66
|
/**
|
|
63
67
|
* @internal
|
|
64
68
|
*/
|
|
65
|
-
export type Filter<
|
|
69
|
+
export type Filter<TObj extends object, TFilter> = Pick<
|
|
70
|
+
TObj,
|
|
71
|
+
FilterKeys<TObj, TFilter>
|
|
72
|
+
>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
declare type KeyFromValue<V, T extends Record<PropertyKey, PropertyKey>> = {
|
|
5
|
-
[K in keyof T]: V extends T[K] ? K : never;
|
|
6
|
-
}[keyof T];
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
declare type Invert<T extends Record<PropertyKey, PropertyKey>> = {
|
|
11
|
-
[V in T[keyof T]]: KeyFromValue<V, T>;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Invert<T>;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=invert.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invert.d.ts","sourceRoot":"","sources":["../../../../../packages/server/src/rpc/internals/invert.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,aAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KAChE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAC3C,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;GAEG;AACH,aAAK,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KACvD,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,EAC/D,GAAG,EAAE,CAAC,GACL,MAAM,CAAC,CAAC,CAAC,CAOX"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
type KeyFromValue<V, T extends Record<PropertyKey, PropertyKey>> = {
|
|
5
|
-
[K in keyof T]: V extends T[K] ? K : never;
|
|
6
|
-
}[keyof T];
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
type Invert<T extends Record<PropertyKey, PropertyKey>> = {
|
|
12
|
-
[V in T[keyof T]]: KeyFromValue<V, T>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export function invert<T extends Record<PropertyKey, PropertyKey>>(
|
|
19
|
-
obj: T,
|
|
20
|
-
): Invert<T> {
|
|
21
|
-
const newObj = Object.create(null) as any;
|
|
22
|
-
for (const key in obj) {
|
|
23
|
-
const v = obj[key];
|
|
24
|
-
newObj[v] = key;
|
|
25
|
-
}
|
|
26
|
-
return newObj;
|
|
27
|
-
}
|