@trpc/client 10.1.0 → 10.3.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,13 +1,14 @@
1
- import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, ProcedureArgs, ProcedureRouterRecord, inferProcedureOutput } from '@trpc/server';
2
- import type { Unsubscribable, inferObservableValue } from '@trpc/server/observable';
1
+ import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, ProcedureArgs, ProcedureRouterRecord } from '@trpc/server';
2
+ import type { Unsubscribable } from '@trpc/server/observable';
3
+ import { inferTransformedProcedureOutput, inferTransformedSubscriptionOutput } from '@trpc/server/shared';
3
4
  import { TRPCClientError } from './TRPCClientError';
4
5
  import { CreateTRPCClientOptions } from './createTRPCClient';
5
6
  import { TRPCClient, TRPCSubscriptionObserver } from './internals/TRPCClient';
6
7
  export declare type inferRouterProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record'], TRouter>;
7
- declare type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferProcedureOutput<TProcedure>>;
8
+ declare type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferTransformedProcedureOutput<TProcedure>>;
8
9
  declare type SubscriptionResolver<TProcedure extends AnyProcedure, TRouter extends AnyRouter> = (...args: [
9
10
  input: ProcedureArgs<TProcedure['_def']>[0],
10
- opts: ProcedureArgs<TProcedure['_def']>[1] & Partial<TRPCSubscriptionObserver<inferObservableValue<inferProcedureOutput<TProcedure>>, TRPCClientError<TRouter>>>
11
+ opts: ProcedureArgs<TProcedure['_def']>[1] & Partial<TRPCSubscriptionObserver<inferTransformedSubscriptionOutput<TProcedure>, TRPCClientError<TRouter>>>
11
12
  ]) => Unsubscribable;
12
13
  declare type DecorateProcedure<TProcedure extends AnyProcedure, TRouter extends AnyRouter> = TProcedure extends AnyQueryProcedure ? {
13
14
  query: Resolver<TProcedure>;
@@ -1 +1 @@
1
- {"version":3,"file":"createTRPCClientProxy.d.ts","sourceRoot":"","sources":["../src/createTRPCClientProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EAErB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,oBAAY,sBAAsB,CAAC,OAAO,SAAS,SAAS,IAC1D,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AAE/D,aAAK,QAAQ,CAAC,UAAU,SAAS,YAAY,IAAI,CAC/C,GAAG,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KACvC,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;AAE/C,aAAK,oBAAoB,CACvB,UAAU,SAAS,YAAY,EAC/B,OAAO,SAAS,SAAS,IACvB,CACF,GAAG,IAAI,EAAE;IACP,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GACxC,OAAO,CACL,wBAAwB,CACtB,oBAAoB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,EACtD,eAAe,CAAC,OAAO,CA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;CAC7B,GACD,UAAU,SAAS,oBAAoB,GACvC;IACE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAC9B,GACD,UAAU,SAAS,wBAAwB,GAC3C;IACE,SAAS,EAAE,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;CACtD,GACD,KAAK,CAAC;AAEV;;GAEG;AACH,aAAK,wBAAwB,CAC3B,WAAW,SAAS,qBAAqB,EACzC,OAAO,SAAS,SAAS,IACvB;KACD,IAAI,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,SAAS,GAC5D,wBAAwB,CACtB,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACnC,WAAW,CAAC,IAAI,CAAC,CAClB,GACD,WAAW,CAAC,IAAI,CAAC,SAAS,YAAY,GACtC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAC7C,KAAK;CACV,CAAC;AAWF,oBAAY,qBAAqB,CAAC,OAAO,SAAS,SAAS,IACzD,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAElC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,gEAoB5B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,gEAKvC"}
@@ -79,7 +79,7 @@ function httpRequest(opts) {
79
79
  const body = getBody(opts);
80
80
  const meta = {};
81
81
  Promise.resolve(opts.headers()).then((headers)=>{
82
- if (type === 'subscription') {
82
+ /* istanbul ignore if */ if (type === 'subscription') {
83
83
  throw new Error('Subscriptions should use wsLink');
84
84
  }
85
85
  return opts.fetch(url, {
@@ -77,7 +77,7 @@ function httpRequest(opts) {
77
77
  const body = getBody(opts);
78
78
  const meta = {};
79
79
  Promise.resolve(opts.headers()).then((headers)=>{
80
- if (type === 'subscription') {
80
+ /* istanbul ignore if */ if (type === 'subscription') {
81
81
  throw new Error('Subscriptions should use wsLink');
82
82
  }
83
83
  return opts.fetch(url, {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var transformResult = require('./transformResult-000baed1.js');
7
7
  var links_splitLink = require('./splitLink-f29e84be.js');
8
8
  var links_httpBatchLink = require('./links/httpBatchLink.js');
9
9
  var shared = require('@trpc/server/shared');
10
- var httpUtils = require('./httpUtils-47077ecd.js');
10
+ var httpUtils = require('./httpUtils-277fd63a.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');
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ export { s as splitLink } from './splitLink-4c75f7be.mjs';
6
6
  import { httpBatchLink } from './links/httpBatchLink.mjs';
7
7
  export { httpBatchLink } from './links/httpBatchLink.mjs';
8
8
  import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
9
- export { g as getFetch } from './httpUtils-01e0c677.mjs';
9
+ export { g as getFetch } from './httpUtils-939364d7.mjs';
10
10
  export { httpLink } from './links/httpLink.mjs';
11
11
  export { loggerLink } from './links/loggerLink.mjs';
12
12
  export { createWSClient, wsLink } from './links/wsLink.mjs';
@@ -1,5 +1,6 @@
1
- import { AnyRouter, ClientDataTransformerOptions, inferProcedureInput, inferProcedureOutput, inferSubscriptionOutput } from '@trpc/server';
1
+ import { AnyRouter, ClientDataTransformerOptions, inferProcedureInput, inferSubscriptionOutput } from '@trpc/server';
2
2
  import { Unsubscribable } from '@trpc/server/observable';
3
+ import { inferTransformedProcedureOutput } from '@trpc/server/shared';
3
4
  import { TRPCClientError } from '../TRPCClientError';
4
5
  import { OperationContext, TRPCClientRuntime, TRPCLink } from '../links/types';
5
6
  interface CreateTRPCClientBaseOptions {
@@ -34,8 +35,8 @@ export declare class TRPCClient<TRouter extends AnyRouter> {
34
35
  constructor(opts: CreateTRPCClientOptions<TRouter>);
35
36
  private $request;
36
37
  private requestAsPromise;
37
- query<TQueries extends TRouter['_def']['queries'], TPath extends string & keyof TQueries, TInput extends inferProcedureInput<TQueries[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferProcedureOutput<TQueries[TPath]>>;
38
- mutation<TMutations extends TRouter['_def']['mutations'], TPath extends string & keyof TMutations, TInput extends inferProcedureInput<TMutations[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferProcedureOutput<TMutations[TPath]>>;
38
+ query<TQueries extends TRouter['_def']['queries'], TPath extends string & keyof TQueries, TInput extends inferProcedureInput<TQueries[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferTransformedProcedureOutput<TQueries[TPath]>>;
39
+ mutation<TMutations extends TRouter['_def']['mutations'], TPath extends string & keyof TMutations, TInput extends inferProcedureInput<TMutations[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferTransformedProcedureOutput<TMutations[TPath]>>;
39
40
  subscription<TSubscriptions extends TRouter['_def']['subscriptions'], TPath extends string & keyof TSubscriptions, TOutput extends inferSubscriptionOutput<TRouter, TPath>, TInput extends inferProcedureInput<TSubscriptions[TPath]>>(path: TPath, input: TInput, opts: TRPCRequestOptions & Partial<TRPCSubscriptionObserver<TOutput, TRPCClientError<TRouter>>>): Unsubscribable;
40
41
  }
41
42
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TRPCClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAE5B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EAIf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,gBAAgB,EAEhB,iBAAiB,EACjB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CAAC,EAAE,kBAAkB;IAUjD,YAAY,CACjB,cAAc,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,EACvD,KAAK,SAAS,MAAM,GAAG,MAAM,cAAc,EAE3C,OAAO,SAAS,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,EACvD,MAAM,SAAS,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAEzD,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,kBAAkB,GACtB,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,GACrE,cAAc;CAyBlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"dedupeLink.d.ts","sourceRoot":"","sources":["../../src/links/dedupeLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,UAAU,CACxB,OAAO,SAAS,SAAS,GAAG,SAAS,KAClC,QAAQ,CAAC,OAAO,CAAC,CA6CrB"}
1
+ {"version":3,"file":"dedupeLink.d.ts","sourceRoot":"","sources":["../../src/links/dedupeLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,UAAU,CACxB,OAAO,SAAS,SAAS,GAAG,SAAS,KAClC,QAAQ,CAAC,OAAO,CAAC,CA2CrB"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
6
  var transformResult = require('../transformResult-000baed1.js');
7
- var httpUtils = require('../httpUtils-47077ecd.js');
7
+ var httpUtils = require('../httpUtils-277fd63a.js');
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
10
10
  * A function that should never be called unless we messed something up.
@@ -1,6 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
2
  import { t as transformResult, T as TRPCClientError } from '../transformResult-b10d288d.mjs';
3
- import { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-01e0c677.mjs';
3
+ import { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-939364d7.mjs';
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
6
6
  * A function that should never be called unless we messed something up.
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
6
  var transformResult = require('../transformResult-000baed1.js');
7
- var httpUtils = require('../httpUtils-47077ecd.js');
7
+ var httpUtils = require('../httpUtils-277fd63a.js');
8
8
 
9
9
  function httpLink(opts) {
10
10
  const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
@@ -1,6 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
2
  import { t as transformResult, T as TRPCClientError } from '../transformResult-b10d288d.mjs';
3
- import { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-01e0c677.mjs';
3
+ import { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-939364d7.mjs';
4
4
 
5
5
  function httpLink(opts) {
6
6
  const resolvedOpts = resolveHTTPLinkOptions(opts);
@@ -1 +1 @@
1
- {"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE5E,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAA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,CAAC;AAEJ,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,UAgB9C;AAED,aAAK,cAAc,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,eAAe,CAAC;AAEhE,wBAAgB,OAAO,CAAC,IAAI,EAAE,cAAc,sBAM3C;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,kBAAkB,GACvB,gBAAgB,CAAC,UAAU,CAAC,CAyC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../src/links/retryLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,SAAS,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAiDpB"}
1
+ {"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../src/links/retryLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,SAAS,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAwCpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../src/links/wsLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAc,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAKL,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC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ws !== conn) {
149
149
  continue;
150
150
  }
151
- req.callbacks.error?.(transformResult.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
152
- if (req.type !== 'subscription') {
151
+ if (state === 'closed') {
152
+ // If the connection was closed, we just call `complete()` on the request
153
153
  delete pendingRequests[key];
154
154
  req.callbacks.complete?.();
155
- } else if (state !== 'closed') {
156
- // request restart of sub with next connection
155
+ continue;
156
+ }
157
+ // The connection was closed either unexpectedly or because of a reconnect
158
+ if (req.type === 'subscription') {
159
+ // Subscriptions will resume after we've reconnected
157
160
  resumeSubscriptionOnReconnect(req);
161
+ } else {
162
+ // Queries and mutations will error if interrupted
163
+ delete pendingRequests[key];
164
+ req.callbacks.error?.(transformResult.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
158
165
  }
159
166
  }
160
167
  });
@@ -184,7 +191,7 @@ function createWSClient(opts) {
184
191
  delete pendingRequests[id];
185
192
  outgoing = outgoing.filter((msg)=>msg.id !== id);
186
193
  callbacks?.complete?.();
187
- if (op.type === 'subscription') {
194
+ if (activeConnection.readyState === WebSocket.OPEN && op.type === 'subscription') {
188
195
  outgoing.push({
189
196
  id,
190
197
  method: 'subscription.stop'
@@ -144,13 +144,20 @@ function createWSClient(opts) {
144
144
  if (req.ws !== conn) {
145
145
  continue;
146
146
  }
147
- req.callbacks.error?.(TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
148
- if (req.type !== 'subscription') {
147
+ if (state === 'closed') {
148
+ // If the connection was closed, we just call `complete()` on the request
149
149
  delete pendingRequests[key];
150
150
  req.callbacks.complete?.();
151
- } else if (state !== 'closed') {
152
- // request restart of sub with next connection
151
+ continue;
152
+ }
153
+ // The connection was closed either unexpectedly or because of a reconnect
154
+ if (req.type === 'subscription') {
155
+ // Subscriptions will resume after we've reconnected
153
156
  resumeSubscriptionOnReconnect(req);
157
+ } else {
158
+ // Queries and mutations will error if interrupted
159
+ delete pendingRequests[key];
160
+ req.callbacks.error?.(TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
154
161
  }
155
162
  }
156
163
  });
@@ -180,7 +187,7 @@ function createWSClient(opts) {
180
187
  delete pendingRequests[id];
181
188
  outgoing = outgoing.filter((msg)=>msg.id !== id);
182
189
  callbacks?.complete?.();
183
- if (op.type === 'subscription') {
190
+ if (activeConnection.readyState === WebSocket.OPEN && op.type === 'subscription') {
184
191
  outgoing.push({
185
192
  id,
186
193
  method: 'subscription.stop'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.1.0",
3
+ "version": "10.3.0",
4
4
  "description": "tRPC Client lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -66,11 +66,11 @@
66
66
  "links"
67
67
  ],
68
68
  "peerDependencies": {
69
- "@trpc/server": "10.1.0"
69
+ "@trpc/server": "10.3.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@testing-library/dom": "^8.18.1",
73
- "@trpc/server": "10.1.0",
73
+ "@trpc/server": "10.3.0",
74
74
  "@types/node": "^18.7.20",
75
75
  "rollup": "^2.79.1",
76
76
  "tsx": "^3.9.0"
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "c3f5520a87039235fbcdfe1cd84b0e87dc248cd4"
81
+ "gitHead": "0d425918917ecadb58c87f5b0af62dfd386727cd"
82
82
  }
@@ -10,13 +10,14 @@ import type {
10
10
  ProcedureArgs,
11
11
  ProcedureRouterRecord,
12
12
  ProcedureType,
13
- inferProcedureOutput,
14
13
  } from '@trpc/server';
15
- import type {
16
- Unsubscribable,
17
- inferObservableValue,
18
- } from '@trpc/server/observable';
19
- import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
14
+ import type { Unsubscribable } from '@trpc/server/observable';
15
+ import {
16
+ createFlatProxy,
17
+ createRecursiveProxy,
18
+ inferTransformedProcedureOutput,
19
+ inferTransformedSubscriptionOutput,
20
+ } from '@trpc/server/shared';
20
21
  import { TRPCClientError } from './TRPCClientError';
21
22
  import { CreateTRPCClientOptions } from './createTRPCClient';
22
23
  import { TRPCClient, TRPCSubscriptionObserver } from './internals/TRPCClient';
@@ -26,7 +27,7 @@ export type inferRouterProxyClient<TRouter extends AnyRouter> =
26
27
 
27
28
  type Resolver<TProcedure extends AnyProcedure> = (
28
29
  ...args: ProcedureArgs<TProcedure['_def']>
29
- ) => Promise<inferProcedureOutput<TProcedure>>;
30
+ ) => Promise<inferTransformedProcedureOutput<TProcedure>>;
30
31
 
31
32
  type SubscriptionResolver<
32
33
  TProcedure extends AnyProcedure,
@@ -37,7 +38,7 @@ type SubscriptionResolver<
37
38
  opts: ProcedureArgs<TProcedure['_def']>[1] &
38
39
  Partial<
39
40
  TRPCSubscriptionObserver<
40
- inferObservableValue<inferProcedureOutput<TProcedure>>,
41
+ inferTransformedSubscriptionOutput<TProcedure>,
41
42
  TRPCClientError<TRouter>
42
43
  >
43
44
  >,
@@ -3,7 +3,6 @@ import {
3
3
  ClientDataTransformerOptions,
4
4
  DataTransformer,
5
5
  inferProcedureInput,
6
- inferProcedureOutput,
7
6
  inferSubscriptionOutput,
8
7
  } from '@trpc/server';
9
8
  import {
@@ -12,6 +11,7 @@ import {
12
11
  observableToPromise,
13
12
  share,
14
13
  } from '@trpc/server/observable';
14
+ import { inferTransformedProcedureOutput } from '@trpc/server/shared';
15
15
  import { TRPCClientError } from '../TRPCClientError';
16
16
  import { createChain } from '../links/internals/createChain';
17
17
  import {
@@ -134,7 +134,7 @@ export class TRPCClient<TRouter extends AnyRouter> {
134
134
  TPath extends string & keyof TQueries,
135
135
  TInput extends inferProcedureInput<TQueries[TPath]>,
136
136
  >(path: TPath, input?: TInput, opts?: TRPCRequestOptions) {
137
- type TOutput = inferProcedureOutput<TQueries[TPath]>;
137
+ type TOutput = inferTransformedProcedureOutput<TQueries[TPath]>;
138
138
  return this.requestAsPromise<TInput, TOutput>({
139
139
  type: 'query',
140
140
  path,
@@ -148,7 +148,7 @@ export class TRPCClient<TRouter extends AnyRouter> {
148
148
  TPath extends string & keyof TMutations,
149
149
  TInput extends inferProcedureInput<TMutations[TPath]>,
150
150
  >(path: TPath, input?: TInput, opts?: TRPCRequestOptions) {
151
- type TOutput = inferProcedureOutput<TMutations[TPath]>;
151
+ type TOutput = inferTransformedProcedureOutput<TMutations[TPath]>;
152
152
  return this.requestAsPromise<TInput, TOutput>({
153
153
  type: 'mutation',
154
154
  path,
@@ -160,6 +160,7 @@ export class TRPCClient<TRouter extends AnyRouter> {
160
160
  public subscription<
161
161
  TSubscriptions extends TRouter['_def']['subscriptions'],
162
162
  TPath extends string & keyof TSubscriptions,
163
+ // TODO - this should probably be updated to use inferTransformedProcedureOutput but this is only hit for legacy clients
163
164
  TOutput extends inferSubscriptionOutput<TRouter, TPath>,
164
165
  TInput extends inferProcedureInput<TSubscriptions[TPath]>,
165
166
  >(
@@ -1,3 +1,5 @@
1
+ /* istanbul ignore file */
2
+ // We're not actually exporting this link
1
3
  import { AnyRouter } from '@trpc/server';
2
4
  import { Observable, observable, share } from '@trpc/server/observable';
3
5
  import { TRPCLink } from './types';
@@ -28,9 +30,7 @@ export function dedupeLink<
28
30
  delete pending[key];
29
31
  }
30
32
  const subscription = next(op).subscribe({
31
- next(v) {
32
- observer.next(v);
33
- },
33
+ ...observer,
34
34
  error(e) {
35
35
  reset();
36
36
  observer.error(e);
@@ -125,6 +125,7 @@ export function httpRequest(
125
125
  const meta = {} as HTTPResult['meta'];
126
126
  Promise.resolve(opts.headers())
127
127
  .then((headers) => {
128
+ /* istanbul ignore if */
128
129
  if (type === 'subscription') {
129
130
  throw new Error('Subscriptions should use wsLink');
130
131
  }
@@ -1,3 +1,5 @@
1
+ /* istanbul ignore file */
2
+ // We're not actually exporting this link
1
3
  import { AnyRouter } from '@trpc/server';
2
4
  import { Unsubscribable, observable } from '@trpc/server/observable';
3
5
  import { TRPCLink } from './types';
@@ -19,6 +21,7 @@ export function retryLink<TRouter extends AnyRouter = AnyRouter>(opts: {
19
21
  next$?.unsubscribe();
20
22
  next$ = next(op).subscribe({
21
23
  error(error) {
24
+ /* istanbul ignore if */
22
25
  if (attempts >= opts.attempts) {
23
26
  observer.error(error);
24
27
  return;
@@ -26,17 +29,7 @@ export function retryLink<TRouter extends AnyRouter = AnyRouter>(opts: {
26
29
  attempt();
27
30
  },
28
31
  next(result) {
29
- if ('result' in result.result) {
30
- isDone = true;
31
- observer.next(result);
32
- return;
33
- }
34
- if (attempts >= opts.attempts) {
35
- isDone = true;
36
- observer.next(result);
37
- return;
38
- }
39
- attempt();
32
+ observer.next(result);
40
33
  },
41
34
  complete() {
42
35
  if (isDone) {
@@ -212,17 +212,25 @@ export function createWSClient(opts: WebSocketClientOptions) {
212
212
  if (req.ws !== conn) {
213
213
  continue;
214
214
  }
215
- req.callbacks.error?.(
216
- TRPCClientError.from(
217
- new TRPCWebSocketClosedError('WebSocket closed prematurely'),
218
- ),
219
- );
220
- if (req.type !== 'subscription') {
215
+
216
+ if (state === 'closed') {
217
+ // If the connection was closed, we just call `complete()` on the request
221
218
  delete pendingRequests[key];
222
219
  req.callbacks.complete?.();
223
- } else if (state !== 'closed') {
224
- // request restart of sub with next connection
220
+ continue;
221
+ }
222
+ // The connection was closed either unexpectedly or because of a reconnect
223
+ if (req.type === 'subscription') {
224
+ // Subscriptions will resume after we've reconnected
225
225
  resumeSubscriptionOnReconnect(req);
226
+ } else {
227
+ // Queries and mutations will error if interrupted
228
+ delete pendingRequests[key];
229
+ req.callbacks.error?.(
230
+ TRPCClientError.from(
231
+ new TRPCWebSocketClosedError('WebSocket closed prematurely'),
232
+ ),
233
+ );
226
234
  }
227
235
  }
228
236
  });
@@ -256,7 +264,10 @@ export function createWSClient(opts: WebSocketClientOptions) {
256
264
  outgoing = outgoing.filter((msg) => msg.id !== id);
257
265
 
258
266
  callbacks?.complete?.();
259
- if (op.type === 'subscription') {
267
+ if (
268
+ activeConnection.readyState === WebSocket.OPEN &&
269
+ op.type === 'subscription'
270
+ ) {
260
271
  outgoing.push({
261
272
  id,
262
273
  method: 'subscription.stop',