@trpc/client 11.33.0 → 11.35.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.
Files changed (66) hide show
  1. package/dist/{httpBatchLink-_bkMj4mk.d.cts → httpBatchLink-50xXDyIp.d.cts} +3 -3
  2. package/dist/{httpBatchLink-DaVHWlLU.d.mts.map → httpBatchLink-50xXDyIp.d.cts.map} +1 -1
  3. package/dist/{httpBatchLink-DaVHWlLU.d.mts → httpBatchLink-D4shlyQy.d.mts} +3 -3
  4. package/dist/{httpBatchLink-_bkMj4mk.d.cts.map → httpBatchLink-D4shlyQy.d.mts.map} +1 -1
  5. package/dist/{httpLink-DN_Ana7a.d.mts → httpLink-Bb6hOyBN.d.mts} +3 -3
  6. package/dist/{httpLink-DN_Ana7a.d.mts.map → httpLink-Bb6hOyBN.d.mts.map} +1 -1
  7. package/dist/{httpUtils-BAs5frdP.d.mts → httpUtils-BbinScxw.d.mts} +2 -2
  8. package/dist/{httpUtils-1z6dzl3V.d.cts.map → httpUtils-BbinScxw.d.mts.map} +1 -1
  9. package/dist/{httpUtils-1z6dzl3V.d.cts → httpUtils-dB1XeokQ.d.cts} +2 -2
  10. package/dist/{httpUtils-BAs5frdP.d.mts.map → httpUtils-dB1XeokQ.d.cts.map} +1 -1
  11. package/dist/index.cjs +4 -3
  12. package/dist/index.d.cts +37 -11
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +40 -14
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +4 -3
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/links/httpBatchLink.d.cts +1 -1
  19. package/dist/links/httpBatchLink.d.mts +1 -1
  20. package/dist/links/httpLink.d.cts +2 -2
  21. package/dist/links/httpLink.d.mts +1 -1
  22. package/dist/links/loggerLink.d.cts +1 -1
  23. package/dist/links/loggerLink.d.mts +1 -1
  24. package/dist/links/splitLink.cjs +1 -1
  25. package/dist/links/splitLink.d.cts +29 -8
  26. package/dist/links/splitLink.d.cts.map +1 -1
  27. package/dist/links/splitLink.d.mts +1 -1
  28. package/dist/links/splitLink.mjs +1 -1
  29. package/dist/links/wsLink/wsLink.d.cts +1 -1
  30. package/dist/links/wsLink/wsLink.d.mts +1 -1
  31. package/dist/{loggerLink-CiVinJOG.d.mts → loggerLink-y1x7WTWX.d.mts} +2 -2
  32. package/dist/{loggerLink-CiVinJOG.d.mts.map → loggerLink-y1x7WTWX.d.mts.map} +1 -1
  33. package/dist/splitLink-BGLTgm1a.d.mts +56 -0
  34. package/dist/splitLink-BGLTgm1a.d.mts.map +1 -0
  35. package/dist/{splitLink-IUbsOwO6.mjs → splitLink-C8U8vvLl.mjs} +10 -12
  36. package/dist/splitLink-C8U8vvLl.mjs.map +1 -0
  37. package/dist/{splitLink-BQoYcpdp.cjs → splitLink-NqS85b92.cjs} +9 -11
  38. package/dist/{types-DW0iJUBU.d.mts → types-BZH1P86I.d.mts} +3 -3
  39. package/dist/types-BZH1P86I.d.mts.map +1 -0
  40. package/dist/{types-DMe6B4SV.d.cts → types-CGS36fjk.d.cts} +3 -3
  41. package/dist/{types-DMe6B4SV.d.cts.map → types-CGS36fjk.d.cts.map} +1 -1
  42. package/dist/{wsLink-DX5fv7-H.d.mts → wsLink-CFh-pvQG.d.mts} +2 -2
  43. package/dist/{wsLink-DX5fv7-H.d.mts.map → wsLink-CFh-pvQG.d.mts.map} +1 -1
  44. package/dist/{wsLink-DuyXOEPt.d.cts → wsLink-CJT5pqFt.d.cts} +2 -2
  45. package/dist/{wsLink-DuyXOEPt.d.cts.map → wsLink-CJT5pqFt.d.cts.map} +1 -1
  46. package/package.json +3 -3
  47. package/skills/client-setup/SKILL.md +15 -10
  48. package/skills/links/SKILL.md +9 -7
  49. package/skills/links/references/client-links-httpBatchLink.md +12 -8
  50. package/skills/links/references/client-links-httpBatchStreamLink.md +9 -6
  51. package/skills/links/references/client-links-httpLink.md +3 -2
  52. package/skills/links/references/client-links-httpSubscriptionLink.md +12 -4
  53. package/skills/links/references/client-links-localLink.md +3 -2
  54. package/skills/links/references/client-links-loggerLink.md +3 -2
  55. package/skills/links/references/client-links-retryLink.md +31 -2
  56. package/skills/links/references/client-links-splitLink.md +22 -6
  57. package/skills/links/references/client-links-wsLink.md +3 -2
  58. package/skills/superjson/SKILL.md +10 -6
  59. package/src/createTRPCClient.ts +8 -2
  60. package/src/links/retryLink.ts +41 -10
  61. package/src/links/splitLink.ts +85 -14
  62. package/src/links/types.ts +5 -2
  63. package/dist/splitLink-ClFN_nbg.d.mts +0 -35
  64. package/dist/splitLink-ClFN_nbg.d.mts.map +0 -1
  65. package/dist/splitLink-IUbsOwO6.mjs.map +0 -1
  66. package/dist/types-DW0iJUBU.d.mts.map +0 -1
@@ -1,5 +1,5 @@
1
- import { T as NonEmptyArray, a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-DMe6B4SV.cjs";
2
- import { t as HTTPLinkBaseOptions } from "./httpUtils-1z6dzl3V.cjs";
1
+ import { T as NonEmptyArray, a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-CGS36fjk.cjs";
2
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-dB1XeokQ.cjs";
3
3
  import { AnyClientTypes } from "@trpc/server/unstable-core-do-not-import";
4
4
  import { AnyRouter as AnyRouter$1 } from "@trpc/server";
5
5
  /**
@@ -41,4 +41,4 @@ declare function httpBatchLink<TRouter extends AnyRouter$1>(opts: HTTPBatchLinkO
41
41
  context: AugmentedOperationContext;
42
42
  }>;
43
43
  export { HTTPBatchLinkOptions as n, httpBatchLink as t };
44
- //# sourceMappingURL=httpBatchLink-_bkMj4mk.d.cts.map
44
+ //# sourceMappingURL=httpBatchLink-50xXDyIp.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpBatchLink-DaVHWlLU.d.mts","names":["AnyRouter"],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"mappings":";;;;;;;;KASY,qBAAqB,cAAc,kBAC7C,oBAAoB;;;;;;;;EAQlB;;;;;;EAMA,UACI,gBACE;IACA,QAAQ,cAAc;QAClB,cAAc,QAAQ;;;;;;;EAQhC;;;;;;;;iBCVY,cAAc,gBAAgBA,aAC5C,MAAM,qBAAqB,wCAC1B,SACD;EAEE,SAAS"}
1
+ {"version":3,"file":"httpBatchLink-50xXDyIp.d.cts","names":["AnyRouter"],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"mappings":";;;;;;;;KASY,qBAAqB,cAAc,kBAC7C,oBAAoB;;;;;;;;EAQlB;;;;;;EAMA,UACI,gBACE;IACA,QAAQ,cAAc;QAClB,cAAc,QAAQ;;;;;;;EAQhC;;;;;;;;iBCVY,cAAc,gBAAgBA,aAC5C,MAAM,qBAAqB,wCAC1B,SACD;EAEE,SAAS"}
@@ -1,5 +1,5 @@
1
- import { S as NonEmptyArray, a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-DW0iJUBU.mjs";
2
- import { t as HTTPLinkBaseOptions } from "./httpUtils-BAs5frdP.mjs";
1
+ import { S as NonEmptyArray, a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-BZH1P86I.mjs";
2
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-BbinScxw.mjs";
3
3
  import { AnyClientTypes } from "@trpc/server/unstable-core-do-not-import";
4
4
  import { AnyRouter as AnyRouter$1 } from "@trpc/server";
5
5
  /**
@@ -41,4 +41,4 @@ declare function httpBatchLink<TRouter extends AnyRouter$1>(opts: HTTPBatchLinkO
41
41
  context: AugmentedOperationContext;
42
42
  }>;
43
43
  export { HTTPBatchLinkOptions as n, httpBatchLink as t };
44
- //# sourceMappingURL=httpBatchLink-DaVHWlLU.d.mts.map
44
+ //# sourceMappingURL=httpBatchLink-D4shlyQy.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpBatchLink-_bkMj4mk.d.cts","names":["AnyRouter"],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"mappings":";;;;;;;;KASY,qBAAqB,cAAc,kBAC7C,oBAAoB;;;;;;;;EAQlB;;;;;;EAMA,UACI,gBACE;IACA,QAAQ,cAAc;QAClB,cAAc,QAAQ;;;;;;;EAQhC;;;;;;;;iBCVY,cAAc,gBAAgBA,aAC5C,MAAM,qBAAqB,wCAC1B,SACD;EAEE,SAAS"}
1
+ {"version":3,"file":"httpBatchLink-D4shlyQy.d.mts","names":["AnyRouter"],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"mappings":";;;;;;;;KASY,qBAAqB,cAAc,kBAC7C,oBAAoB;;;;;;;;EAQlB;;;;;;EAMA,UACI,gBACE;IACA,QAAQ,cAAc;QAClB,cAAc,QAAQ;;;;;;;EAQhC;;;;;;;;iBCVY,cAAc,gBAAgBA,aAC5C,MAAM,qBAAqB,wCAC1B,SACD;EAEE,SAAS"}
@@ -1,5 +1,5 @@
1
- import { t as HTTPLinkBaseOptions } from "./httpUtils-BAs5frdP.mjs";
2
- import { a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-DW0iJUBU.mjs";
1
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-BbinScxw.mjs";
2
+ import { a as Operation, n as HTTPHeaders, p as TRPCLink, t as AugmentedOperationContext } from "./types-BZH1P86I.mjs";
3
3
  import { AnyClientTypes, AnyRouter } from "@trpc/server/unstable-core-do-not-import";
4
4
  /**
5
5
  * The options of `httpLink`.
@@ -24,4 +24,4 @@ declare function httpLink<TRouter extends AnyRouter = AnyRouter>(opts: HTTPLinkO
24
24
  context: AugmentedOperationContext;
25
25
  }>;
26
26
  export { httpLink as n, HTTPLinkOptions as t };
27
- //# sourceMappingURL=httpLink-DN_Ana7a.d.mts.map
27
+ //# sourceMappingURL=httpLink-Bb6hOyBN.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpLink-DN_Ana7a.d.mts","names":[],"sources":["../src/links/httpLink.ts"],"mappings":";;;;;;;KAgCY,gBAAgB,cAAc,kBACxC,oBAAoB;;;;;;EAMlB,UACI,gBACE;IAAQ,IAAI;QAAgB,cAAc,QAAQ;;;;;;;iBA0C5C,SAAS,gBAAgB,YAAY,WACnD,MAAM,gBAAgB,wCACrB,SACD;EAEE,SAAS"}
1
+ {"version":3,"file":"httpLink-Bb6hOyBN.d.mts","names":[],"sources":["../src/links/httpLink.ts"],"mappings":";;;;;;;KAgCY,gBAAgB,cAAc,kBACxC,oBAAoB;;;;;;EAMlB,UACI,gBACE;IAAQ,IAAI;QAAgB,cAAc,QAAQ;;;;;;;iBA0C5C,SAAS,gBAAgB,YAAY,WACnD,MAAM,gBAAgB,wCACrB,SACD;EAEE,SAAS"}
@@ -1,4 +1,4 @@
1
- import { b as FetchEsque } from "./types-DW0iJUBU.mjs";
1
+ import { b as FetchEsque } from "./types-BZH1P86I.mjs";
2
2
  import { n as TransformerOptions } from "./unstable-internals-CnrO49lh.mjs";
3
3
  import { AnyClientTypes, PathSeparator } from "@trpc/server/unstable-core-do-not-import";
4
4
  /**
@@ -27,4 +27,4 @@ type HTTPLinkBaseOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = {
27
27
  pathSeparator?: PathSeparator;
28
28
  } & TransformerOptions<TRoot>;
29
29
  export { HTTPLinkBaseOptions as t };
30
- //# sourceMappingURL=httpUtils-BAs5frdP.d.mts.map
30
+ //# sourceMappingURL=httpUtils-BbinScxw.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpUtils-1z6dzl3V.d.cts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"mappings":";;;;;;;KA4BY,oBACV,cAAc,KAAK;;EAGnB,cAAc;;;;EAId,QAAQ;;;;;;EAMR;;;;;;;EAOA,gBAAgB;IACd,mBAAmB"}
1
+ {"version":3,"file":"httpUtils-BbinScxw.d.mts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"mappings":";;;;;;;KA4BY,oBACV,cAAc,KAAK;;EAGnB,cAAc;;;;EAId,QAAQ;;;;;;EAMR;;;;;;;EAOA,gBAAgB;IACd,mBAAmB"}
@@ -1,4 +1,4 @@
1
- import { C as FetchEsque } from "./types-DMe6B4SV.cjs";
1
+ import { C as FetchEsque } from "./types-CGS36fjk.cjs";
2
2
  import { TransformerOptions } from "./unstable-internals.cjs";
3
3
  import { AnyClientTypes, PathSeparator } from "@trpc/server/unstable-core-do-not-import";
4
4
  /**
@@ -27,4 +27,4 @@ type HTTPLinkBaseOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = {
27
27
  pathSeparator?: PathSeparator;
28
28
  } & TransformerOptions<TRoot>;
29
29
  export { HTTPLinkBaseOptions as t };
30
- //# sourceMappingURL=httpUtils-1z6dzl3V.d.cts.map
30
+ //# sourceMappingURL=httpUtils-dB1XeokQ.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpUtils-BAs5frdP.d.mts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"mappings":";;;;;;;KA4BY,oBACV,cAAc,KAAK;;EAGnB,cAAc;;;;EAId,QAAQ;;;;;;EAMR;;;;;;;EAOA,gBAAgB;IACd,mBAAmB"}
1
+ {"version":3,"file":"httpUtils-dB1XeokQ.d.cts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"mappings":";;;;;;;KA4BY,oBACV,cAAc,KAAK;;EAGnB,cAAc;;;;EAId,QAAQ;;;;;;EAMR;;;;;;;EAOA,gBAAgB;IACd,mBAAmB"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_splitLink = require("./splitLink-BQoYcpdp.cjs");
2
+ const require_splitLink = require("./splitLink-NqS85b92.cjs");
3
3
  const require_TRPCClientError = require("./TRPCClientError-irOPxS6c.cjs");
4
4
  const require_objectSpread2 = require("./objectSpread2-Xm0br5eL.cjs");
5
5
  const require_httpUtils = require("./httpUtils-coYP4VfN.cjs");
@@ -542,7 +542,7 @@ const unstable_httpSubscriptionLink = httpSubscriptionLink;
542
542
  /* istanbul ignore file -- @preserve */
543
543
  /**
544
544
  * Retries failed operations. Subscriptions resume from the last tracked event
545
- * id.
545
+ * id. A call can pass its own `retry` in `context`.
546
546
  *
547
547
  * @see https://trpc.io/docs/client/links/retryLink
548
548
  */
@@ -568,7 +568,8 @@ function retryLink(opts) {
568
568
  const subscription = callOpts.next(op).subscribe({
569
569
  error(error) {
570
570
  var _opts$retryDelayMs, _opts$retryDelayMs2;
571
- const shouldRetry = opts.retry({
571
+ const callRetry = op.context["retry"];
572
+ const shouldRetry = (typeof callRetry === "function" ? callRetry : opts.retry)({
572
573
  op,
573
574
  attempts,
574
575
  error
package/dist/index.d.cts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { t as TRPCConnectionState } from "./subscriptions-CvJnusYO.cjs";
2
- import { C as FetchEsque, E as TRPCProcedureOptions, S as isTRPCClientError, _ as isNonJsonSerializable, a as Operation, b as TRPCClientErrorBase, c as OperationResultEnvelope, d as TRPCClientRuntime, f as TRPCFetch, g as isFormData, h as inferLinksDeclaredContext, i as NoLinkReadsContext, l as OperationResultObservable, m as inferLinksContext, n as HTTPHeaders, o as OperationContext, p as TRPCLink, r as LinkDecl, s as OperationLink, t as AugmentedOperationContext, u as OperationResultObserver, v as isOctetType, w as NativeFetchEsque, x as TRPCClientErrorLike, y as TRPCClientError } from "./types-DMe6B4SV.cjs";
3
- import { n as HTTPBatchLinkOptions, t as httpBatchLink } from "./httpBatchLink-_bkMj4mk.cjs";
2
+ import { C as FetchEsque, E as TRPCProcedureOptions, S as isTRPCClientError, _ as isNonJsonSerializable, a as Operation, b as TRPCClientErrorBase, c as OperationResultEnvelope, d as TRPCClientRuntime, f as TRPCFetch, g as isFormData, h as inferLinksDeclaredContext, i as NoLinkReadsContext, l as OperationResultObservable, m as inferLinksContext, n as HTTPHeaders, o as OperationContext, p as TRPCLink, r as LinkDecl, s as OperationLink, t as AugmentedOperationContext, u as OperationResultObserver, v as isOctetType, w as NativeFetchEsque, x as TRPCClientErrorLike, y as TRPCClientError } from "./types-CGS36fjk.cjs";
3
+ import { n as HTTPBatchLinkOptions, t as httpBatchLink } from "./httpBatchLink-50xXDyIp.cjs";
4
4
  import { HTTPLinkOptions, httpLink } from "./links/httpLink.cjs";
5
5
  import { LoggerLinkOptions, loggerLink } from "./links/loggerLink.cjs";
6
6
  import { splitLink } from "./links/splitLink.cjs";
7
- import { a as WebSocketClientOptions, c as jsonEncoder, i as createWSClient, n as wsLink, o as UrlOptionsWithConnectionParams, r as TRPCWebSocketClient, s as Encoder, t as WebSocketLinkOptions } from "./wsLink-DuyXOEPt.cjs";
7
+ import { a as WebSocketClientOptions, c as jsonEncoder, i as createWSClient, n as wsLink, o as UrlOptionsWithConnectionParams, r as TRPCWebSocketClient, s as Encoder, t as WebSocketLinkOptions } from "./wsLink-CJT5pqFt.cjs";
8
8
  import { TransformerOptions } from "./unstable-internals.cjs";
9
- import { t as HTTPLinkBaseOptions } from "./httpUtils-1z6dzl3V.cjs";
9
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-dB1XeokQ.cjs";
10
10
  import { AnyClientTypes, AnyProcedure, AnyRouter, ErrorHandlerOptions, EventSourceLike, InferrableClientTypes, ProcedureType, RouterRecord, TypeError, inferAsyncIterableYield, inferClientTypes, inferProcedureErrorShape, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
11
11
  import { Unsubscribable } from "@trpc/server/observable";
12
12
  import { AnyRouter as AnyRouter$1 } from "@trpc/server";
@@ -268,9 +268,12 @@ export type CreateTRPCClientWithRouterOptions<TRouter extends AnyRouter, TLinks
268
268
  * ```ts
269
269
  * const client = createTRPCClient({
270
270
  * router: routerType<AppRouter>(),
271
- * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
271
+ * links: [retryLink({ retry: () => false }), httpBatchLink({ url })],
272
272
  * });
273
- * const post = await client.post.byId.query({ id: '1' });
273
+ * const post = await client.post.byId.query(
274
+ * { id: '1' },
275
+ * { context: { retry: (opts) => opts.attempts <= 3 } },
276
+ * );
274
277
  * ```
275
278
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
276
279
  */
@@ -286,6 +289,9 @@ export declare function createTRPCClient<TRouter extends AnyRouter, const TLinks
286
289
  * const post = await client.post.byId.query({ id: '1' });
287
290
  * ```
288
291
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
292
+ * @deprecated Pass the router's type as `router: routerType<AppRouter>()`
293
+ * instead of a type argument, so the links can type each call's `context`.
294
+ * The type argument form is removed in v12.
289
295
  */
290
296
  export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
291
297
  /**
@@ -356,17 +362,37 @@ export declare function httpSubscriptionLink<TInferrable extends InferrableClien
356
362
  * @deprecated Use {@link httpSubscriptionLink} instead.
357
363
  */
358
364
  export declare const unstable_httpSubscriptionLink: typeof httpSubscriptionLink;
365
+ type RetryFn<TInferrable extends InferrableClientTypes> = (opts: RetryFnOptions<TInferrable>) => boolean;
366
+ /**
367
+ * The `context` calls can pass through `retryLink`: the fields added to
368
+ * `OperationContext` (`TAugmented`), which its callbacks may read, and
369
+ * `retry`.
370
+ * @public
371
+ */
372
+ export type RetryLinkContext<TInferrable extends InferrableClientTypes, TAugmented extends object = AugmentedOperationContext> = Omit<TAugmented, 'retry'> & {
373
+ /**
374
+ * Decides whether to retry this call, in place of the link's `retry`.
375
+ * Anything else, such as a flag added to `OperationContext` that the
376
+ * link's `retry` reads, is left to the link.
377
+ * @example client.post.byId.query(input, { context: { retry: (opts) => opts.attempts <= 3 } })
378
+ */
379
+ retry?: RetryFn<TInferrable> | ('retry' extends keyof TAugmented ? TAugmented['retry'] : never);
380
+ };
359
381
  interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
360
382
  /**
361
- * The retry function
383
+ * The retry function. A call's `context.retry` replaces it for that call.
362
384
  */
363
- retry: (opts: RetryFnOptions<TInferrable>) => boolean;
385
+ retry: RetryFn<TInferrable>;
364
386
  /**
365
387
  * The delay between retries in ms (defaults to 0)
366
388
  */
367
389
  retryDelayMs?: (attempt: number) => number;
368
390
  }
369
- interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
391
+ /**
392
+ * What a `retry` function is given.
393
+ * @public
394
+ */
395
+ export interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
370
396
  /**
371
397
  * The operation that failed
372
398
  */
@@ -382,12 +408,12 @@ interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
382
408
  }
383
409
  /**
384
410
  * Retries failed operations. Subscriptions resume from the last tracked event
385
- * id.
411
+ * id. A call can pass its own `retry` in `context`.
386
412
  *
387
413
  * @see https://trpc.io/docs/client/links/retryLink
388
414
  */
389
415
  export declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable, {
390
- context: AugmentedOperationContext;
416
+ context: RetryLinkContext<TInferrable>;
391
417
  }>;
392
418
  /**
393
419
  * Passed to {@link LocalLinkOptions.createContext}.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["AnyRouter"],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/routerType.ts","../src/safe.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"mappings":";;;;;;;;;;;;;UA6BiB;;;;;EAKf,UAAU;;;;;EAKV,SAAS;;;UAIM,yBAAyB,QAAQ;;EAEhD,YAAY;IAAQ,SAAS;;;EAE7B,SAAS,OAAO,wBAAwB;;EAExC,UAAU,KAAK;;;;;EAKf;;EAEA;;EAEA,0BAA0B,OAAO,oBAAoB;;KAGlD,oBAAoB;;;;;;KAOb,iCAAiC,SAAS,WAEnD,QAAQ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AAQ,WAAW,WAClB,kBAAkB;;;;;wBCvRL,SACd,kBAAkB,aAAa,mBAC9B;;;;;;;YCkBS,2BAA2B,cAAc,kBACnD,qBAAqB;;;;;;;EAOnB;;;;;;;;wBAeY,oBAAoB,gBAAgBA,aAClD,MAAM,2BAA2B,wCAChC,SACD;EAEE,SAAS;;;;;qBA2NA,qCAA4B;;;;KCzOpC,4BACH,cAAc,gBACd,qBAAqB,gBAAgB,wBAAwB;;;;;EAM7D,cAAc;;;;;EAKd,qBACI,gBAAgB,WAAW,kBACzB;IACA,IAAI;QAEF,gBAAgB,WAAW,gBAC3B,QAAQ,gBAAgB,WAAW;IACzC,KAAK,oBAAoB,2BAC3B,mBAAmB,SACnB;;;;;;wBAOc,qBACd,oBAAoB,uBACpB,qBAAqB,gBAAgB,gBAErC,MAAM,4BACJ,iBAAiB,cACjB,gBAED,SACD;EAEE,SAAS;;;;;qBA6KA,sCAA6B;UCxPhC,iBAAiB,oBAAoB;;;;EAI7C,QAAQ,MAAM,eAAe;;;;EAI7B,gBAAgB;;UAGR,eAAe,oBAAoB;;;;EAI3C,IAAI;;;;EAIJ,OAAO,gBAAgB;;;;EAIvB;;;;;;;;wBASc,UAAU,oBAAoB,uBAC5C,MAAM,iBAAiB,eACtB,SACD;EAEE,SAAS;;;;;YCND;;;;;EAKV;;;;;IAKE,QAAQ;;;;;;;;YASA,iBAAiB,gBAAgB;;;;;EAK3C,QAAQ;;;;;;EAMR,gBACE,MAAM,kCACH,QAAQ,mBAAmB;;;;;EAKhC,WAAW,MAAM,oBAAoB,mBAAmB;IACtD,mBAAmB,iBAAiB;;;;;;;wBAQxB,UAAU,gBAAgB,WACxC,MAAM,iBAAiB,WACtB,SAAS;EAAW;;;;;;qBAqQV,2BAAkB;;;;;qBAMlB,+BAAsB"}
1
+ {"version":3,"file":"index.d.cts","names":["AnyRouter"],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/routerType.ts","../src/safe.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"mappings":";;;;;;;;;;;;;UA6BiB;;;;;EAKf,UAAU;;;;;EAKV,SAAS;;;UAIM,yBAAyB,QAAQ;;EAEhD,YAAY;IAAQ,SAAS;;;EAE7B,SAAS,OAAO,wBAAwB;;EAExC,UAAU,KAAK;;;;;EAKf;;EAEA;;EAEA,0BAA0B,OAAO,oBAAoB;;KAGlD,oBAAoB;;;;;;KAOb,iCAAiC,SAAS,WAEnD,QAAQ,6BAER,cAAc,QAAQ;;;;;KAOb,0BAA0B,QAAQ,UAAU,QACtD,yBAAyB,QAAQ,cAG9B,QAAQ,cAAc,KAAK,yBAAyB,QAAQ,SAAS,SACtE;;;;;KAeQ,wBAAwB,gBAAgB;;;;;;EAMlD,OAAO,SAAS;EAChB,cAAc;;;;;;qBAOH,kBAAkB,oBAAoB;mBAChC;WACD,SAAS;UACjB;EAER,YAAY,MAAM,wBAAwB;UASlC;UAkBM;;EAmBP,MAAM,cAAc,iBAAiB,OAAO,qBAAkB;;EAU9D,SAAS,cAAc,iBAAiB,OAAO,qBAAkB;;;;;;;EAejE,aACL,cACA,gBACA,MAAM,mCAAmC,gBAAgB,cACvD,qBACD;EACI,aACL,cAAc,qBACZ,QAAQ,kCAAkC,gBAAgB,eAC1D,oBAEF,cACA,gBACA,OAAO,iCAAiC,SACvC;;;;;;wBCnMW,wBAAwB,gBAAgB,WACtD,MAAM,wBAAwB,WAC7B,kBAAkB;cCRP;;;;;;iBAOG,WAAW,gBAAgB;YAChC,kBAAkB;;;;;;;;;;;;;;;;;wBAkBd,WAAW,gBAAgB,cAAc,WAAW;;;;cCvB/C;;;;;KAMT,kBAAkB,OAAO,eAAe,QAAQ;YAChD,gBAAgB;;;;;KAMhB,eAAe,eAAe;EACxC,YAAY;EACZ;;;;;;KAOU,WAAW,OAAO,yBAChB,MAAM,OAAO,8BACb,iBAAiB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IvB;;;;;;;;wBASc,UAAU,oBAAoB,uBAC5C,MAAM,iBAAiB,eACtB,SAAS;EAAe,SAAS,iBAAiB;;;;;YChCzC;;;;;EAKV;;;;;IAKE,QAAQ;;;;;;;;YASA,iBAAiB,gBAAgB;;;;;EAK3C,QAAQ;;;;;;EAMR,gBACE,MAAM,kCACH,QAAQ,mBAAmB;;;;;EAKhC,WAAW,MAAM,oBAAoB,mBAAmB;IACtD,mBAAmB,iBAAiB;;;;;;;wBAQxB,UAAU,gBAAgB,WACxC,MAAM,iBAAiB,WACtB,SAAS;EAAW;;;;;;qBAqQV,2BAAkB;;;;;qBAMlB,+BAAsB"}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { t as TRPCConnectionState } from "./subscriptions-CvJnusYO.mjs";
2
- import { C as TRPCProcedureOptions, _ as TRPCClientErrorBase, a as Operation, b as FetchEsque, c as OperationResultEnvelope, d as TRPCClientRuntime, f as TRPCFetch, g as TRPCClientError, h as inferLinksDeclaredContext, i as NoLinkReadsContext, l as OperationResultObservable, m as inferLinksContext, n as HTTPHeaders, o as OperationContext, p as TRPCLink, r as LinkDecl, s as OperationLink, t as AugmentedOperationContext, u as OperationResultObserver, v as TRPCClientErrorLike, x as NativeFetchEsque, y as isTRPCClientError } from "./types-DW0iJUBU.mjs";
3
- import { n as HTTPBatchLinkOptions, t as httpBatchLink } from "./httpBatchLink-DaVHWlLU.mjs";
4
- import { n as httpLink, t as HTTPLinkOptions } from "./httpLink-DN_Ana7a.mjs";
5
- import { n as loggerLink, t as LoggerLinkOptions } from "./loggerLink-CiVinJOG.mjs";
6
- import { t as splitLink } from "./splitLink-ClFN_nbg.mjs";
7
- import { a as WebSocketClientOptions, c as jsonEncoder, i as createWSClient, n as wsLink, o as UrlOptionsWithConnectionParams, r as TRPCWebSocketClient, s as Encoder, t as WebSocketLinkOptions } from "./wsLink-DX5fv7-H.mjs";
2
+ import { C as TRPCProcedureOptions, _ as TRPCClientErrorBase, a as Operation, b as FetchEsque, c as OperationResultEnvelope, d as TRPCClientRuntime, f as TRPCFetch, g as TRPCClientError, h as inferLinksDeclaredContext, i as NoLinkReadsContext, l as OperationResultObservable, m as inferLinksContext, n as HTTPHeaders, o as OperationContext, p as TRPCLink, r as LinkDecl, s as OperationLink, t as AugmentedOperationContext, u as OperationResultObserver, v as TRPCClientErrorLike, x as NativeFetchEsque, y as isTRPCClientError } from "./types-BZH1P86I.mjs";
3
+ import { n as HTTPBatchLinkOptions, t as httpBatchLink } from "./httpBatchLink-D4shlyQy.mjs";
4
+ import { n as httpLink, t as HTTPLinkOptions } from "./httpLink-Bb6hOyBN.mjs";
5
+ import { n as loggerLink, t as LoggerLinkOptions } from "./loggerLink-y1x7WTWX.mjs";
6
+ import { t as splitLink } from "./splitLink-BGLTgm1a.mjs";
7
+ import { a as WebSocketClientOptions, c as jsonEncoder, i as createWSClient, n as wsLink, o as UrlOptionsWithConnectionParams, r as TRPCWebSocketClient, s as Encoder, t as WebSocketLinkOptions } from "./wsLink-CFh-pvQG.mjs";
8
8
  import { n as TransformerOptions } from "./unstable-internals-CnrO49lh.mjs";
9
- import { t as HTTPLinkBaseOptions } from "./httpUtils-BAs5frdP.mjs";
9
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-BbinScxw.mjs";
10
10
  import { Unsubscribable } from "@trpc/server/observable";
11
11
  import { AnyClientTypes, AnyProcedure, AnyRouter, ErrorHandlerOptions, EventSourceLike, InferrableClientTypes, ProcedureType, RouterRecord, TypeError, inferAsyncIterableYield, inferClientTypes, inferProcedureErrorShape, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
12
12
  import { AnyRouter as AnyRouter$1 } from "@trpc/server";
@@ -278,9 +278,12 @@ export type CreateTRPCClientWithRouterOptions<TRouter extends AnyRouter, TLinks
278
278
  * ```ts
279
279
  * const client = createTRPCClient({
280
280
  * router: routerType<AppRouter>(),
281
- * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
281
+ * links: [retryLink({ retry: () => false }), httpBatchLink({ url })],
282
282
  * });
283
- * const post = await client.post.byId.query({ id: '1' });
283
+ * const post = await client.post.byId.query(
284
+ * { id: '1' },
285
+ * { context: { retry: (opts) => opts.attempts <= 3 } },
286
+ * );
284
287
  * ```
285
288
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
286
289
  */
@@ -296,6 +299,9 @@ export declare function createTRPCClient<TRouter extends AnyRouter, const TLinks
296
299
  * const post = await client.post.byId.query({ id: '1' });
297
300
  * ```
298
301
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
302
+ * @deprecated Pass the router's type as `router: routerType<AppRouter>()`
303
+ * instead of a type argument, so the links can type each call's `context`.
304
+ * The type argument form is removed in v12.
299
305
  */
300
306
  export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
301
307
  /**
@@ -366,17 +372,37 @@ export declare function httpSubscriptionLink<TInferrable extends InferrableClien
366
372
  * @deprecated Use {@link httpSubscriptionLink} instead.
367
373
  */
368
374
  export declare const unstable_httpSubscriptionLink: typeof httpSubscriptionLink;
375
+ type RetryFn<TInferrable extends InferrableClientTypes> = (opts: RetryFnOptions<TInferrable>) => boolean;
376
+ /**
377
+ * The `context` calls can pass through `retryLink`: the fields added to
378
+ * `OperationContext` (`TAugmented`), which its callbacks may read, and
379
+ * `retry`.
380
+ * @public
381
+ */
382
+ export type RetryLinkContext<TInferrable extends InferrableClientTypes, TAugmented extends object = AugmentedOperationContext> = Omit<TAugmented, 'retry'> & {
383
+ /**
384
+ * Decides whether to retry this call, in place of the link's `retry`.
385
+ * Anything else, such as a flag added to `OperationContext` that the
386
+ * link's `retry` reads, is left to the link.
387
+ * @example client.post.byId.query(input, { context: { retry: (opts) => opts.attempts <= 3 } })
388
+ */
389
+ retry?: RetryFn<TInferrable> | ('retry' extends keyof TAugmented ? TAugmented['retry'] : never);
390
+ };
369
391
  interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
370
392
  /**
371
- * The retry function
393
+ * The retry function. A call's `context.retry` replaces it for that call.
372
394
  */
373
- retry: (opts: RetryFnOptions<TInferrable>) => boolean;
395
+ retry: RetryFn<TInferrable>;
374
396
  /**
375
397
  * The delay between retries in ms (defaults to 0)
376
398
  */
377
399
  retryDelayMs?: (attempt: number) => number;
378
400
  }
379
- interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
401
+ /**
402
+ * What a `retry` function is given.
403
+ * @public
404
+ */
405
+ export interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
380
406
  /**
381
407
  * The operation that failed
382
408
  */
@@ -392,12 +418,12 @@ interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
392
418
  }
393
419
  /**
394
420
  * Retries failed operations. Subscriptions resume from the last tracked event
395
- * id.
421
+ * id. A call can pass its own `retry` in `context`.
396
422
  *
397
423
  * @see https://trpc.io/docs/client/links/retryLink
398
424
  */
399
425
  export declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable, {
400
- context: AugmentedOperationContext;
426
+ context: RetryLinkContext<TInferrable>;
401
427
  }>;
402
428
  /**
403
429
  * Passed to {@link LocalLinkOptions.createContext}.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["AnyRouter"],"sources":["../src/links/internals/contentTypes.ts","../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/routerType.ts","../src/safe.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"mappings":";;;;;;;;;;;;;wBACgB,YACd,iBACC,SAAS,WAAW,eAAe;;wBAStB,WAAW,iBAAc,SAAA;;;;;;wBASzB,sBAAsB,iBAAc,SAAA,OAAA,WAAA,WAAA;;UCQnC;;;;;EAKf,UAAU;;;;;EAKV,SAAS;;;UAI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AM,iBAAiB,WACtB,SAAS;EAAW;;;;;;qBAqQV,2BAAkB;;;;;qBAMlB,+BAAsB"}
1
+ {"version":3,"file":"index.d.mts","names":["AnyRouter"],"sources":["../src/links/internals/contentTypes.ts","../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/routerType.ts","../src/safe.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"mappings":";;;;;;;;;;;;;wBACgB,YACd,iBACC,SAAS,WAAW,eAAe;;wBAStB,WAAW,iBAAc,SAAA;;;;;;wBASzB,sBAAsB,iBAAc,SAAA,OAAA,WAAA,WAAA;;UCQnC;;;;;EAKf,UAAU;;;;;EAKV,SAAS;;;UAIM,yBAAyB,QAAQ;;EAEhD,YAAY;IAAQ,SAAS;;;EAE7B,SAAS,OAAO,wBAAwB;;EAExC,UAAU,KAAK;;;;;EAKf;;EAEA;;EAEA,0BAA0B,OAAO,oBAAoB;;KAGlD,oBAAoB;;;;;;KAOb,iCAAiC,SAAS,WAEnD,QAAQ,6BAER,cAAc,QAAQ;;;;;KAOb,0BAA0B,QAAQ,UAAU,QACtD,yBAAyB,QAAQ,cAG9B,QAAQ,cAAc,KAAK,yBAAyB,QAAQ,SAAS,SACtE;;;;;KAeQ,wBAAwB,gBAAgB;;;;;;EAMlD,OAAO,SAAS;EAChB,cAAc;;;;;;qBAOH,kBAAkB,oBAAoB;mBAChC;WACD,SAAS;UACjB;EAER,YAAY,MAAM,wBAAwB;UASlC;UAkBM;;EAmBP,MAAM,cAAc,iBAAiB,OAAO,qBAAkB;;EAU9D,SAAS,cAAc,iBAAiB,OAAO,qBAAkB;;;;;;;EAejE,aACL,cACA,gBACA,MAAM,mCAAmC,gBAAgB,cACvD,qBACD;EACI,aACL,cAAc,qBACZ,QAAQ,kCAAkC,gBAAgB,eAC1D,oBAEF,cACA,gBACA,OAAO,iCAAiC,SACv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iB,cACjB,gBAED,SACD;EAEE,SAAS;;;;;qBA6KA,sCAA6B;KCxPrC,QAAQ,oBAAoB,0BAC/B,MAAM,eAAe;;;;;;;YASX,iBACV,oBAAoB,uBACpB,4BAA4B,6BAC1B,KAAK;;;;;;;EAOP,QACI,QAAQ,sCACe,aAAa;;UAGhC,iBAAiB,oBAAoB;;;;EAI7C,OAAO,QAAQ;;;;EAIf,gBAAgB;;;;;;iBAOD,eAAe,oBAAoB;;;;EAIlD,IAAI;;;;EAIJ,OAAO,gBAAgB;;;;EAIvB;;;;;;;;wBASc,UAAU,oBAAoB,uBAC5C,MAAM,iBAAiB,eACtB,SAAS;EAAe,SAAS,iBAAiB;;;;;YChCzC;;;;;EAKV;;;;;IAKE,QAAQ;;;;;;;;YASA,iBAAiB,gBAAgB;;;;;EAK3C,QAAQ;;;;;;EAMR,gBACE,MAAM,kCACH,QAAQ,mBAAmB;;;;;EAKhC,WAAW,MAAM,oBAAoB,mBAAmB;IACtD,mBAAmB,iBAAiB;;;;;;;wBAQxB,UAAU,gBAAgB,WACxC,MAAM,iBAAiB,WACtB,SAAS;EAAW;;;;;;qBAqQV,2BAAkB;;;;;qBAMlB,+BAAsB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createChain, t as splitLink } from "./splitLink-IUbsOwO6.mjs";
1
+ import { n as createChain, t as splitLink } from "./splitLink-C8U8vvLl.mjs";
2
2
  import { n as isTRPCClientError, t as TRPCClientError } from "./TRPCClientError-DE6-fd1n.mjs";
3
3
  import { n as _defineProperty, t as _objectSpread2 } from "./objectSpread2-pyA4QVO4.mjs";
4
4
  import { c as allAbortSignals, d as throwIfAborted, f as getFetch, l as raceAbortSignals, n as getBody, o as resolveHTTPLinkOptions, r as getUrl, s as abortSignalToPromise, t as fetchHTTPResponse, u as raceAbortSignalsWithCleanup } from "./httpUtils-HxB0aY5z.mjs";
@@ -541,7 +541,7 @@ const unstable_httpSubscriptionLink = httpSubscriptionLink;
541
541
  /* istanbul ignore file -- @preserve */
542
542
  /**
543
543
  * Retries failed operations. Subscriptions resume from the last tracked event
544
- * id.
544
+ * id. A call can pass its own `retry` in `context`.
545
545
  *
546
546
  * @see https://trpc.io/docs/client/links/retryLink
547
547
  */
@@ -567,7 +567,8 @@ function retryLink(opts) {
567
567
  const subscription = callOpts.next(op).subscribe({
568
568
  error(error) {
569
569
  var _opts$retryDelayMs, _opts$retryDelayMs2;
570
- const shouldRetry = opts.retry({
570
+ const callRetry = op.context["retry"];
571
+ const shouldRetry = (typeof callRetry === "function" ? callRetry : opts.retry)({
571
572
  op,
572
573
  attempts,
573
574
  error