@trpc/client 10.24.0 → 10.25.1

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/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 ={} }) {
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 ={} }) {
@@ -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 +1 @@
1
- {"version":3,"file":"loggerLink.d.ts","sourceRoot":"","sources":["../../src/links/loggerLink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AAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEJ,aAAK,YAAY,CAAC,OAAO,SAAS,SAAS,IAAI,CAC7C,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAC/B,IAAI,CAAC;AAOV,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,SAAS;IAC1D,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAqED,wBAAgB,UAAU,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAC9D,IAAI,GAAE,iBAAiB,CAAC,OAAO,CAAM,GACpC,QAAQ,CAAC,OAAO,CAAC,CA2CnB"}
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var isObject = require('../isObject-617ad59e.js');
7
6
 
8
7
  const palette = {
9
8
  query: [
@@ -26,12 +25,19 @@ function isFormData(value) {
26
25
  }
27
26
  return value instanceof FormData;
28
27
  }
28
+ function fromEntries(fd) {
29
+ const result = {};
30
+ for (const [key, value] of fd){
31
+ result[key] = value;
32
+ }
33
+ return result;
34
+ }
29
35
  // maybe this should be moved to it's own package
30
36
  const defaultLogger = (c = console)=>(props)=>{
31
37
  const { direction , type , path , context , id } = props;
32
38
  const [light, dark] = palette[type];
33
39
  const rawInput = props.input;
34
- const input = isObject.isObject(rawInput) && isFormData(rawInput) ? Object.fromEntries(rawInput) : props.input;
40
+ const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
35
41
  const css = `
36
42
  background-color: #${direction === 'up' ? light : dark};
37
43
  color: ${direction === 'up' ? 'black' : 'white'};
@@ -1,5 +1,4 @@
1
1
  import { observable, tap } from '@trpc/server/observable';
2
- import { i as isObject } from '../isObject-3ec9fe00.mjs';
3
2
 
4
3
  const palette = {
5
4
  query: [
@@ -22,12 +21,19 @@ function isFormData(value) {
22
21
  }
23
22
  return value instanceof FormData;
24
23
  }
24
+ function fromEntries(fd) {
25
+ const result = {};
26
+ for (const [key, value] of fd){
27
+ result[key] = value;
28
+ }
29
+ return result;
30
+ }
25
31
  // maybe this should be moved to it's own package
26
32
  const defaultLogger = (c = console)=>(props)=>{
27
33
  const { direction , type , path , context , id } = props;
28
34
  const [light, dark] = palette[type];
29
35
  const rawInput = props.input;
30
- const input = isObject(rawInput) && isFormData(rawInput) ? Object.fromEntries(rawInput) : props.input;
36
+ const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
31
37
  const css = `
32
38
  background-color: #${direction === 'up' ? light : dark};
33
39
  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.24.0",
3
+ "version": "10.25.1",
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.24.0"
72
+ "@trpc/server": "10.25.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@testing-library/dom": "^9.0.0",
76
- "@trpc/server": "10.24.0",
76
+ "@trpc/server": "10.25.1",
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": "165ff9fe6d8c52cbdf413b1eac52d66a7c2205f0"
91
+ "gitHead": "712b2adfe369f19ebfdbed5e5637aef513d38aea"
92
92
  }
@@ -1,7 +1,6 @@
1
1
  import { AnyRouter } from '@trpc/server';
2
2
  import { observable, tap } from '@trpc/server/observable';
3
3
  import { TRPCClientError } from '..';
4
- import { isObject } from './internals/isObject';
5
4
  import { Operation, OperationResultEnvelope, TRPCLink } from './types';
6
5
 
7
6
  type ConsoleEsque = {
@@ -65,6 +64,14 @@ function isFormData(value: unknown): value is FormData {
65
64
  return value instanceof FormData;
66
65
  }
67
66
 
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
+
68
75
  // maybe this should be moved to it's own package
69
76
  const defaultLogger =
70
77
  <TRouter extends AnyRouter>(
@@ -76,10 +83,7 @@ const defaultLogger =
76
83
 
77
84
  const rawInput = props.input;
78
85
 
79
- const input =
80
- isObject(rawInput) && isFormData(rawInput)
81
- ? Object.fromEntries(rawInput)
82
- : props.input;
86
+ const input = isFormData(rawInput) ? fromEntries(rawInput) : rawInput;
83
87
 
84
88
  const css = `
85
89
  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;