@trpc/client 11.0.0-alpha-tmp-12-06-react.674 → 11.0.0-alpha-tmp-issues-6374.696
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 +51 -50
- package/dist/createTRPCClient.d.ts +17 -4
- package/dist/createTRPCClient.d.ts.map +1 -1
- package/dist/createTRPCClient.js +5 -2
- package/dist/createTRPCClient.mjs +6 -3
- package/dist/internals/TRPCUntypedClient.d.ts +3 -2
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/TRPCUntypedClient.js +3 -0
- package/dist/internals/TRPCUntypedClient.mjs +3 -1
- package/dist/links/internals/createChain.d.ts +4 -4
- package/dist/links/internals/createChain.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/createTRPCClient.ts +31 -9
- package/src/internals/TRPCUntypedClient.ts +9 -6
- package/src/links/internals/createChain.ts +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 20.
|
|
2
|
+
"bundleSize": 66295,
|
|
3
|
+
"bundleOrigSize": 83878,
|
|
4
|
+
"bundleReduction": 20.96,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"removedExports": [],
|
|
15
15
|
"dependents": [],
|
|
16
|
-
"percent": 27.
|
|
16
|
+
"percent": 27.18,
|
|
17
17
|
"reduction": 10.3
|
|
18
18
|
},
|
|
19
19
|
{
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 11.
|
|
28
|
+
"percent": 11.75,
|
|
29
29
|
"reduction": 0
|
|
30
30
|
},
|
|
31
31
|
{
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"removedExports": [],
|
|
39
39
|
"dependents": [],
|
|
40
|
-
"percent": 9.
|
|
40
|
+
"percent": 9.06,
|
|
41
41
|
"reduction": 4.42
|
|
42
42
|
},
|
|
43
43
|
{
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"removedExports": [],
|
|
51
51
|
"dependents": [],
|
|
52
|
-
"percent": 8.
|
|
52
|
+
"percent": 8.44,
|
|
53
53
|
"reduction": 19.44
|
|
54
54
|
},
|
|
55
55
|
{
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"/src/links/httpBatchLink.ts",
|
|
65
65
|
"/src/links/httpBatchStreamLink.ts"
|
|
66
66
|
],
|
|
67
|
-
"percent": 6.
|
|
67
|
+
"percent": 6.16,
|
|
68
68
|
"reduction": 5.64
|
|
69
69
|
},
|
|
70
70
|
{
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
],
|
|
77
77
|
"removedExports": [],
|
|
78
78
|
"dependents": [],
|
|
79
|
-
"percent": 5.
|
|
79
|
+
"percent": 5.94,
|
|
80
80
|
"reduction": 5.59
|
|
81
81
|
},
|
|
82
82
|
{
|
|
@@ -99,9 +99,25 @@
|
|
|
99
99
|
"/src/links/httpBatchStreamLink.ts",
|
|
100
100
|
"/src/links/httpSubscriptionLink.ts"
|
|
101
101
|
],
|
|
102
|
-
"percent": 5.
|
|
102
|
+
"percent": 5.57,
|
|
103
103
|
"reduction": 37.14
|
|
104
104
|
},
|
|
105
|
+
{
|
|
106
|
+
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
107
|
+
"size": 3289,
|
|
108
|
+
"origSize": 4742,
|
|
109
|
+
"renderedExports": [
|
|
110
|
+
"TRPCUntypedClient",
|
|
111
|
+
"untypedClientSymbol"
|
|
112
|
+
],
|
|
113
|
+
"removedExports": [],
|
|
114
|
+
"dependents": [
|
|
115
|
+
"/src/createTRPCUntypedClient.ts",
|
|
116
|
+
"/src/createTRPCClient.ts"
|
|
117
|
+
],
|
|
118
|
+
"percent": 4.96,
|
|
119
|
+
"reduction": 30.64
|
|
120
|
+
},
|
|
105
121
|
{
|
|
106
122
|
"id": "/src/links/httpLink.ts",
|
|
107
123
|
"size": 3179,
|
|
@@ -111,24 +127,9 @@
|
|
|
111
127
|
],
|
|
112
128
|
"removedExports": [],
|
|
113
129
|
"dependents": [],
|
|
114
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.8,
|
|
115
131
|
"reduction": 14.24
|
|
116
132
|
},
|
|
117
|
-
{
|
|
118
|
-
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
119
|
-
"size": 3158,
|
|
120
|
-
"origSize": 4578,
|
|
121
|
-
"renderedExports": [
|
|
122
|
-
"TRPCUntypedClient"
|
|
123
|
-
],
|
|
124
|
-
"removedExports": [],
|
|
125
|
-
"dependents": [
|
|
126
|
-
"/src/createTRPCUntypedClient.ts",
|
|
127
|
-
"/src/createTRPCClient.ts"
|
|
128
|
-
],
|
|
129
|
-
"percent": 4.78,
|
|
130
|
-
"reduction": 31.02
|
|
131
|
-
},
|
|
132
133
|
{
|
|
133
134
|
"id": "/src/TRPCClientError.ts",
|
|
134
135
|
"size": 2787,
|
|
@@ -146,7 +147,7 @@
|
|
|
146
147
|
"/src/links/httpSubscriptionLink.ts",
|
|
147
148
|
"/src/internals/TRPCUntypedClient.ts"
|
|
148
149
|
],
|
|
149
|
-
"percent": 4.
|
|
150
|
+
"percent": 4.2,
|
|
150
151
|
"reduction": 21.8
|
|
151
152
|
},
|
|
152
153
|
{
|
|
@@ -158,9 +159,26 @@
|
|
|
158
159
|
],
|
|
159
160
|
"removedExports": [],
|
|
160
161
|
"dependents": [],
|
|
161
|
-
"percent": 3.
|
|
162
|
+
"percent": 3.31,
|
|
162
163
|
"reduction": 18.8
|
|
163
164
|
},
|
|
165
|
+
{
|
|
166
|
+
"id": "/src/createTRPCClient.ts",
|
|
167
|
+
"size": 1322,
|
|
168
|
+
"origSize": 5233,
|
|
169
|
+
"renderedExports": [
|
|
170
|
+
"clientCallTypeToProcedureType",
|
|
171
|
+
"createTRPCClientProxy",
|
|
172
|
+
"createTRPCClient",
|
|
173
|
+
"getUntypedClient"
|
|
174
|
+
],
|
|
175
|
+
"removedExports": [],
|
|
176
|
+
"dependents": [
|
|
177
|
+
"/src/index.ts"
|
|
178
|
+
],
|
|
179
|
+
"percent": 1.99,
|
|
180
|
+
"reduction": 74.74
|
|
181
|
+
},
|
|
164
182
|
{
|
|
165
183
|
"id": "/src/internals/signals.ts",
|
|
166
184
|
"size": 1188,
|
|
@@ -175,30 +193,13 @@
|
|
|
175
193
|
"/src/links/httpBatchStreamLink.ts",
|
|
176
194
|
"/src/links/httpSubscriptionLink.ts"
|
|
177
195
|
],
|
|
178
|
-
"percent": 1.8,
|
|
179
|
-
"reduction": 3.88
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"id": "/src/createTRPCClient.ts",
|
|
183
|
-
"size": 1185,
|
|
184
|
-
"origSize": 4665,
|
|
185
|
-
"renderedExports": [
|
|
186
|
-
"clientCallTypeToProcedureType",
|
|
187
|
-
"createTRPCClientProxy",
|
|
188
|
-
"createTRPCClient",
|
|
189
|
-
"getUntypedClient"
|
|
190
|
-
],
|
|
191
|
-
"removedExports": [],
|
|
192
|
-
"dependents": [
|
|
193
|
-
"/src/index.ts"
|
|
194
|
-
],
|
|
195
196
|
"percent": 1.79,
|
|
196
|
-
"reduction":
|
|
197
|
+
"reduction": 3.88
|
|
197
198
|
},
|
|
198
199
|
{
|
|
199
200
|
"id": "/src/links/internals/createChain.ts",
|
|
200
201
|
"size": 690,
|
|
201
|
-
"origSize":
|
|
202
|
+
"origSize": 1062,
|
|
202
203
|
"renderedExports": [
|
|
203
204
|
"createChain"
|
|
204
205
|
],
|
|
@@ -207,8 +208,8 @@
|
|
|
207
208
|
"/src/links/splitLink.ts",
|
|
208
209
|
"/src/internals/TRPCUntypedClient.ts"
|
|
209
210
|
],
|
|
210
|
-
"percent": 1.
|
|
211
|
-
"reduction":
|
|
211
|
+
"percent": 1.04,
|
|
212
|
+
"reduction": 35.03
|
|
212
213
|
},
|
|
213
214
|
{
|
|
214
215
|
"id": "/src/links/splitLink.ts",
|
|
@@ -233,7 +234,7 @@
|
|
|
233
234
|
"dependents": [
|
|
234
235
|
"/src/unstable-internals.ts"
|
|
235
236
|
],
|
|
236
|
-
"percent": 0.
|
|
237
|
+
"percent": 0.85,
|
|
237
238
|
"reduction": 66.71
|
|
238
239
|
},
|
|
239
240
|
{
|
|
@@ -2,12 +2,22 @@ import type { Unsubscribable } from '@trpc/server/observable';
|
|
|
2
2
|
import type { AnyProcedure, AnyRouter, inferClientTypes, inferProcedureInput, inferTransformedProcedureOutput, IntersectionError, ProcedureOptions, ProcedureType, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type { CreateTRPCClientOptions } from './createTRPCUntypedClient';
|
|
4
4
|
import type { TRPCSubscriptionObserver, UntypedClientProperties } from './internals/TRPCUntypedClient';
|
|
5
|
-
import { TRPCUntypedClient } from './internals/TRPCUntypedClient';
|
|
5
|
+
import { TRPCUntypedClient, untypedClientSymbol } from './internals/TRPCUntypedClient';
|
|
6
6
|
import type { TRPCClientError } from './TRPCClientError';
|
|
7
7
|
/**
|
|
8
8
|
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter, TRouter['_def']['record']> & {
|
|
11
|
+
[untypedClientSymbol]: TRPCUntypedClient<{
|
|
12
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
13
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* @deprecated use {@link TRPCClient} instead
|
|
9
19
|
**/
|
|
10
|
-
export type inferRouterClient<TRouter extends AnyRouter> =
|
|
20
|
+
export type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
11
21
|
type ResolverDef = {
|
|
12
22
|
input: any;
|
|
13
23
|
output: any;
|
|
@@ -41,7 +51,7 @@ export declare const clientCallTypeToProcedureType: (clientCallType: string) =>
|
|
|
41
51
|
/**
|
|
42
52
|
* Creates a proxy client and shows type errors if you have query names that collide with built-in properties
|
|
43
53
|
*/
|
|
44
|
-
export type CreateTRPCClient<TRouter extends AnyRouter> =
|
|
54
|
+
export type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter> extends infer $Value ? UntypedClientProperties & keyof $Value extends never ? TRPCClient<TRouter> : IntersectionError<UntypedClientProperties & keyof $Value> : never;
|
|
45
55
|
/**
|
|
46
56
|
* @internal
|
|
47
57
|
*/
|
|
@@ -51,6 +61,9 @@ export declare function createTRPCClient<TRouter extends AnyRouter>(opts: Create
|
|
|
51
61
|
* Get an untyped client from a proxy client
|
|
52
62
|
* @internal
|
|
53
63
|
*/
|
|
54
|
-
export declare function getUntypedClient<TRouter extends AnyRouter>(client:
|
|
64
|
+
export declare function getUntypedClient<TRouter extends AnyRouter>(client: TRPCClient<TRouter> | TRPCUntypedClient<TRouter>): TRPCUntypedClient<{
|
|
65
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
66
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
67
|
+
}>;
|
|
55
68
|
export {};
|
|
56
69
|
//# sourceMappingURL=createTRPCClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTRPCClient.d.ts","sourceRoot":"","sources":["../src/createTRPCClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACb,MAAM,0CAA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xD,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,GACvD,iBAAiB,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;IAC/D,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC;CAClE,CAAC,CAKD"}
|
package/dist/createTRPCClient.js
CHANGED
|
@@ -26,7 +26,7 @@ const clientCallTypeMap = {
|
|
|
26
26
|
if (client.hasOwnProperty(key)) {
|
|
27
27
|
return client[key];
|
|
28
28
|
}
|
|
29
|
-
if (key ===
|
|
29
|
+
if (key === TRPCUntypedClient.untypedClientSymbol) {
|
|
30
30
|
return client;
|
|
31
31
|
}
|
|
32
32
|
return proxy[key];
|
|
@@ -41,7 +41,10 @@ function createTRPCClient(opts) {
|
|
|
41
41
|
* Get an untyped client from a proxy client
|
|
42
42
|
* @internal
|
|
43
43
|
*/ function getUntypedClient(client) {
|
|
44
|
-
|
|
44
|
+
if (client instanceof TRPCUntypedClient.TRPCUntypedClient) {
|
|
45
|
+
return client;
|
|
46
|
+
}
|
|
47
|
+
return client[TRPCUntypedClient.untypedClientSymbol];
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRecursiveProxy, createFlatProxy } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
-
import { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
|
|
2
|
+
import { untypedClientSymbol, TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
|
|
3
3
|
|
|
4
4
|
const clientCallTypeMap = {
|
|
5
5
|
query: 'query',
|
|
@@ -24,7 +24,7 @@ const clientCallTypeMap = {
|
|
|
24
24
|
if (client.hasOwnProperty(key)) {
|
|
25
25
|
return client[key];
|
|
26
26
|
}
|
|
27
|
-
if (key ===
|
|
27
|
+
if (key === untypedClientSymbol) {
|
|
28
28
|
return client;
|
|
29
29
|
}
|
|
30
30
|
return proxy[key];
|
|
@@ -39,7 +39,10 @@ function createTRPCClient(opts) {
|
|
|
39
39
|
* Get an untyped client from a proxy client
|
|
40
40
|
* @internal
|
|
41
41
|
*/ function getUntypedClient(client) {
|
|
42
|
-
|
|
42
|
+
if (client instanceof TRPCUntypedClient) {
|
|
43
|
+
return client;
|
|
44
|
+
}
|
|
45
|
+
return client[untypedClientSymbol];
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, getUntypedClient };
|
|
@@ -27,15 +27,16 @@ export type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {
|
|
|
27
27
|
};
|
|
28
28
|
/** @internal */
|
|
29
29
|
export type UntypedClientProperties = '$request' | 'links' | 'mutation' | 'query' | 'requestAsPromise' | 'requestId' | 'runtime' | 'subscription';
|
|
30
|
-
export declare class TRPCUntypedClient<
|
|
30
|
+
export declare class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
|
31
31
|
private readonly links;
|
|
32
32
|
readonly runtime: TRPCClientRuntime;
|
|
33
33
|
private requestId;
|
|
34
|
-
constructor(opts: CreateTRPCClientOptions<
|
|
34
|
+
constructor(opts: CreateTRPCClientOptions<TInferrable>);
|
|
35
35
|
private $request;
|
|
36
36
|
private requestAsPromise;
|
|
37
37
|
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
38
38
|
mutation(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
39
39
|
subscription(path: string, input: unknown, opts: Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>> & TRPCRequestOptions): Unsubscribable;
|
|
40
40
|
}
|
|
41
|
+
export declare const untypedClientSymbol: unique symbol;
|
|
41
42
|
//# sourceMappingURL=TRPCUntypedClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,SAAS,EACT,uBAAuB,EACvB,qBAAqB,EAErB,SAAS,EACV,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB,CAAC,MAAM,EAAE,MAAM;IACtD,SAAS,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,MAAM,EAAE,CAAC,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACzD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,uBAAuB,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;CACvE;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,qBAAqB,IAAI;IAC3E,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,WAAW,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IAAI,CAAC;CACvE;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,qBAAqB,IAAI;IAC3E,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,SAAS,CAAC,qEAAqE,CAAC,CAAC;CAChG,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAC/B,UAAU,GACV,OAAO,GACP,UAAU,GACV,OAAO,GACP,kBAAkB,GAClB,WAAW,GACX,SAAS,GACT,cAAc,CAAC;AAEnB,qBAAa,iBAAiB,CAAC,WAAW,SAAS,qBAAqB;IACtE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+B;IACrD,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,uBAAuB,CAAC,WAAW,CAAC;IAStD,OAAO,CAAC,QAAQ;YAkBF,gBAAgB;IAmBvB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IAS9D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IASjE,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,CACX,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAC9D,GACC,kBAAkB,GACnB,cAAc;CAwClB;AAED,eAAO,MAAM,mBAAmB,eAAuB,CAAC"}
|
|
@@ -33,6 +33,7 @@ class TRPCUntypedClient {
|
|
|
33
33
|
try {
|
|
34
34
|
const req$ = this.$request(opts);
|
|
35
35
|
const envelope = await observable.observableToPromise(req$);
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
37
|
const data = envelope.result.data;
|
|
37
38
|
return data;
|
|
38
39
|
} catch (err) {
|
|
@@ -111,5 +112,7 @@ class TRPCUntypedClient {
|
|
|
111
112
|
this.links = opts.links.map((link)=>link(this.runtime));
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
const untypedClientSymbol = Symbol('TRPCClient');
|
|
114
116
|
|
|
115
117
|
exports.TRPCUntypedClient = TRPCUntypedClient;
|
|
118
|
+
exports.untypedClientSymbol = untypedClientSymbol;
|
|
@@ -31,6 +31,7 @@ class TRPCUntypedClient {
|
|
|
31
31
|
try {
|
|
32
32
|
const req$ = this.$request(opts);
|
|
33
33
|
const envelope = await observableToPromise(req$);
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
34
35
|
const data = envelope.result.data;
|
|
35
36
|
return data;
|
|
36
37
|
} catch (err) {
|
|
@@ -109,5 +110,6 @@ class TRPCUntypedClient {
|
|
|
109
110
|
this.links = opts.links.map((link)=>link(this.runtime));
|
|
110
111
|
}
|
|
111
112
|
}
|
|
113
|
+
const untypedClientSymbol = Symbol('TRPCClient');
|
|
112
114
|
|
|
113
|
-
export { TRPCUntypedClient };
|
|
115
|
+
export { TRPCUntypedClient, untypedClientSymbol };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import';
|
|
2
2
|
import type { Operation, OperationLink, OperationResultObservable } from '../types';
|
|
3
3
|
/** @internal */
|
|
4
|
-
export declare function createChain<
|
|
5
|
-
links: OperationLink<
|
|
4
|
+
export declare function createChain<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown>(opts: {
|
|
5
|
+
links: OperationLink<TInferrable, TInput, TOutput>[];
|
|
6
6
|
op: Operation<TInput>;
|
|
7
|
-
}): OperationResultObservable<
|
|
7
|
+
}): OperationResultObservable<TInferrable, TOutput>;
|
|
8
8
|
//# sourceMappingURL=createChain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createChain.d.ts","sourceRoot":"","sources":["../../../src/links/internals/createChain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"createChain.d.ts","sourceRoot":"","sources":["../../../src/links/internals/createChain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB,gBAAgB;AAChB,wBAAgB,WAAW,CACzB,WAAW,SAAS,qBAAqB,EACzC,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,EACjB,IAAI,EAAE;IACN,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACrD,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CACvB,GAAG,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAuBlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-
|
|
3
|
+
"version": "11.0.0-alpha-tmp-issues-6374.696+c944cfbf2",
|
|
4
4
|
"description": "The tRPC client library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"!**/__tests__"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@trpc/server": "11.0.0-alpha-tmp-
|
|
81
|
-
"typescript": ">=5.
|
|
80
|
+
"@trpc/server": "11.0.0-alpha-tmp-issues-6374.696+c944cfbf2",
|
|
81
|
+
"typescript": ">=5.7.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@trpc/server": "11.0.0-alpha-tmp-
|
|
84
|
+
"@trpc/server": "11.0.0-alpha-tmp-issues-6374.696+c944cfbf2",
|
|
85
85
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
86
86
|
"@types/node": "^22.9.0",
|
|
87
87
|
"eslint": "^9.13.0",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"rollup": "^4.24.4",
|
|
91
91
|
"tslib": "^2.8.1",
|
|
92
92
|
"tsx": "^4.0.0",
|
|
93
|
-
"typescript": "^5.7.
|
|
93
|
+
"typescript": "^5.7.2",
|
|
94
94
|
"undici": "^7.0.0"
|
|
95
95
|
},
|
|
96
96
|
"publishConfig": {
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"funding": [
|
|
100
100
|
"https://trpc.io/sponsor"
|
|
101
101
|
],
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "c944cfbf28c0723b087dfd4b2d26c554457374f0"
|
|
103
103
|
}
|
package/src/createTRPCClient.ts
CHANGED
|
@@ -20,14 +20,30 @@ import type {
|
|
|
20
20
|
TRPCSubscriptionObserver,
|
|
21
21
|
UntypedClientProperties,
|
|
22
22
|
} from './internals/TRPCUntypedClient';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
TRPCUntypedClient,
|
|
25
|
+
untypedClientSymbol,
|
|
26
|
+
} from './internals/TRPCUntypedClient';
|
|
24
27
|
import type { TRPCClientError } from './TRPCClientError';
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* @public
|
|
31
|
+
*/
|
|
32
|
+
export type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<
|
|
33
|
+
TRouter,
|
|
34
|
+
TRouter['_def']['record']
|
|
35
|
+
> & {
|
|
36
|
+
[untypedClientSymbol]: TRPCUntypedClient<{
|
|
37
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
38
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
* @deprecated use {@link TRPCClient} instead
|
|
28
45
|
**/
|
|
29
|
-
export type inferRouterClient<TRouter extends AnyRouter> =
|
|
30
|
-
DecoratedProcedureRecord<TRouter, TRouter['_def']['record']>;
|
|
46
|
+
export type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
31
47
|
|
|
32
48
|
type ResolverDef = {
|
|
33
49
|
input: any;
|
|
@@ -119,9 +135,9 @@ export const clientCallTypeToProcedureType = (
|
|
|
119
135
|
* Creates a proxy client and shows type errors if you have query names that collide with built-in properties
|
|
120
136
|
*/
|
|
121
137
|
export type CreateTRPCClient<TRouter extends AnyRouter> =
|
|
122
|
-
|
|
138
|
+
TRPCClient<TRouter> extends infer $Value
|
|
123
139
|
? UntypedClientProperties & keyof $Value extends never
|
|
124
|
-
?
|
|
140
|
+
? TRPCClient<TRouter>
|
|
125
141
|
: IntersectionError<UntypedClientProperties & keyof $Value>
|
|
126
142
|
: never;
|
|
127
143
|
|
|
@@ -145,7 +161,7 @@ export function createTRPCClientProxy<TRouter extends AnyRouter>(
|
|
|
145
161
|
if (client.hasOwnProperty(key)) {
|
|
146
162
|
return (client as any)[key as any];
|
|
147
163
|
}
|
|
148
|
-
if (key ===
|
|
164
|
+
if (key === untypedClientSymbol) {
|
|
149
165
|
return client;
|
|
150
166
|
}
|
|
151
167
|
return proxy[key];
|
|
@@ -165,7 +181,13 @@ export function createTRPCClient<TRouter extends AnyRouter>(
|
|
|
165
181
|
* @internal
|
|
166
182
|
*/
|
|
167
183
|
export function getUntypedClient<TRouter extends AnyRouter>(
|
|
168
|
-
client:
|
|
169
|
-
): TRPCUntypedClient<
|
|
170
|
-
|
|
184
|
+
client: TRPCClient<TRouter> | TRPCUntypedClient<TRouter>,
|
|
185
|
+
): TRPCUntypedClient<{
|
|
186
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
187
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
188
|
+
}> {
|
|
189
|
+
if (client instanceof TRPCUntypedClient) {
|
|
190
|
+
return client;
|
|
191
|
+
}
|
|
192
|
+
return client[untypedClientSymbol];
|
|
171
193
|
}
|
|
@@ -55,12 +55,12 @@ export type UntypedClientProperties =
|
|
|
55
55
|
| 'runtime'
|
|
56
56
|
| 'subscription';
|
|
57
57
|
|
|
58
|
-
export class TRPCUntypedClient<
|
|
59
|
-
private readonly links: OperationLink<
|
|
58
|
+
export class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
|
59
|
+
private readonly links: OperationLink<TInferrable>[];
|
|
60
60
|
public readonly runtime: TRPCClientRuntime;
|
|
61
61
|
private requestId: number;
|
|
62
62
|
|
|
63
|
-
constructor(opts: CreateTRPCClientOptions<
|
|
63
|
+
constructor(opts: CreateTRPCClientOptions<TInferrable>) {
|
|
64
64
|
this.requestId = 0;
|
|
65
65
|
|
|
66
66
|
this.runtime = {};
|
|
@@ -76,8 +76,8 @@ export class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
|
76
76
|
context?: OperationContext;
|
|
77
77
|
signal: Maybe<AbortSignal>;
|
|
78
78
|
}) {
|
|
79
|
-
const chain$ = createChain<
|
|
80
|
-
links: this.links as OperationLink<
|
|
79
|
+
const chain$ = createChain<TInferrable, TInput, TOutput>({
|
|
80
|
+
links: this.links as OperationLink<TInferrable, TInput, TOutput>[],
|
|
81
81
|
op: {
|
|
82
82
|
...opts,
|
|
83
83
|
context: opts.context ?? {},
|
|
@@ -99,7 +99,8 @@ export class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
|
99
99
|
type TValue = inferObservableValue<typeof req$>;
|
|
100
100
|
|
|
101
101
|
const envelope = await observableToPromise<TValue>(req$);
|
|
102
|
-
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
+
const data = envelope.result.data!;
|
|
103
104
|
return data;
|
|
104
105
|
} catch (err) {
|
|
105
106
|
throw TRPCClientError.from(err as Error);
|
|
@@ -171,3 +172,5 @@ export class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
174
|
}
|
|
175
|
+
|
|
176
|
+
export const untypedClientSymbol = Symbol('TRPCClient');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
|
-
import type {
|
|
2
|
+
import type { InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type {
|
|
4
4
|
Operation,
|
|
5
5
|
OperationLink,
|
|
@@ -8,13 +8,13 @@ import type {
|
|
|
8
8
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
export function createChain<
|
|
11
|
-
|
|
11
|
+
TInferrable extends InferrableClientTypes,
|
|
12
12
|
TInput = unknown,
|
|
13
13
|
TOutput = unknown,
|
|
14
14
|
>(opts: {
|
|
15
|
-
links: OperationLink<
|
|
15
|
+
links: OperationLink<TInferrable, TInput, TOutput>[];
|
|
16
16
|
op: Operation<TInput>;
|
|
17
|
-
}): OperationResultObservable<
|
|
17
|
+
}): OperationResultObservable<TInferrable, TOutput> {
|
|
18
18
|
return observable((observer) => {
|
|
19
19
|
function execute(index = 0, op = opts.op) {
|
|
20
20
|
const next = opts.links[index];
|