@trpc/client 10.25.1 → 10.26.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.
@@ -1,4 +1,4 @@
1
- import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, IntersectionError, ProcedureArgs, ProcedureRouterRecord } from '@trpc/server';
1
+ import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, IntersectionError, ProcedureArgs, ProcedureRouterRecord, ProcedureType } from '@trpc/server';
2
2
  import type { Unsubscribable } from '@trpc/server/observable';
3
3
  import { inferTransformedProcedureOutput, inferTransformedSubscriptionOutput } from '@trpc/server/shared';
4
4
  import { TRPCClientError } from './TRPCClientError';
@@ -7,7 +7,8 @@ import { CreateTRPCClientOptions } from './createTRPCUntypedClient';
7
7
  import { TRPCSubscriptionObserver, UntypedClientProperties } from './internals/TRPCUntypedClient';
8
8
  /** @public */
9
9
  export declare type inferRouterProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']>;
10
- declare type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferTransformedProcedureOutput<TProcedure>>;
10
+ /** @internal */
11
+ export declare type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferTransformedProcedureOutput<TProcedure>>;
11
12
  declare type SubscriptionResolver<TProcedure extends AnyProcedure> = (...args: [
12
13
  input: ProcedureArgs<TProcedure['_def']>[0],
13
14
  opts: ProcedureArgs<TProcedure['_def']>[1] & Partial<TRPCSubscriptionObserver<inferTransformedSubscriptionOutput<TProcedure>, TRPCClientError<TProcedure>>>
@@ -25,6 +26,8 @@ declare type DecorateProcedure<TProcedure extends AnyProcedure> = TProcedure ext
25
26
  declare type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
26
27
  [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
27
28
  };
29
+ /** @internal */
30
+ export declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
28
31
  export declare type CreateTRPCProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']> extends infer TProcedureRecord ? UntypedClientProperties & keyof TProcedureRecord extends never ? TProcedureRecord : IntersectionError<UntypedClientProperties & keyof TProcedureRecord> : never;
29
32
  /**
30
33
  * @deprecated use `createTRPCProxyClient` instead
@@ -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,EAEtB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAGL,+BAA+B,EAC/B,kCAAkC,EACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,wBAAwB,EAExB,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,cAAc;AACd,oBAAY,sBAAsB,CAAC,OAAO,SAAS,SAAS,IAC1D,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEtD,aAAK,QAAQ,CAAC,UAAU,SAAS,YAAY,IAAI,CAC/C,GAAG,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAA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AQ,CAAC,CAC1B,SAAS,MAAM,gBAAgB,GAC5B,uBAAuB,GAAG,MAAM,gBAAgB,SAAS,KAAK,GAC5D,gBAAgB,GAChB,iBAAiB,CAAC,uBAAuB,GAAG,MAAM,gBAAgB,CAAC,GACrE,KAAK,CAAC;AAEZ;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,kCAe5B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,kCAKvC"}
package/dist/index.js CHANGED
@@ -135,6 +135,9 @@ const clientCallTypeMap = {
135
135
  mutate: 'mutation',
136
136
  subscribe: 'subscription'
137
137
  };
138
+ /** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
139
+ return clientCallTypeMap[clientCallType];
140
+ };
138
141
  /**
139
142
  * @deprecated use `createTRPCProxyClient` instead
140
143
  * @internal
@@ -148,8 +151,7 @@ const clientCallTypeMap = {
148
151
  key,
149
152
  ...path
150
153
  ];
151
- const clientCallType = pathCopy.pop();
152
- const procedureType = clientCallTypeMap[clientCallType];
154
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
153
155
  const fullPath = pathCopy.join('.');
154
156
  return client[procedureType](fullPath, ...args);
155
157
  });
@@ -196,6 +198,7 @@ exports.httpLinkFactory = links_httpLink.httpLinkFactory;
196
198
  exports.loggerLink = links_loggerLink.loggerLink;
197
199
  exports.createWSClient = links_wsLink.createWSClient;
198
200
  exports.wsLink = links_wsLink.wsLink;
201
+ exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
199
202
  exports.createTRPCClient = createTRPCClient;
200
203
  exports.createTRPCClientProxy = createTRPCClientProxy;
201
204
  exports.createTRPCProxyClient = createTRPCProxyClient;
package/dist/index.mjs CHANGED
@@ -135,6 +135,9 @@ const clientCallTypeMap = {
135
135
  mutate: 'mutation',
136
136
  subscribe: 'subscription'
137
137
  };
138
+ /** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
139
+ return clientCallTypeMap[clientCallType];
140
+ };
138
141
  /**
139
142
  * @deprecated use `createTRPCProxyClient` instead
140
143
  * @internal
@@ -148,8 +151,7 @@ const clientCallTypeMap = {
148
151
  key,
149
152
  ...path
150
153
  ];
151
- const clientCallType = pathCopy.pop();
152
- const procedureType = clientCallTypeMap[clientCallType];
154
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
153
155
  const fullPath = pathCopy.join('.');
154
156
  return client[procedureType](fullPath, ...args);
155
157
  });
@@ -187,4 +189,4 @@ const experimental_formDataLink = httpLinkFactory({
187
189
  requester: formDataRequester
188
190
  });
189
191
 
190
- export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink };
192
+ export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink };
@@ -1,3 +1,4 @@
1
+ /// <reference lib="dom.iterable" />
1
2
  import { AnyRouter } from '@trpc/server';
2
3
  import { TRPCClientError } from '..';
3
4
  import { Operation, OperationResultEnvelope, TRPCLink } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"loggerLink.d.ts","sourceRoot":"","sources":["../../src/links/loggerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvE,aAAK,YAAY,GAAG;IAClB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,aAAK,eAAe,CAAC,OAAO,SAAS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AC;CACxB;AA+DD,wBAAgB,UAAU,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAC9D,IAAI,GAAE,iBAAiB,CAAC,OAAO,CAAM,GACpC,QAAQ,CAAC,OAAO,CAAC,CA2CnB"}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
6
 
7
+ /// <reference lib="dom.iterable" />
7
8
  const palette = {
8
9
  query: [
9
10
  '72e3ff',
@@ -25,19 +26,12 @@ function isFormData(value) {
25
26
  }
26
27
  return value instanceof FormData;
27
28
  }
28
- function fromEntries(fd) {
29
- const result = {};
30
- for (const [key, value] of fd){
31
- result[key] = value;
32
- }
33
- return result;
34
- }
35
29
  // maybe this should be moved to it's own package
36
30
  const defaultLogger = (c = console)=>(props)=>{
37
31
  const { direction , type , path , context , id } = props;
38
32
  const [light, dark] = palette[type];
39
33
  const rawInput = props.input;
40
- const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
34
+ const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
41
35
  const css = `
42
36
  background-color: #${direction === 'up' ? light : dark};
43
37
  color: ${direction === 'up' ? 'black' : 'white'};
@@ -1,5 +1,6 @@
1
1
  import { observable, tap } from '@trpc/server/observable';
2
2
 
3
+ /// <reference lib="dom.iterable" />
3
4
  const palette = {
4
5
  query: [
5
6
  '72e3ff',
@@ -21,19 +22,12 @@ function isFormData(value) {
21
22
  }
22
23
  return value instanceof FormData;
23
24
  }
24
- function fromEntries(fd) {
25
- const result = {};
26
- for (const [key, value] of fd){
27
- result[key] = value;
28
- }
29
- return result;
30
- }
31
25
  // maybe this should be moved to it's own package
32
26
  const defaultLogger = (c = console)=>(props)=>{
33
27
  const { direction , type , path , context , id } = props;
34
28
  const [light, dark] = palette[type];
35
29
  const rawInput = props.input;
36
- const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
30
+ const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
37
31
  const css = `
38
32
  background-color: #${direction === 'up' ? light : dark};
39
33
  color: ${direction === 'up' ? 'black' : 'white'};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.25.1",
3
+ "version": "10.26.0",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -69,11 +69,11 @@
69
69
  "links"
70
70
  ],
71
71
  "peerDependencies": {
72
- "@trpc/server": "10.25.1"
72
+ "@trpc/server": "10.26.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@testing-library/dom": "^9.0.0",
76
- "@trpc/server": "10.25.1",
76
+ "@trpc/server": "10.26.0",
77
77
  "@types/isomorphic-fetch": "^0.0.36",
78
78
  "@types/node": "^18.7.20",
79
79
  "eslint": "^8.40.0",
@@ -88,5 +88,5 @@
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  },
91
- "gitHead": "712b2adfe369f19ebfdbed5e5637aef513d38aea"
91
+ "gitHead": "877c5b499676e21e7ebdf79eacde300ffc03325d"
92
92
  }
@@ -30,7 +30,8 @@ import {
30
30
  export type inferRouterProxyClient<TRouter extends AnyRouter> =
31
31
  DecoratedProcedureRecord<TRouter['_def']['record']>;
32
32
 
33
- type Resolver<TProcedure extends AnyProcedure> = (
33
+ /** @internal */
34
+ export type Resolver<TProcedure extends AnyProcedure> = (
34
35
  ...args: ProcedureArgs<TProcedure['_def']>
35
36
  ) => Promise<inferTransformedProcedureOutput<TProcedure>>;
36
37
 
@@ -79,6 +80,13 @@ const clientCallTypeMap: Record<keyof DecorateProcedure<any>, ProcedureType> = {
79
80
  subscribe: 'subscription',
80
81
  };
81
82
 
83
+ /** @internal */
84
+ export const clientCallTypeToProcedureType = (
85
+ clientCallType: string,
86
+ ): ProcedureType => {
87
+ return clientCallTypeMap[clientCallType as keyof typeof clientCallTypeMap];
88
+ };
89
+
82
90
  export type CreateTRPCProxyClient<TRouter extends AnyRouter> =
83
91
  DecoratedProcedureRecord<
84
92
  TRouter['_def']['record']
@@ -101,9 +109,7 @@ export function createTRPCClientProxy<TRouter extends AnyRouter>(
101
109
  }
102
110
  return createRecursiveProxy(({ path, args }) => {
103
111
  const pathCopy = [key, ...path];
104
- const clientCallType = pathCopy.pop()! as keyof DecorateProcedure<any>;
105
-
106
- const procedureType = clientCallTypeMap[clientCallType];
112
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop()!);
107
113
 
108
114
  const fullPath = pathCopy.join('.');
109
115
 
@@ -1,3 +1,10 @@
1
+ /// <reference lib="dom.iterable" />
2
+
3
+ // `dom.iterable` types are explicitly required for extracting `FormData` values,
4
+ // as all implementations of `Symbol.iterable` are separated from the main `dom` types.
5
+ // Using triple-slash directive makes sure that it will be available,
6
+ // even if end-user `tsconfig.json` omits it in the `lib` array.
7
+
1
8
  import { AnyRouter } from '@trpc/server';
2
9
  import { observable, tap } from '@trpc/server/observable';
3
10
  import { TRPCClientError } from '..';
@@ -64,14 +71,6 @@ function isFormData(value: unknown): value is FormData {
64
71
  return value instanceof FormData;
65
72
  }
66
73
 
67
- function fromEntries(fd: FormData) {
68
- const result: Record<string, unknown> = {};
69
- for (const [key, value] of fd) {
70
- result[key] = value;
71
- }
72
- return result;
73
- }
74
-
75
74
  // maybe this should be moved to it's own package
76
75
  const defaultLogger =
77
76
  <TRouter extends AnyRouter>(
@@ -83,7 +82,9 @@ const defaultLogger =
83
82
 
84
83
  const rawInput = props.input;
85
84
 
86
- const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
85
+ const input = isFormData(rawInput)
86
+ ? Object.fromEntries(rawInput)
87
+ : rawInput;
87
88
 
88
89
  const css = `
89
90
  background-color: #${direction === 'up' ? light : dark};