@trpc/client 11.32.1 → 11.33.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 (76) hide show
  1. package/dist/httpBatchLink-DRitkRBC.mjs.map +1 -1
  2. package/dist/{httpBatchLink-DbD4ZGAM.d.cts → httpBatchLink-DaVHWlLU.d.mts} +6 -4
  3. package/dist/{httpBatchLink-DbD4ZGAM.d.cts.map → httpBatchLink-DaVHWlLU.d.mts.map} +1 -1
  4. package/dist/{httpBatchLink-Dk3_n5pP.d.mts → httpBatchLink-_bkMj4mk.d.cts} +6 -4
  5. package/dist/{httpBatchLink-Dk3_n5pP.d.mts.map → httpBatchLink-_bkMj4mk.d.cts.map} +1 -1
  6. package/dist/httpLink-Cmg_mV7L.mjs.map +1 -1
  7. package/dist/{httpLink-BjZdBzr6.d.mts → httpLink-DN_Ana7a.d.mts} +6 -4
  8. package/dist/httpLink-DN_Ana7a.d.mts.map +1 -0
  9. package/dist/{httpUtils-CxgZ3W-1.d.cts → httpUtils-1z6dzl3V.d.cts} +2 -2
  10. package/dist/{httpUtils-CxgZ3W-1.d.cts.map → httpUtils-1z6dzl3V.d.cts.map} +1 -1
  11. package/dist/{httpUtils-gZ7bAQ6T.d.mts → httpUtils-BAs5frdP.d.mts} +2 -2
  12. package/dist/{httpUtils-gZ7bAQ6T.d.mts.map → httpUtils-BAs5frdP.d.mts.map} +1 -1
  13. package/dist/index.cjs +22 -14
  14. package/dist/index.d.cts +93 -21
  15. package/dist/index.d.cts.map +1 -1
  16. package/dist/index.d.mts +96 -24
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +22 -15
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/links/httpBatchLink.d.cts +1 -1
  21. package/dist/links/httpBatchLink.d.mts +1 -1
  22. package/dist/links/httpLink.d.cts +5 -3
  23. package/dist/links/httpLink.d.cts.map +1 -1
  24. package/dist/links/httpLink.d.mts +1 -1
  25. package/dist/links/loggerLink.d.cts +4 -2
  26. package/dist/links/loggerLink.d.cts.map +1 -1
  27. package/dist/links/loggerLink.d.mts +1 -1
  28. package/dist/links/loggerLink.mjs.map +1 -1
  29. package/dist/links/splitLink.cjs +1 -1
  30. package/dist/links/splitLink.d.cts +21 -8
  31. package/dist/links/splitLink.d.cts.map +1 -1
  32. package/dist/links/splitLink.d.mts +1 -1
  33. package/dist/links/splitLink.mjs +1 -1
  34. package/dist/links/wsLink/wsLink.d.cts +1 -1
  35. package/dist/links/wsLink/wsLink.d.mts +1 -1
  36. package/dist/{loggerLink-CBPx95zm.d.mts → loggerLink-CiVinJOG.d.mts} +5 -3
  37. package/dist/loggerLink-CiVinJOG.d.mts.map +1 -0
  38. package/dist/{splitLink-BBLj14Dv.cjs → splitLink-BQoYcpdp.cjs} +3 -0
  39. package/dist/splitLink-ClFN_nbg.d.mts +35 -0
  40. package/dist/splitLink-ClFN_nbg.d.mts.map +1 -0
  41. package/dist/{splitLink-PFsRy7Mf.mjs → splitLink-IUbsOwO6.mjs} +4 -1
  42. package/dist/splitLink-IUbsOwO6.mjs.map +1 -0
  43. package/dist/{types-BhHxuBsu.d.cts → types-DMe6B4SV.d.cts} +65 -8
  44. package/dist/types-DMe6B4SV.d.cts.map +1 -0
  45. package/dist/{types-BG-3kpeg.d.mts → types-DW0iJUBU.d.mts} +65 -8
  46. package/dist/types-DW0iJUBU.d.mts.map +1 -0
  47. package/dist/wsLink-C_Zg2yXV.mjs.map +1 -1
  48. package/dist/{wsLink-DU5wj6kH.d.mts → wsLink-DX5fv7-H.d.mts} +5 -3
  49. package/dist/{wsLink-BlAMQb0i.d.cts.map → wsLink-DX5fv7-H.d.mts.map} +1 -1
  50. package/dist/{wsLink-BlAMQb0i.d.cts → wsLink-DuyXOEPt.d.cts} +5 -3
  51. package/dist/{wsLink-DU5wj6kH.d.mts.map → wsLink-DuyXOEPt.d.cts.map} +1 -1
  52. package/package.json +3 -3
  53. package/skills/client-setup/SKILL.md +1 -1
  54. package/skills/links/SKILL.md +58 -1
  55. package/skills/superjson/SKILL.md +1 -1
  56. package/src/createTRPCClient.ts +88 -21
  57. package/src/index.ts +1 -0
  58. package/src/internals/types.ts +8 -5
  59. package/src/links/httpBatchLink.ts +6 -2
  60. package/src/links/httpBatchStreamLink.ts +6 -2
  61. package/src/links/httpLink.ts +6 -1
  62. package/src/links/httpSubscriptionLink.ts +6 -2
  63. package/src/links/localLink.ts +1 -1
  64. package/src/links/loggerLink.ts +11 -2
  65. package/src/links/retryLink.ts +6 -2
  66. package/src/links/splitLink.ts +52 -10
  67. package/src/links/types.ts +109 -3
  68. package/src/links/wsLink/wsLink.ts +1 -1
  69. package/src/routerType.ts +31 -0
  70. package/dist/httpLink-BjZdBzr6.d.mts.map +0 -1
  71. package/dist/loggerLink-CBPx95zm.d.mts.map +0 -1
  72. package/dist/splitLink-BtPz7lCB.d.mts +0 -23
  73. package/dist/splitLink-BtPz7lCB.d.mts.map +0 -1
  74. package/dist/splitLink-PFsRy7Mf.mjs.map +0 -1
  75. package/dist/types-BG-3kpeg.d.mts.map +0 -1
  76. package/dist/types-BhHxuBsu.d.cts.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { t as TRPCConnectionState } from "./subscriptions-CvJnusYO.mjs";
2
- import { a as OperationResultEnvelope, c as TRPCClientRuntime, d as TRPCClientError, f as TRPCClientErrorBase, g as NativeFetchEsque, h as FetchEsque, i as OperationLink, l as TRPCFetch, m as isTRPCClientError, n as Operation, o as OperationResultObservable, p as TRPCClientErrorLike, r as OperationContext, s as OperationResultObserver, t as HTTPHeaders, u as TRPCLink, v as TRPCProcedureOptions } from "./types-BG-3kpeg.mjs";
3
- import { n as HTTPBatchLinkOptions, t as httpBatchLink } from "./httpBatchLink-Dk3_n5pP.mjs";
4
- import { n as httpLink, t as HTTPLinkOptions } from "./httpLink-BjZdBzr6.mjs";
5
- import { n as loggerLink, t as LoggerLinkOptions } from "./loggerLink-CBPx95zm.mjs";
6
- import { t as splitLink } from "./splitLink-BtPz7lCB.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-DU5wj6kH.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";
8
8
  import { n as TransformerOptions } from "./unstable-internals-CnrO49lh.mjs";
9
- import { t as HTTPLinkBaseOptions } from "./httpUtils-gZ7bAQ6T.mjs";
9
+ import { t as HTTPLinkBaseOptions } from "./httpUtils-BAs5frdP.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";
@@ -107,6 +107,31 @@ export declare class TRPCUntypedClient<TInferrable extends InferrableClientTypes
107
107
  * Meant for libraries built on tRPC; apps should use `createTRPCClient`.
108
108
  */
109
109
  export declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<TRouter>;
110
+ declare const routerTypeBrand: unique symbol;
111
+ /**
112
+ * A value that carries a router's type and nothing else. Made by
113
+ * {@link routerType}.
114
+ * @public
115
+ */
116
+ export interface RouterType<TRouter extends AnyRouter> {
117
+ readonly [routerTypeBrand]: TRouter;
118
+ }
119
+ /**
120
+ * Passes a router's type to `createTRPCClient({ router })` as a normal
121
+ * option, instead of a type argument. Nothing about the router exists at
122
+ * runtime, so it's safe to import the router's type only.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const client = createTRPCClient({
127
+ * router: routerType<AppRouter>(),
128
+ * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
129
+ * });
130
+ * ```
131
+ * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
132
+ * @public
133
+ */
134
+ export declare function routerType<TRouter extends AnyRouter>(): RouterType<TRouter>;
110
135
  /**
111
136
  * @internal
112
137
  */
@@ -162,13 +187,16 @@ declare const untypedClientSymbol: unique symbol;
162
187
  /**
163
188
  * A typed client for a router, as `createTRPCClient` returns it. Each
164
189
  * procedure has `.query()`, `.mutate()` or `.subscribe()`.
190
+ *
191
+ * `TContext` is the `context` calls take; `createTRPCClient({ router,
192
+ * links })` infers it from the links.
165
193
  * @see https://trpc.io/docs/client/vanilla/infer-types
166
194
  * @public
167
195
  **/
168
- export type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<{
196
+ export type TRPCClient<TRouter extends AnyRouter, TContext extends object = Record<string, unknown>> = DecoratedProcedureRecord<{
169
197
  transformer: TRouter['_def']['_config']['$types']['transformer'];
170
198
  errorShape: TRouter['_def']['_config']['$types']['errorShape'];
171
- }, TRouter['_def']['record']> & {
199
+ }, TRouter['_def']['record'], TContext> & {
172
200
  [untypedClientSymbol]: TRPCUntypedClient<TRouter>;
173
201
  };
174
202
  /**
@@ -186,31 +214,31 @@ type coerceAsyncGeneratorToIterable<T> = T extends AsyncGenerator<infer $T, infe
186
214
  * The `.query()` or `.mutate()` of a procedure on the client.
187
215
  * @internal
188
216
  */
189
- export type Resolver<TDef extends TRPCResolverDef> = (input: TDef['input'], opts?: TRPCProcedureOptions) => TRPCTaggedPromise<coerceAsyncGeneratorToIterable<TDef['output']>, TDef['errorShape']>;
217
+ export type Resolver<TDef extends TRPCResolverDef, TContext extends object = Record<string, unknown>> = (input: TDef['input'], opts?: TRPCProcedureOptions<TContext>) => TRPCTaggedPromise<coerceAsyncGeneratorToIterable<TDef['output']>, TDef['errorShape']>;
190
218
  /**
191
219
  * The `.subscribe()` of a subscription procedure on the client.
192
220
  * @internal
193
221
  */
194
- export type SubscriptionResolver<TDef extends TRPCResolverDef> = {
195
- (input: TDef['input'], opts: TRPCSubscriptionCallbacks<TDef['output'], TRPCClientError<TDef>> & TRPCProcedureOptions): Unsubscribable;
196
- <TOpts extends TRPCProcedureOptions & Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> = TRPCProcedureOptions>(input: TDef['input'], opts?: TRPCSubscriptionWithoutCallbacks<TOpts>): AsyncIterableIterator<inferAsyncIterableYield<TDef['output']>>;
222
+ export type SubscriptionResolver<TDef extends TRPCResolverDef, TContext extends object = Record<string, unknown>> = {
223
+ (input: TDef['input'], opts: TRPCSubscriptionCallbacks<TDef['output'], TRPCClientError<TDef>> & TRPCProcedureOptions<TContext>): Unsubscribable;
224
+ <TOpts extends TRPCProcedureOptions<TContext> & Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> = TRPCProcedureOptions<TContext>>(input: TDef['input'], opts?: TRPCSubscriptionWithoutCallbacks<TOpts>): AsyncIterableIterator<inferAsyncIterableYield<TDef['output']>>;
197
225
  };
198
- type DecorateProcedure<TType extends ProcedureType, TDef extends TRPCResolverDef> = TType extends 'query' ? {
199
- query: Resolver<TDef>;
226
+ type DecorateProcedure<TType extends ProcedureType, TDef extends TRPCResolverDef, TContext extends object> = TType extends 'query' ? {
227
+ query: Resolver<TDef, TContext>;
200
228
  } : TType extends 'mutation' ? {
201
- mutate: Resolver<TDef>;
229
+ mutate: Resolver<TDef, TContext>;
202
230
  } : TType extends 'subscription' ? {
203
- subscribe: SubscriptionResolver<TDef>;
231
+ subscribe: SubscriptionResolver<TDef, TContext>;
204
232
  } : never;
205
233
  /**
206
234
  * @internal
207
235
  */
208
- type DecoratedProcedureRecord<TRoot extends InferrableClientTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
236
+ type DecoratedProcedureRecord<TRoot extends InferrableClientTypes, TRecord extends RouterRecord, TContext extends object> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
209
237
  input: inferProcedureInput<$Value>;
210
238
  output: inferTransformedProcedureOutput<inferClientTypes<TRoot>, $Value>;
211
239
  errorShape: inferProcedureErrorShape<TRoot, $Value>;
212
240
  transformer: inferClientTypes<TRoot>['transformer'];
213
- }> : $Value extends RouterRecord ? DecoratedProcedureRecord<TRoot, $Value> : never : never; };
241
+ }, TContext> : $Value extends RouterRecord ? DecoratedProcedureRecord<TRoot, $Value, TContext> : never : never; };
214
242
  /**
215
243
  * The procedure type of a client method: `query`, `mutate` or `subscribe`.
216
244
  * @internal
@@ -221,6 +249,42 @@ export declare const clientCallTypeToProcedureType: (clientCallType: string) =>
221
249
  * @internal
222
250
  */
223
251
  export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): TRPCClient<TRouter>;
252
+ /**
253
+ * The options of `createTRPCClient` with the router's type passed as
254
+ * `router: routerType<AppRouter>()`.
255
+ * @public
256
+ */
257
+ export type CreateTRPCClientWithRouterOptions<TRouter extends AnyRouter, TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[]> = Omit<CreateTRPCClientOptions<TRouter>, 'links'> & {
258
+ /**
259
+ * The router's type, from `routerType<AppRouter>()`. It's a type only:
260
+ * nothing about the router is sent or bundled.
261
+ */
262
+ router: RouterType<TRouter>;
263
+ /**
264
+ * The links each call goes through, in order. The last one must send
265
+ * the call, such as `httpBatchLink`. What they declare types each call's
266
+ * `context`, and which methods the client has. Pass them inline or
267
+ * `as const`: in an array declared without it, TypeScript can merge the
268
+ * links' types and drop what one declares.
269
+ * @see https://trpc.io/docs/client/links
270
+ */
271
+ links: TLinks;
272
+ };
273
+ /**
274
+ * Creates a typed client for a router. Pass the router's type with
275
+ * `routerType`, and the links that send its calls. What the links declare
276
+ * types each call's `context`.
277
+ * @example
278
+ * ```ts
279
+ * const client = createTRPCClient({
280
+ * router: routerType<AppRouter>(),
281
+ * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
282
+ * });
283
+ * const post = await client.post.byId.query({ id: '1' });
284
+ * ```
285
+ * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
286
+ */
287
+ export declare function createTRPCClient<TRouter extends AnyRouter, const TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[]>(opts: CreateTRPCClientWithRouterOptions<TRouter, TLinks>): TRPCClient<TRouter, inferLinksContext<TLinks>>;
224
288
  /**
225
289
  * Creates a typed client for a router. Pass the router's type, and the
226
290
  * links that send its calls.
@@ -266,7 +330,9 @@ export type HTTPBatchStreamLinkOptions<TRoot extends AnyClientTypes> = HTTPBatch
266
330
  *
267
331
  * @see https://trpc.io/docs/client/links/httpBatchStreamLink
268
332
  */
269
- export declare function httpBatchStreamLink<TRouter extends AnyRouter$1>(opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
333
+ export declare function httpBatchStreamLink<TRouter extends AnyRouter$1>(opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter, {
334
+ context: AugmentedOperationContext;
335
+ }>;
270
336
  /**
271
337
  * @deprecated Use {@link httpBatchStreamLink} instead.
272
338
  */
@@ -293,7 +359,9 @@ type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes, TEventSource exte
293
359
  *
294
360
  * @see https://trpc.io/docs/client/links/httpSubscriptionLink
295
361
  */
296
- export declare function httpSubscriptionLink<TInferrable extends InferrableClientTypes, TEventSource extends EventSourceLike.AnyConstructor>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>, TEventSource>): TRPCLink<TInferrable>;
362
+ export declare function httpSubscriptionLink<TInferrable extends InferrableClientTypes, TEventSource extends EventSourceLike.AnyConstructor>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>, TEventSource>): TRPCLink<TInferrable, {
363
+ context: AugmentedOperationContext;
364
+ }>;
297
365
  /**
298
366
  * @deprecated Use {@link httpSubscriptionLink} instead.
299
367
  */
@@ -328,7 +396,9 @@ interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
328
396
  *
329
397
  * @see https://trpc.io/docs/client/links/retryLink
330
398
  */
331
- export declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable>;
399
+ export declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable, {
400
+ context: AugmentedOperationContext;
401
+ }>;
332
402
  /**
333
403
  * Passed to {@link LocalLinkOptions.createContext}.
334
404
  */
@@ -374,7 +444,9 @@ export type LocalLinkOptions<TRouter extends AnyRouter> = {
374
444
  *
375
445
  * @see https://trpc.io/docs/client/links/localLink
376
446
  */
377
- export declare function localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter>;
447
+ export declare function localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter, {
448
+ context: {};
449
+ }>;
378
450
  /**
379
451
  * @deprecated Use {@link localLink} instead.
380
452
  * @function
@@ -385,5 +457,5 @@ export declare const unstable_localLink: typeof localLink;
385
457
  * future major release.
386
458
  */
387
459
  export declare const experimental_localLink: typeof localLink;
388
- export { type CreateTRPCClientOptions, type Encoder, HTTPBatchLinkOptions, HTTPHeaders, HTTPLinkOptions, LoggerLinkOptions, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, type SafeResult, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, type TRPCProcedureOptions, type TRPCTaggedPromise as TRPCPromise, type TRPCRequestOptions, type TRPCWebSocketClient, type WebSocketClientOptions, WebSocketLinkOptions, createTRPCClient as createTRPCProxyClient, createWSClient, httpBatchLink, httpLink, type inferRouterClient as inferRouterProxyClient, isTRPCClientError, jsonEncoder, loggerLink, splitLink, wsLink };
460
+ export { AugmentedOperationContext, type CreateTRPCClientOptions, type Encoder, HTTPBatchLinkOptions, HTTPHeaders, HTTPLinkOptions, LinkDecl, LoggerLinkOptions, NoLinkReadsContext, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, type SafeResult, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, type TRPCProcedureOptions, type TRPCTaggedPromise as TRPCPromise, type TRPCRequestOptions, type TRPCWebSocketClient, type WebSocketClientOptions, WebSocketLinkOptions, createTRPCClient as createTRPCProxyClient, createWSClient, httpBatchLink, httpLink, inferLinksContext, inferLinksDeclaredContext, type inferRouterClient as inferRouterProxyClient, isTRPCClientError, jsonEncoder, loggerLink, splitLink, wsLink };
389
461
  //# sourceMappingURL=index.d.mts.map
@@ -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/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,SACvC;;;;;;wBCnMW,wBAAwB,gBAAgB,WACtD,MAAM,wBAAwB,WAC7B,kBAAkB;;;;cCLA;;;;;KAMT,kBAAkB,OAAO,eAAe,QA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es.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,SACvC;;;;;;wBCnMW,wBAAwB,gBAAgB,WACtD,MAAM,wBAAwB,WAC7B,kBAAkB;cCRP;;;;;;iBAOG,WAAW,gBAAgB;YAChC,kBAAkB;;;;;;;;;;;;;;;;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AoB;;;;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"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createChain, t as splitLink } from "./splitLink-PFsRy7Mf.mjs";
1
+ import { n as createChain, t as splitLink } from "./splitLink-IUbsOwO6.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";
@@ -168,20 +168,8 @@ function createTRPCClientProxy(client) {
168
168
  return proxy[key];
169
169
  });
170
170
  }
171
- /**
172
- * Creates a typed client for a router. Pass the router's type, and the
173
- * links that send its calls.
174
- * @example
175
- * ```ts
176
- * const client = createTRPCClient<AppRouter>({
177
- * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
178
- * });
179
- * const post = await client.post.byId.query({ id: '1' });
180
- * ```
181
- * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
182
- */
183
171
  function createTRPCClient(opts) {
184
- return createTRPCClientProxy(new TRPCUntypedClient(opts));
172
+ return createTRPCClientProxy(new TRPCUntypedClient({ links: [...opts.links] }));
185
173
  }
186
174
  /**
187
175
  * The untyped client behind a typed client, which calls procedures by
@@ -191,6 +179,25 @@ function createTRPCClient(opts) {
191
179
  function getUntypedClient(client) {
192
180
  return client[untypedClientSymbol];
193
181
  }
182
+ // src/routerType.ts
183
+ /**
184
+ * Passes a router's type to `createTRPCClient({ router })` as a normal
185
+ * option, instead of a type argument. Nothing about the router exists at
186
+ * runtime, so it's safe to import the router's type only.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const client = createTRPCClient({
191
+ * router: routerType<AppRouter>(),
192
+ * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
193
+ * });
194
+ * ```
195
+ * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
196
+ * @public
197
+ */
198
+ function routerType() {
199
+ return {};
200
+ }
194
201
  // src/links/httpBatchStreamLink.ts
195
202
  /**
196
203
  * A terminating link that batches calls like `httpBatchLink`, but streams each
@@ -928,6 +935,6 @@ async function safe(promise) {
928
935
  return [void 0, cause];
929
936
  }
930
937
  }
931
- export { TRPCClientError, TRPCUntypedClient, clientCallTypeToProcedureType, createTRPCClient, createTRPCClient as createTRPCProxyClient, createTRPCClientProxy, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, jsonEncoder, localLink, loggerLink, retryLink, safe, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, unstable_localLink, wsLink };
938
+ export { TRPCClientError, TRPCUntypedClient, clientCallTypeToProcedureType, createTRPCClient, createTRPCClient as createTRPCProxyClient, createTRPCClientProxy, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, jsonEncoder, localLink, loggerLink, retryLink, routerType, safe, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, unstable_localLink, wsLink };
932
939
 
933
940
  //# sourceMappingURL=index.mjs.map