@trpc/client 11.0.0-rc.789 → 11.0.0-rc.795
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 +13 -13
- package/dist/createTRPCClient.d.ts +27 -15
- package/dist/createTRPCClient.d.ts.map +1 -1
- package/dist/createTRPCClient.js +3 -5
- package/dist/createTRPCClient.mjs +3 -5
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/internals/TRPCUntypedClient.d.ts +2 -4
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/links/wsLink/wsClient/wsConnection.d.ts +1 -1
- package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/createTRPCClient.ts +44 -41
- package/src/index.ts +0 -4
- package/src/internals/TRPCUntypedClient.ts +3 -14
- package/src/links/wsLink/wsClient/wsConnection.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 75585,
|
|
3
|
+
"bundleOrigSize": 94308,
|
|
4
|
+
"bundleReduction": 19.85,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink/wsClient/wsClient.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
{
|
|
45
45
|
"id": "/src/links/wsLink/wsClient/wsConnection.ts",
|
|
46
46
|
"size": 5861,
|
|
47
|
-
"origSize":
|
|
47
|
+
"origSize": 6205,
|
|
48
48
|
"renderedExports": [
|
|
49
49
|
"WsConnection",
|
|
50
50
|
"backwardCompatibility"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
55
55
|
],
|
|
56
56
|
"percent": 7.75,
|
|
57
|
-
"reduction": 5.
|
|
57
|
+
"reduction": 5.54
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"id": "/src/links/loggerLink.ts",
|
|
@@ -141,13 +141,13 @@
|
|
|
141
141
|
],
|
|
142
142
|
"removedExports": [],
|
|
143
143
|
"dependents": [],
|
|
144
|
-
"percent": 4.
|
|
144
|
+
"percent": 4.36,
|
|
145
145
|
"reduction": 12.56
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
149
149
|
"size": 3158,
|
|
150
|
-
"origSize":
|
|
150
|
+
"origSize": 4417,
|
|
151
151
|
"renderedExports": [
|
|
152
152
|
"TRPCUntypedClient"
|
|
153
153
|
],
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
"/src/createTRPCClient.ts"
|
|
158
158
|
],
|
|
159
159
|
"percent": 4.18,
|
|
160
|
-
"reduction":
|
|
160
|
+
"reduction": 28.5
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"id": "/src/TRPCClientError.ts",
|
|
@@ -230,8 +230,8 @@
|
|
|
230
230
|
},
|
|
231
231
|
{
|
|
232
232
|
"id": "/src/createTRPCClient.ts",
|
|
233
|
-
"size":
|
|
234
|
-
"origSize":
|
|
233
|
+
"size": 1170,
|
|
234
|
+
"origSize": 4737,
|
|
235
235
|
"renderedExports": [
|
|
236
236
|
"clientCallTypeToProcedureType",
|
|
237
237
|
"createTRPCClientProxy",
|
|
@@ -242,8 +242,8 @@
|
|
|
242
242
|
"dependents": [
|
|
243
243
|
"/src/index.ts"
|
|
244
244
|
],
|
|
245
|
-
"percent": 1.
|
|
246
|
-
"reduction":
|
|
245
|
+
"percent": 1.55,
|
|
246
|
+
"reduction": 75.3
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
249
|
"id": "/src/links/wsLink/wsLink.ts",
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
{
|
|
406
406
|
"id": "/src/index.ts",
|
|
407
407
|
"size": 0,
|
|
408
|
-
"origSize":
|
|
408
|
+
"origSize": 540,
|
|
409
409
|
"renderedExports": [],
|
|
410
410
|
"removedExports": [],
|
|
411
411
|
"dependents": [],
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import type { Unsubscribable } from '@trpc/server/observable';
|
|
2
|
-
import type { AnyProcedure, AnyRouter, inferClientTypes, inferProcedureInput,
|
|
2
|
+
import type { AnyProcedure, AnyRouter, inferClientTypes, inferProcedureInput, InferrableClientTypes, inferTransformedProcedureOutput, ProcedureType, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type { CreateTRPCClientOptions } from './createTRPCUntypedClient';
|
|
4
|
-
import type { TRPCSubscriptionObserver
|
|
4
|
+
import type { TRPCSubscriptionObserver } from './internals/TRPCUntypedClient';
|
|
5
5
|
import { TRPCUntypedClient } from './internals/TRPCUntypedClient';
|
|
6
6
|
import type { TRPCProcedureOptions } from './internals/types';
|
|
7
7
|
import type { TRPCClientError } from './TRPCClientError';
|
|
8
8
|
/**
|
|
9
9
|
* @public
|
|
10
|
+
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
|
10
11
|
**/
|
|
11
|
-
export type inferRouterClient<TRouter extends AnyRouter> =
|
|
12
|
+
export type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
|
16
|
+
**/
|
|
17
|
+
export type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
18
|
+
declare const untypedClientSymbol: unique symbol;
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
**/
|
|
22
|
+
export type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<{
|
|
23
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
24
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
25
|
+
}, TRouter['_def']['record']> & {
|
|
26
|
+
[untypedClientSymbol]: TRPCUntypedClient<TRouter>;
|
|
27
|
+
};
|
|
12
28
|
type ResolverDef = {
|
|
13
29
|
input: any;
|
|
14
30
|
output: any;
|
|
@@ -29,29 +45,25 @@ type DecorateProcedure<TType extends ProcedureType, TDef extends ResolverDef> =
|
|
|
29
45
|
/**
|
|
30
46
|
* @internal
|
|
31
47
|
*/
|
|
32
|
-
type DecoratedProcedureRecord<
|
|
48
|
+
type DecoratedProcedureRecord<TRoot extends InferrableClientTypes, TRecord extends RouterRecord> = {
|
|
33
49
|
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
|
34
50
|
input: inferProcedureInput<$Value>;
|
|
35
|
-
output: inferTransformedProcedureOutput<inferClientTypes<
|
|
36
|
-
errorShape: inferClientTypes<
|
|
37
|
-
transformer: inferClientTypes<
|
|
38
|
-
}> : $Value extends RouterRecord ? DecoratedProcedureRecord<
|
|
51
|
+
output: inferTransformedProcedureOutput<inferClientTypes<TRoot>, $Value>;
|
|
52
|
+
errorShape: inferClientTypes<TRoot>['errorShape'];
|
|
53
|
+
transformer: inferClientTypes<TRoot>['transformer'];
|
|
54
|
+
}> : $Value extends RouterRecord ? DecoratedProcedureRecord<TRoot, $Value> : never : never;
|
|
39
55
|
};
|
|
40
56
|
/** @internal */
|
|
41
57
|
export declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
|
|
42
|
-
/**
|
|
43
|
-
* Creates a proxy client and shows type errors if you have query names that collide with built-in properties
|
|
44
|
-
*/
|
|
45
|
-
export type CreateTRPCClient<TRouter extends AnyRouter> = inferRouterClient<TRouter> extends infer $Value ? UntypedClientProperties & keyof $Value extends never ? inferRouterClient<TRouter> : IntersectionError<UntypedClientProperties & keyof $Value> : never;
|
|
46
58
|
/**
|
|
47
59
|
* @internal
|
|
48
60
|
*/
|
|
49
|
-
export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>):
|
|
50
|
-
export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>):
|
|
61
|
+
export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): TRPCClient<TRouter>;
|
|
62
|
+
export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
|
|
51
63
|
/**
|
|
52
64
|
* Get an untyped client from a proxy client
|
|
53
65
|
* @internal
|
|
54
66
|
*/
|
|
55
|
-
export declare function getUntypedClient<TRouter extends AnyRouter>(client:
|
|
67
|
+
export declare function getUntypedClient<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): TRPCUntypedClient<TRouter>;
|
|
56
68
|
export {};
|
|
57
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,
|
|
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,qBAAqB,EACrB,+BAA+B,EAC/B,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAKlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+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C,CAAC;KACrD,CACF,GACD,MAAM,SAAS,YAAY,GACzB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,GACvC,KAAK,GACT,KAAK;CACV,CAAC;AAWF,gBAAgB;AAChB,eAAO,MAAM,6BAA6B,mBACxB,MAAM,KACrB,aAEF,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACjC,UAAU,CAAC,OAAO,CAAC,CAerB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,UAAU,CAAC,OAAO,CAAC,CAIrB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAC1B,iBAAiB,CAAC,OAAO,CAAC,CAE5B"}
|
package/dist/createTRPCClient.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
4
4
|
var TRPCUntypedClient = require('./internals/TRPCUntypedClient.js');
|
|
5
5
|
|
|
6
|
+
const untypedClientSymbol = Symbol.for('trpc_untypedClient');
|
|
6
7
|
const clientCallTypeMap = {
|
|
7
8
|
query: 'query',
|
|
8
9
|
mutate: 'mutation',
|
|
@@ -23,10 +24,7 @@ const clientCallTypeMap = {
|
|
|
23
24
|
return client[procedureType](fullPath, ...args);
|
|
24
25
|
});
|
|
25
26
|
return unstableCoreDoNotImport.createFlatProxy((key)=>{
|
|
26
|
-
if (
|
|
27
|
-
return client[key];
|
|
28
|
-
}
|
|
29
|
-
if (key === '__untypedClient') {
|
|
27
|
+
if (key === untypedClientSymbol) {
|
|
30
28
|
return client;
|
|
31
29
|
}
|
|
32
30
|
return proxy[key];
|
|
@@ -41,7 +39,7 @@ function createTRPCClient(opts) {
|
|
|
41
39
|
* Get an untyped client from a proxy client
|
|
42
40
|
* @internal
|
|
43
41
|
*/ function getUntypedClient(client) {
|
|
44
|
-
return client
|
|
42
|
+
return client[untypedClientSymbol];
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRecursiveProxy, createFlatProxy } from '@trpc/server/unstable-core-do-not-import';
|
|
2
2
|
import { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
|
|
3
3
|
|
|
4
|
+
const untypedClientSymbol = Symbol.for('trpc_untypedClient');
|
|
4
5
|
const clientCallTypeMap = {
|
|
5
6
|
query: 'query',
|
|
6
7
|
mutate: 'mutation',
|
|
@@ -21,10 +22,7 @@ const clientCallTypeMap = {
|
|
|
21
22
|
return client[procedureType](fullPath, ...args);
|
|
22
23
|
});
|
|
23
24
|
return createFlatProxy((key)=>{
|
|
24
|
-
if (
|
|
25
|
-
return client[key];
|
|
26
|
-
}
|
|
27
|
-
if (key === '__untypedClient') {
|
|
25
|
+
if (key === untypedClientSymbol) {
|
|
28
26
|
return client;
|
|
29
27
|
}
|
|
30
28
|
return proxy[key];
|
|
@@ -39,7 +37,7 @@ function createTRPCClient(opts) {
|
|
|
39
37
|
* Get an untyped client from a proxy client
|
|
40
38
|
* @internal
|
|
41
39
|
*/ function getUntypedClient(client) {
|
|
42
|
-
return client
|
|
40
|
+
return client[untypedClientSymbol];
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, getUntypedClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,6 @@ export {
|
|
|
8
8
|
* @deprecated - use `createTRPCClient` instead
|
|
9
9
|
*/
|
|
10
10
|
createTRPCClient as createTRPCProxyClient,
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated - use `CreateTRPCClient` instead
|
|
13
|
-
*/
|
|
14
|
-
type CreateTRPCClient as CreateTRPCProxyClient,
|
|
15
11
|
/**
|
|
16
12
|
* @deprecated - use `inferRouterClient` instead
|
|
17
13
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AAExB,OAAO;AACL;;GAEG;AACH,gBAAgB,IAAI,qBAAqB;AACzC;;GAEG;AACH,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AAExB,OAAO;AACL;;GAEG;AACH,gBAAgB,IAAI,qBAAqB;AACzC;;GAEG;AACH,KAAK,iBAAiB,IAAI,sBAAsB,GACjD,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -25,13 +25,11 @@ export type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {
|
|
|
25
25
|
links: TRPCLink<TRouter>[];
|
|
26
26
|
transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
export type UntypedClientProperties = '$request' | 'links' | 'mutation' | 'query' | 'requestAsPromise' | 'requestId' | 'runtime' | 'subscription';
|
|
30
|
-
export declare class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
28
|
+
export declare class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
|
31
29
|
private readonly links;
|
|
32
30
|
readonly runtime: TRPCClientRuntime;
|
|
33
31
|
private requestId;
|
|
34
|
-
constructor(opts: CreateTRPCClientOptions<
|
|
32
|
+
constructor(opts: CreateTRPCClientOptions<TInferrable>);
|
|
35
33
|
private $request;
|
|
36
34
|
private requestAsPromise;
|
|
37
35
|
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
@@ -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,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AC,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,CAAC,EAAE,SAAS,CAAC,qEAAqE,CAAC,CAAC;CAChG,CAAC;AAEF,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;IAkBvB,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UrlOptionsWithConnectionParams } from '
|
|
1
|
+
import type { UrlOptionsWithConnectionParams } from '../../internals/urlWithConnectionParams';
|
|
2
2
|
interface PingPongOptions {
|
|
3
3
|
/**
|
|
4
4
|
* The interval (in milliseconds) between "PING" messages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsConnection.d.ts","sourceRoot":"","sources":["../../../../src/links/wsLink/wsClient/wsConnection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsConnection.d.ts","sourceRoot":"","sources":["../../../../src/links/wsLink/wsClient/wsConnection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAoB9F,UAAU,eAAe;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAuDD,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,CAAC,EAAE,OAAO,SAAS,CAAC;IACrC,UAAU,EAAE,8BAA8B,CAAC;IAC3C,SAAS,EAAE,eAAe,GAAG;QAC3B,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED;;;GAGG;AACH,qBAAa,YAAY;IACvB,MAAM,CAAC,YAAY,SAAK;IACjB,EAAE,SAA+B;IAExC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;IAC5D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,SAAgB,YAAY,sEAA2C;gBAE3D,IAAI,EAAE,0BAA0B;IAY5C,IAAW,EAAE,qBAEZ;IAED,OAAO,KAAK,EAAE,QAEb;IAED;;OAEG;IACI,MAAM,IAAI,IAAI,IAAI;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAI1C;;OAEG;IACI,QAAQ,IAAI,IAAI,IAAI;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAQ5C;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW,CAA8B;IACpC,IAAI;IAgCjB;;;OAGG;IACU,KAAK;CAOnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,YAAY;;;;;;;;;;;;SA0B7D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.795+394b0f5cc",
|
|
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-rc.
|
|
80
|
+
"@trpc/server": "11.0.0-rc.795+394b0f5cc",
|
|
81
81
|
"typescript": ">=5.7.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@trpc/server": "11.0.0-rc.
|
|
84
|
+
"@trpc/server": "11.0.0-rc.795+394b0f5cc",
|
|
85
85
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
86
86
|
"@types/node": "^22.9.0",
|
|
87
87
|
"eslint": "^9.13.0",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"funding": [
|
|
100
100
|
"https://trpc.io/sponsor"
|
|
101
101
|
],
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "394b0f5cc328937156cc75a772b3280231d4a2e2"
|
|
103
103
|
}
|
package/src/createTRPCClient.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type {
|
|
|
5
5
|
AnyRouter,
|
|
6
6
|
inferClientTypes,
|
|
7
7
|
inferProcedureInput,
|
|
8
|
+
InferrableClientTypes,
|
|
8
9
|
inferTransformedProcedureOutput,
|
|
9
|
-
IntersectionError,
|
|
10
10
|
ProcedureType,
|
|
11
11
|
RouterRecord,
|
|
12
12
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
@@ -15,19 +15,37 @@ import {
|
|
|
15
15
|
createRecursiveProxy,
|
|
16
16
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
17
17
|
import type { CreateTRPCClientOptions } from './createTRPCUntypedClient';
|
|
18
|
-
import type {
|
|
19
|
-
TRPCSubscriptionObserver,
|
|
20
|
-
UntypedClientProperties,
|
|
21
|
-
} from './internals/TRPCUntypedClient';
|
|
18
|
+
import type { TRPCSubscriptionObserver } from './internals/TRPCUntypedClient';
|
|
22
19
|
import { TRPCUntypedClient } from './internals/TRPCUntypedClient';
|
|
23
20
|
import type { TRPCProcedureOptions } from './internals/types';
|
|
24
21
|
import type { TRPCClientError } from './TRPCClientError';
|
|
25
22
|
|
|
26
23
|
/**
|
|
27
24
|
* @public
|
|
25
|
+
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
|
26
|
+
**/
|
|
27
|
+
export type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
|
28
32
|
**/
|
|
29
|
-
export type
|
|
30
|
-
|
|
33
|
+
export type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
|
34
|
+
|
|
35
|
+
const untypedClientSymbol = Symbol.for('trpc_untypedClient');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
**/
|
|
40
|
+
export type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<
|
|
41
|
+
{
|
|
42
|
+
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
|
43
|
+
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
|
44
|
+
},
|
|
45
|
+
TRouter['_def']['record']
|
|
46
|
+
> & {
|
|
47
|
+
[untypedClientSymbol]: TRPCUntypedClient<TRouter>;
|
|
48
|
+
};
|
|
31
49
|
|
|
32
50
|
type ResolverDef = {
|
|
33
51
|
input: any;
|
|
@@ -76,7 +94,7 @@ type DecorateProcedure<
|
|
|
76
94
|
* @internal
|
|
77
95
|
*/
|
|
78
96
|
type DecoratedProcedureRecord<
|
|
79
|
-
|
|
97
|
+
TRoot extends InferrableClientTypes,
|
|
80
98
|
TRecord extends RouterRecord,
|
|
81
99
|
> = {
|
|
82
100
|
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
@@ -86,15 +104,15 @@ type DecoratedProcedureRecord<
|
|
|
86
104
|
{
|
|
87
105
|
input: inferProcedureInput<$Value>;
|
|
88
106
|
output: inferTransformedProcedureOutput<
|
|
89
|
-
inferClientTypes<
|
|
107
|
+
inferClientTypes<TRoot>,
|
|
90
108
|
$Value
|
|
91
109
|
>;
|
|
92
|
-
errorShape: inferClientTypes<
|
|
93
|
-
transformer: inferClientTypes<
|
|
110
|
+
errorShape: inferClientTypes<TRoot>['errorShape'];
|
|
111
|
+
transformer: inferClientTypes<TRoot>['transformer'];
|
|
94
112
|
}
|
|
95
113
|
>
|
|
96
114
|
: $Value extends RouterRecord
|
|
97
|
-
? DecoratedProcedureRecord<
|
|
115
|
+
? DecoratedProcedureRecord<TRoot, $Value>
|
|
98
116
|
: never
|
|
99
117
|
: never;
|
|
100
118
|
};
|
|
@@ -115,37 +133,22 @@ export const clientCallTypeToProcedureType = (
|
|
|
115
133
|
return clientCallTypeMap[clientCallType as keyof typeof clientCallTypeMap];
|
|
116
134
|
};
|
|
117
135
|
|
|
118
|
-
/**
|
|
119
|
-
* Creates a proxy client and shows type errors if you have query names that collide with built-in properties
|
|
120
|
-
*/
|
|
121
|
-
export type CreateTRPCClient<TRouter extends AnyRouter> =
|
|
122
|
-
inferRouterClient<TRouter> extends infer $Value
|
|
123
|
-
? UntypedClientProperties & keyof $Value extends never
|
|
124
|
-
? inferRouterClient<TRouter>
|
|
125
|
-
: IntersectionError<UntypedClientProperties & keyof $Value>
|
|
126
|
-
: never;
|
|
127
|
-
|
|
128
136
|
/**
|
|
129
137
|
* @internal
|
|
130
138
|
*/
|
|
131
139
|
export function createTRPCClientProxy<TRouter extends AnyRouter>(
|
|
132
140
|
client: TRPCUntypedClient<TRouter>,
|
|
133
|
-
):
|
|
134
|
-
const proxy = createRecursiveProxy<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return createFlatProxy<CreateTRPCClient<TRouter>>((key) => {
|
|
145
|
-
if (client.hasOwnProperty(key)) {
|
|
146
|
-
return (client as any)[key as any];
|
|
147
|
-
}
|
|
148
|
-
if (key === '__untypedClient') {
|
|
141
|
+
): TRPCClient<TRouter> {
|
|
142
|
+
const proxy = createRecursiveProxy<TRPCClient<TRouter>>(({ path, args }) => {
|
|
143
|
+
const pathCopy = [...path];
|
|
144
|
+
const procedureType = clientCallTypeToProcedureType(pathCopy.pop()!);
|
|
145
|
+
|
|
146
|
+
const fullPath = pathCopy.join('.');
|
|
147
|
+
|
|
148
|
+
return (client[procedureType] as any)(fullPath, ...(args as any));
|
|
149
|
+
});
|
|
150
|
+
return createFlatProxy<TRPCClient<TRouter>>((key) => {
|
|
151
|
+
if (key === untypedClientSymbol) {
|
|
149
152
|
return client;
|
|
150
153
|
}
|
|
151
154
|
return proxy[key];
|
|
@@ -154,7 +157,7 @@ export function createTRPCClientProxy<TRouter extends AnyRouter>(
|
|
|
154
157
|
|
|
155
158
|
export function createTRPCClient<TRouter extends AnyRouter>(
|
|
156
159
|
opts: CreateTRPCClientOptions<TRouter>,
|
|
157
|
-
):
|
|
160
|
+
): TRPCClient<TRouter> {
|
|
158
161
|
const client = new TRPCUntypedClient(opts);
|
|
159
162
|
const proxy = createTRPCClientProxy<TRouter>(client);
|
|
160
163
|
return proxy;
|
|
@@ -165,7 +168,7 @@ export function createTRPCClient<TRouter extends AnyRouter>(
|
|
|
165
168
|
* @internal
|
|
166
169
|
*/
|
|
167
170
|
export function getUntypedClient<TRouter extends AnyRouter>(
|
|
168
|
-
client:
|
|
171
|
+
client: TRPCClient<TRouter>,
|
|
169
172
|
): TRPCUntypedClient<TRouter> {
|
|
170
|
-
return
|
|
173
|
+
return client[untypedClientSymbol];
|
|
171
174
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,10 +11,6 @@ export {
|
|
|
11
11
|
* @deprecated - use `createTRPCClient` instead
|
|
12
12
|
*/
|
|
13
13
|
createTRPCClient as createTRPCProxyClient,
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated - use `CreateTRPCClient` instead
|
|
16
|
-
*/
|
|
17
|
-
type CreateTRPCClient as CreateTRPCProxyClient,
|
|
18
14
|
/**
|
|
19
15
|
* @deprecated - use `inferRouterClient` instead
|
|
20
16
|
*/
|
|
@@ -44,23 +44,12 @@ export type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {
|
|
|
44
44
|
transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
| '$request'
|
|
50
|
-
| 'links'
|
|
51
|
-
| 'mutation'
|
|
52
|
-
| 'query'
|
|
53
|
-
| 'requestAsPromise'
|
|
54
|
-
| 'requestId'
|
|
55
|
-
| 'runtime'
|
|
56
|
-
| 'subscription';
|
|
57
|
-
|
|
58
|
-
export class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
59
|
-
private readonly links: OperationLink<AnyRouter>[];
|
|
47
|
+
export class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
|
48
|
+
private readonly links: OperationLink<TInferrable>[];
|
|
60
49
|
public readonly runtime: TRPCClientRuntime;
|
|
61
50
|
private requestId: number;
|
|
62
51
|
|
|
63
|
-
constructor(opts: CreateTRPCClientOptions<
|
|
52
|
+
constructor(opts: CreateTRPCClientOptions<TInferrable>) {
|
|
64
53
|
this.requestId = 0;
|
|
65
54
|
|
|
66
55
|
this.runtime = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UrlOptionsWithConnectionParams } from '@trpc/client/links/internals/urlWithConnectionParams';
|
|
2
1
|
import { behaviorSubject } from '@trpc/server/observable';
|
|
2
|
+
import type { UrlOptionsWithConnectionParams } from '../../internals/urlWithConnectionParams';
|
|
3
3
|
import { prepareUrl, withResolvers } from './utils';
|
|
4
4
|
|
|
5
5
|
/**
|