@trpc/client 10.25.0 → 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
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var transformResult = require('./transformResult-12020457.js');
6
+ var transformResult = require('./transformResult-ee98835f.js');
7
7
  var links_splitLink = require('./splitLink-f29e84be.js');
8
8
  var shared = require('@trpc/server/shared');
9
9
  var httpUtils = require('./httpUtils-90a6bccb.js');
@@ -11,7 +11,6 @@ var links_httpBatchLink = require('./links/httpBatchLink.js');
11
11
  var links_httpLink = require('./links/httpLink.js');
12
12
  var links_loggerLink = require('./links/loggerLink.js');
13
13
  var links_wsLink = require('./links/wsLink.js');
14
- require('./isObject-617ad59e.js');
15
14
 
16
15
  class TRPCUntypedClient {
17
16
  $request({ type , input , path , context ={} }) {
@@ -136,6 +135,9 @@ const clientCallTypeMap = {
136
135
  mutate: 'mutation',
137
136
  subscribe: 'subscription'
138
137
  };
138
+ /** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
139
+ return clientCallTypeMap[clientCallType];
140
+ };
139
141
  /**
140
142
  * @deprecated use `createTRPCProxyClient` instead
141
143
  * @internal
@@ -149,8 +151,7 @@ const clientCallTypeMap = {
149
151
  key,
150
152
  ...path
151
153
  ];
152
- const clientCallType = pathCopy.pop();
153
- const procedureType = clientCallTypeMap[clientCallType];
154
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
154
155
  const fullPath = pathCopy.join('.');
155
156
  return client[procedureType](fullPath, ...args);
156
157
  });
@@ -197,6 +198,7 @@ exports.httpLinkFactory = links_httpLink.httpLinkFactory;
197
198
  exports.loggerLink = links_loggerLink.loggerLink;
198
199
  exports.createWSClient = links_wsLink.createWSClient;
199
200
  exports.wsLink = links_wsLink.wsLink;
201
+ exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
200
202
  exports.createTRPCClient = createTRPCClient;
201
203
  exports.createTRPCClientProxy = createTRPCClientProxy;
202
204
  exports.createTRPCProxyClient = createTRPCProxyClient;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { share, observableToPromise } from '@trpc/server/observable';
2
- import { T as TRPCClientError } from './transformResult-403dc1d4.mjs';
3
- export { T as TRPCClientError } from './transformResult-403dc1d4.mjs';
2
+ import { T as TRPCClientError } from './transformResult-a4d3dad0.mjs';
3
+ export { T as TRPCClientError } from './transformResult-a4d3dad0.mjs';
4
4
  import { c as createChain } from './splitLink-4c75f7be.mjs';
5
5
  export { s as splitLink } from './splitLink-4c75f7be.mjs';
6
6
  import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
@@ -11,7 +11,6 @@ import { httpLinkFactory } from './links/httpLink.mjs';
11
11
  export { httpLink, httpLinkFactory } from './links/httpLink.mjs';
12
12
  export { loggerLink } from './links/loggerLink.mjs';
13
13
  export { createWSClient, wsLink } from './links/wsLink.mjs';
14
- import './isObject-3ec9fe00.mjs';
15
14
 
16
15
  class TRPCUntypedClient {
17
16
  $request({ type , input , path , context ={} }) {
@@ -136,6 +135,9 @@ const clientCallTypeMap = {
136
135
  mutate: 'mutation',
137
136
  subscribe: 'subscription'
138
137
  };
138
+ /** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
139
+ return clientCallTypeMap[clientCallType];
140
+ };
139
141
  /**
140
142
  * @deprecated use `createTRPCProxyClient` instead
141
143
  * @internal
@@ -149,8 +151,7 @@ const clientCallTypeMap = {
149
151
  key,
150
152
  ...path
151
153
  ];
152
- const clientCallType = pathCopy.pop();
153
- const procedureType = clientCallTypeMap[clientCallType];
154
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
154
155
  const fullPath = pathCopy.join('.');
155
156
  return client[procedureType](fullPath, ...args);
156
157
  });
@@ -188,4 +189,4 @@ const experimental_formDataLink = httpLinkFactory({
188
189
  requester: formDataRequester
189
190
  });
190
191
 
191
- export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink };
192
+ export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink };
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var transformResult = require('../transformResult-12020457.js');
6
+ var transformResult = require('../transformResult-ee98835f.js');
7
7
  var httpUtils = require('../httpUtils-90a6bccb.js');
8
- require('../isObject-617ad59e.js');
9
8
 
10
9
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
11
10
  * A function that should never be called unless we messed something up.
@@ -1,7 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
- import { t as transformResult, T as TRPCClientError } from '../transformResult-403dc1d4.mjs';
2
+ import { t as transformResult, T as TRPCClientError } from '../transformResult-a4d3dad0.mjs';
3
3
  import { r as resolveHTTPLinkOptions, a as getUrl, j as jsonHttpRequester } from '../httpUtils-8a5c637a.mjs';
4
- import '../isObject-3ec9fe00.mjs';
5
4
 
6
5
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
7
6
  * A function that should never be called unless we messed something up.
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var transformResult = require('../transformResult-12020457.js');
6
+ var transformResult = require('../transformResult-ee98835f.js');
7
7
  var httpUtils = require('../httpUtils-90a6bccb.js');
8
- require('../isObject-617ad59e.js');
9
8
 
10
9
  function httpLinkFactory(factoryOpts) {
11
10
  return (opts)=>{
@@ -1,7 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
- import { t as transformResult, T as TRPCClientError } from '../transformResult-403dc1d4.mjs';
2
+ import { t as transformResult, T as TRPCClientError } from '../transformResult-a4d3dad0.mjs';
3
3
  import { r as resolveHTTPLinkOptions, j as jsonHttpRequester } from '../httpUtils-8a5c637a.mjs';
4
- import '../isObject-3ec9fe00.mjs';
5
4
 
6
5
  function httpLinkFactory(factoryOpts) {
7
6
  return (opts)=>{
@@ -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;AAErC,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,SAAS,IAC1C,CAAC,SAAS,GAAG;IACX,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC,GACF;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;CACrE,CAAC;AACN,aAAK,SAAS,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5
5
  var observable = require('@trpc/server/observable');
6
- var isObject = require('../isObject-617ad59e.js');
7
6
 
7
+ /// <reference lib="dom.iterable" />
8
8
  const palette = {
9
9
  query: [
10
10
  '72e3ff',
@@ -31,7 +31,7 @@ const defaultLogger = (c = console)=>(props)=>{
31
31
  const { direction , type , path , context , id } = props;
32
32
  const [light, dark] = palette[type];
33
33
  const rawInput = props.input;
34
- const input = isObject.isObject(rawInput) && isFormData(rawInput) ? Object.fromEntries(rawInput) : props.input;
34
+ const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
35
35
  const css = `
36
36
  background-color: #${direction === 'up' ? light : dark};
37
37
  color: ${direction === 'up' ? 'black' : 'white'};
@@ -1,6 +1,6 @@
1
1
  import { observable, tap } from '@trpc/server/observable';
2
- import { i as isObject } from '../isObject-3ec9fe00.mjs';
3
2
 
3
+ /// <reference lib="dom.iterable" />
4
4
  const palette = {
5
5
  query: [
6
6
  '72e3ff',
@@ -27,7 +27,7 @@ const defaultLogger = (c = console)=>(props)=>{
27
27
  const { direction , type , path , context , id } = props;
28
28
  const [light, dark] = palette[type];
29
29
  const rawInput = props.input;
30
- const input = isObject(rawInput) && isFormData(rawInput) ? Object.fromEntries(rawInput) : props.input;
30
+ const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
31
31
  const css = `
32
32
  background-color: #${direction === 'up' ? light : dark};
33
33
  color: ${direction === 'up' ? 'black' : 'white'};
@@ -3,13 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var transformResult = require('../transformResult-12020457.js');
7
- require('../isObject-617ad59e.js');
6
+ var transformResult = require('../transformResult-ee98835f.js');
8
7
 
9
8
  /* istanbul ignore next -- @preserve */ const retryDelay = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
10
9
 
11
10
  function createWSClient(opts) {
12
- const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = retryDelay , onOpen , onClose } = opts;
11
+ const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = retryDelay , onOpen , onClose , } = opts;
13
12
  /* istanbul ignore next -- @preserve */ if (!WebSocketImpl) {
14
13
  throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
15
14
  }
@@ -1,11 +1,10 @@
1
1
  import { observable } from '@trpc/server/observable';
2
- import { T as TRPCClientError, t as transformResult } from '../transformResult-403dc1d4.mjs';
3
- import '../isObject-3ec9fe00.mjs';
2
+ import { T as TRPCClientError, t as transformResult } from '../transformResult-a4d3dad0.mjs';
4
3
 
5
4
  /* istanbul ignore next -- @preserve */ const retryDelay = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
6
5
 
7
6
  function createWSClient(opts) {
8
- const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = retryDelay , onOpen , onClose } = opts;
7
+ const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = retryDelay , onOpen , onClose , } = opts;
9
8
  /* istanbul ignore next -- @preserve */ if (!WebSocketImpl) {
10
9
  throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
11
10
  }
@@ -1,5 +1,3 @@
1
- import { i as isObject } from './isObject-246cec0f.js';
2
-
3
1
  class TRPCClientError extends Error {
4
2
  constructor(message, opts) {
5
3
  const cause = opts?.cause;
@@ -32,6 +30,11 @@ class TRPCClientError extends Error {
32
30
  }
33
31
  }
34
32
 
33
+ function isObject(value) {
34
+ // check that value is object
35
+ return !!value && !Array.isArray(value) && typeof value === 'object';
36
+ }
37
+
35
38
  // FIXME:
36
39
  // - the generics here are probably unnecessary
37
40
  // - the RPC-spec could probably be simplified to combine HTTP + WS
@@ -1,5 +1,3 @@
1
- import { i as isObject } from './isObject-3ec9fe00.mjs';
2
-
3
1
  class TRPCClientError extends Error {
4
2
  static from(cause, opts = {}) {
5
3
  if (!(cause instanceof Error)) {
@@ -34,6 +32,11 @@ class TRPCClientError extends Error {
34
32
  }
35
33
  }
36
34
 
35
+ function isObject(value) {
36
+ // check that value is object
37
+ return !!value && !Array.isArray(value) && typeof value === 'object';
38
+ }
39
+
37
40
  // FIXME:
38
41
  // - the generics here are probably unnecessary
39
42
  // - the RPC-spec could probably be simplified to combine HTTP + WS
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var isObject = require('./isObject-617ad59e.js');
4
-
5
3
  class TRPCClientError extends Error {
6
4
  static from(cause, opts = {}) {
7
5
  if (!(cause instanceof Error)) {
@@ -36,6 +34,11 @@ class TRPCClientError extends Error {
36
34
  }
37
35
  }
38
36
 
37
+ function isObject(value) {
38
+ // check that value is object
39
+ return !!value && !Array.isArray(value) && typeof value === 'object';
40
+ }
41
+
39
42
  // FIXME:
40
43
  // - the generics here are probably unnecessary
41
44
  // - the RPC-spec could probably be simplified to combine HTTP + WS
@@ -74,10 +77,10 @@ class TRPCClientError extends Error {
74
77
  throw new TRPCClientError('Unable to transform response from server');
75
78
  }
76
79
  // check that output of the transformers is a valid TRPCResponse
77
- if (!result.ok && (!isObject.isObject(result.error.error) || typeof result.error.error.code !== 'number')) {
80
+ if (!result.ok && (!isObject(result.error.error) || typeof result.error.error.code !== 'number')) {
78
81
  throw new TRPCClientError('Badly formatted response from server');
79
82
  }
80
- if (result.ok && !isObject.isObject(result.result)) {
83
+ if (result.ok && !isObject(result.result)) {
81
84
  throw new TRPCClientError('Badly formatted response from server');
82
85
  }
83
86
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.25.0",
3
+ "version": "10.26.0",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -69,24 +69,24 @@
69
69
  "links"
70
70
  ],
71
71
  "peerDependencies": {
72
- "@trpc/server": "10.25.0"
72
+ "@trpc/server": "10.26.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@testing-library/dom": "^9.0.0",
76
- "@trpc/server": "10.25.0",
76
+ "@trpc/server": "10.26.0",
77
77
  "@types/isomorphic-fetch": "^0.0.36",
78
78
  "@types/node": "^18.7.20",
79
- "eslint": "^8.30.0",
79
+ "eslint": "^8.40.0",
80
80
  "expect-type": "^0.15.0",
81
81
  "isomorphic-fetch": "^3.0.0",
82
82
  "node-fetch": "^3.3.0",
83
83
  "rollup": "^2.79.1",
84
- "tsx": "^3.12.3",
84
+ "tsx": "^3.12.7",
85
85
  "undici": "^5.14.0",
86
86
  "vitest": "^0.28.5"
87
87
  },
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  },
91
- "gitHead": "58764a39f45299cd1b99af47d4a27ace46698555"
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,7 +1,13 @@
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 '..';
4
- import { isObject } from './internals/isObject';
5
11
  import { Operation, OperationResultEnvelope, TRPCLink } from './types';
6
12
 
7
13
  type ConsoleEsque = {
@@ -76,10 +82,9 @@ const defaultLogger =
76
82
 
77
83
  const rawInput = props.input;
78
84
 
79
- const input =
80
- isObject(rawInput) && isFormData(rawInput)
81
- ? Object.fromEntries(rawInput)
82
- : props.input;
85
+ const input = isFormData(rawInput)
86
+ ? Object.fromEntries(rawInput)
87
+ : rawInput;
83
88
 
84
89
  const css = `
85
90
  background-color: #${direction === 'up' ? light : dark};
@@ -1,6 +0,0 @@
1
- function isObject(value) {
2
- // check that value is object
3
- return !!value && !Array.isArray(value) && typeof value === 'object';
4
- }
5
-
6
- export { isObject as i };
@@ -1,6 +0,0 @@
1
- function isObject(value) {
2
- // check that value is object
3
- return !!value && !Array.isArray(value) && typeof value === 'object';
4
- }
5
-
6
- export { isObject as i };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- function isObject(value) {
4
- // check that value is object
5
- return !!value && !Array.isArray(value) && typeof value === 'object';
6
- }
7
-
8
- exports.isObject = isObject;