@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.215 → 11.0.0-alpha-tmp-export-from-main.211
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/@trpc-core-unstable-do-not-import-this-please.d.ts +9 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +1 -1
- package/dist/@trpc-server/http.d.ts.map +1 -1
- package/dist/@trpc-server.d.ts +3 -3
- package/dist/@trpc-server.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.js +7 -12
- package/dist/adapters/aws-lambda/index.mjs +3 -8
- package/dist/adapters/aws-lambda/utils.d.ts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -8
- package/dist/adapters/express.mjs +2 -8
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/index.js +4 -12
- package/dist/adapters/fastify/index.mjs +2 -10
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
- package/dist/adapters/fetch/index.js +4 -10
- package/dist/adapters/fetch/index.mjs +2 -8
- package/dist/adapters/fetch/types.d.ts +1 -1
- package/dist/adapters/next.d.ts +1 -1
- package/dist/adapters/next.js +5 -11
- package/dist/adapters/next.mjs +3 -9
- package/dist/adapters/node-http/content-type/json/index.js +3 -5
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
- package/dist/adapters/node-http/index.js +2 -8
- package/dist/adapters/node-http/index.mjs +2 -8
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/types.d.ts +2 -2
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -1
- package/dist/adapters/standalone.js +2 -8
- package/dist/adapters/standalone.mjs +2 -8
- package/dist/adapters/ws.d.ts +1 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -31
- package/dist/adapters/ws.mjs +1 -6
- package/dist/http.d.ts +6 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -12
- package/dist/http.mjs +1 -7
- package/dist/index.js +41 -15
- package/dist/index.mjs +1 -5
- package/dist/{nodeHTTPRequestHandler-257a3b5f.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
- package/dist/{nodeHTTPRequestHandler-f4b7e374.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
- package/dist/{nodeHTTPRequestHandler-29178135.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
- package/dist/observable.d.ts +2 -2
- package/dist/observable.d.ts.map +1 -1
- package/dist/observable.js +25 -9
- package/dist/observable.mjs +1 -3
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -5
- package/dist/rpc.mjs +1 -2
- package/dist/shared.js +9 -4
- package/dist/shared.mjs +1 -2
- package/package.json +125 -53
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +9 -0
- package/src/@trpc-server/http.ts +1 -2
- package/src/@trpc-server.ts +3 -3
- package/src/adapters/aws-lambda/index.ts +1 -1
- package/src/adapters/aws-lambda/utils.ts +1 -1
- package/src/adapters/express.ts +2 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +1 -1
- package/src/adapters/fetch/types.ts +1 -1
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
- package/src/adapters/node-http/types.ts +3 -2
- package/src/adapters/standalone.ts +1 -1
- package/src/adapters/ws.ts +10 -9
- package/src/http.ts +6 -6
- package/src/observable.ts +2 -2
- package/src/rpc.ts +2 -2
- package/dist/TRPCError-10da405a.js +0 -61
- package/dist/TRPCError-14edcf88.mjs +0 -63
- package/dist/TRPCError-e2c8eb77.js +0 -67
- package/dist/batchStreamFormatter-1971db27.js +0 -32
- package/dist/batchStreamFormatter-378277dc.mjs +0 -30
- package/dist/batchStreamFormatter-4375dc8b.js +0 -31
- package/dist/bundle-analysis.json +0 -767
- package/dist/contentType-2ed02bef.mjs +0 -52
- package/dist/contentType-3a829011.js +0 -54
- package/dist/contentType-e4a2373e.js +0 -59
- package/dist/createProxy-0306dcaa.mjs +0 -121
- package/dist/createProxy-7e413449.js +0 -127
- package/dist/createProxy-dce0c414.js +0 -116
- package/dist/initTRPC-2cef03ab.js +0 -384
- package/dist/initTRPC-38faa18f.js +0 -371
- package/dist/initTRPC-fa1b3d57.mjs +0 -376
- package/dist/observable-2a5a96d5.js +0 -125
- package/dist/observable-62674916.js +0 -125
- package/dist/observable-6d025a37.mjs +0 -121
- package/dist/operators-0cc4956a.js +0 -99
- package/dist/operators-b08617cb.js +0 -103
- package/dist/operators-d0c3e794.mjs +0 -99
- package/dist/parseTRPCMessage-6e6c204e.js +0 -65
- package/dist/parseTRPCMessage-8eb0bbe9.mjs +0 -62
- package/dist/parseTRPCMessage-ebdfe3ca.js +0 -67
- package/dist/resolveHTTPResponse-833ca2b8.js +0 -265
- package/dist/resolveHTTPResponse-9322334c.mjs +0 -291
- package/dist/resolveHTTPResponse-d64c48e1.js +0 -293
- package/dist/rootConfig-3371c473.js +0 -89
- package/dist/rootConfig-571c9267.js +0 -94
- package/dist/rootConfig-6b04a6b8.mjs +0 -81
- package/dist/router-3344b52a.js +0 -262
- package/dist/router-919c37eb.js +0 -259
- package/dist/router-d6789e4b.mjs +0 -252
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -35
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -51
- package/dist/unstable-core-do-not-import/index.mjs +0 -11
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/observable/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/observable.d.ts +0 -13
- package/dist/unstable-core-do-not-import/observable/observable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/operators.d.ts +0 -8
- package/dist/unstable-core-do-not-import/observable/operators.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/types.d.ts +0 -26
- package/dist/unstable-core-do-not-import/observable/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -31
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -108
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/observable/index.ts +0 -10
- package/src/unstable-core-do-not-import/observable/observable.ts +0 -155
- package/src/unstable-core-do-not-import/observable/operators.ts +0 -119
- package/src/unstable-core-do-not-import/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -66
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MonoTypeOperatorFunction,
|
|
3
|
-
Observer,
|
|
4
|
-
OperatorFunction,
|
|
5
|
-
Unsubscribable,
|
|
6
|
-
} from './types';
|
|
7
|
-
|
|
8
|
-
export function map<TValueBefore, TError, TValueAfter>(
|
|
9
|
-
project: (value: TValueBefore, index: number) => TValueAfter,
|
|
10
|
-
): OperatorFunction<TValueBefore, TError, TValueAfter, TError> {
|
|
11
|
-
return (originalObserver) => {
|
|
12
|
-
return {
|
|
13
|
-
subscribe(observer) {
|
|
14
|
-
let index = 0;
|
|
15
|
-
const subscription = originalObserver.subscribe({
|
|
16
|
-
next(value) {
|
|
17
|
-
observer.next?.(project(value, index++));
|
|
18
|
-
},
|
|
19
|
-
error(error) {
|
|
20
|
-
observer.error?.(error);
|
|
21
|
-
},
|
|
22
|
-
complete() {
|
|
23
|
-
observer.complete?.();
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return subscription;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ShareConfig {}
|
|
33
|
-
export function share<TValue, TError>(
|
|
34
|
-
_opts?: ShareConfig,
|
|
35
|
-
): MonoTypeOperatorFunction<TValue, TError> {
|
|
36
|
-
return (originalObserver) => {
|
|
37
|
-
let refCount = 0;
|
|
38
|
-
|
|
39
|
-
let subscription: Unsubscribable | null = null;
|
|
40
|
-
const observers: Partial<Observer<TValue, TError>>[] = [];
|
|
41
|
-
|
|
42
|
-
function startIfNeeded() {
|
|
43
|
-
if (subscription) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
subscription = originalObserver.subscribe({
|
|
47
|
-
next(value) {
|
|
48
|
-
for (const observer of observers) {
|
|
49
|
-
observer.next?.(value);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
error(error) {
|
|
53
|
-
for (const observer of observers) {
|
|
54
|
-
observer.error?.(error);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
complete() {
|
|
58
|
-
for (const observer of observers) {
|
|
59
|
-
observer.complete?.();
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function resetIfNeeded() {
|
|
65
|
-
// "resetOnRefCountZero"
|
|
66
|
-
if (refCount === 0 && subscription) {
|
|
67
|
-
const _sub = subscription;
|
|
68
|
-
subscription = null;
|
|
69
|
-
_sub.unsubscribe();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
subscribe(observer) {
|
|
75
|
-
refCount++;
|
|
76
|
-
|
|
77
|
-
observers.push(observer);
|
|
78
|
-
startIfNeeded();
|
|
79
|
-
return {
|
|
80
|
-
unsubscribe() {
|
|
81
|
-
refCount--;
|
|
82
|
-
resetIfNeeded();
|
|
83
|
-
|
|
84
|
-
const index = observers.findIndex((v) => v === observer);
|
|
85
|
-
|
|
86
|
-
if (index > -1) {
|
|
87
|
-
observers.splice(index, 1);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function tap<TValue, TError>(
|
|
97
|
-
observer: Partial<Observer<TValue, TError>>,
|
|
98
|
-
): MonoTypeOperatorFunction<TValue, TError> {
|
|
99
|
-
return (originalObserver) => {
|
|
100
|
-
return {
|
|
101
|
-
subscribe(observer2) {
|
|
102
|
-
return originalObserver.subscribe({
|
|
103
|
-
next(v) {
|
|
104
|
-
observer.next?.(v);
|
|
105
|
-
observer2.next?.(v);
|
|
106
|
-
},
|
|
107
|
-
error(v) {
|
|
108
|
-
observer.error?.(v);
|
|
109
|
-
observer2.error?.(v);
|
|
110
|
-
},
|
|
111
|
-
complete() {
|
|
112
|
-
observer.complete?.();
|
|
113
|
-
observer2.complete?.();
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export interface Unsubscribable {
|
|
2
|
-
unsubscribe(): void;
|
|
3
|
-
}
|
|
4
|
-
export type UnsubscribeFn = () => void;
|
|
5
|
-
interface Subscribable<TValue, TError> {
|
|
6
|
-
subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
|
|
7
|
-
}
|
|
8
|
-
export interface Observable<TValue, TError>
|
|
9
|
-
extends Subscribable<TValue, TError> {
|
|
10
|
-
pipe(): Observable<TValue, TError>;
|
|
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>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface Observer<TValue, TError> {
|
|
50
|
-
next: (value: TValue) => void;
|
|
51
|
-
error: (err: TError) => void;
|
|
52
|
-
complete: () => void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type TeardownLogic =
|
|
56
|
-
// | SubscriptionLike
|
|
57
|
-
Unsubscribable | UnsubscribeFn | void;
|
|
58
|
-
|
|
59
|
-
export type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
60
|
-
|
|
61
|
-
export type OperatorFunction<
|
|
62
|
-
TValueBefore,
|
|
63
|
-
TErrorBefore,
|
|
64
|
-
TValueAfter,
|
|
65
|
-
TErrorAfter,
|
|
66
|
-
> = UnaryFunction<
|
|
67
|
-
Subscribable<TValueBefore, TErrorBefore>,
|
|
68
|
-
Subscribable<TValueAfter, TErrorAfter>
|
|
69
|
-
>;
|
|
70
|
-
|
|
71
|
-
export type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<
|
|
72
|
-
TValue,
|
|
73
|
-
TError,
|
|
74
|
-
TValue,
|
|
75
|
-
TError
|
|
76
|
-
>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// zod / @decs/typeschema
|
|
2
|
-
export type ParserZodEsque<TInput, TParsedInput> = {
|
|
3
|
-
_input: TInput;
|
|
4
|
-
_output: TParsedInput;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type ParserMyZodEsque<TInput> = {
|
|
8
|
-
parse: (input: any) => TInput;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ParserSuperstructEsque<TInput> = {
|
|
12
|
-
create: (input: unknown) => TInput;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ParserCustomValidatorEsque<TInput> = (
|
|
16
|
-
input: unknown,
|
|
17
|
-
) => Promise<TInput> | TInput;
|
|
18
|
-
|
|
19
|
-
export type ParserYupEsque<TInput> = {
|
|
20
|
-
validateSync: (input: unknown) => TInput;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type ParserScaleEsque<TInput> = {
|
|
24
|
-
assert(value: unknown): asserts value is TInput;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type ParserWithoutInput<TInput> =
|
|
28
|
-
| ParserCustomValidatorEsque<TInput>
|
|
29
|
-
| ParserMyZodEsque<TInput>
|
|
30
|
-
| ParserScaleEsque<TInput>
|
|
31
|
-
| ParserSuperstructEsque<TInput>
|
|
32
|
-
| ParserYupEsque<TInput>;
|
|
33
|
-
|
|
34
|
-
export type ParserWithInputOutput<TInput, TParsedInput> = ParserZodEsque<
|
|
35
|
-
TInput,
|
|
36
|
-
TParsedInput
|
|
37
|
-
>;
|
|
38
|
-
|
|
39
|
-
export type Parser = ParserWithInputOutput<any, any> | ParserWithoutInput<any>;
|
|
40
|
-
|
|
41
|
-
export type inferParser<TParser extends Parser> =
|
|
42
|
-
TParser extends ParserWithInputOutput<infer $TIn, infer $TOut>
|
|
43
|
-
? {
|
|
44
|
-
in: $TIn;
|
|
45
|
-
out: $TOut;
|
|
46
|
-
}
|
|
47
|
-
: TParser extends ParserWithoutInput<infer $InOut>
|
|
48
|
-
? {
|
|
49
|
-
in: $InOut;
|
|
50
|
-
out: $InOut;
|
|
51
|
-
}
|
|
52
|
-
: never;
|
|
53
|
-
|
|
54
|
-
export type ParseFn<TType> = (value: unknown) => Promise<TType> | TType;
|
|
55
|
-
|
|
56
|
-
export function getParseFn<TType>(procedureParser: Parser): ParseFn<TType> {
|
|
57
|
-
const parser = procedureParser as any;
|
|
58
|
-
|
|
59
|
-
if (typeof parser === 'function') {
|
|
60
|
-
// ParserCustomValidatorEsque
|
|
61
|
-
return parser;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (typeof parser.parseAsync === 'function') {
|
|
65
|
-
// ParserZodEsque
|
|
66
|
-
return parser.parseAsync.bind(parser);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (typeof parser.parse === 'function') {
|
|
70
|
-
// ParserZodEsque
|
|
71
|
-
// ParserValibotEsque (<= v0.12.X)
|
|
72
|
-
return parser.parse.bind(parser);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (typeof parser.validateSync === 'function') {
|
|
76
|
-
// ParserYupEsque
|
|
77
|
-
return parser.validateSync.bind(parser);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (typeof parser.create === 'function') {
|
|
81
|
-
// ParserSuperstructEsque
|
|
82
|
-
return parser.create.bind(parser);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (typeof parser.assert === 'function') {
|
|
86
|
-
// ParserScaleEsque
|
|
87
|
-
return (value) => {
|
|
88
|
-
parser.assert(value);
|
|
89
|
-
return value as TType;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
throw new Error('Could not find a validator fn');
|
|
94
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { inferObservableValue } from './observable';
|
|
2
|
-
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
3
|
-
import type { Serialize } from './serialize';
|
|
4
|
-
import type { DefaultDataTransformer } from './transformer';
|
|
5
|
-
import type { inferConfig, TRPCInferrable } from './TRPCInferrable';
|
|
6
|
-
|
|
7
|
-
export const procedureTypes = ['query', 'mutation', 'subscription'] as const;
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export type ProcedureType = (typeof procedureTypes)[number];
|
|
12
|
-
|
|
13
|
-
type ClientContext = Record<string, unknown>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export interface ProcedureOptions {
|
|
19
|
-
/**
|
|
20
|
-
* Client-side context
|
|
21
|
-
*/
|
|
22
|
-
context?: ClientContext;
|
|
23
|
-
signal?: AbortSignal;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export type ProcedureArgs<TParams extends AnyProcedure['_def']> =
|
|
30
|
-
void extends TParams['_input_in']
|
|
31
|
-
? [input?: undefined | void, opts?: ProcedureOptions]
|
|
32
|
-
: undefined extends TParams['_input_in']
|
|
33
|
-
? [input?: TParams['_input_in'] | void, opts?: ProcedureOptions]
|
|
34
|
-
: [input: TParams['_input_in'], opts?: ProcedureOptions];
|
|
35
|
-
|
|
36
|
-
interface BuiltProcedureDef {
|
|
37
|
-
input: unknown;
|
|
38
|
-
output: unknown;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export interface Procedure<
|
|
45
|
-
TType extends ProcedureType,
|
|
46
|
-
TDef extends BuiltProcedureDef,
|
|
47
|
-
> {
|
|
48
|
-
_def: {
|
|
49
|
-
_input_in: TDef['input'];
|
|
50
|
-
_output_out: TDef['output'];
|
|
51
|
-
procedure: true;
|
|
52
|
-
type: TType;
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
* Meta is not inferrable on individual procedures, only on the router
|
|
56
|
-
*/
|
|
57
|
-
meta: unknown;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
(opts: ProcedureCallOptions): Promise<unknown>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface QueryProcedure<TDef extends BuiltProcedureDef>
|
|
66
|
-
extends Procedure<'query', TDef> {}
|
|
67
|
-
|
|
68
|
-
export interface MutationProcedure<TDef extends BuiltProcedureDef>
|
|
69
|
-
extends Procedure<'mutation', TDef> {}
|
|
70
|
-
|
|
71
|
-
export interface SubscriptionProcedure<TDef extends BuiltProcedureDef>
|
|
72
|
-
extends Procedure<'subscription', TDef> {}
|
|
73
|
-
|
|
74
|
-
export type AnyQueryProcedure = QueryProcedure<any>;
|
|
75
|
-
export type AnyMutationProcedure = MutationProcedure<any>;
|
|
76
|
-
export type AnySubscriptionProcedure = SubscriptionProcedure<any>;
|
|
77
|
-
export type AnyProcedure = Procedure<ProcedureType, any>;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
export type inferTransformedProcedureOutput<
|
|
83
|
-
TInferrable extends TRPCInferrable,
|
|
84
|
-
TProcedure extends AnyProcedure,
|
|
85
|
-
> = inferConfig<TInferrable>['transformer'] extends DefaultDataTransformer
|
|
86
|
-
? Serialize<TProcedure['_def']['_output_out']>
|
|
87
|
-
: TProcedure['_def']['_output_out'];
|
|
88
|
-
|
|
89
|
-
/** @internal */
|
|
90
|
-
export type inferTransformedSubscriptionOutput<
|
|
91
|
-
TInferrable extends TRPCInferrable,
|
|
92
|
-
TProcedure extends AnyProcedure,
|
|
93
|
-
> = inferConfig<TInferrable>['transformer'] extends DefaultDataTransformer
|
|
94
|
-
? Serialize<inferObservableValue<TProcedure['_def']['_output_out']>>
|
|
95
|
-
: inferObservableValue<TProcedure['_def']['_output_out']>;
|
|
96
|
-
|
|
97
|
-
export type inferHandlerInput<TProcedure extends AnyProcedure> = ProcedureArgs<
|
|
98
|
-
inferProcedureParams<TProcedure>
|
|
99
|
-
>;
|
|
100
|
-
|
|
101
|
-
export type inferProcedureInput<TProcedure extends AnyProcedure> =
|
|
102
|
-
inferProcedureParams<TProcedure>['_input_in'];
|
|
103
|
-
|
|
104
|
-
export type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure
|
|
105
|
-
? TProcedure['_def']
|
|
106
|
-
: never;
|
|
107
|
-
export type inferProcedureOutput<TProcedure> =
|
|
108
|
-
inferProcedureParams<TProcedure>['_output_out'];
|