@trpc/client 10.30.0 → 10.31.0

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.
@@ -3,10 +3,12 @@ import type { Unsubscribable } from '@trpc/server/observable';
3
3
  import { inferTransformedProcedureOutput, inferTransformedSubscriptionOutput } from '@trpc/server/shared';
4
4
  import { TRPCClient } from './createTRPCClient';
5
5
  import { CreateTRPCClientOptions } from './createTRPCUntypedClient';
6
- import { TRPCSubscriptionObserver, UntypedClientProperties } from './internals/TRPCUntypedClient';
6
+ import { TRPCSubscriptionObserver, TRPCUntypedClient, UntypedClientProperties } from './internals/TRPCUntypedClient';
7
7
  import { TRPCClientError } from './TRPCClientError';
8
- /** @public */
9
- export type inferRouterProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']>;
8
+ /**
9
+ * @public
10
+ **/
11
+ export type inferRouterProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter, TRouter['_def']['record']>;
10
12
  /** @internal */
11
13
  export type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferTransformedProcedureOutput<TProcedure>>;
12
14
  type SubscriptionResolver<TProcedure extends AnyProcedure> = (...args: [
@@ -23,17 +25,25 @@ type DecorateProcedure<TProcedure extends AnyProcedure> = TProcedure extends Any
23
25
  /**
24
26
  * @internal
25
27
  */
26
- type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
27
- [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
28
+ type DecoratedProcedureRecord<TRouter extends AnyRouter, TProcedures extends ProcedureRouterRecord> = {
29
+ [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TRouter, TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
28
30
  };
29
31
  /** @internal */
30
32
  export declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
31
- export type CreateTRPCProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']> extends infer TProcedureRecord ? UntypedClientProperties & keyof TProcedureRecord extends never ? TProcedureRecord : IntersectionError<UntypedClientProperties & keyof TProcedureRecord> : never;
33
+ /**
34
+ * Creates a proxy client and shows type errors if you have query names that collide with built-in properties
35
+ */
36
+ export type CreateTRPCProxyClient<TRouter extends AnyRouter> = inferRouterProxyClient<TRouter> extends infer $ProcedureRecord ? UntypedClientProperties & keyof $ProcedureRecord extends never ? inferRouterProxyClient<TRouter> : IntersectionError<UntypedClientProperties & keyof $ProcedureRecord> : never;
32
37
  /**
33
38
  * @deprecated use `createTRPCProxyClient` instead
34
39
  * @internal
35
40
  */
36
41
  export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): CreateTRPCProxyClient<TRouter>;
37
42
  export declare function createTRPCProxyClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
43
+ /**
44
+ * Get an untyped client from a proxy client
45
+ * @internal
46
+ */
47
+ export declare function getUntypedClient<TRouter extends AnyRouter>(client: inferRouterProxyClient<TRouter>): TRPCUntypedClient<TRouter>;
38
48
  export {};
39
49
  //# sourceMappingURL=createTRPCClientProxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTRPCClientProxy.d.ts","sourceRoot":"","sources":["../src/createTRPCClientProxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,C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AM,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACtC,iBAAiB,CAAC,OAAO,CAAC,CAE5B"}
@@ -1,5 +1,5 @@
1
1
  import { AnyRouter } from '@trpc/server';
2
2
  import { CreateTRPCClientOptions, TRPCUntypedClient } from './internals/TRPCUntypedClient';
3
- export declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<AnyRouter>;
3
+ export declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<TRouter>;
4
4
  export type { CreateTRPCClientOptions, TRPCRequestOptions, TRPCUntypedClient, } from './internals/TRPCUntypedClient';
5
5
  //# sourceMappingURL=createTRPCUntypedClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTRPCUntypedClient.d.ts","sourceRoot":"","sources":["../src/createTRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,gCAIvC;AAED,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"createTRPCUntypedClient.d.ts","sourceRoot":"","sources":["../src/createTRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,iBAAiB,CAAC,OAAO,CAAC,CAE5B;AAED,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -119,8 +119,7 @@ class TRPCUntypedClient {
119
119
  }
120
120
 
121
121
  function createTRPCUntypedClient(opts) {
122
- const client = new TRPCUntypedClient(opts);
123
- return client;
122
+ return new TRPCUntypedClient(opts);
124
123
  }
125
124
 
126
125
  /**
@@ -146,6 +145,9 @@ const clientCallTypeMap = {
146
145
  if (client.hasOwnProperty(key)) {
147
146
  return client[key];
148
147
  }
148
+ if (key === '__untypedClient') {
149
+ return client;
150
+ }
149
151
  return shared.createRecursiveProxy(({ path , args })=>{
150
152
  const pathCopy = [
151
153
  key,
@@ -162,6 +164,12 @@ function createTRPCProxyClient(opts) {
162
164
  const proxy = createTRPCClientProxy(client);
163
165
  return proxy;
164
166
  }
167
+ /**
168
+ * Get an untyped client from a proxy client
169
+ * @internal
170
+ */ function getUntypedClient(client) {
171
+ return client.__untypedClient;
172
+ }
165
173
 
166
174
  function getTextDecoder(customTextDecoder) {
167
175
  if (customTextDecoder) {
@@ -363,4 +371,5 @@ exports.createTRPCClientProxy = createTRPCClientProxy;
363
371
  exports.createTRPCProxyClient = createTRPCProxyClient;
364
372
  exports.createTRPCUntypedClient = createTRPCUntypedClient;
365
373
  exports.experimental_formDataLink = experimental_formDataLink;
374
+ exports.getUntypedClient = getUntypedClient;
366
375
  exports.unstable_httpBatchStreamLink = unstable_httpBatchStreamLink;
package/dist/index.mjs CHANGED
@@ -120,8 +120,7 @@ class TRPCUntypedClient {
120
120
  }
121
121
 
122
122
  function createTRPCUntypedClient(opts) {
123
- const client = new TRPCUntypedClient(opts);
124
- return client;
123
+ return new TRPCUntypedClient(opts);
125
124
  }
126
125
 
127
126
  /**
@@ -147,6 +146,9 @@ const clientCallTypeMap = {
147
146
  if (client.hasOwnProperty(key)) {
148
147
  return client[key];
149
148
  }
149
+ if (key === '__untypedClient') {
150
+ return client;
151
+ }
150
152
  return createRecursiveProxy(({ path , args })=>{
151
153
  const pathCopy = [
152
154
  key,
@@ -163,6 +165,12 @@ function createTRPCProxyClient(opts) {
163
165
  const proxy = createTRPCClientProxy(client);
164
166
  return proxy;
165
167
  }
168
+ /**
169
+ * Get an untyped client from a proxy client
170
+ * @internal
171
+ */ function getUntypedClient(client) {
172
+ return client.__untypedClient;
173
+ }
166
174
 
167
175
  function getTextDecoder(customTextDecoder) {
168
176
  if (customTextDecoder) {
@@ -349,4 +357,4 @@ const experimental_formDataLink = httpLinkFactory({
349
357
  requester: formDataRequester
350
358
  });
351
359
 
352
- export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink, unstable_httpBatchStreamLink };
360
+ export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink, getUntypedClient, unstable_httpBatchStreamLink };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.30.0",
3
+ "version": "10.31.0",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -76,11 +76,11 @@
76
76
  "!**/*.test.*"
77
77
  ],
78
78
  "peerDependencies": {
79
- "@trpc/server": "10.30.0"
79
+ "@trpc/server": "10.31.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@testing-library/dom": "^9.0.0",
83
- "@trpc/server": "10.30.0",
83
+ "@trpc/server": "10.31.0",
84
84
  "@types/isomorphic-fetch": "^0.0.36",
85
85
  "@types/node": "^18.16.16",
86
86
  "eslint": "^8.40.0",
@@ -98,5 +98,5 @@
98
98
  "funding": [
99
99
  "https://trpc.io/sponsor"
100
100
  ],
101
- "gitHead": "a841051a4deb9428acee54e98798e8c2402a0a35"
101
+ "gitHead": "9cdac1b53f02cceefe2fb9b01e20599b6faced60"
102
102
  }
@@ -26,9 +26,11 @@ import {
26
26
  } from './internals/TRPCUntypedClient';
27
27
  import { TRPCClientError } from './TRPCClientError';
28
28
 
29
- /** @public */
29
+ /**
30
+ * @public
31
+ **/
30
32
  export type inferRouterProxyClient<TRouter extends AnyRouter> =
31
- DecoratedProcedureRecord<TRouter['_def']['record']>;
33
+ DecoratedProcedureRecord<TRouter, TRouter['_def']['record']>;
32
34
 
33
35
  /** @internal */
34
36
  export type Resolver<TProcedure extends AnyProcedure> = (
@@ -66,9 +68,12 @@ type DecorateProcedure<TProcedure extends AnyProcedure> =
66
68
  /**
67
69
  * @internal
68
70
  */
69
- type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
71
+ type DecoratedProcedureRecord<
72
+ TRouter extends AnyRouter,
73
+ TProcedures extends ProcedureRouterRecord,
74
+ > = {
70
75
  [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
71
- ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']>
76
+ ? DecoratedProcedureRecord<TRouter, TProcedures[TKey]['_def']['record']>
72
77
  : TProcedures[TKey] extends AnyProcedure
73
78
  ? DecorateProcedure<TProcedures[TKey]>
74
79
  : never;
@@ -87,13 +92,14 @@ export const clientCallTypeToProcedureType = (
87
92
  return clientCallTypeMap[clientCallType as keyof typeof clientCallTypeMap];
88
93
  };
89
94
 
95
+ /**
96
+ * Creates a proxy client and shows type errors if you have query names that collide with built-in properties
97
+ */
90
98
  export type CreateTRPCProxyClient<TRouter extends AnyRouter> =
91
- DecoratedProcedureRecord<
92
- TRouter['_def']['record']
93
- > extends infer TProcedureRecord
94
- ? UntypedClientProperties & keyof TProcedureRecord extends never
95
- ? TProcedureRecord
96
- : IntersectionError<UntypedClientProperties & keyof TProcedureRecord>
99
+ inferRouterProxyClient<TRouter> extends infer $ProcedureRecord
100
+ ? UntypedClientProperties & keyof $ProcedureRecord extends never
101
+ ? inferRouterProxyClient<TRouter>
102
+ : IntersectionError<UntypedClientProperties & keyof $ProcedureRecord>
97
103
  : never;
98
104
 
99
105
  /**
@@ -102,11 +108,14 @@ export type CreateTRPCProxyClient<TRouter extends AnyRouter> =
102
108
  */
103
109
  export function createTRPCClientProxy<TRouter extends AnyRouter>(
104
110
  client: TRPCClient<TRouter>,
105
- ) {
111
+ ): CreateTRPCProxyClient<TRouter> {
106
112
  return createFlatProxy<CreateTRPCProxyClient<TRouter>>((key) => {
107
113
  if (client.hasOwnProperty(key)) {
108
114
  return (client as any)[key as any];
109
115
  }
116
+ if (key === '__untypedClient') {
117
+ return client;
118
+ }
110
119
  return createRecursiveProxy(({ path, args }) => {
111
120
  const pathCopy = [key, ...path];
112
121
  const procedureType = clientCallTypeToProcedureType(pathCopy.pop()!);
@@ -120,8 +129,18 @@ export function createTRPCClientProxy<TRouter extends AnyRouter>(
120
129
 
121
130
  export function createTRPCProxyClient<TRouter extends AnyRouter>(
122
131
  opts: CreateTRPCClientOptions<TRouter>,
123
- ) {
132
+ ): CreateTRPCProxyClient<TRouter> {
124
133
  const client = new TRPCUntypedClient(opts);
125
134
  const proxy = createTRPCClientProxy(client as TRPCClient<TRouter>);
126
135
  return proxy;
127
136
  }
137
+
138
+ /**
139
+ * Get an untyped client from a proxy client
140
+ * @internal
141
+ */
142
+ export function getUntypedClient<TRouter extends AnyRouter>(
143
+ client: inferRouterProxyClient<TRouter>,
144
+ ): TRPCUntypedClient<TRouter> {
145
+ return (client as any).__untypedClient;
146
+ }
@@ -6,9 +6,8 @@ import {
6
6
 
7
7
  export function createTRPCUntypedClient<TRouter extends AnyRouter>(
8
8
  opts: CreateTRPCClientOptions<TRouter>,
9
- ) {
10
- const client = new TRPCUntypedClient(opts);
11
- return client;
9
+ ): TRPCUntypedClient<TRouter> {
10
+ return new TRPCUntypedClient(opts);
12
11
  }
13
12
 
14
13
  export type {