@trpc/client 11.33.0 → 11.34.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 (59) 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 +34 -11
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +37 -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 +1 -1
  48. package/skills/links/SKILL.md +3 -3
  49. package/skills/links/references/client-links-retryLink.md +28 -0
  50. package/skills/links/references/client-links-splitLink.md +22 -6
  51. package/skills/superjson/SKILL.md +1 -1
  52. package/src/createTRPCClient.ts +5 -2
  53. package/src/links/retryLink.ts +41 -10
  54. package/src/links/splitLink.ts +85 -14
  55. package/src/links/types.ts +5 -2
  56. package/dist/splitLink-ClFN_nbg.d.mts +0 -35
  57. package/dist/splitLink-ClFN_nbg.d.mts.map +0 -1
  58. package/dist/splitLink-IUbsOwO6.mjs.map +0 -1
  59. package/dist/types-DW0iJUBU.d.mts.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { t as _objectSpread2 } from "./objectSpread2-pyA4QVO4.mjs";
1
2
  import { observable } from "@trpc/server/observable";
2
3
  // src/links/internals/createChain.ts
3
4
  /** @internal */
@@ -20,24 +21,21 @@ function createChain(opts) {
20
21
  function asArray(value) {
21
22
  return Array.isArray(value) ? value : [value];
22
23
  }
23
- /**
24
- * Sends each operation down one of two link chains, based on `condition`.
25
- *
26
- * Calls take the `context` both chains read. `condition` may read the
27
- * fields added to `OperationContext`.
28
- *
29
- * @see https://trpc.io/docs/client/links/splitLink
30
- */
24
+ function withDefaults(defaults, context) {
25
+ const merged = _objectSpread2(_objectSpread2({}, defaults), context);
26
+ for (const key of Reflect.ownKeys(defaults)) if (merged[key] === void 0) merged[key] = defaults[key];
27
+ return merged;
28
+ }
31
29
  function splitLink(opts) {
32
30
  return (runtime) => {
33
31
  const yes = asArray(opts.true).map((link) => link(runtime));
34
32
  const no = asArray(opts.false).map((link) => link(runtime));
35
33
  return (props) => {
36
34
  return observable((observer) => {
37
- const links = opts.condition(props.op) ? yes : no;
35
+ const op = opts.context ? _objectSpread2(_objectSpread2({}, props.op), {}, { context: withDefaults(opts.context, props.op.context) }) : props.op;
38
36
  return createChain({
39
- op: props.op,
40
- links
37
+ op,
38
+ links: opts.condition(op) ? yes : no
41
39
  }).subscribe(observer);
42
40
  });
43
41
  };
@@ -45,4 +43,4 @@ function splitLink(opts) {
45
43
  }
46
44
  export { createChain as n, splitLink as t };
47
45
 
48
- //# sourceMappingURL=splitLink-IUbsOwO6.mjs.map
46
+ //# sourceMappingURL=splitLink-C8U8vvLl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitLink-C8U8vvLl.mjs","names":[],"sources":["../src/links/internals/createChain.ts","../src/links/splitLink.ts"],"sourcesContent":["import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport type {\n Operation,\n OperationLink,\n OperationResultObservable,\n} from '../types';\n\n/** @internal */\nexport function createChain<\n TRouter extends AnyRouter,\n TInput = unknown,\n TOutput = unknown,\n>(opts: {\n links: OperationLink<TRouter, TInput, TOutput>[];\n op: Operation<TInput>;\n}): OperationResultObservable<TRouter, TOutput> {\n return observable((observer) => {\n function execute(index = 0, op = opts.op) {\n const next = opts.links[index];\n if (!next) {\n throw new Error(\n 'No more links to execute - did you forget to add an ending link?',\n );\n }\n const subscription = next({\n op,\n next(nextOp) {\n const nextObserver = execute(index + 1, nextOp);\n\n return nextObserver;\n },\n });\n return subscription;\n }\n\n const obs$ = execute();\n return obs$.subscribe(observer);\n });\n}\n","import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport { createChain } from './internals/createChain';\nimport type {\n AugmentedOperationContext,\n inferLinksDeclaredContext,\n Operation,\n OperationContext,\n TRPCLink,\n} from './types';\n\nfunction asArray<TType>(value: TType | readonly TType[]): readonly TType[] {\n return Array.isArray(value) ? value : [value as TType];\n}\n\n// a field the call leaves out, or sets to `undefined`, takes its default\nfunction withDefaults(\n defaults: Record<PropertyKey, unknown>,\n context: OperationContext,\n): OperationContext {\n // spreading copies symbol keys too\n const merged: Record<PropertyKey, unknown> = { ...defaults, ...context };\n for (const key of Reflect.ownKeys(defaults)) {\n if (merged[key] === undefined) merged[key] = defaults[key];\n }\n return merged;\n}\n\n/**\n * A `splitLink` branch: one link or a chain of them.\n * @internal\n */\ntype SplitLinkBranch<TRouter extends AnyRouter> =\n | TRPCLink<TRouter, any>\n | readonly TRPCLink<TRouter, any>[];\n\n// a tuple, so links whose declarations nest aren't merged into one\ntype asLinks<TBranch> = TBranch extends readonly unknown[]\n ? TBranch\n : [TBranch];\n\ninterface SplitLinkOptions<\n TRouter extends AnyRouter,\n TTrue extends SplitLinkBranch<TRouter>,\n TFalse extends SplitLinkBranch<TRouter>,\n TContext extends object,\n> {\n /**\n * Picks the chain for an operation.\n */\n condition: (op: Operation<unknown, TContext>) => boolean;\n /**\n * The link to execute next if the test function returns `true`.\n */\n true: TTrue;\n /**\n * The link to execute next if the test function returns `false`.\n */\n false: TFalse;\n}\n\n// the types the branches' links read the defaults' fields as, so a\n// default that a branch would read as another type is an error\ntype fitBranchContext<TContext, TTrue, TFalse> =\n inferLinksDeclaredContext<\n [...asLinks<TTrue>, ...asLinks<TFalse>]\n > extends infer $Branches\n ? { [TKey in keyof TContext & keyof $Branches]: $Branches[TKey] }\n : never;\n\ntype SplitLink<\n TRouter extends AnyRouter,\n TTrue extends SplitLinkBranch<TRouter>,\n TFalse extends SplitLinkBranch<TRouter>,\n TContext extends object,\n> = TRPCLink<\n TRouter,\n {\n context: TContext &\n inferLinksDeclaredContext<[...asLinks<TTrue>, ...asLinks<TFalse>]>;\n }\n>;\n\n/**\n * Sends each operation down one of two link chains, based on `condition`.\n *\n * Calls take the `context` both chains read. Give `context` defaults to\n * declare the fields `condition` reads; without them, `condition` reads\n * the fields added to `OperationContext`.\n * @example\n * splitLink({\n * context: { skipBatch: false },\n * condition: (op) => op.context.skipBatch,\n * true: httpLink({ url }),\n * false: httpBatchLink({ url }),\n * })\n *\n * @see https://trpc.io/docs/client/links/splitLink\n */\nexport function splitLink<\n TRouter extends AnyRouter = AnyRouter,\n // with an explicit router type, a branch is still a link or an array\n const TTrue extends SplitLinkBranch<TRouter> = SplitLinkBranch<TRouter>,\n const TFalse extends SplitLinkBranch<TRouter> = SplitLinkBranch<TRouter>,\n>(\n opts: SplitLinkOptions<TRouter, TTrue, TFalse, OperationContext> & {\n context?: never;\n },\n // `condition` may read the fields added to `OperationContext`\n): SplitLink<TRouter, TTrue, TFalse, AugmentedOperationContext>;\nexport function splitLink<\n TRouter extends AnyRouter,\n const TTrue extends SplitLinkBranch<TRouter>,\n const TFalse extends SplitLinkBranch<TRouter>,\n TContext extends object,\n>(\n opts: SplitLinkOptions<TRouter, TTrue, TFalse, TContext> & {\n /**\n * Values for the `context` fields `condition` reads, used when a call\n * leaves one out. Their types are the fields calls can pass. A field a\n * call passes replaces its default whole: nested objects aren't merged.\n * A field the branches' links also read must fit their type.\n */\n context: TContext & fitBranchContext<TContext, TTrue, TFalse>;\n },\n): SplitLink<TRouter, TTrue, TFalse, TContext>;\nexport function splitLink(\n opts: SplitLinkOptions<\n AnyRouter,\n SplitLinkBranch<AnyRouter>,\n SplitLinkBranch<AnyRouter>,\n any\n > & { context?: Record<PropertyKey, unknown> },\n): TRPCLink<AnyRouter> {\n return (runtime) => {\n const yes = asArray(opts.true).map((link) => link(runtime));\n const no = asArray(opts.false).map((link) => link(runtime));\n return (props) => {\n return observable((observer) => {\n const op = opts.context\n ? {\n ...props.op,\n context: withDefaults(opts.context, props.op.context),\n }\n : props.op;\n const links = opts.condition(op) ? yes : no;\n return createChain({ op, links }).subscribe(observer);\n });\n };\n };\n}\n"],"mappings":";;;;AASA,SAAgB,YAId,MAG8C;CAC9C,OAAO,YAAY,aAAa;EAC9B,SAAS,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI;GACxC,MAAM,OAAO,KAAK,MAAM;GACxB,IAAI,CAAC,MACH,MAAM,IAAI,MACR,kEACF;GAUF,OARqB,KAAK;IACxB;IACA,KAAK,QAAQ;KAGX,OAFqB,QAAQ,QAAQ,GAAG,MAEtB;IACpB;GACF,CACkB;EACpB;EAGA,OADa,QACH,CAAC,CAAC,UAAU,QAAQ;CAChC,CAAC;AACH;;AC5BA,SAAS,QAAe,OAAmD;CACzE,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAc;AACvD;AAGA,SAAS,aACP,UACA,SACkB;CAElB,MAAM,SAAA,eAAA,eAAA,CAAA,GAA4C,QAAA,GAAa,OAAQ;CACvE,KAAK,MAAM,OAAO,QAAQ,QAAQ,QAAQ,GACxC,IAAI,OAAO,SAAS,KAAA,GAAW,OAAO,OAAO,SAAS;CAExD,OAAO;AACT;AAoGA,SAAgB,UACd,MAMqB;CACrB,QAAQ,YAAY;EAClB,MAAM,MAAM,QAAQ,KAAK,IAAI,CAAC,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC;EAC1D,MAAM,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC;EAC1D,QAAQ,UAAU;GAChB,OAAO,YAAY,aAAa;IAC9B,MAAM,KAAK,KAAK,UAAA,eAAA,eAAA,CAAA,GAEP,MAAM,EAAA,GAAA,CAAA,GAAA,EACT,SAAS,aAAa,KAAK,SAAS,MAAM,GAAG,OAAO,EAAA,CACtD,IACA,MAAM;IAEV,OAAO,YAAY;KAAE;KAAI,OADX,KAAK,UAAU,EAAE,IAAI,MAAM;IACV,CAAC,CAAC,CAAC,UAAU,QAAQ;GACtD,CAAC;EACH;CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ const require_objectSpread2 = require("./objectSpread2-Xm0br5eL.cjs");
1
2
  let _trpc_server_observable = require("@trpc/server/observable");
2
3
  // src/links/internals/createChain.ts
3
4
  /** @internal */
@@ -20,24 +21,21 @@ function createChain(opts) {
20
21
  function asArray(value) {
21
22
  return Array.isArray(value) ? value : [value];
22
23
  }
23
- /**
24
- * Sends each operation down one of two link chains, based on `condition`.
25
- *
26
- * Calls take the `context` both chains read. `condition` may read the
27
- * fields added to `OperationContext`.
28
- *
29
- * @see https://trpc.io/docs/client/links/splitLink
30
- */
24
+ function withDefaults(defaults, context) {
25
+ const merged = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, defaults), context);
26
+ for (const key of Reflect.ownKeys(defaults)) if (merged[key] === void 0) merged[key] = defaults[key];
27
+ return merged;
28
+ }
31
29
  function splitLink(opts) {
32
30
  return (runtime) => {
33
31
  const yes = asArray(opts.true).map((link) => link(runtime));
34
32
  const no = asArray(opts.false).map((link) => link(runtime));
35
33
  return (props) => {
36
34
  return (0, _trpc_server_observable.observable)((observer) => {
37
- const links = opts.condition(props.op) ? yes : no;
35
+ const op = opts.context ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.op), {}, { context: withDefaults(opts.context, props.op.context) }) : props.op;
38
36
  return createChain({
39
- op: props.op,
40
- links
37
+ op,
38
+ links: opts.condition(op) ? yes : no
41
39
  }).subscribe(observer);
42
40
  });
43
41
  };
@@ -160,13 +160,13 @@ type AugmentedOperationContext = { [TKey in keyof OperationContext as string ext
160
160
  * A procedure call as it goes through the links.
161
161
  * @internal
162
162
  */
163
- type Operation<TInput = unknown> = {
163
+ type Operation<TInput = unknown, TContext extends object = OperationContext> = {
164
164
  /** A number unique to the call within its client. */
165
165
  id: number;
166
166
  type: 'mutation' | 'query' | 'subscription';
167
167
  input: TInput;
168
168
  path: string;
169
- context: OperationContext;
169
+ context: TContext;
170
170
  signal: Maybe<AbortSignal>;
171
171
  };
172
172
  interface HeadersInitEsque {
@@ -269,4 +269,4 @@ type inferLinksDeclaredContext<TLinks extends readonly unknown[]> = UnionToInter
269
269
  */
270
270
  type inferLinksContext<TLinks extends readonly unknown[]> = inferLinksDeclaredContext<TLinks> extends (infer $Context) ? $Context extends unknown ? keyof $Context extends never ? NoLinkReadsContext : Simplify<Partial<$Context>> : never : never;
271
271
  export { TRPCProcedureOptions as C, NonEmptyArray as S, TRPCClientErrorBase as _, Operation as a, FetchEsque as b, OperationResultEnvelope as c, TRPCClientRuntime as d, TRPCFetch as f, TRPCClientError as g, inferLinksDeclaredContext as h, NoLinkReadsContext as i, OperationResultObservable as l, inferLinksContext as m, HTTPHeaders as n, OperationContext as o, TRPCLink as p, LinkDecl as r, OperationLink as s, AugmentedOperationContext as t, OperationResultObserver as u, TRPCClientErrorLike as v, NativeFetchEsque as x, isTRPCClientError as y };
272
- //# sourceMappingURL=types-DW0iJUBU.d.mts.map
272
+ //# sourceMappingURL=types-BZH1P86I.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BZH1P86I.d.mts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/types.ts"],"mappings":";;;;;;;;;;KAOY,cACV,OAAO,cAAc,cACrB,OAAO,cAAc,qBAClB,QAAQ;;;;;KAMD,oBACV,KAAK,cACL,OAAO,8BACJ,QAAQ;UAEI;EACf;;;;;;;;;UAUe;;;;EAIf,OAAO,2BAA2B,WAAW,eAAe,OAAO;;;;EAKnE,+BAA+B;;;;EAK/B;;;;EAKA,SAAS;;;;;;KAOC;EACV,iBAAiB,4BAA4B;;KAGnC;EACV,GACE,4BACA,cAAc,uBACb;;;;;;UAOY;WACN;WACA,OAAO,4BAA4B;;;;;;;EAO5C,QAAQ;;;;;KAME,cAAc,UAAU,UAAU;;;;;;;UAU7B,qBACf,0BAA0B;;;;;EAM1B,UAAU;;;;;;EAMV,SAAS;;KCpGN,gBAAgB,oBAAoB,yBACvC,iBAAiB;;UAEF,oBAAoB,eAAe;WACzC;;WAEA,OAAO,MAAM;;WAEb,MAAM,MAAM;;;;;;;KAOX,oBAAoB,oBAAoB,yBAClD,oBAAoB,gBAAgB;;;;;iBAMtB,kBAAkB,oBAAoB,uBACpD,iBACC,SAAS,gBAAgB;;;;;;cA4Bf,gBAAgB,2BAA2B,+BAC9C,iBACG,oBAAoB,gBAAgB;;WAKtB,OAAK;;WAEd,OAAO,MAAM,gBAAgB;;WAE7B,MAAM,MAAM,gBAAgB;;;;;;EAOrC,MAAI;EAEX,YACE,iBACA;IACE,SAAS,MAAM,kBAAkB,gBAAgB;IACjD,QAAQ;IACR,OAAO;;;;;;SAuBG,KAAK,2BAA2B,uBAC5C,QAAQ,QAAQ,iCAChB;IAAQ,OAAO;IAAyB,QAAQ;MAC/C,gBAAgB;;;;;;;UC3FJ,yBAAyB;;;;;;;;KAS9B,+BAER,cAAc,mCAAmC,eAAe,OAC/D,iBAAiB;;;;;KAOV,UACV,kBACA,0BAA0B;;EAG1B;EACA;EACA,OAAO;EACP;EACA,SAAS;EACT,QAAQ,MAAM;;UAGN;GACP,OAAO,aAAa;;;;;;KAOX,cACR,mBACA;;;;KAKQ,aACV,aACA,UAAU,gBACP,QAAQ;;UAGI;;;;;;UASA,wBAAwB,SAAS;EAChD,QACI,kBAAkB,qBAClB,oBAAoB,qBACpB,oBAAoB;EACxB,UAAU;;;;;;KAOA,0BACV,oBAAoB,uBACpB,WACE,WACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;KAON,wBACV,oBAAoB,uBACpB,WACE,SACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;;;KASN,cACV,oBAAoB,uBACpB,kBACA,sBACG;EACH,IAAI,UAAU;EACd,OACE,IAAI,UAAU,YACX,0BAA0B,aAAa;MACxC,0BAA0B,aAAa;;;;;;;UAQ5B;;;;;EAKf;;;;;;;;;;;KAYU,SACV,oBAAoB,uBACpB,cAAc,WAAW,cACrB,MAAM,sBAAsB,cAAc;;WAErC,UAAU;;KAGhB,oBAAoB,WACvB,sBAAsB,KAAK,mCAClB,WAAW,0BAClB;KAKC,cAAc,SAAS,8CACF,QACpB,YAAY,sBAAsB,UAClC;KAGD,iBAAiB,SAAS,wBAE3B,iBAAiB,QACf,mBACA;EAAgB,eAAe;IAC7B;cAIM;;;;;;KAUF;YACA;;;;;;;KAQA,0BAA0B,qCAGpC,oBACE,8BAA6B,SACzB;EACI,SAAS,iBAAiB,cAAc;;EAGtC,eAAe;IACvB;;;;;;KAQM,kBAAkB,qCAC5B,0BAA0B,uBAAsB,YAE5C,iCACQ,yBACJ,qBAEA,SAAS,QAAQ"}
@@ -170,13 +170,13 @@ type AugmentedOperationContext = { [TKey in keyof OperationContext as string ext
170
170
  * A procedure call as it goes through the links.
171
171
  * @internal
172
172
  */
173
- type Operation<TInput = unknown> = {
173
+ type Operation<TInput = unknown, TContext extends object = OperationContext> = {
174
174
  /** A number unique to the call within its client. */
175
175
  id: number;
176
176
  type: 'mutation' | 'query' | 'subscription';
177
177
  input: TInput;
178
178
  path: string;
179
- context: OperationContext;
179
+ context: TContext;
180
180
  signal: Maybe<AbortSignal>;
181
181
  };
182
182
  interface HeadersInitEsque {
@@ -279,4 +279,4 @@ type inferLinksDeclaredContext<TLinks extends readonly unknown[]> = UnionToInter
279
279
  */
280
280
  type inferLinksContext<TLinks extends readonly unknown[]> = inferLinksDeclaredContext<TLinks> extends (infer $Context) ? $Context extends unknown ? keyof $Context extends never ? NoLinkReadsContext : Simplify<Partial<$Context>> : never : never;
281
281
  export { FetchEsque as C, TRPCProcedureOptions as E, isTRPCClientError as S, NonEmptyArray as T, isNonJsonSerializable as _, Operation as a, TRPCClientErrorBase as b, OperationResultEnvelope as c, TRPCClientRuntime as d, TRPCFetch as f, isFormData as g, inferLinksDeclaredContext as h, NoLinkReadsContext as i, OperationResultObservable as l, inferLinksContext as m, HTTPHeaders as n, OperationContext as o, TRPCLink as p, LinkDecl as r, OperationLink as s, AugmentedOperationContext as t, OperationResultObserver as u, isOctetType as v, NativeFetchEsque as w, TRPCClientErrorLike as x, TRPCClientError as y };
282
- //# sourceMappingURL=types-DMe6B4SV.d.cts.map
282
+ //# sourceMappingURL=types-CGS36fjk.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-DMe6B4SV.d.cts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/internals/contentTypes.ts","../src/links/types.ts"],"mappings":";;;;;;;;;;KAOY,cACV,OAAO,cAAc,cACrB,OAAO,cAAc,qBAClB,QAAQ;;;;;KAMD,oBACV,KAAK,cACL,OAAO,8BACJ,QAAQ;UAEI;EACf;;;;;;;;;UAUe;;;;EAIf,OAAO,2BAA2B,WAAW,eAAe,OAAO;;;;EAKnE,+BAA+B;;;;EAK/B;;;;EAKA,SAAS;;;;;;KAOC;EACV,iBAAiB,4BAA4B;;KAGnC;EACV,GACE,4BACA,cAAc,uBACb;;;;;;UAOY;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wBACV,oBAAoB,uBACpB,WACE,SACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;;;KASN,cACV,oBAAoB,uBACpB,kBACA,sBACG;EACH,IAAI,UAAU;EACd,OACE,IAAI,UAAU,YACX,0BAA0B,aAAa;MACxC,0BAA0B,aAAa;;;;;;;UAQ5B;;;;;EAKf;;;;;;;;;;;KAYU,SACV,oBAAoB,uBACpB,cAAc,WAAW,cACrB,MAAM,sBAAsB,cAAc;;WAErC,UAAU;;KAGhB,oBAAoB,WACvB,sBAAsB,KAAK,mCAClB,WAAW,0BAClB;KAKC,cAAc,SAAS,8CACF,QACpB,YAAY,sBAAsB,UAClC;KAGD,iBAAiB,SAAS,wBAE3B,iBAAiB,QACf,mBACA;EAAgB,eAAe;IAC7B;cAIM;;;;;;KAUF;YACA;;;;;;;KAQA,0BAA0B,qCAGpC,oBACE,8BAA6B,SACzB;EACI,SAAS,iBAAiB,cAAc;;EAGtC,eAAe;IACvB;;;;;;KAQM,kBAAkB,qCAC5B,0BAA0B,uBAAsB,YAE5C,iCACQ,yBACJ,qBAEA,SAAS,QAAQ"}
1
+ {"version":3,"file":"types-CGS36fjk.d.cts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/internals/contentTypes.ts","../src/links/types.ts"],"mappings":";;;;;;;;;;KAOY,cACV,OAAO,cAAc,cACrB,OAAO,cAAc,qBAClB,QAAQ;;;;;KAMD,oBACV,KAAK,cACL,OAAO,8BACJ,QAAQ;UAEI;EACf;;;;;;;;;UAUe;;;;EAIf,OAAO,2BAA2B,WAAW,eAAe,OAAO;;;;EAKnE,+BAA+B;;;;EAK/B;;;;EAKA,SAAS;;;;;;KAOC;EACV,iBAAiB,4BAA4B;;KAGnC;EACV,GACE,4BACA,cAAc,uBACb;;;;;;UAOY;WACN;WACA,OAAO,4BAA4B;;;;;;;EAO5C,QAAQ;;;;;KAME,cAAc,UAAU,UAAU;;;;;;;UAU7B,qBACf,0BAA0B;;;;;EAM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pB,kBACA,sBACG;EACH,IAAI,UAAU;EACd,OACE,IAAI,UAAU,YACX,0BAA0B,aAAa;MACxC,0BAA0B,aAAa;;;;;;;UAQ5B;;;;;EAKf;;;;;;;;;;;KAYU,SACV,oBAAoB,uBACpB,cAAc,WAAW,cACrB,MAAM,sBAAsB,cAAc;;WAErC,UAAU;;KAGhB,oBAAoB,WACvB,sBAAsB,KAAK,mCAClB,WAAW,0BAClB;KAKC,cAAc,SAAS,8CACF,QACpB,YAAY,sBAAsB,UAClC;KAGD,iBAAiB,SAAS,wBAE3B,iBAAiB,QACf,mBACA;EAAgB,eAAe;IAC7B;cAIM;;;;;;KAUF;YACA;;;;;;;KAQA,0BAA0B,qCAGpC,oBACE,8BAA6B,SACzB;EACI,SAAS,iBAAiB,cAAc;;EAGtC,eAAe;IACvB;;;;;;KAQM,kBAAkB,qCAC5B,0BAA0B,uBAAsB,YAE5C,iCACQ,yBACJ,qBAEA,SAAS,QAAQ"}
@@ -1,5 +1,5 @@
1
1
  import { n as TransformerOptions } from "./unstable-internals-CnrO49lh.mjs";
2
- import { a as Operation, c as OperationResultEnvelope, g as TRPCClientError, p as TRPCLink } from "./types-DW0iJUBU.mjs";
2
+ import { a as Operation, c as OperationResultEnvelope, g as TRPCClientError, p as TRPCLink } from "./types-BZH1P86I.mjs";
3
3
  import { t as TRPCConnectionState } from "./subscriptions-CvJnusYO.mjs";
4
4
  import { BehaviorSubject } from "@trpc/server/observable";
5
5
  import { AnyRouter, CombinedDataTransformer, Encoder, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
@@ -309,4 +309,4 @@ declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TR
309
309
  context: {};
310
310
  }>;
311
311
  export { WebSocketClientOptions as a, jsonEncoder as c, createWSClient as i, wsLink as n, UrlOptionsWithConnectionParams as o, TRPCWebSocketClient as r, Encoder as s, WebSocketLinkOptions as t };
312
- //# sourceMappingURL=wsLink-DX5fv7-H.d.mts.map
312
+ //# sourceMappingURL=wsLink-CFh-pvQG.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wsLink-DX5fv7-H.d.mts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","../src/links/wsLink/wsLink.ts"],"mappings":";;;;;;;;;;cAOa,aAAa;;;;KCWd,gBAAgB,KAAK,WAAW,IAAI,QAAQ;UAEvC;;;;EAIf,KAAK;;;;;;;EAQL,mBAAmB,gBAAgB;;;;;;;UCxBpB,+BAA+B;;;;EAI9C,mBAAmB;;;;;EAKnB,gBAAgB;;;;EAIhB;;;;EAIA,WAAW,MAAM;;;;EAIjB,WAAW;IAAU;;;;;EAIrB;;;;;IAKE;;;;;IAKA;;;;;EAKF;;;;IAIE;;;;;IAKA;;;;;IAKA;;;;;;EAMF,uBAAuB;;;;;;cCWZ;;;;WAIK,iBAAiB,gBAC/B,oBAAoB,gBAAgB;UAG9B;UACA;;;;;;;UASA;mBACS;;;;;;UAMT;mBACS;UACT;;;;;UAKA;mBACS;mBAIA;mBACA;mBACA;EAEjB,YAAY,MAAM;;;;;;UA4DV;UAUA;;;;;UAeM;;;;;EAmDD,SAAK;;;;;;;;;;;EAqDX,UACL,MAAM,MAAM,MAAM,OAAO,UACzB,aACA;IAEA,IAAI,KAAK;IACT,aAAa;IACb;wCACD,WAAA,iCAAA,gBAAA,iBAAA,gBAAA;;;;MAwEU;;;;;;;;;;;;;;;;;;UAaH;;;;UAIA;;;;;UAKA;;;;;;UAMA;;;;UAIA;;;;;;;;;;;UAWA;;mBAES;;;;;;;;;UAUT;;;;;;;;UA2FA;;;;;;;UA8CA;UAiBA;UASA;;;;UAaA;;;;;;UAWA;;;;;UAaA;UA0BA;UAqNA;UA+DA;;;;UASA;;;;;;UAqBA;;;;;UAWA;;;;;;;;iBCh9BM,eAAe,MAAM,yBAAsB;;;;KAO/C,sBAAsB,kBAAkB;;;;;;KCIxC,qBAAqB,gBAAgB;;;;EAI/C,QAAQ;IACN,mBAAmB,iBAAiB;;;;;;iBAOxB,OAAO,gBAAgB,WACrC,MAAM,qBAAqB,WAC1B,SAAS;EAAW"}
1
+ {"version":3,"file":"wsLink-CFh-pvQG.d.mts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","../src/links/wsLink/wsLink.ts"],"mappings":";;;;;;;;;;cAOa,aAAa;;;;KCWd,gBAAgB,KAAK,WAAW,IAAI,QAAQ;UAEvC;;;;EAIf,KAAK;;;;;;;EAQL,mBAAmB,gBAAgB;;;;;;;UCxBpB,+BAA+B;;;;EAI9C,mBAAmB;;;;;EAKnB,gBAAgB;;;;EAIhB;;;;EAIA,WAAW,MAAM;;;;EAIjB,WAAW;IAAU;;;;;EAIrB;;;;;IAKE;;;;;IAKA;;;;;EAKF;;;;IAIE;;;;;IAKA;;;;;IAKA;;;;;;EAMF,uBAAuB;;;;;;cCWZ;;;;WAIK,iBAAiB,gBAC/B,oBAAoB,gBAAgB;UAG9B;UACA;;;;;;;UASA;mBACS;;;;;;UAMT;mBACS;UACT;;;;;UAKA;mBACS;mBAIA;mBACA;mBACA;EAEjB,YAAY,MAAM;;;;;;UA4DV;UAUA;;;;;UAeM;;;;;EAmDD,SAAK;;;;;;;;;;;EAqDX,UACL,MAAM,MAAM,MAAM,OAAO,UACzB,aACA;IAEA,IAAI,KAAK;IACT,aAAa;IACb;wCACD,WAAA,iCAAA,gBAAA,iBAAA,gBAAA;;;;MAwEU;;;;;;;;;;;;;;;;;;UAaH;;;;UAIA;;;;;UAKA;;;;;;UAMA;;;;UAIA;;;;;;;;;;;UAWA;;mBAES;;;;;;;;;UAUT;;;;;;;;UA2FA;;;;;;;UA8CA;UAiBA;UASA;;;;UAaA;;;;;;UAWA;;;;;UAaA;UA0BA;UAqNA;UA+DA;;;;UASA;;;;;;UAqBA;;;;;UAWA;;;;;;;;iBCh9BM,eAAe,MAAM,yBAAsB;;;;KAO/C,sBAAsB,kBAAkB;;;;;;KCIxC,qBAAqB,gBAAgB;;;;EAI/C,QAAQ;IACN,mBAAmB,iBAAiB;;;;;;iBAOxB,OAAO,gBAAgB,WACrC,MAAM,qBAAqB,WAC1B,SAAS;EAAW"}
@@ -1,5 +1,5 @@
1
1
  import { TransformerOptions } from "./unstable-internals.cjs";
2
- import { a as Operation, c as OperationResultEnvelope, p as TRPCLink, y as TRPCClientError } from "./types-DMe6B4SV.cjs";
2
+ import { a as Operation, c as OperationResultEnvelope, p as TRPCLink, y as TRPCClientError } from "./types-CGS36fjk.cjs";
3
3
  import { t as TRPCConnectionState } from "./subscriptions-CvJnusYO.cjs";
4
4
  import { AnyRouter, CombinedDataTransformer, Encoder, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
5
5
  import { BehaviorSubject } from "@trpc/server/observable";
@@ -309,4 +309,4 @@ declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TR
309
309
  context: {};
310
310
  }>;
311
311
  export { WebSocketClientOptions as a, jsonEncoder as c, createWSClient as i, wsLink as n, UrlOptionsWithConnectionParams as o, TRPCWebSocketClient as r, Encoder as s, WebSocketLinkOptions as t };
312
- //# sourceMappingURL=wsLink-DuyXOEPt.d.cts.map
312
+ //# sourceMappingURL=wsLink-CJT5pqFt.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wsLink-DuyXOEPt.d.cts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","../src/links/wsLink/wsLink.ts"],"mappings":";;;;;;;;;;cAOa,aAAa;;;;KCWd,gBAAgB,KAAK,WAAW,IAAI,QAAQ;UAEvC;;;;EAIf,KAAK;;;;;;;EAQL,mBAAmB,gBAAgB;;;;;;;UCxBpB,+BAA+B;;;;EAI9C,mBAAmB;;;;;EAKnB,gBAAgB;;;;EAIhB;;;;EAIA,WAAW,MAAM;;;;EAIjB,WAAW;IAAU;;;;;EAIrB;;;;;IAKE;;;;;IAKA;;;;;EAKF;;;;IAIE;;;;;IAKA;;;;;IAKA;;;;;;EAMF,uBAAuB;;;;;;cCWZ;;;;WAIK,iBAAiB,gBAC/B,oBAAoB,gBAAgB;UAG9B;UACA;;;;;;;UASA;mBACS;;;;;;UAMT;mBACS;UACT;;;;;UAKA;mBACS;mBAIA;mBACA;mBACA;EAEjB,YAAY,MAAM;;;;;;UA4DV;UAUA;;;;;UAeM;;;;;EAmDD,SAAK;;;;;;;;;;;EAqDX,UACL,MAAM,MAAM,MAAM,OAAO,UACzB,aACA;IAEA,IAAI,KAAK;IACT,aAAa;IACb;wCACD,WAAA,iCAAA,gBAAA,iBAAA,gBAAA;;;;MAwEU;;;;;;;;;;;;;;;;;;UAaH;;;;UAIA;;;;;UAKA;;;;;;UAMA;;;;UAIA;;;;;;;;;;;UAWA;;mBAES;;;;;;;;;UAUT;;;;;;;;UA2FA;;;;;;;UA8CA;UAiBA;UASA;;;;UAaA;;;;;;UAWA;;;;;UAaA;UA0BA;UAqNA;UA+DA;;;;UASA;;;;;;UAqBA;;;;;UAWA;;;;;;;;iBCh9BM,eAAe,MAAM,yBAAsB;;;;KAO/C,sBAAsB,kBAAkB;;;;;;KCIxC,qBAAqB,gBAAgB;;;;EAI/C,QAAQ;IACN,mBAAmB,iBAAiB;;;;;;iBAOxB,OAAO,gBAAgB,WACrC,MAAM,qBAAqB,WAC1B,SAAS;EAAW"}
1
+ {"version":3,"file":"wsLink-CJT5pqFt.d.cts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","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",
4
4
  "sideEffects": false,
5
- "version": "11.33.0",
5
+ "version": "11.34.0",
6
6
  "description": "The tRPC client library",
7
7
  "author": "KATT",
8
8
  "license": "MIT",
@@ -100,12 +100,12 @@
100
100
  "skills"
101
101
  ],
102
102
  "peerDependencies": {
103
- "@trpc/server": "11.33.0",
103
+ "@trpc/server": "11.34.0",
104
104
  "typescript": ">=5.7.2"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@tanstack/intent": "0.5.6",
108
- "@trpc/server": "11.33.0",
108
+ "@trpc/server": "11.34.0",
109
109
  "@types/isomorphic-fetch": "^0.0.39",
110
110
  "@types/node": "^24.19.2",
111
111
  "dataloader": "^2.2.3",
@@ -12,7 +12,7 @@ sources:
12
12
  metadata:
13
13
  type: core
14
14
  library: trpc
15
- library_version: 11.33.0
15
+ library_version: 11.34.0
16
16
  ---
17
17
 
18
18
  <!-- Generated from www/v11/docs/client/vanilla/setup.md by www/build/skills.ts. Edit the docs instead. -->
@@ -17,7 +17,7 @@ sources:
17
17
  metadata:
18
18
  type: core
19
19
  library: trpc
20
- library_version: 11.33.0
20
+ library_version: 11.34.0
21
21
  ---
22
22
 
23
23
  <!-- Generated from www/v11/docs/client/links.md by www/build/skills.ts. Edit the docs instead. -->
@@ -108,7 +108,7 @@ The `links` array that you add to the tRPC client config should have at least on
108
108
  | Link | Use it for |
109
109
  | --- | --- |
110
110
  | [`httpBatchLink`](https://trpc.io/docs/client/links/httpBatchLink) | Queries and mutations. Calls made together, for example in a `Promise.all`, are sent as one HTTP request. |
111
- | [`httpLink`](https://trpc.io/docs/client/links/httpLink) | One HTTP request per call, for example to [skip batching](https://trpc.io/docs/client/links/splitLink#disable-batching-for-certain-requests) or to send [`FormData` and binary inputs](https://trpc.io/docs/server/non-json-content-types). |
111
+ | [`httpLink`](https://trpc.io/docs/client/links/httpLink) | One HTTP request per call, for example to [skip batching](https://trpc.io/docs/client/links/splitLink#typed-context) or to send [`FormData` and binary inputs](https://trpc.io/docs/server/non-json-content-types). |
112
112
  | [`httpBatchStreamLink`](https://trpc.io/docs/client/links/httpBatchStreamLink) | Batching, but each response is streamed as soon as it's ready. Required for procedures that return async generators or promises nested in the output. |
113
113
  | [`httpSubscriptionLink`](https://trpc.io/docs/client/links/httpSubscriptionLink) | Subscriptions over Server-sent Events. |
114
114
  | [`wsLink`](https://trpc.io/docs/client/links/wsLink) | Any operation over a WebSocket. |
@@ -150,7 +150,7 @@ For an example use case, see [Disable batching for certain requests](https://trp
150
150
 
151
151
  ### Typing call options
152
152
 
153
- Create the client with `router: routerType<AppRouter>()` and the `context` each call takes is typed from the links. A link declares what it reads with the second type argument of `TRPCLink`.
153
+ Create the client with `router: routerType<AppRouter>()` and the `context` each call takes is typed from the links. A link declares what it reads with the second type argument of `TRPCLink`. Built-in links declare theirs: [`retryLink`](https://trpc.io/docs/client/links/retryLink#changing-retries-for-one-call) reads `retry`.
154
154
 
155
155
  ```ts no-check
156
156
  import type { TRPCLink } from '@trpc/client';
@@ -52,6 +52,34 @@ In the example above, we add the `retryLink` before the `httpBatchLink`. The `re
52
52
  - Retry the request if the error is a `TRPCClientError` with a status code of 500 or if we couldn't get a valid tRPC error.
53
53
  - Retry the request up to 3 times.
54
54
 
55
+ ## Changing retries for one call
56
+
57
+ Pass a `retry` function in a call's `context` to use it instead of the link's `retry` for that call. With `router: routerType<AppRouter>()`, it's typed like the link's.
58
+
59
+ ```ts no-check
60
+ import {
61
+ createTRPCClient,
62
+ httpBatchLink,
63
+ retryLink,
64
+ routerType,
65
+ } from '@trpc/client';
66
+ import type { AppRouter } from './server';
67
+
68
+ const client = createTRPCClient({
69
+ router: routerType<AppRouter>(),
70
+ links: [
71
+ // retry queries and mutations
72
+ retryLink({ retry: (opts) => opts.attempts <= 3 }),
73
+ httpBatchLink({ url: 'http://localhost:3000' }),
74
+ ],
75
+ });
76
+
77
+ // never send a payment twice
78
+ await client.createPayment.mutate(undefined, {
79
+ context: { retry: () => false },
80
+ });
81
+ ```
82
+
55
83
  ## Options
56
84
 
57
85
  ```ts no-check
@@ -20,24 +20,27 @@ Let's say you're using `httpBatchLink` as the terminating link in your tRPC clie
20
20
 
21
21
  #### 1. Configure client / `utils/trpc.ts`
22
22
 
23
+ `context` gives the fields `condition` reads, with their defaults:
24
+
23
25
  ```ts no-check title="client/index.ts"
24
26
  import {
25
27
  createTRPCClient,
26
28
  httpBatchLink,
27
29
  httpLink,
30
+ routerType,
28
31
  splitLink,
29
32
  } from '@trpc/client';
30
33
  import type { AppRouter } from './server';
31
34
 
32
35
  const url = `http://localhost:3000`;
33
36
 
34
- const client = createTRPCClient<AppRouter>({
37
+ const client = createTRPCClient({
38
+ router: routerType<AppRouter>(),
35
39
  links: [
36
40
  splitLink({
37
- condition(op) {
38
- // check for context property `skipBatch`
39
- return Boolean(op.context.skipBatch);
40
- },
41
+ // the `context` this condition reads, with its defaults
42
+ context: { skipBatch: false },
43
+ condition: (op) => op.context.skipBatch,
41
44
  // when condition is true, use normal request
42
45
  true: httpLink({
43
46
  url,
@@ -84,12 +87,25 @@ export function MyComponent() {
84
87
  }
85
88
  ```
86
89
 
90
+ ### Typed `context`
91
+
92
+ With `context: { skipBatch: false }` and `router: routerType<AppRouter>()`, calls take `skipBatch?: boolean`, so passing anything else is a type error. A call that leaves it out, or passes `undefined`, gets `false`. A field the call passes replaces its default whole: nested objects aren't merged. Without `context`, calls take only what the branches' links declare.
93
+
87
94
  ## `splitLink` Options
88
95
 
89
- The `splitLink` function takes an options object that has three fields: `condition`, `true`, and `false`.
96
+ The `splitLink` function takes an options object with `condition`, `true` and `false`, and optionally `context`.
90
97
 
91
98
  ```ts no-check
92
99
  declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
100
+ /**
101
+ * Values for the `context` fields `condition` reads, used when a call
102
+ * leaves one out. Their types are the fields calls can pass. Without it,
103
+ * calls take only what the branches' links declare.
104
+ */
105
+ context?: Record<string, unknown>;
106
+ /**
107
+ * Picks the chain for an operation.
108
+ */
93
109
  condition: (op: Operation) => boolean;
94
110
  /**
95
111
  * The link to execute next if the test function returns `true`.
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: composition
11
11
  library: trpc
12
- library_version: 11.33.0
12
+ library_version: 11.34.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/data-transformers.md by www/build/skills.ts. Edit the docs instead. -->
@@ -238,9 +238,12 @@ export type CreateTRPCClientWithRouterOptions<
238
238
  * ```ts
239
239
  * const client = createTRPCClient({
240
240
  * router: routerType<AppRouter>(),
241
- * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
241
+ * links: [retryLink({ retry: () => false }), httpBatchLink({ url })],
242
242
  * });
243
- * const post = await client.post.byId.query({ id: '1' });
243
+ * const post = await client.post.byId.query(
244
+ * { id: '1' },
245
+ * { context: { retry: (opts) => opts.attempts <= 3 } },
246
+ * );
244
247
  * ```
245
248
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
246
249
  */
@@ -7,18 +7,47 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';
7
7
  import type { TRPCClientError } from '../TRPCClientError';
8
8
  import type { AugmentedOperationContext, Operation, TRPCLink } from './types';
9
9
 
10
+ type RetryFn<TInferrable extends InferrableClientTypes> = (
11
+ opts: RetryFnOptions<TInferrable>,
12
+ ) => boolean;
13
+
14
+ /**
15
+ * The `context` calls can pass through `retryLink`: the fields added to
16
+ * `OperationContext` (`TAugmented`), which its callbacks may read, and
17
+ * `retry`.
18
+ * @public
19
+ */
20
+ export type RetryLinkContext<
21
+ TInferrable extends InferrableClientTypes,
22
+ TAugmented extends object = AugmentedOperationContext,
23
+ > = Omit<TAugmented, 'retry'> & {
24
+ /**
25
+ * Decides whether to retry this call, in place of the link's `retry`.
26
+ * Anything else, such as a flag added to `OperationContext` that the
27
+ * link's `retry` reads, is left to the link.
28
+ * @example client.post.byId.query(input, { context: { retry: (opts) => opts.attempts <= 3 } })
29
+ */
30
+ retry?:
31
+ | RetryFn<TInferrable>
32
+ | ('retry' extends keyof TAugmented ? TAugmented['retry'] : never);
33
+ };
34
+
10
35
  interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
11
36
  /**
12
- * The retry function
37
+ * The retry function. A call's `context.retry` replaces it for that call.
13
38
  */
14
- retry: (opts: RetryFnOptions<TInferrable>) => boolean;
39
+ retry: RetryFn<TInferrable>;
15
40
  /**
16
41
  * The delay between retries in ms (defaults to 0)
17
42
  */
18
43
  retryDelayMs?: (attempt: number) => number;
19
44
  }
20
45
 
21
- interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
46
+ /**
47
+ * What a `retry` function is given.
48
+ * @public
49
+ */
50
+ export interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
22
51
  /**
23
52
  * The operation that failed
24
53
  */
@@ -35,17 +64,13 @@ interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
35
64
 
36
65
  /**
37
66
  * Retries failed operations. Subscriptions resume from the last tracked event
38
- * id.
67
+ * id. A call can pass its own `retry` in `context`.
39
68
  *
40
69
  * @see https://trpc.io/docs/client/links/retryLink
41
70
  */
42
71
  export function retryLink<TInferrable extends InferrableClientTypes>(
43
72
  opts: RetryLinkOptions<TInferrable>,
44
- ): TRPCLink<
45
- TInferrable,
46
- // its callbacks may read the fields added to `OperationContext`
47
- { context: AugmentedOperationContext }
48
- > {
73
+ ): TRPCLink<TInferrable, { context: RetryLinkContext<TInferrable> }> {
49
74
  // initialized config
50
75
  return () => {
51
76
  // initialized in app
@@ -83,7 +108,13 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
83
108
 
84
109
  const subscription = callOpts.next(op).subscribe({
85
110
  error(error) {
86
- const shouldRetry = opts.retry({
111
+ const callRetry = op.context['retry'];
112
+ // a `retry` that isn't a function is a flag for the link's own `retry`
113
+ const retry =
114
+ typeof callRetry === 'function'
115
+ ? (callRetry as RetryFn<TInferrable>)
116
+ : opts.retry;
117
+ const shouldRetry = retry({
87
118
  op,
88
119
  attempts,
89
120
  error,
@@ -5,6 +5,7 @@ import type {
5
5
  AugmentedOperationContext,
6
6
  inferLinksDeclaredContext,
7
7
  Operation,
8
+ OperationContext,
8
9
  TRPCLink,
9
10
  } from './types';
10
11
 
@@ -12,6 +13,19 @@ function asArray<TType>(value: TType | readonly TType[]): readonly TType[] {
12
13
  return Array.isArray(value) ? value : [value as TType];
13
14
  }
14
15
 
16
+ // a field the call leaves out, or sets to `undefined`, takes its default
17
+ function withDefaults(
18
+ defaults: Record<PropertyKey, unknown>,
19
+ context: OperationContext,
20
+ ): OperationContext {
21
+ // spreading copies symbol keys too
22
+ const merged: Record<PropertyKey, unknown> = { ...defaults, ...context };
23
+ for (const key of Reflect.ownKeys(defaults)) {
24
+ if (merged[key] === undefined) merged[key] = defaults[key];
25
+ }
26
+ return merged;
27
+ }
28
+
15
29
  /**
16
30
  * A `splitLink` branch: one link or a chain of them.
17
31
  * @internal
@@ -29,11 +43,12 @@ interface SplitLinkOptions<
29
43
  TRouter extends AnyRouter,
30
44
  TTrue extends SplitLinkBranch<TRouter>,
31
45
  TFalse extends SplitLinkBranch<TRouter>,
46
+ TContext extends object,
32
47
  > {
33
48
  /**
34
49
  * Picks the chain for an operation.
35
50
  */
36
- condition: (op: Operation) => boolean;
51
+ condition: (op: Operation<unknown, TContext>) => boolean;
37
52
  /**
38
53
  * The link to execute next if the test function returns `true`.
39
54
  */
@@ -44,11 +59,41 @@ interface SplitLinkOptions<
44
59
  false: TFalse;
45
60
  }
46
61
 
62
+ // the types the branches' links read the defaults' fields as, so a
63
+ // default that a branch would read as another type is an error
64
+ type fitBranchContext<TContext, TTrue, TFalse> =
65
+ inferLinksDeclaredContext<
66
+ [...asLinks<TTrue>, ...asLinks<TFalse>]
67
+ > extends infer $Branches
68
+ ? { [TKey in keyof TContext & keyof $Branches]: $Branches[TKey] }
69
+ : never;
70
+
71
+ type SplitLink<
72
+ TRouter extends AnyRouter,
73
+ TTrue extends SplitLinkBranch<TRouter>,
74
+ TFalse extends SplitLinkBranch<TRouter>,
75
+ TContext extends object,
76
+ > = TRPCLink<
77
+ TRouter,
78
+ {
79
+ context: TContext &
80
+ inferLinksDeclaredContext<[...asLinks<TTrue>, ...asLinks<TFalse>]>;
81
+ }
82
+ >;
83
+
47
84
  /**
48
85
  * Sends each operation down one of two link chains, based on `condition`.
49
86
  *
50
- * Calls take the `context` both chains read. `condition` may read the
51
- * fields added to `OperationContext`.
87
+ * Calls take the `context` both chains read. Give `context` defaults to
88
+ * declare the fields `condition` reads; without them, `condition` reads
89
+ * the fields added to `OperationContext`.
90
+ * @example
91
+ * splitLink({
92
+ * context: { skipBatch: false },
93
+ * condition: (op) => op.context.skipBatch,
94
+ * true: httpLink({ url }),
95
+ * false: httpBatchLink({ url }),
96
+ * })
52
97
  *
53
98
  * @see https://trpc.io/docs/client/links/splitLink
54
99
  */
@@ -58,22 +103,48 @@ export function splitLink<
58
103
  const TTrue extends SplitLinkBranch<TRouter> = SplitLinkBranch<TRouter>,
59
104
  const TFalse extends SplitLinkBranch<TRouter> = SplitLinkBranch<TRouter>,
60
105
  >(
61
- opts: SplitLinkOptions<TRouter, TTrue, TFalse>,
62
- ): TRPCLink<
63
- TRouter,
64
- {
65
- // `condition` may read the fields added to `OperationContext`
66
- context: AugmentedOperationContext &
67
- inferLinksDeclaredContext<[...asLinks<TTrue>, ...asLinks<TFalse>]>;
68
- }
69
- > {
106
+ opts: SplitLinkOptions<TRouter, TTrue, TFalse, OperationContext> & {
107
+ context?: never;
108
+ },
109
+ // `condition` may read the fields added to `OperationContext`
110
+ ): SplitLink<TRouter, TTrue, TFalse, AugmentedOperationContext>;
111
+ export function splitLink<
112
+ TRouter extends AnyRouter,
113
+ const TTrue extends SplitLinkBranch<TRouter>,
114
+ const TFalse extends SplitLinkBranch<TRouter>,
115
+ TContext extends object,
116
+ >(
117
+ opts: SplitLinkOptions<TRouter, TTrue, TFalse, TContext> & {
118
+ /**
119
+ * Values for the `context` fields `condition` reads, used when a call
120
+ * leaves one out. Their types are the fields calls can pass. A field a
121
+ * call passes replaces its default whole: nested objects aren't merged.
122
+ * A field the branches' links also read must fit their type.
123
+ */
124
+ context: TContext & fitBranchContext<TContext, TTrue, TFalse>;
125
+ },
126
+ ): SplitLink<TRouter, TTrue, TFalse, TContext>;
127
+ export function splitLink(
128
+ opts: SplitLinkOptions<
129
+ AnyRouter,
130
+ SplitLinkBranch<AnyRouter>,
131
+ SplitLinkBranch<AnyRouter>,
132
+ any
133
+ > & { context?: Record<PropertyKey, unknown> },
134
+ ): TRPCLink<AnyRouter> {
70
135
  return (runtime) => {
71
136
  const yes = asArray(opts.true).map((link) => link(runtime));
72
137
  const no = asArray(opts.false).map((link) => link(runtime));
73
138
  return (props) => {
74
139
  return observable((observer) => {
75
- const links = opts.condition(props.op) ? yes : no;
76
- return createChain({ op: props.op, links }).subscribe(observer);
140
+ const op = opts.context
141
+ ? {
142
+ ...props.op,
143
+ context: withDefaults(opts.context, props.op.context),
144
+ }
145
+ : props.op;
146
+ const links = opts.condition(op) ? yes : no;
147
+ return createChain({ op, links }).subscribe(observer);
77
148
  });
78
149
  };
79
150
  };