@trpc/client 11.34.0 → 11.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -289,6 +289,9 @@ export declare function createTRPCClient<TRouter extends AnyRouter, const TLinks
289
289
  * const post = await client.post.byId.query({ id: '1' });
290
290
  * ```
291
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.
292
295
  */
293
296
  export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
294
297
  /**
@@ -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,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,YA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d,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;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"}
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":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;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
@@ -299,6 +299,9 @@ export declare function createTRPCClient<TRouter extends AnyRouter, const TLinks
299
299
  * const post = await client.post.byId.query({ id: '1' });
300
300
  * ```
301
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.
302
305
  */
303
306
  export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
304
307
  /**
@@ -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;;;UAIM,yBAAyB,QAAQ;;EAEhD,YAAY;IAAQ,SAAS;;;EAE7B,SAAS,OAAO,wBAAwB;;EAExC,UAAU,KAAK;;;;;EAKf;;EAEA;;EAEA,0BAA0B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B,UAAU,gBAAgB,WACxC,MAAM,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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gBAErC,MAAM,4BACJ,iBAAiB,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/createTRPCClient.ts","../src/routerType.ts","../src/links/httpBatchStreamLink.ts","../src/internals/inputWithTrackedEventId.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts","../src/safe.ts"],"sourcesContent":["import type {\n inferObservableValue,\n Unsubscribable,\n} from '@trpc/server/observable';\nimport {\n observable,\n observableToAsyncIterable,\n observableToPromise,\n share,\n} from '@trpc/server/observable';\nimport type {\n AnyRouter,\n inferAsyncIterableYield,\n InferrableClientTypes,\n Maybe,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createChain } from '../links/internals/createChain';\nimport type { TRPCConnectionState } from '../links/internals/subscriptions';\nimport type {\n OperationContext,\n OperationLink,\n TRPCClientRuntime,\n TRPCLink,\n} from '../links/types';\nimport { TRPCClientError } from '../TRPCClientError';\n\ntype TRPCType = 'mutation' | 'query' | 'subscription';\n/** The options of a call made with the untyped client. */\nexport interface TRPCRequestOptions {\n /**\n * Context for the links, such as a flag a `splitLink` reads.\n * @see https://trpc.io/docs/client/links#managing-context\n */\n context?: OperationContext;\n /**\n * Aborts the call. With `httpBatchLink`, the request is only aborted once\n * every call in its batch is, so an aborted call can still get a result.\n */\n signal?: AbortSignal;\n}\n\n/** The callbacks a subscription takes on the client. */\nexport interface TRPCSubscriptionObserver<TValue, TError> {\n /** Called when the link sends a `started` result. */\n onStarted: (opts: { context: OperationContext | undefined }) => void;\n /** Called with each event. */\n onData: (value: inferAsyncIterableYield<TValue>) => void;\n /** Called when the subscription ends with an error. */\n onError: (err: TError) => void;\n /**\n * Called when the link sends a `stopped` result. Not every link sends\n * one; `localLink` doesn't.\n */\n onStopped: () => void;\n /** Called when the subscription's observable completes, for any reason. */\n onComplete: () => void;\n /** Called when the connection connects, drops or reconnects. */\n onConnectionStateChange: (state: TRPCConnectionState<TError>) => void;\n}\n\ntype ObserverKey = keyof TRPCSubscriptionObserver<unknown, unknown>;\n\n/**\n * Subscription options without callbacks: `TOpts` must not have any of the\n * callback keys, not even set to `undefined`.\n * @internal\n */\nexport type TRPCSubscriptionWithoutCallbacks<TOpts> = TOpts & {\n // `keyof` a union only has its shared keys, so this one catches each member\n [TKey in ObserverKey]?: never;\n} & {\n [TKey in keyof TOpts & ObserverKey]: never;\n};\n\n/**\n * Subscription callbacks, at least one of which is defined.\n * @internal\n */\nexport type TRPCSubscriptionCallbacks<TValue, TError> = Partial<\n TRPCSubscriptionObserver<TValue, TError>\n> &\n {\n [TKey in ObserverKey]: Pick<TRPCSubscriptionObserver<TValue, TError>, TKey>;\n }[ObserverKey];\n\nconst observerKeys: ObserverKey[] = [\n 'onStarted',\n 'onData',\n 'onError',\n 'onStopped',\n 'onComplete',\n 'onConnectionStateChange',\n];\n\n/**\n * The options of `createTRPCClient`.\n * @internal\n */\nexport type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {\n /**\n * The links each call goes through, in order. The last one must send\n * the call, such as `httpBatchLink`.\n * @see https://trpc.io/docs/client/links\n */\n links: TRPCLink<TRouter>[];\n transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;\n};\n\n/**\n * A client that calls procedures by path string, without types.\n * `createTRPCClient` wraps one.\n */\nexport class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {\n private readonly links: OperationLink<TInferrable>[];\n public readonly runtime: TRPCClientRuntime;\n private requestId: number;\n\n constructor(opts: CreateTRPCClientOptions<TInferrable>) {\n this.requestId = 0;\n\n this.runtime = {};\n\n // Initialize the links\n this.links = opts.links.map((link) => link(this.runtime));\n }\n\n private $request<TInput = unknown, TOutput = unknown>(opts: {\n type: TRPCType;\n input: TInput;\n path: string;\n context?: OperationContext;\n signal: Maybe<AbortSignal>;\n }) {\n const chain$ = createChain<AnyRouter, TInput, TOutput>({\n links: this.links as OperationLink<any, any, any>[],\n op: {\n ...opts,\n context: opts.context ?? {},\n id: ++this.requestId,\n },\n });\n return chain$.pipe(share());\n }\n\n private async requestAsPromise<TInput = unknown, TOutput = unknown>(opts: {\n type: TRPCType;\n input: TInput;\n path: string;\n context?: OperationContext;\n signal: Maybe<AbortSignal>;\n }): Promise<TOutput> {\n try {\n const req$ = this.$request<TInput, TOutput>(opts);\n type TValue = inferObservableValue<typeof req$>;\n\n const envelope = await observableToPromise<TValue>(req$);\n const data = (envelope.result as any).data;\n return data;\n } catch (err) {\n throw TRPCClientError.from(err as Error);\n }\n }\n /** Calls a query. */\n public query(path: string, input?: unknown, opts?: TRPCRequestOptions) {\n return this.requestAsPromise<unknown, unknown>({\n type: 'query',\n path,\n input,\n context: opts?.context,\n signal: opts?.signal,\n });\n }\n /** Calls a mutation. */\n public mutation(path: string, input?: unknown, opts?: TRPCRequestOptions) {\n return this.requestAsPromise<unknown, unknown>({\n type: 'mutation',\n path,\n input,\n context: opts?.context,\n signal: opts?.signal,\n });\n }\n /**\n * Starts a subscription. With callbacks, returns what stops it. Without,\n * returns an async iterator to read it with `for await`, which `signal`,\n * `break` or `return()` stops. It can be iterated once.\n * @see https://trpc.io/docs/client/vanilla/setup#5-use-subscriptions\n */\n public subscription(\n path: string,\n input: unknown,\n opts: TRPCSubscriptionCallbacks<unknown, TRPCClientError<AnyRouter>> &\n TRPCRequestOptions,\n ): Unsubscribable;\n public subscription<\n TOpts extends TRPCRequestOptions &\n Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>> =\n TRPCRequestOptions,\n >(\n path: string,\n input: unknown,\n opts?: TRPCSubscriptionWithoutCallbacks<TOpts>,\n ): AsyncIterableIterator<unknown>;\n public subscription(\n path: string,\n input: unknown,\n opts: Partial<\n TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>\n > &\n TRPCRequestOptions = {},\n ): Unsubscribable | AsyncIterableIterator<unknown> {\n const hasCallbacks = observerKeys.some(\n (key) => typeof opts[key] === 'function',\n );\n const observable$ = this.$request({\n type: 'subscription',\n path,\n input,\n context: opts.context,\n signal: opts.signal,\n });\n if (!hasCallbacks) {\n const data$ = observable<unknown, TRPCClientError<AnyRouter>>(\n (observer) =>\n observable$.subscribe({\n next(envelope) {\n if (\n envelope.result.type === 'data' ||\n envelope.result.type === undefined\n ) {\n observer.next(envelope.result.data);\n }\n },\n error: (err) => observer.error(err),\n complete: () => observer.complete(),\n }),\n );\n const iterator = observableToAsyncIterable(\n data$,\n opts.signal ?? new AbortController().signal,\n );\n // a second loop over the same iterator would split the data with the\n // first, or end straight away once the first has left\n let iterated = false;\n iterator[Symbol.asyncIterator] = () => {\n if (iterated) {\n throw new Error(\n 'A subscription can only be iterated once. Call subscribe() again for another loop.',\n );\n }\n iterated = true;\n return iterator;\n };\n return iterator;\n }\n return observable$.subscribe({\n next(envelope) {\n switch (envelope.result.type) {\n case 'state': {\n opts.onConnectionStateChange?.(envelope.result);\n break;\n }\n case 'started': {\n opts.onStarted?.({\n context: envelope.context,\n });\n break;\n }\n case 'stopped': {\n opts.onStopped?.();\n break;\n }\n case 'data':\n case undefined: {\n opts.onData?.(envelope.result.data);\n break;\n }\n }\n },\n error(err) {\n opts.onError?.(err);\n },\n complete() {\n opts.onComplete?.();\n },\n });\n }\n}\n","import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport type { CreateTRPCClientOptions } from './internals/TRPCUntypedClient';\nimport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\n\n/**\n * Creates a client that calls procedures by path string, without types.\n * Meant for libraries built on tRPC; apps should use `createTRPCClient`.\n */\nexport function createTRPCUntypedClient<TRouter extends AnyRouter>(\n opts: CreateTRPCClientOptions<TRouter>,\n): TRPCUntypedClient<TRouter> {\n return new TRPCUntypedClient(opts);\n}\n\nexport type {\n CreateTRPCClientOptions,\n TRPCRequestOptions,\n} from './internals/TRPCUntypedClient';\nexport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\n","/* oxlint-disable typescript/no-non-null-assertion */\nimport type { Unsubscribable } from '@trpc/server/observable';\nimport type {\n AnyProcedure,\n AnyRouter,\n inferAsyncIterableYield,\n inferClientTypes,\n inferProcedureErrorShape,\n inferProcedureInput,\n InferrableClientTypes,\n inferTransformedProcedureOutput,\n ProcedureType,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n createFlatProxy,\n createRecursiveProxy,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type { CreateTRPCClientOptions } from './createTRPCUntypedClient';\nimport type {\n TRPCSubscriptionCallbacks,\n TRPCSubscriptionObserver,\n TRPCSubscriptionWithoutCallbacks,\n} from './internals/TRPCUntypedClient';\nimport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\nimport type { TRPCProcedureOptions } from './internals/types';\nimport type { inferLinksContext, TRPCLink } from './links/types';\nimport type { RouterType } from './routerType';\nimport type { TRPCTaggedPromise } from './safe';\nimport type { TRPCClientError } from './TRPCClientError';\n\n/**\n * The type of a client for a router.\n * @deprecated Use {@link TRPCClient} instead. This will be removed in v12.\n * @public\n **/\nexport type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;\n\n/**\n * The type of a client for a router.\n * @deprecated Use {@link TRPCClient} instead. This will be removed in v12.\n * @public\n **/\nexport type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;\n\nconst untypedClientSymbol = Symbol.for('trpc_untypedClient');\n\n/**\n * A typed client for a router, as `createTRPCClient` returns it. Each\n * procedure has `.query()`, `.mutate()` or `.subscribe()`.\n *\n * `TContext` is the `context` calls take; `createTRPCClient({ router,\n * links })` infers it from the links.\n * @see https://trpc.io/docs/client/vanilla/infer-types\n * @public\n **/\nexport type TRPCClient<\n TRouter extends AnyRouter,\n TContext extends object = Record<string, unknown>,\n> = DecoratedProcedureRecord<\n {\n transformer: TRouter['_def']['_config']['$types']['transformer'];\n errorShape: TRouter['_def']['_config']['$types']['errorShape'];\n },\n TRouter['_def']['record'],\n TContext\n> & {\n [untypedClientSymbol]: TRPCUntypedClient<TRouter>;\n};\n\n/**\n * A procedure's types, as the client sees them.\n * @internal\n */\nexport type TRPCResolverDef = {\n input: any;\n output: any;\n transformer: boolean;\n errorShape: any;\n};\n\ntype coerceAsyncGeneratorToIterable<T> =\n T extends AsyncGenerator<infer $T, infer $Return, infer $Next>\n ? AsyncIterable<$T, $Return, $Next>\n : T;\n\n/**\n * The `.query()` or `.mutate()` of a procedure on the client.\n * @internal\n */\nexport type Resolver<\n TDef extends TRPCResolverDef,\n TContext extends object = Record<string, unknown>,\n> = (\n input: TDef['input'],\n opts?: TRPCProcedureOptions<TContext>,\n) => TRPCTaggedPromise<\n coerceAsyncGeneratorToIterable<TDef['output']>,\n TDef['errorShape']\n>;\n\n/**\n * The `.subscribe()` of a subscription procedure on the client.\n * @internal\n */\nexport type SubscriptionResolver<\n TDef extends TRPCResolverDef,\n TContext extends object = Record<string, unknown>,\n> = {\n (\n input: TDef['input'],\n opts: TRPCSubscriptionCallbacks<TDef['output'], TRPCClientError<TDef>> &\n TRPCProcedureOptions<TContext>,\n ): Unsubscribable;\n <\n TOpts extends TRPCProcedureOptions<TContext> &\n Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> =\n TRPCProcedureOptions<TContext>,\n >(\n input: TDef['input'],\n opts?: TRPCSubscriptionWithoutCallbacks<TOpts>,\n ): AsyncIterableIterator<inferAsyncIterableYield<TDef['output']>>;\n};\n\ntype DecorateProcedure<\n TType extends ProcedureType,\n TDef extends TRPCResolverDef,\n TContext extends object,\n> = TType extends 'query'\n ? { query: Resolver<TDef, TContext> }\n : TType extends 'mutation'\n ? { mutate: Resolver<TDef, TContext> }\n : TType extends 'subscription'\n ? { subscribe: SubscriptionResolver<TDef, TContext> }\n : never;\n\n/**\n * @internal\n */\ntype DecoratedProcedureRecord<\n TRoot extends InferrableClientTypes,\n TRecord extends RouterRecord,\n TContext extends object,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<\n $Value['_def']['type'],\n {\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<\n inferClientTypes<TRoot>,\n $Value\n >;\n errorShape: inferProcedureErrorShape<TRoot, $Value>;\n transformer: inferClientTypes<TRoot>['transformer'];\n },\n TContext\n >\n : $Value extends RouterRecord\n ? DecoratedProcedureRecord<TRoot, $Value, TContext>\n : never\n : never;\n};\n\nconst clientCallTypeMap: Record<\n keyof DecorateProcedure<any, any, any>,\n ProcedureType\n> = {\n query: 'query',\n mutate: 'mutation',\n subscribe: 'subscription',\n};\n\n/**\n * The procedure type of a client method: `query`, `mutate` or `subscribe`.\n * @internal\n */\nexport const clientCallTypeToProcedureType = (\n clientCallType: string,\n): ProcedureType => {\n return clientCallTypeMap[clientCallType as keyof typeof clientCallTypeMap];\n};\n\n/**\n * Wraps an untyped client in the typed proxy `createTRPCClient` returns.\n * @internal\n */\nexport function createTRPCClientProxy<TRouter extends AnyRouter>(\n client: TRPCUntypedClient<TRouter>,\n): TRPCClient<TRouter> {\n const proxy = createRecursiveProxy<TRPCClient<TRouter>>(({ path, args }) => {\n const pathCopy = [...path];\n const procedureType = clientCallTypeToProcedureType(pathCopy.pop()!);\n\n const fullPath = pathCopy.join('.');\n\n return (client[procedureType] as any)(fullPath, ...(args as any));\n });\n return createFlatProxy<TRPCClient<TRouter>>((key) => {\n if (key === untypedClientSymbol) {\n return client;\n }\n return proxy[key];\n });\n}\n\n/**\n * The options of `createTRPCClient` with the router's type passed as\n * `router: routerType<AppRouter>()`.\n * @public\n */\nexport type CreateTRPCClientWithRouterOptions<\n TRouter extends AnyRouter,\n TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[],\n> = Omit<CreateTRPCClientOptions<TRouter>, 'links'> & {\n /**\n * The router's type, from `routerType<AppRouter>()`. It's a type only:\n * nothing about the router is sent or bundled.\n */\n router: RouterType<TRouter>;\n /**\n * The links each call goes through, in order. The last one must send\n * the call, such as `httpBatchLink`. What they declare types each call's\n * `context`, and which methods the client has. Pass them inline or\n * `as const`: in an array declared without it, TypeScript can merge the\n * links' types and drop what one declares.\n * @see https://trpc.io/docs/client/links\n */\n links: TLinks;\n};\n\n/**\n * Creates a typed client for a router. Pass the router's type with\n * `routerType`, and the links that send its calls. What the links declare\n * types each call's `context`.\n * @example\n * ```ts\n * const client = createTRPCClient({\n * router: routerType<AppRouter>(),\n * links: [retryLink({ retry: () => false }), httpBatchLink({ url })],\n * });\n * const post = await client.post.byId.query(\n * { id: '1' },\n * { context: { retry: (opts) => opts.attempts <= 3 } },\n * );\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n */\nexport function createTRPCClient<\n TRouter extends AnyRouter,\n // with an explicit router type, the links aren't inferred\n const TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[],\n>(\n opts: CreateTRPCClientWithRouterOptions<TRouter, TLinks>,\n): TRPCClient<TRouter, inferLinksContext<TLinks>>;\n/**\n * Creates a typed client for a router. Pass the router's type, and the\n * links that send its calls.\n * @example\n * ```ts\n * const client = createTRPCClient<AppRouter>({\n * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],\n * });\n * const post = await client.post.byId.query({ id: '1' });\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n */\n// Kept last: `ReturnType<typeof createTRPCClient>` reads the last overload.\nexport function createTRPCClient<TRouter extends AnyRouter>(\n opts: CreateTRPCClientOptions<TRouter>,\n): TRPCClient<TRouter>;\nexport function createTRPCClient<TRouter extends AnyRouter>(\n opts: Omit<CreateTRPCClientOptions<TRouter>, 'links'> & {\n links: readonly TRPCLink<TRouter, any>[];\n },\n): TRPCClient<TRouter> {\n // `router` is a type only, so the untyped client ignores it\n const client = new TRPCUntypedClient<TRouter>({\n links: [...opts.links],\n });\n const proxy = createTRPCClientProxy<TRouter>(client);\n return proxy;\n}\n\n/**\n * The untyped client behind a typed client, which calls procedures by\n * path string.\n * @internal\n */\nexport function getUntypedClient<TRouter extends AnyRouter>(\n client: TRPCClient<TRouter>,\n): TRPCUntypedClient<TRouter> {\n return client[untypedClientSymbol];\n}\n","import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\n\ndeclare const routerTypeBrand: unique symbol;\n\n/**\n * A value that carries a router's type and nothing else. Made by\n * {@link routerType}.\n * @public\n */\nexport interface RouterType<TRouter extends AnyRouter> {\n readonly [routerTypeBrand]: TRouter;\n}\n\n/**\n * Passes a router's type to `createTRPCClient({ router })` as a normal\n * option, instead of a type argument. Nothing about the router exists at\n * runtime, so it's safe to import the router's type only.\n *\n * @example\n * ```ts\n * const client = createTRPCClient({\n * router: routerType<AppRouter>(),\n * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],\n * });\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n * @public\n */\nexport function routerType<TRouter extends AnyRouter>(): RouterType<TRouter> {\n return {} as RouterType<TRouter>;\n}\n","import type { AnyRouter, ProcedureType } from '@trpc/server';\nimport { observable } from '@trpc/server/observable';\nimport type { TRPCErrorShape, TRPCResponse } from '@trpc/server/rpc';\nimport type { AnyClientTypes } from '@trpc/server/unstable-core-do-not-import';\nimport { jsonlStreamConsumer } from '@trpc/server/unstable-core-do-not-import';\nimport type { BatchLoader } from '../internals/dataLoader';\nimport { dataLoader } from '../internals/dataLoader';\nimport {\n allAbortSignals,\n raceAbortSignals,\n raceAbortSignalsWithCleanup,\n} from '../internals/signals';\nimport type { NonEmptyArray } from '../internals/types';\nimport { TRPCClientError } from '../TRPCClientError';\nimport type { HTTPBatchLinkOptions } from './HTTPBatchLinkOptions';\nimport type { HTTPResult } from './internals/httpUtils';\nimport {\n fetchHTTPResponse,\n getBody,\n getUrl,\n resolveHTTPLinkOptions,\n} from './internals/httpUtils';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\n/**\n * Options for {@link httpBatchStreamLink}. Takes the same options as\n * `httpBatchLink`, plus `streamHeader`.\n *\n * @see https://trpc.io/docs/client/links/httpBatchStreamLink#options\n */\nexport type HTTPBatchStreamLinkOptions<TRoot extends AnyClientTypes> =\n HTTPBatchLinkOptions<TRoot> & {\n /**\n * Which header to use to signal the server that the client wants a streaming response.\n * - `'trpc-accept'` (default): sends `trpc-accept: application/jsonl` header\n * - `'accept'`: sends `Accept: application/jsonl` header, which can avoid CORS preflight for cross-origin streaming queries. Be aware that `application/jsonl` is not an official MIME type and so this is not completely spec-compliant - you should test that your infrastructure supports this value.\n * @default 'trpc-accept'\n */\n streamHeader?: 'trpc-accept' | 'accept';\n };\n\ntype BatchStreamOperation = Operation & {\n releaseSignal: () => void;\n /** Aborts the op's signal once its response has nothing left to stream */\n settle: () => void;\n};\n\n/**\n * A terminating link that batches calls like `httpBatchLink`, but streams each\n * response back as soon as it is ready.\n *\n * @see https://trpc.io/docs/client/links/httpBatchStreamLink\n */\nexport function httpBatchStreamLink<TRouter extends AnyRouter>(\n opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>,\n): TRPCLink<\n TRouter,\n // its callbacks may read the fields added to `OperationContext`\n { context: AugmentedOperationContext }\n> {\n const resolvedOpts = resolveHTTPLinkOptions(opts);\n const maxURLLength = opts.maxURLLength ?? Infinity;\n const maxItems = opts.maxItems ?? Infinity;\n\n return () => {\n const batchLoader = (\n type: ProcedureType,\n ): BatchLoader<BatchStreamOperation, HTTPResult> => {\n return {\n validate(batchOps) {\n if (maxURLLength === Infinity && maxItems === Infinity) {\n // escape hatch for quick calcs\n return true;\n }\n if (batchOps.length > maxItems) {\n return false;\n }\n const path = batchOps.map((op) => op.path).join(',');\n const inputs = batchOps.map((op) => op.input);\n\n const url = getUrl({\n ...resolvedOpts,\n type,\n path,\n inputs,\n signal: null,\n });\n\n return url.length <= maxURLLength;\n },\n async fetch(batchOps) {\n const path = batchOps.map((op) => op.path).join(',');\n const inputs = batchOps.map((op) => op.input);\n\n const batchSignals = allAbortSignals(\n ...batchOps.map((op) => op.signal),\n );\n const abortController = new AbortController();\n abortController.signal.addEventListener(\n 'abort',\n () => {\n for (const op of batchOps) {\n op.releaseSignal();\n }\n },\n { once: true },\n );\n\n const responsePromise = fetchHTTPResponse({\n ...resolvedOpts,\n signal: raceAbortSignals(batchSignals, abortController.signal),\n type,\n contentTypeHeader: 'application/json',\n trpcAcceptHeader: 'application/jsonl',\n trpcAcceptHeaderKey: opts.streamHeader ?? 'trpc-accept',\n getUrl,\n getBody,\n inputs,\n path,\n headers() {\n if (!opts.headers) {\n return {};\n }\n if (typeof opts.headers === 'function') {\n return opts.headers({\n opList: batchOps as NonEmptyArray<BatchStreamOperation>,\n });\n }\n return opts.headers;\n },\n });\n\n const res = await responsePromise;\n\n if (!res.ok) {\n // Server returned a non-2xx response (e.g. batching disabled).\n // The body is plain JSON, not JSONL, so parse it directly and\n // propagate the same error to every operation in the batch.\n const json = (await res.json()) as TRPCResponse;\n if ('error' in json) {\n json.error = resolvedOpts.transformer.output.deserialize(\n json.error,\n );\n }\n\n return batchOps.map((): Promise<HTTPResult> =>\n Promise.resolve({\n json,\n meta: {\n response: res,\n },\n }),\n );\n }\n\n const [head] = await jsonlStreamConsumer<\n Record<string, Promise<any>>\n >({\n // oxlint-disable-next-line typescript/no-non-null-assertion\n from: res.body!,\n deserialize: (data) =>\n resolvedOpts.transformer.output.deserialize(data),\n onError: () => abortController.abort(),\n // An op with nothing left to stream must not hold the batch open.\n onSettled: (settled) => batchOps[Number(settled.key)]?.settle(),\n formatError(opts) {\n const error = opts.error as TRPCErrorShape;\n return TRPCClientError.from({\n error,\n });\n },\n abortController,\n });\n const promises = Object.keys(batchOps).map(\n async (key): Promise<HTTPResult> => {\n let json: TRPCResponse = await Promise.resolve(head[key]);\n\n if ('result' in json) {\n /**\n * Not very pretty, but we need to unwrap nested data as promises\n * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value\n */\n const result = await Promise.resolve(json.result);\n json = {\n result: {\n data: await Promise.resolve(result.data),\n },\n };\n }\n\n return {\n json,\n meta: {\n response: res,\n },\n };\n },\n );\n return promises;\n },\n };\n };\n\n const query = dataLoader(batchLoader('query'));\n const mutation = dataLoader(batchLoader('mutation'));\n\n const loaders = { query, mutation };\n return ({ op }) => {\n return observable((observer) => {\n /* istanbul ignore if -- @preserve */\n if (op.type === 'subscription') {\n throw new Error(\n 'Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`',\n );\n }\n const ac = new AbortController();\n const loader = loaders[op.type];\n const { signal, cleanup } = raceAbortSignalsWithCleanup(\n op.signal,\n ac.signal,\n );\n const promise = loader.load({\n ...op,\n signal,\n releaseSignal: cleanup,\n settle: () => ac.abort(),\n });\n\n let isDone = false;\n let _res = undefined as HTTPResult | undefined;\n promise\n .then((res) => {\n isDone = true;\n _res = res;\n if ('error' in res.json) {\n // A failed op has nothing left to stream, so it must not hold the batch open.\n ac.abort();\n observer.error(\n TRPCClientError.from(res.json, {\n meta: res.meta,\n }),\n );\n return;\n } else if ('result' in res.json) {\n observer.next({\n context: res.meta,\n result: res.json.result,\n });\n observer.complete();\n return;\n }\n\n observer.complete();\n })\n .catch((err) => {\n isDone = true;\n ac.abort();\n observer.error(\n TRPCClientError.from(err, {\n meta: _res?.meta,\n }),\n );\n });\n\n return () => {\n if (!isDone) {\n ac.abort();\n }\n };\n });\n };\n };\n}\n\n/**\n * @deprecated Use {@link httpBatchStreamLink} instead.\n */\nexport const unstable_httpBatchStreamLink = httpBatchStreamLink;\n","import { isPlainObject } from '@trpc/server/unstable-core-do-not-import';\n\nexport function inputWithTrackedEventId(\n input: unknown,\n lastEventId: string | undefined,\n) {\n if (!lastEventId) {\n return input;\n }\n // Spreading an array, a `Date` or a class instance would corrupt it, so only\n // a plain object can carry the id.\n if (input != null && !isPlainObject(input)) {\n return input;\n }\n return {\n ...(input ?? {}),\n lastEventId,\n };\n}\n","import { behaviorSubject, observable } from '@trpc/server/observable';\nimport type { TRPCErrorShape, TRPCResult } from '@trpc/server/rpc';\nimport type {\n AnyClientTypes,\n EventSourceLike,\n inferClientTypes,\n InferrableClientTypes,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n resolvePathSeparator,\n retryableRpcCodes,\n run,\n sseStreamConsumer,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport { raceAbortSignals } from '../internals/signals';\nimport { TRPCClientError } from '../TRPCClientError';\nimport type { TRPCConnectionState } from '../unstable-internals';\nimport { getTransformer, type TransformerOptions } from '../unstable-internals';\nimport { getUrl, type HTTPLinkBaseOptions } from './internals/httpUtils';\nimport {\n resultOf,\n type UrlOptionsWithConnectionParams,\n} from './internals/urlWithConnectionParams';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\nasync function urlWithConnectionParams(\n opts: UrlOptionsWithConnectionParams,\n): Promise<string> {\n let url = await resultOf(opts.url);\n if (opts.connectionParams) {\n const params = await resultOf(opts.connectionParams);\n\n const prefix = url.includes('?') ? '&' : '?';\n url +=\n prefix + 'connectionParams=' + encodeURIComponent(JSON.stringify(params));\n }\n\n return url;\n}\n\n/**\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink#httpsubscriptionlink-options\n */\ntype HTTPSubscriptionLinkOptions<\n TRoot extends AnyClientTypes,\n TEventSource extends EventSourceLike.AnyConstructor = typeof EventSource,\n> = {\n /**\n * The `EventSource` class to use, for runtimes that don't have one.\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink#custom-headers-through-ponyfill\n */\n EventSource?: TEventSource;\n /**\n * Options passed to the `EventSource`, or a function that returns them for\n * each subscription.\n */\n eventSourceOptions?:\n | EventSourceLike.InitDictOf<TEventSource>\n | ((opts: {\n op: Operation;\n }) =>\n | EventSourceLike.InitDictOf<TEventSource>\n | Promise<EventSourceLike.InitDictOf<TEventSource>>);\n} & Pick<HTTPLinkBaseOptions<TRoot>, 'pathSeparator'> &\n TransformerOptions<TRoot> &\n UrlOptionsWithConnectionParams;\n\n/**\n * A terminating link that runs subscriptions over Server-Sent Events.\n *\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink\n */\nexport function httpSubscriptionLink<\n TInferrable extends InferrableClientTypes,\n TEventSource extends EventSourceLike.AnyConstructor,\n>(\n opts: HTTPSubscriptionLinkOptions<\n inferClientTypes<TInferrable>,\n TEventSource\n >,\n): TRPCLink<\n TInferrable,\n // its callbacks may read the fields added to `OperationContext`\n { context: AugmentedOperationContext }\n> {\n const transformer = getTransformer(opts.transformer);\n const pathSeparator = resolvePathSeparator(opts.pathSeparator);\n\n return () => {\n return ({ op }) => {\n return observable((observer) => {\n const { type, path, input } = op;\n\n /* istanbul ignore if -- @preserve */\n if (type !== 'subscription') {\n throw new Error('httpSubscriptionLink only supports subscriptions');\n }\n\n let lastEventId: string | undefined = undefined;\n const ac = new AbortController();\n const signal = raceAbortSignals(op.signal, ac.signal);\n const eventSourceStream = sseStreamConsumer<{\n EventSource: TEventSource;\n data: Partial<{\n id?: string;\n data: unknown;\n }>;\n error: TRPCErrorShape;\n }>({\n url: async () =>\n getUrl({\n transformer,\n url: await urlWithConnectionParams(opts),\n input: inputWithTrackedEventId(input, lastEventId),\n path,\n pathSeparator,\n type,\n signal: null,\n }),\n init: () => resultOf(opts.eventSourceOptions, { op }),\n signal,\n deserialize: (data) => transformer.output.deserialize(data),\n EventSource: opts.EventSource ?? (globalThis.EventSource as never),\n });\n\n const connectionState = behaviorSubject<\n TRPCConnectionState<TRPCClientError<any>>\n >({\n type: 'state',\n state: 'connecting',\n error: null,\n });\n\n const connectionSub = connectionState.subscribe({\n next(state) {\n observer.next({\n result: state,\n });\n },\n });\n run(async () => {\n for await (const chunk of eventSourceStream) {\n switch (chunk.type) {\n case 'ping':\n // do nothing\n break;\n case 'data':\n const chunkData = chunk.data;\n\n let result: TRPCResult<unknown>;\n if (chunkData.id) {\n // if the `tracked()`-helper is used, we always have an `id` field\n lastEventId = chunkData.id;\n result = {\n id: chunkData.id,\n data: chunkData,\n };\n } else {\n result = {\n data: chunkData.data,\n };\n }\n\n observer.next({\n result,\n context: {\n eventSource: chunk.eventSource,\n },\n });\n break;\n case 'connected': {\n observer.next({\n result: {\n type: 'started',\n },\n context: {\n eventSource: chunk.eventSource,\n },\n });\n connectionState.next({\n type: 'state',\n state: 'pending',\n error: null,\n });\n break;\n }\n case 'serialized-error': {\n const error = TRPCClientError.from({ error: chunk.error });\n\n if (retryableRpcCodes.includes(chunk.error.code)) {\n //\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error,\n });\n break;\n }\n //\n // non-retryable error, cancel the subscription\n throw error;\n }\n case 'connecting': {\n const lastState = connectionState.get();\n\n const error = chunk.event && TRPCClientError.from(chunk.event);\n if (!error && lastState.state === 'connecting') {\n break;\n }\n\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error,\n });\n break;\n }\n case 'timeout': {\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error: new TRPCClientError(\n `Timeout of ${chunk.ms}ms reached while waiting for a response`,\n ),\n });\n }\n }\n }\n observer.next({\n result: {\n type: 'stopped',\n },\n });\n connectionState.next({\n type: 'state',\n state: 'idle',\n error: null,\n });\n observer.complete();\n }).catch((error) => {\n observer.error(TRPCClientError.from(error));\n });\n\n return () => {\n observer.complete();\n ac.abort();\n connectionSub.unsubscribe();\n };\n });\n };\n };\n}\n\n/**\n * @deprecated Use {@link httpSubscriptionLink} instead.\n */\nexport const unstable_httpSubscriptionLink = httpSubscriptionLink;\n","/* istanbul ignore file -- @preserve */\n// We're not actually exporting this link\nimport type { Unsubscribable } from '@trpc/server/observable';\nimport { observable } from '@trpc/server/observable';\nimport type { InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport type { TRPCClientError } from '../TRPCClientError';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\ntype RetryFn<TInferrable extends InferrableClientTypes> = (\n opts: RetryFnOptions<TInferrable>,\n) => boolean;\n\n/**\n * The `context` calls can pass through `retryLink`: the fields added to\n * `OperationContext` (`TAugmented`), which its callbacks may read, and\n * `retry`.\n * @public\n */\nexport type RetryLinkContext<\n TInferrable extends InferrableClientTypes,\n TAugmented extends object = AugmentedOperationContext,\n> = Omit<TAugmented, 'retry'> & {\n /**\n * Decides whether to retry this call, in place of the link's `retry`.\n * Anything else, such as a flag added to `OperationContext` that the\n * link's `retry` reads, is left to the link.\n * @example client.post.byId.query(input, { context: { retry: (opts) => opts.attempts <= 3 } })\n */\n retry?:\n | RetryFn<TInferrable>\n | ('retry' extends keyof TAugmented ? TAugmented['retry'] : never);\n};\n\ninterface RetryLinkOptions<TInferrable extends InferrableClientTypes> {\n /**\n * The retry function. A call's `context.retry` replaces it for that call.\n */\n retry: RetryFn<TInferrable>;\n /**\n * The delay between retries in ms (defaults to 0)\n */\n retryDelayMs?: (attempt: number) => number;\n}\n\n/**\n * What a `retry` function is given.\n * @public\n */\nexport interface RetryFnOptions<TInferrable extends InferrableClientTypes> {\n /**\n * The operation that failed\n */\n op: Operation;\n /**\n * The error that occurred\n */\n error: TRPCClientError<TInferrable>;\n /**\n * The number of attempts that have been made (including the first call)\n */\n attempts: number;\n}\n\n/**\n * Retries failed operations. Subscriptions resume from the last tracked event\n * id. A call can pass its own `retry` in `context`.\n *\n * @see https://trpc.io/docs/client/links/retryLink\n */\nexport function retryLink<TInferrable extends InferrableClientTypes>(\n opts: RetryLinkOptions<TInferrable>,\n): TRPCLink<TInferrable, { context: RetryLinkContext<TInferrable> }> {\n // initialized config\n return () => {\n // initialized in app\n return (callOpts) => {\n // initialized for request\n return observable((observer) => {\n let next$: Unsubscribable;\n let currentAttempt = 0;\n let disposed = false;\n let callNextTimeout: ReturnType<typeof setTimeout> | undefined =\n undefined;\n\n let lastEventId: string | undefined = undefined;\n\n attempt(1);\n\n function opWithLastEventId() {\n const op = callOpts.op;\n if (!lastEventId) {\n return op;\n }\n\n return {\n ...op,\n input: inputWithTrackedEventId(op.input, lastEventId),\n };\n }\n\n function attempt(attempts: number) {\n if (disposed) {\n return;\n }\n currentAttempt = attempts;\n const op = opWithLastEventId();\n\n const subscription = callOpts.next(op).subscribe({\n error(error) {\n const callRetry = op.context['retry'];\n // a `retry` that isn't a function is a flag for the link's own `retry`\n const retry =\n typeof callRetry === 'function'\n ? (callRetry as RetryFn<TInferrable>)\n : opts.retry;\n const shouldRetry = retry({\n op,\n attempts,\n error,\n });\n if (disposed) {\n return;\n }\n if (!shouldRetry) {\n observer.error(error);\n return;\n }\n const delayMs = opts.retryDelayMs?.(attempts) ?? 0;\n if (disposed) {\n return;\n }\n\n if (delayMs <= 0) {\n attempt(attempts + 1);\n return;\n }\n callNextTimeout = setTimeout(\n () => attempt(attempts + 1),\n delayMs,\n );\n },\n next(envelope) {\n //\n if (\n (!envelope.result.type || envelope.result.type === 'data') &&\n envelope.result.id\n ) {\n //\n lastEventId = envelope.result.id;\n }\n\n observer.next(envelope);\n },\n complete() {\n observer.complete();\n },\n });\n\n // A synchronous error may have already subscribed the next attempt.\n if (disposed) {\n subscription.unsubscribe();\n } else if (currentAttempt === attempts) {\n next$ = subscription;\n }\n }\n return () => {\n disposed = true;\n next$.unsubscribe();\n clearTimeout(callNextTimeout);\n };\n });\n };\n };\n}\n","import {\n getTRPCErrorFromUnknown,\n getTRPCErrorShape,\n isTrackedEnvelope,\n} from '@trpc/server';\nimport {\n behaviorSubject,\n isObservable,\n observable,\n observableToAsyncIterable,\n} from '@trpc/server/observable';\nimport { TRPC_ERROR_CODES_BY_KEY, type TRPCResult } from '@trpc/server/rpc';\nimport {\n callProcedure,\n isAbortError,\n isAsyncIterable,\n iteratorResource,\n makeResource,\n retryableRpcCodes,\n run,\n type AnyRouter,\n type ErrorHandlerOptions,\n type inferClientTypes,\n type inferRouterContext,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport {\n abortSignalToPromise,\n raceAbortSignals,\n throwIfAborted,\n} from '../internals/signals';\nimport { getTransformer } from '../internals/transformer';\nimport type { TransformerOptions } from '../internals/transformer';\nimport { isTRPCClientError, TRPCClientError } from '../TRPCClientError';\nimport type { TRPCConnectionState } from './internals/subscriptions';\nimport type { TRPCLink } from './types';\n\n/**\n * Passed to {@link LocalLinkOptions.createContext}.\n */\nexport type LocalLinkCreateContextOptions = {\n /**\n * What tRPC knows about the call, like the `info` that adapters pass to\n * their `createContext`.\n */\n info: {\n /**\n * Aborts when the call is cancelled or unsubscribed. Pass it on to work\n * that creating the context starts, such as `fetch()` calls.\n */\n signal: AbortSignal;\n };\n};\n\n/**\n * Options for {@link localLink}.\n *\n * @see https://trpc.io/docs/client/links/localLink#options\n */\nexport type LocalLinkOptions<TRouter extends AnyRouter> = {\n /**\n * The router to call.\n * @see https://trpc.io/docs/client/links/localLink#router\n */\n router: TRouter;\n /**\n * Creates the context for each call. `info.signal` aborts when the call\n * is cancelled.\n * @see https://trpc.io/docs/client/links/localLink#createcontext\n */\n createContext: (\n opts: LocalLinkCreateContextOptions,\n ) => Promise<inferRouterContext<TRouter>>;\n /**\n * Called when a procedure throws.\n * @see https://trpc.io/docs/client/links/localLink#onerror\n */\n onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;\n} & TransformerOptions<inferClientTypes<TRouter>>;\n\n/**\n * A terminating link that calls procedures on a router in the same process,\n * without HTTP.\n *\n * @see https://trpc.io/docs/client/links/localLink\n */\nexport function localLink<TRouter extends AnyRouter>(\n opts: LocalLinkOptions<TRouter>,\n): TRPCLink<TRouter, { context: {} }> {\n const transformer = getTransformer(opts.transformer);\n\n const transformChunk = (chunk: unknown) => {\n if (opts.transformer) {\n // assume transformer will do the right thing\n return chunk;\n }\n // Special case for undefined, because `JSON.stringify(undefined)` throws\n if (chunk === undefined) {\n return chunk;\n }\n const serialized = JSON.stringify(transformer.input.serialize(chunk));\n const deserialized = JSON.parse(transformer.output.deserialize(serialized));\n return deserialized;\n };\n\n return () =>\n ({ op }) =>\n observable((observer) => {\n let ctx: inferRouterContext<TRouter> | undefined = undefined;\n const ac = new AbortController();\n\n const signal = raceAbortSignals(op.signal, ac.signal);\n const signalPromise = abortSignalToPromise(signal);\n\n signalPromise.catch(() => {\n // prevent unhandled rejection\n });\n\n let input = op.input;\n async function runProcedure(newInput: unknown): Promise<unknown> {\n input = newInput;\n\n // don't start work for a call that was cancelled before it ran\n throwIfAborted(signal);\n ctx = await opts.createContext({ info: { signal } });\n throwIfAborted(signal);\n\n return callProcedure({\n router: opts.router,\n path: op.path,\n getRawInput: async () => newInput,\n ctx,\n type: op.type,\n signal,\n batchIndex: 0,\n });\n }\n\n function onErrorCallback(cause: unknown) {\n if (isAbortError(cause)) {\n return;\n }\n opts.onError?.({\n error: getTRPCErrorFromUnknown(cause),\n type: op.type,\n path: op.path,\n input,\n ctx,\n });\n }\n\n function coerceToTRPCClientError(cause: unknown) {\n if (isTRPCClientError<TRouter>(cause)) {\n return cause;\n }\n const error = getTRPCErrorFromUnknown(cause);\n\n const shape = getTRPCErrorShape({\n config: opts.router._def._config,\n ctx,\n error,\n input,\n path: op.path,\n type: op.type,\n });\n return TRPCClientError.from(\n { error: transformChunk(shape) },\n { cause: cause instanceof Error ? cause : undefined },\n );\n }\n\n run(async () => {\n switch (op.type) {\n case 'query':\n case 'mutation': {\n const result = await Promise.race([\n runProcedure(op.input),\n signalPromise,\n ]);\n if (!isAsyncIterable(result)) {\n observer.next({\n result: { data: transformChunk(result) },\n });\n observer.complete();\n break;\n }\n\n observer.next({\n result: {\n data: (async function* () {\n await using iterator = iteratorResource(result);\n using _finally = makeResource({}, () => {\n observer.complete();\n });\n try {\n while (true) {\n const res = await Promise.race([\n iterator.next(),\n signalPromise,\n ]);\n if (res.done) {\n return transformChunk(res.value);\n }\n yield transformChunk(res.value);\n }\n } catch (cause) {\n onErrorCallback(cause);\n throw coerceToTRPCClientError(cause);\n }\n })(),\n },\n });\n break;\n }\n case 'subscription': {\n const connectionState = behaviorSubject<\n TRPCConnectionState<TRPCClientError<any>>\n >({\n type: 'state',\n state: 'connecting',\n error: null,\n });\n\n const connectionSub = connectionState.subscribe({\n next(state) {\n observer.next({\n result: state,\n });\n },\n });\n let lastEventId: string | undefined = undefined;\n\n using _finally = makeResource({}, async () => {\n connectionState.next({\n type: 'state',\n state: 'idle',\n error: null,\n });\n connectionSub.unsubscribe();\n });\n\n // returning from here means the stream ended, so this completes\n // below - a throw is left to the `.catch()`, which needs the\n // observer to still be open by the time it runs\n await run(async () => {\n while (true) {\n const procedureResult = await runProcedure(\n inputWithTrackedEventId(op.input, lastEventId),\n );\n const result = isObservable(procedureResult)\n ? observableToAsyncIterable(procedureResult, signal)\n : procedureResult;\n if (!isAsyncIterable(result)) {\n throw new Error('Expected an async iterable');\n }\n await using iterator = iteratorResource(result);\n\n observer.next({\n result: {\n type: 'started',\n },\n });\n connectionState.next({\n type: 'state',\n state: 'pending',\n error: null,\n });\n\n // Use a while loop to handle errors and reconnects\n while (true) {\n let res;\n try {\n res = await Promise.race([\n iterator.next(),\n signalPromise,\n ]);\n } catch (cause) {\n if (isAbortError(cause)) {\n return;\n }\n const error = getTRPCErrorFromUnknown(cause);\n\n if (\n !retryableRpcCodes.includes(\n TRPC_ERROR_CODES_BY_KEY[error.code],\n )\n ) {\n throw coerceToTRPCClientError(error);\n }\n\n onErrorCallback(error);\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error: coerceToTRPCClientError(error),\n });\n\n break;\n }\n\n if (res.done) {\n return;\n }\n let chunk: TRPCResult<unknown>;\n if (isTrackedEnvelope(res.value)) {\n lastEventId = res.value[0];\n\n chunk = {\n id: res.value[0],\n data: {\n id: res.value[0],\n data: res.value[1],\n },\n };\n } else {\n chunk = {\n data: res.value,\n };\n }\n\n observer.next({\n result: {\n ...chunk,\n data: transformChunk(chunk.data),\n },\n });\n }\n }\n });\n\n observer.complete();\n break;\n }\n }\n }).catch((cause) => {\n onErrorCallback(cause);\n observer.error(coerceToTRPCClientError(cause));\n });\n\n return () => {\n ac.abort();\n };\n });\n}\n\n/**\n * @deprecated Use {@link localLink} instead.\n * @function\n */\nexport const unstable_localLink = localLink;\n\n/**\n * @deprecated Use {@link localLink} instead. This alias will be removed in a\n * future major release.\n */\nexport const experimental_localLink = localLink;\n","import type { TRPCClientError } from './TRPCClientError';\n\n/**\n * @internal\n */\nexport declare const errorShapeTag: unique symbol;\n\n/**\n * The promise a client's `.query()` or `.mutate()` returns, tagged with\n * the procedure's error shape for `safe()`.\n */\nexport type TRPCTaggedPromise<TData, TErrorShape> = Promise<TData> & {\n readonly [errorShapeTag]: TErrorShape;\n};\n\n/**\n * @internal\n */\nexport type inferSafeError<TErrorShape> = TRPCClientError<{\n errorShape: TErrorShape;\n transformer: boolean;\n}>;\n\n/**\n * What `safe()` resolves to: `[data, undefined]` or `[undefined, error]`.\n * @see https://trpc.io/docs/client/vanilla/error-handling#errors-as-values-with-safe\n */\nexport type SafeResult<TData, TErrorShape> =\n | readonly [data: TData, error: undefined]\n | readonly [data: undefined, error: inferSafeError<TErrorShape>];\n\n/**\n * Awaits a client `.query()` or `.mutate()` call without throwing, and\n * returns a `[data, error]` pair typed with the procedure's error shape.\n *\n * @example\n * ```ts\n * const [post, error] = await safe(client.post.byId.query({ id }));\n * if (error) {\n * console.error(error);\n * }\n *\n * const id = post.id;\n * ```\n * @see https://trpc.io/docs/client/vanilla/error-handling#errors-as-values-with-safe\n */\nexport async function safe<TData, TErrorShape>(\n promise: TRPCTaggedPromise<TData, TErrorShape>,\n): Promise<SafeResult<TData, TErrorShape>> {\n try {\n return [await promise, undefined];\n } catch (cause) {\n return [undefined, cause as inferSafeError<TErrorShape>];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsFA,MAAM,eAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAoBA,IAAa,oBAAb,MAA0E;CAKxE,YAAY,MAA4C;EAJvC,gBAAA,MAAA,SAAA,KAAA,CAAA;EACD,gBAAA,MAAA,WAAA,KAAA,CAAA;EACR,gBAAA,MAAA,aAAA,KAAA,CAAA;EAGN,KAAK,YAAY;EAEjB,KAAK,UAAU,CAAC;EAGhB,KAAK,QAAQ,KAAK,MAAM,KAAK,SAAS,KAAK,KAAK,OAAO,CAAC;CAC1D;CAEA,SAAsD,MAMnD;;EASD,OARe,YAAwC;GACrD,OAAO,KAAK;GACZ,IAAA,eAAA,eAAA,CAAA,GACK,IAAA,GAAA,CAAA,GAAA;IACH,UAAA,gBAAS,KAAK,aAAA,QAAA,kBAAA,KAAA,IAAA,gBAAW,CAAC;IAC1B,IAAI,EAAE,KAAK;GACb,CAAA;EACF,CACY,CAAC,CAAC,KAAK,MAAM,CAAC;CAC5B;CAEA,MAAc,iBAAsD,MAM/C;EACnB,IAAI;GACF,MAAM,OAAO,KAAK,SAA0B,IAAI;GAKhD,QADc,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SACyC;CACzC,IAAI;EACF,OAAO,CAAC,MAAM,SAAS,KAAA,CAAS;CAClC,SAAS,OAAO;EACd,OAAO,CAAC,KAAA,GAAW,KAAoC;CACzD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/createTRPCClient.ts","../src/routerType.ts","../src/links/httpBatchStreamLink.ts","../src/internals/inputWithTrackedEventId.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts","../src/safe.ts"],"sourcesContent":["import type {\n inferObservableValue,\n Unsubscribable,\n} from '@trpc/server/observable';\nimport {\n observable,\n observableToAsyncIterable,\n observableToPromise,\n share,\n} from '@trpc/server/observable';\nimport type {\n AnyRouter,\n inferAsyncIterableYield,\n InferrableClientTypes,\n Maybe,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createChain } from '../links/internals/createChain';\nimport type { TRPCConnectionState } from '../links/internals/subscriptions';\nimport type {\n OperationContext,\n OperationLink,\n TRPCClientRuntime,\n TRPCLink,\n} from '../links/types';\nimport { TRPCClientError } from '../TRPCClientError';\n\ntype TRPCType = 'mutation' | 'query' | 'subscription';\n/** The options of a call made with the untyped client. */\nexport interface TRPCRequestOptions {\n /**\n * Context for the links, such as a flag a `splitLink` reads.\n * @see https://trpc.io/docs/client/links#managing-context\n */\n context?: OperationContext;\n /**\n * Aborts the call. With `httpBatchLink`, the request is only aborted once\n * every call in its batch is, so an aborted call can still get a result.\n */\n signal?: AbortSignal;\n}\n\n/** The callbacks a subscription takes on the client. */\nexport interface TRPCSubscriptionObserver<TValue, TError> {\n /** Called when the link sends a `started` result. */\n onStarted: (opts: { context: OperationContext | undefined }) => void;\n /** Called with each event. */\n onData: (value: inferAsyncIterableYield<TValue>) => void;\n /** Called when the subscription ends with an error. */\n onError: (err: TError) => void;\n /**\n * Called when the link sends a `stopped` result. Not every link sends\n * one; `localLink` doesn't.\n */\n onStopped: () => void;\n /** Called when the subscription's observable completes, for any reason. */\n onComplete: () => void;\n /** Called when the connection connects, drops or reconnects. */\n onConnectionStateChange: (state: TRPCConnectionState<TError>) => void;\n}\n\ntype ObserverKey = keyof TRPCSubscriptionObserver<unknown, unknown>;\n\n/**\n * Subscription options without callbacks: `TOpts` must not have any of the\n * callback keys, not even set to `undefined`.\n * @internal\n */\nexport type TRPCSubscriptionWithoutCallbacks<TOpts> = TOpts & {\n // `keyof` a union only has its shared keys, so this one catches each member\n [TKey in ObserverKey]?: never;\n} & {\n [TKey in keyof TOpts & ObserverKey]: never;\n};\n\n/**\n * Subscription callbacks, at least one of which is defined.\n * @internal\n */\nexport type TRPCSubscriptionCallbacks<TValue, TError> = Partial<\n TRPCSubscriptionObserver<TValue, TError>\n> &\n {\n [TKey in ObserverKey]: Pick<TRPCSubscriptionObserver<TValue, TError>, TKey>;\n }[ObserverKey];\n\nconst observerKeys: ObserverKey[] = [\n 'onStarted',\n 'onData',\n 'onError',\n 'onStopped',\n 'onComplete',\n 'onConnectionStateChange',\n];\n\n/**\n * The options of `createTRPCClient`.\n * @internal\n */\nexport type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {\n /**\n * The links each call goes through, in order. The last one must send\n * the call, such as `httpBatchLink`.\n * @see https://trpc.io/docs/client/links\n */\n links: TRPCLink<TRouter>[];\n transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;\n};\n\n/**\n * A client that calls procedures by path string, without types.\n * `createTRPCClient` wraps one.\n */\nexport class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {\n private readonly links: OperationLink<TInferrable>[];\n public readonly runtime: TRPCClientRuntime;\n private requestId: number;\n\n constructor(opts: CreateTRPCClientOptions<TInferrable>) {\n this.requestId = 0;\n\n this.runtime = {};\n\n // Initialize the links\n this.links = opts.links.map((link) => link(this.runtime));\n }\n\n private $request<TInput = unknown, TOutput = unknown>(opts: {\n type: TRPCType;\n input: TInput;\n path: string;\n context?: OperationContext;\n signal: Maybe<AbortSignal>;\n }) {\n const chain$ = createChain<AnyRouter, TInput, TOutput>({\n links: this.links as OperationLink<any, any, any>[],\n op: {\n ...opts,\n context: opts.context ?? {},\n id: ++this.requestId,\n },\n });\n return chain$.pipe(share());\n }\n\n private async requestAsPromise<TInput = unknown, TOutput = unknown>(opts: {\n type: TRPCType;\n input: TInput;\n path: string;\n context?: OperationContext;\n signal: Maybe<AbortSignal>;\n }): Promise<TOutput> {\n try {\n const req$ = this.$request<TInput, TOutput>(opts);\n type TValue = inferObservableValue<typeof req$>;\n\n const envelope = await observableToPromise<TValue>(req$);\n const data = (envelope.result as any).data;\n return data;\n } catch (err) {\n throw TRPCClientError.from(err as Error);\n }\n }\n /** Calls a query. */\n public query(path: string, input?: unknown, opts?: TRPCRequestOptions) {\n return this.requestAsPromise<unknown, unknown>({\n type: 'query',\n path,\n input,\n context: opts?.context,\n signal: opts?.signal,\n });\n }\n /** Calls a mutation. */\n public mutation(path: string, input?: unknown, opts?: TRPCRequestOptions) {\n return this.requestAsPromise<unknown, unknown>({\n type: 'mutation',\n path,\n input,\n context: opts?.context,\n signal: opts?.signal,\n });\n }\n /**\n * Starts a subscription. With callbacks, returns what stops it. Without,\n * returns an async iterator to read it with `for await`, which `signal`,\n * `break` or `return()` stops. It can be iterated once.\n * @see https://trpc.io/docs/client/vanilla/setup#5-use-subscriptions\n */\n public subscription(\n path: string,\n input: unknown,\n opts: TRPCSubscriptionCallbacks<unknown, TRPCClientError<AnyRouter>> &\n TRPCRequestOptions,\n ): Unsubscribable;\n public subscription<\n TOpts extends TRPCRequestOptions &\n Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>> =\n TRPCRequestOptions,\n >(\n path: string,\n input: unknown,\n opts?: TRPCSubscriptionWithoutCallbacks<TOpts>,\n ): AsyncIterableIterator<unknown>;\n public subscription(\n path: string,\n input: unknown,\n opts: Partial<\n TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>\n > &\n TRPCRequestOptions = {},\n ): Unsubscribable | AsyncIterableIterator<unknown> {\n const hasCallbacks = observerKeys.some(\n (key) => typeof opts[key] === 'function',\n );\n const observable$ = this.$request({\n type: 'subscription',\n path,\n input,\n context: opts.context,\n signal: opts.signal,\n });\n if (!hasCallbacks) {\n const data$ = observable<unknown, TRPCClientError<AnyRouter>>(\n (observer) =>\n observable$.subscribe({\n next(envelope) {\n if (\n envelope.result.type === 'data' ||\n envelope.result.type === undefined\n ) {\n observer.next(envelope.result.data);\n }\n },\n error: (err) => observer.error(err),\n complete: () => observer.complete(),\n }),\n );\n const iterator = observableToAsyncIterable(\n data$,\n opts.signal ?? new AbortController().signal,\n );\n // a second loop over the same iterator would split the data with the\n // first, or end straight away once the first has left\n let iterated = false;\n iterator[Symbol.asyncIterator] = () => {\n if (iterated) {\n throw new Error(\n 'A subscription can only be iterated once. Call subscribe() again for another loop.',\n );\n }\n iterated = true;\n return iterator;\n };\n return iterator;\n }\n return observable$.subscribe({\n next(envelope) {\n switch (envelope.result.type) {\n case 'state': {\n opts.onConnectionStateChange?.(envelope.result);\n break;\n }\n case 'started': {\n opts.onStarted?.({\n context: envelope.context,\n });\n break;\n }\n case 'stopped': {\n opts.onStopped?.();\n break;\n }\n case 'data':\n case undefined: {\n opts.onData?.(envelope.result.data);\n break;\n }\n }\n },\n error(err) {\n opts.onError?.(err);\n },\n complete() {\n opts.onComplete?.();\n },\n });\n }\n}\n","import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport type { CreateTRPCClientOptions } from './internals/TRPCUntypedClient';\nimport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\n\n/**\n * Creates a client that calls procedures by path string, without types.\n * Meant for libraries built on tRPC; apps should use `createTRPCClient`.\n */\nexport function createTRPCUntypedClient<TRouter extends AnyRouter>(\n opts: CreateTRPCClientOptions<TRouter>,\n): TRPCUntypedClient<TRouter> {\n return new TRPCUntypedClient(opts);\n}\n\nexport type {\n CreateTRPCClientOptions,\n TRPCRequestOptions,\n} from './internals/TRPCUntypedClient';\nexport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\n","/* oxlint-disable typescript/no-non-null-assertion */\nimport type { Unsubscribable } from '@trpc/server/observable';\nimport type {\n AnyProcedure,\n AnyRouter,\n inferAsyncIterableYield,\n inferClientTypes,\n inferProcedureErrorShape,\n inferProcedureInput,\n InferrableClientTypes,\n inferTransformedProcedureOutput,\n ProcedureType,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n createFlatProxy,\n createRecursiveProxy,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type { CreateTRPCClientOptions } from './createTRPCUntypedClient';\nimport type {\n TRPCSubscriptionCallbacks,\n TRPCSubscriptionObserver,\n TRPCSubscriptionWithoutCallbacks,\n} from './internals/TRPCUntypedClient';\nimport { TRPCUntypedClient } from './internals/TRPCUntypedClient';\nimport type { TRPCProcedureOptions } from './internals/types';\nimport type { inferLinksContext, TRPCLink } from './links/types';\nimport type { RouterType } from './routerType';\nimport type { TRPCTaggedPromise } from './safe';\nimport type { TRPCClientError } from './TRPCClientError';\n\n/**\n * The type of a client for a router.\n * @deprecated Use {@link TRPCClient} instead. This will be removed in v12.\n * @public\n **/\nexport type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;\n\n/**\n * The type of a client for a router.\n * @deprecated Use {@link TRPCClient} instead. This will be removed in v12.\n * @public\n **/\nexport type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;\n\nconst untypedClientSymbol = Symbol.for('trpc_untypedClient');\n\n/**\n * A typed client for a router, as `createTRPCClient` returns it. Each\n * procedure has `.query()`, `.mutate()` or `.subscribe()`.\n *\n * `TContext` is the `context` calls take; `createTRPCClient({ router,\n * links })` infers it from the links.\n * @see https://trpc.io/docs/client/vanilla/infer-types\n * @public\n **/\nexport type TRPCClient<\n TRouter extends AnyRouter,\n TContext extends object = Record<string, unknown>,\n> = DecoratedProcedureRecord<\n {\n transformer: TRouter['_def']['_config']['$types']['transformer'];\n errorShape: TRouter['_def']['_config']['$types']['errorShape'];\n },\n TRouter['_def']['record'],\n TContext\n> & {\n [untypedClientSymbol]: TRPCUntypedClient<TRouter>;\n};\n\n/**\n * A procedure's types, as the client sees them.\n * @internal\n */\nexport type TRPCResolverDef = {\n input: any;\n output: any;\n transformer: boolean;\n errorShape: any;\n};\n\ntype coerceAsyncGeneratorToIterable<T> =\n T extends AsyncGenerator<infer $T, infer $Return, infer $Next>\n ? AsyncIterable<$T, $Return, $Next>\n : T;\n\n/**\n * The `.query()` or `.mutate()` of a procedure on the client.\n * @internal\n */\nexport type Resolver<\n TDef extends TRPCResolverDef,\n TContext extends object = Record<string, unknown>,\n> = (\n input: TDef['input'],\n opts?: TRPCProcedureOptions<TContext>,\n) => TRPCTaggedPromise<\n coerceAsyncGeneratorToIterable<TDef['output']>,\n TDef['errorShape']\n>;\n\n/**\n * The `.subscribe()` of a subscription procedure on the client.\n * @internal\n */\nexport type SubscriptionResolver<\n TDef extends TRPCResolverDef,\n TContext extends object = Record<string, unknown>,\n> = {\n (\n input: TDef['input'],\n opts: TRPCSubscriptionCallbacks<TDef['output'], TRPCClientError<TDef>> &\n TRPCProcedureOptions<TContext>,\n ): Unsubscribable;\n <\n TOpts extends TRPCProcedureOptions<TContext> &\n Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> =\n TRPCProcedureOptions<TContext>,\n >(\n input: TDef['input'],\n opts?: TRPCSubscriptionWithoutCallbacks<TOpts>,\n ): AsyncIterableIterator<inferAsyncIterableYield<TDef['output']>>;\n};\n\ntype DecorateProcedure<\n TType extends ProcedureType,\n TDef extends TRPCResolverDef,\n TContext extends object,\n> = TType extends 'query'\n ? { query: Resolver<TDef, TContext> }\n : TType extends 'mutation'\n ? { mutate: Resolver<TDef, TContext> }\n : TType extends 'subscription'\n ? { subscribe: SubscriptionResolver<TDef, TContext> }\n : never;\n\n/**\n * @internal\n */\ntype DecoratedProcedureRecord<\n TRoot extends InferrableClientTypes,\n TRecord extends RouterRecord,\n TContext extends object,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<\n $Value['_def']['type'],\n {\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<\n inferClientTypes<TRoot>,\n $Value\n >;\n errorShape: inferProcedureErrorShape<TRoot, $Value>;\n transformer: inferClientTypes<TRoot>['transformer'];\n },\n TContext\n >\n : $Value extends RouterRecord\n ? DecoratedProcedureRecord<TRoot, $Value, TContext>\n : never\n : never;\n};\n\nconst clientCallTypeMap: Record<\n keyof DecorateProcedure<any, any, any>,\n ProcedureType\n> = {\n query: 'query',\n mutate: 'mutation',\n subscribe: 'subscription',\n};\n\n/**\n * The procedure type of a client method: `query`, `mutate` or `subscribe`.\n * @internal\n */\nexport const clientCallTypeToProcedureType = (\n clientCallType: string,\n): ProcedureType => {\n return clientCallTypeMap[clientCallType as keyof typeof clientCallTypeMap];\n};\n\n/**\n * Wraps an untyped client in the typed proxy `createTRPCClient` returns.\n * @internal\n */\nexport function createTRPCClientProxy<TRouter extends AnyRouter>(\n client: TRPCUntypedClient<TRouter>,\n): TRPCClient<TRouter> {\n const proxy = createRecursiveProxy<TRPCClient<TRouter>>(({ path, args }) => {\n const pathCopy = [...path];\n const procedureType = clientCallTypeToProcedureType(pathCopy.pop()!);\n\n const fullPath = pathCopy.join('.');\n\n return (client[procedureType] as any)(fullPath, ...(args as any));\n });\n return createFlatProxy<TRPCClient<TRouter>>((key) => {\n if (key === untypedClientSymbol) {\n return client;\n }\n return proxy[key];\n });\n}\n\n/**\n * The options of `createTRPCClient` with the router's type passed as\n * `router: routerType<AppRouter>()`.\n * @public\n */\nexport type CreateTRPCClientWithRouterOptions<\n TRouter extends AnyRouter,\n TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[],\n> = Omit<CreateTRPCClientOptions<TRouter>, 'links'> & {\n /**\n * The router's type, from `routerType<AppRouter>()`. It's a type only:\n * nothing about the router is sent or bundled.\n */\n router: RouterType<TRouter>;\n /**\n * The links each call goes through, in order. The last one must send\n * the call, such as `httpBatchLink`. What they declare types each call's\n * `context`, and which methods the client has. Pass them inline or\n * `as const`: in an array declared without it, TypeScript can merge the\n * links' types and drop what one declares.\n * @see https://trpc.io/docs/client/links\n */\n links: TLinks;\n};\n\n/**\n * Creates a typed client for a router. Pass the router's type with\n * `routerType`, and the links that send its calls. What the links declare\n * types each call's `context`.\n * @example\n * ```ts\n * const client = createTRPCClient({\n * router: routerType<AppRouter>(),\n * links: [retryLink({ retry: () => false }), httpBatchLink({ url })],\n * });\n * const post = await client.post.byId.query(\n * { id: '1' },\n * { context: { retry: (opts) => opts.attempts <= 3 } },\n * );\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n */\nexport function createTRPCClient<\n TRouter extends AnyRouter,\n // with an explicit router type, the links aren't inferred\n const TLinks extends readonly TRPCLink<TRouter, any>[] = TRPCLink<TRouter>[],\n>(\n opts: CreateTRPCClientWithRouterOptions<TRouter, TLinks>,\n): TRPCClient<TRouter, inferLinksContext<TLinks>>;\n/**\n * Creates a typed client for a router. Pass the router's type, and the\n * links that send its calls.\n * @example\n * ```ts\n * const client = createTRPCClient<AppRouter>({\n * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],\n * });\n * const post = await client.post.byId.query({ id: '1' });\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n * @deprecated Pass the router's type as `router: routerType<AppRouter>()`\n * instead of a type argument, so the links can type each call's `context`.\n * The type argument form is removed in v12.\n */\n// Kept last: `ReturnType<typeof createTRPCClient>` reads the last overload.\nexport function createTRPCClient<TRouter extends AnyRouter>(\n opts: CreateTRPCClientOptions<TRouter>,\n): TRPCClient<TRouter>;\nexport function createTRPCClient<TRouter extends AnyRouter>(\n opts: Omit<CreateTRPCClientOptions<TRouter>, 'links'> & {\n links: readonly TRPCLink<TRouter, any>[];\n },\n): TRPCClient<TRouter> {\n // `router` is a type only, so the untyped client ignores it\n const client = new TRPCUntypedClient<TRouter>({\n links: [...opts.links],\n });\n const proxy = createTRPCClientProxy<TRouter>(client);\n return proxy;\n}\n\n/**\n * The untyped client behind a typed client, which calls procedures by\n * path string.\n * @internal\n */\nexport function getUntypedClient<TRouter extends AnyRouter>(\n client: TRPCClient<TRouter>,\n): TRPCUntypedClient<TRouter> {\n return client[untypedClientSymbol];\n}\n","import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\n\ndeclare const routerTypeBrand: unique symbol;\n\n/**\n * A value that carries a router's type and nothing else. Made by\n * {@link routerType}.\n * @public\n */\nexport interface RouterType<TRouter extends AnyRouter> {\n readonly [routerTypeBrand]: TRouter;\n}\n\n/**\n * Passes a router's type to `createTRPCClient({ router })` as a normal\n * option, instead of a type argument. Nothing about the router exists at\n * runtime, so it's safe to import the router's type only.\n *\n * @example\n * ```ts\n * const client = createTRPCClient({\n * router: routerType<AppRouter>(),\n * links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],\n * });\n * ```\n * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client\n * @public\n */\nexport function routerType<TRouter extends AnyRouter>(): RouterType<TRouter> {\n return {} as RouterType<TRouter>;\n}\n","import type { AnyRouter, ProcedureType } from '@trpc/server';\nimport { observable } from '@trpc/server/observable';\nimport type { TRPCErrorShape, TRPCResponse } from '@trpc/server/rpc';\nimport type { AnyClientTypes } from '@trpc/server/unstable-core-do-not-import';\nimport { jsonlStreamConsumer } from '@trpc/server/unstable-core-do-not-import';\nimport type { BatchLoader } from '../internals/dataLoader';\nimport { dataLoader } from '../internals/dataLoader';\nimport {\n allAbortSignals,\n raceAbortSignals,\n raceAbortSignalsWithCleanup,\n} from '../internals/signals';\nimport type { NonEmptyArray } from '../internals/types';\nimport { TRPCClientError } from '../TRPCClientError';\nimport type { HTTPBatchLinkOptions } from './HTTPBatchLinkOptions';\nimport type { HTTPResult } from './internals/httpUtils';\nimport {\n fetchHTTPResponse,\n getBody,\n getUrl,\n resolveHTTPLinkOptions,\n} from './internals/httpUtils';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\n/**\n * Options for {@link httpBatchStreamLink}. Takes the same options as\n * `httpBatchLink`, plus `streamHeader`.\n *\n * @see https://trpc.io/docs/client/links/httpBatchStreamLink#options\n */\nexport type HTTPBatchStreamLinkOptions<TRoot extends AnyClientTypes> =\n HTTPBatchLinkOptions<TRoot> & {\n /**\n * Which header to use to signal the server that the client wants a streaming response.\n * - `'trpc-accept'` (default): sends `trpc-accept: application/jsonl` header\n * - `'accept'`: sends `Accept: application/jsonl` header, which can avoid CORS preflight for cross-origin streaming queries. Be aware that `application/jsonl` is not an official MIME type and so this is not completely spec-compliant - you should test that your infrastructure supports this value.\n * @default 'trpc-accept'\n */\n streamHeader?: 'trpc-accept' | 'accept';\n };\n\ntype BatchStreamOperation = Operation & {\n releaseSignal: () => void;\n /** Aborts the op's signal once its response has nothing left to stream */\n settle: () => void;\n};\n\n/**\n * A terminating link that batches calls like `httpBatchLink`, but streams each\n * response back as soon as it is ready.\n *\n * @see https://trpc.io/docs/client/links/httpBatchStreamLink\n */\nexport function httpBatchStreamLink<TRouter extends AnyRouter>(\n opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>,\n): TRPCLink<\n TRouter,\n // its callbacks may read the fields added to `OperationContext`\n { context: AugmentedOperationContext }\n> {\n const resolvedOpts = resolveHTTPLinkOptions(opts);\n const maxURLLength = opts.maxURLLength ?? Infinity;\n const maxItems = opts.maxItems ?? Infinity;\n\n return () => {\n const batchLoader = (\n type: ProcedureType,\n ): BatchLoader<BatchStreamOperation, HTTPResult> => {\n return {\n validate(batchOps) {\n if (maxURLLength === Infinity && maxItems === Infinity) {\n // escape hatch for quick calcs\n return true;\n }\n if (batchOps.length > maxItems) {\n return false;\n }\n const path = batchOps.map((op) => op.path).join(',');\n const inputs = batchOps.map((op) => op.input);\n\n const url = getUrl({\n ...resolvedOpts,\n type,\n path,\n inputs,\n signal: null,\n });\n\n return url.length <= maxURLLength;\n },\n async fetch(batchOps) {\n const path = batchOps.map((op) => op.path).join(',');\n const inputs = batchOps.map((op) => op.input);\n\n const batchSignals = allAbortSignals(\n ...batchOps.map((op) => op.signal),\n );\n const abortController = new AbortController();\n abortController.signal.addEventListener(\n 'abort',\n () => {\n for (const op of batchOps) {\n op.releaseSignal();\n }\n },\n { once: true },\n );\n\n const responsePromise = fetchHTTPResponse({\n ...resolvedOpts,\n signal: raceAbortSignals(batchSignals, abortController.signal),\n type,\n contentTypeHeader: 'application/json',\n trpcAcceptHeader: 'application/jsonl',\n trpcAcceptHeaderKey: opts.streamHeader ?? 'trpc-accept',\n getUrl,\n getBody,\n inputs,\n path,\n headers() {\n if (!opts.headers) {\n return {};\n }\n if (typeof opts.headers === 'function') {\n return opts.headers({\n opList: batchOps as NonEmptyArray<BatchStreamOperation>,\n });\n }\n return opts.headers;\n },\n });\n\n const res = await responsePromise;\n\n if (!res.ok) {\n // Server returned a non-2xx response (e.g. batching disabled).\n // The body is plain JSON, not JSONL, so parse it directly and\n // propagate the same error to every operation in the batch.\n const json = (await res.json()) as TRPCResponse;\n if ('error' in json) {\n json.error = resolvedOpts.transformer.output.deserialize(\n json.error,\n );\n }\n\n return batchOps.map((): Promise<HTTPResult> =>\n Promise.resolve({\n json,\n meta: {\n response: res,\n },\n }),\n );\n }\n\n const [head] = await jsonlStreamConsumer<\n Record<string, Promise<any>>\n >({\n // oxlint-disable-next-line typescript/no-non-null-assertion\n from: res.body!,\n deserialize: (data) =>\n resolvedOpts.transformer.output.deserialize(data),\n onError: () => abortController.abort(),\n // An op with nothing left to stream must not hold the batch open.\n onSettled: (settled) => batchOps[Number(settled.key)]?.settle(),\n formatError(opts) {\n const error = opts.error as TRPCErrorShape;\n return TRPCClientError.from({\n error,\n });\n },\n abortController,\n });\n const promises = Object.keys(batchOps).map(\n async (key): Promise<HTTPResult> => {\n let json: TRPCResponse = await Promise.resolve(head[key]);\n\n if ('result' in json) {\n /**\n * Not very pretty, but we need to unwrap nested data as promises\n * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value\n */\n const result = await Promise.resolve(json.result);\n json = {\n result: {\n data: await Promise.resolve(result.data),\n },\n };\n }\n\n return {\n json,\n meta: {\n response: res,\n },\n };\n },\n );\n return promises;\n },\n };\n };\n\n const query = dataLoader(batchLoader('query'));\n const mutation = dataLoader(batchLoader('mutation'));\n\n const loaders = { query, mutation };\n return ({ op }) => {\n return observable((observer) => {\n /* istanbul ignore if -- @preserve */\n if (op.type === 'subscription') {\n throw new Error(\n 'Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`',\n );\n }\n const ac = new AbortController();\n const loader = loaders[op.type];\n const { signal, cleanup } = raceAbortSignalsWithCleanup(\n op.signal,\n ac.signal,\n );\n const promise = loader.load({\n ...op,\n signal,\n releaseSignal: cleanup,\n settle: () => ac.abort(),\n });\n\n let isDone = false;\n let _res = undefined as HTTPResult | undefined;\n promise\n .then((res) => {\n isDone = true;\n _res = res;\n if ('error' in res.json) {\n // A failed op has nothing left to stream, so it must not hold the batch open.\n ac.abort();\n observer.error(\n TRPCClientError.from(res.json, {\n meta: res.meta,\n }),\n );\n return;\n } else if ('result' in res.json) {\n observer.next({\n context: res.meta,\n result: res.json.result,\n });\n observer.complete();\n return;\n }\n\n observer.complete();\n })\n .catch((err) => {\n isDone = true;\n ac.abort();\n observer.error(\n TRPCClientError.from(err, {\n meta: _res?.meta,\n }),\n );\n });\n\n return () => {\n if (!isDone) {\n ac.abort();\n }\n };\n });\n };\n };\n}\n\n/**\n * @deprecated Use {@link httpBatchStreamLink} instead.\n */\nexport const unstable_httpBatchStreamLink = httpBatchStreamLink;\n","import { isPlainObject } from '@trpc/server/unstable-core-do-not-import';\n\nexport function inputWithTrackedEventId(\n input: unknown,\n lastEventId: string | undefined,\n) {\n if (!lastEventId) {\n return input;\n }\n // Spreading an array, a `Date` or a class instance would corrupt it, so only\n // a plain object can carry the id.\n if (input != null && !isPlainObject(input)) {\n return input;\n }\n return {\n ...(input ?? {}),\n lastEventId,\n };\n}\n","import { behaviorSubject, observable } from '@trpc/server/observable';\nimport type { TRPCErrorShape, TRPCResult } from '@trpc/server/rpc';\nimport type {\n AnyClientTypes,\n EventSourceLike,\n inferClientTypes,\n InferrableClientTypes,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n resolvePathSeparator,\n retryableRpcCodes,\n run,\n sseStreamConsumer,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport { raceAbortSignals } from '../internals/signals';\nimport { TRPCClientError } from '../TRPCClientError';\nimport type { TRPCConnectionState } from '../unstable-internals';\nimport { getTransformer, type TransformerOptions } from '../unstable-internals';\nimport { getUrl, type HTTPLinkBaseOptions } from './internals/httpUtils';\nimport {\n resultOf,\n type UrlOptionsWithConnectionParams,\n} from './internals/urlWithConnectionParams';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\nasync function urlWithConnectionParams(\n opts: UrlOptionsWithConnectionParams,\n): Promise<string> {\n let url = await resultOf(opts.url);\n if (opts.connectionParams) {\n const params = await resultOf(opts.connectionParams);\n\n const prefix = url.includes('?') ? '&' : '?';\n url +=\n prefix + 'connectionParams=' + encodeURIComponent(JSON.stringify(params));\n }\n\n return url;\n}\n\n/**\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink#httpsubscriptionlink-options\n */\ntype HTTPSubscriptionLinkOptions<\n TRoot extends AnyClientTypes,\n TEventSource extends EventSourceLike.AnyConstructor = typeof EventSource,\n> = {\n /**\n * The `EventSource` class to use, for runtimes that don't have one.\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink#custom-headers-through-ponyfill\n */\n EventSource?: TEventSource;\n /**\n * Options passed to the `EventSource`, or a function that returns them for\n * each subscription.\n */\n eventSourceOptions?:\n | EventSourceLike.InitDictOf<TEventSource>\n | ((opts: {\n op: Operation;\n }) =>\n | EventSourceLike.InitDictOf<TEventSource>\n | Promise<EventSourceLike.InitDictOf<TEventSource>>);\n} & Pick<HTTPLinkBaseOptions<TRoot>, 'pathSeparator'> &\n TransformerOptions<TRoot> &\n UrlOptionsWithConnectionParams;\n\n/**\n * A terminating link that runs subscriptions over Server-Sent Events.\n *\n * @see https://trpc.io/docs/client/links/httpSubscriptionLink\n */\nexport function httpSubscriptionLink<\n TInferrable extends InferrableClientTypes,\n TEventSource extends EventSourceLike.AnyConstructor,\n>(\n opts: HTTPSubscriptionLinkOptions<\n inferClientTypes<TInferrable>,\n TEventSource\n >,\n): TRPCLink<\n TInferrable,\n // its callbacks may read the fields added to `OperationContext`\n { context: AugmentedOperationContext }\n> {\n const transformer = getTransformer(opts.transformer);\n const pathSeparator = resolvePathSeparator(opts.pathSeparator);\n\n return () => {\n return ({ op }) => {\n return observable((observer) => {\n const { type, path, input } = op;\n\n /* istanbul ignore if -- @preserve */\n if (type !== 'subscription') {\n throw new Error('httpSubscriptionLink only supports subscriptions');\n }\n\n let lastEventId: string | undefined = undefined;\n const ac = new AbortController();\n const signal = raceAbortSignals(op.signal, ac.signal);\n const eventSourceStream = sseStreamConsumer<{\n EventSource: TEventSource;\n data: Partial<{\n id?: string;\n data: unknown;\n }>;\n error: TRPCErrorShape;\n }>({\n url: async () =>\n getUrl({\n transformer,\n url: await urlWithConnectionParams(opts),\n input: inputWithTrackedEventId(input, lastEventId),\n path,\n pathSeparator,\n type,\n signal: null,\n }),\n init: () => resultOf(opts.eventSourceOptions, { op }),\n signal,\n deserialize: (data) => transformer.output.deserialize(data),\n EventSource: opts.EventSource ?? (globalThis.EventSource as never),\n });\n\n const connectionState = behaviorSubject<\n TRPCConnectionState<TRPCClientError<any>>\n >({\n type: 'state',\n state: 'connecting',\n error: null,\n });\n\n const connectionSub = connectionState.subscribe({\n next(state) {\n observer.next({\n result: state,\n });\n },\n });\n run(async () => {\n for await (const chunk of eventSourceStream) {\n switch (chunk.type) {\n case 'ping':\n // do nothing\n break;\n case 'data':\n const chunkData = chunk.data;\n\n let result: TRPCResult<unknown>;\n if (chunkData.id) {\n // if the `tracked()`-helper is used, we always have an `id` field\n lastEventId = chunkData.id;\n result = {\n id: chunkData.id,\n data: chunkData,\n };\n } else {\n result = {\n data: chunkData.data,\n };\n }\n\n observer.next({\n result,\n context: {\n eventSource: chunk.eventSource,\n },\n });\n break;\n case 'connected': {\n observer.next({\n result: {\n type: 'started',\n },\n context: {\n eventSource: chunk.eventSource,\n },\n });\n connectionState.next({\n type: 'state',\n state: 'pending',\n error: null,\n });\n break;\n }\n case 'serialized-error': {\n const error = TRPCClientError.from({ error: chunk.error });\n\n if (retryableRpcCodes.includes(chunk.error.code)) {\n //\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error,\n });\n break;\n }\n //\n // non-retryable error, cancel the subscription\n throw error;\n }\n case 'connecting': {\n const lastState = connectionState.get();\n\n const error = chunk.event && TRPCClientError.from(chunk.event);\n if (!error && lastState.state === 'connecting') {\n break;\n }\n\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error,\n });\n break;\n }\n case 'timeout': {\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error: new TRPCClientError(\n `Timeout of ${chunk.ms}ms reached while waiting for a response`,\n ),\n });\n }\n }\n }\n observer.next({\n result: {\n type: 'stopped',\n },\n });\n connectionState.next({\n type: 'state',\n state: 'idle',\n error: null,\n });\n observer.complete();\n }).catch((error) => {\n observer.error(TRPCClientError.from(error));\n });\n\n return () => {\n observer.complete();\n ac.abort();\n connectionSub.unsubscribe();\n };\n });\n };\n };\n}\n\n/**\n * @deprecated Use {@link httpSubscriptionLink} instead.\n */\nexport const unstable_httpSubscriptionLink = httpSubscriptionLink;\n","/* istanbul ignore file -- @preserve */\n// We're not actually exporting this link\nimport type { Unsubscribable } from '@trpc/server/observable';\nimport { observable } from '@trpc/server/observable';\nimport type { InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport type { TRPCClientError } from '../TRPCClientError';\nimport type { AugmentedOperationContext, Operation, TRPCLink } from './types';\n\ntype RetryFn<TInferrable extends InferrableClientTypes> = (\n opts: RetryFnOptions<TInferrable>,\n) => boolean;\n\n/**\n * The `context` calls can pass through `retryLink`: the fields added to\n * `OperationContext` (`TAugmented`), which its callbacks may read, and\n * `retry`.\n * @public\n */\nexport type RetryLinkContext<\n TInferrable extends InferrableClientTypes,\n TAugmented extends object = AugmentedOperationContext,\n> = Omit<TAugmented, 'retry'> & {\n /**\n * Decides whether to retry this call, in place of the link's `retry`.\n * Anything else, such as a flag added to `OperationContext` that the\n * link's `retry` reads, is left to the link.\n * @example client.post.byId.query(input, { context: { retry: (opts) => opts.attempts <= 3 } })\n */\n retry?:\n | RetryFn<TInferrable>\n | ('retry' extends keyof TAugmented ? TAugmented['retry'] : never);\n};\n\ninterface RetryLinkOptions<TInferrable extends InferrableClientTypes> {\n /**\n * The retry function. A call's `context.retry` replaces it for that call.\n */\n retry: RetryFn<TInferrable>;\n /**\n * The delay between retries in ms (defaults to 0)\n */\n retryDelayMs?: (attempt: number) => number;\n}\n\n/**\n * What a `retry` function is given.\n * @public\n */\nexport interface RetryFnOptions<TInferrable extends InferrableClientTypes> {\n /**\n * The operation that failed\n */\n op: Operation;\n /**\n * The error that occurred\n */\n error: TRPCClientError<TInferrable>;\n /**\n * The number of attempts that have been made (including the first call)\n */\n attempts: number;\n}\n\n/**\n * Retries failed operations. Subscriptions resume from the last tracked event\n * id. A call can pass its own `retry` in `context`.\n *\n * @see https://trpc.io/docs/client/links/retryLink\n */\nexport function retryLink<TInferrable extends InferrableClientTypes>(\n opts: RetryLinkOptions<TInferrable>,\n): TRPCLink<TInferrable, { context: RetryLinkContext<TInferrable> }> {\n // initialized config\n return () => {\n // initialized in app\n return (callOpts) => {\n // initialized for request\n return observable((observer) => {\n let next$: Unsubscribable;\n let currentAttempt = 0;\n let disposed = false;\n let callNextTimeout: ReturnType<typeof setTimeout> | undefined =\n undefined;\n\n let lastEventId: string | undefined = undefined;\n\n attempt(1);\n\n function opWithLastEventId() {\n const op = callOpts.op;\n if (!lastEventId) {\n return op;\n }\n\n return {\n ...op,\n input: inputWithTrackedEventId(op.input, lastEventId),\n };\n }\n\n function attempt(attempts: number) {\n if (disposed) {\n return;\n }\n currentAttempt = attempts;\n const op = opWithLastEventId();\n\n const subscription = callOpts.next(op).subscribe({\n error(error) {\n const callRetry = op.context['retry'];\n // a `retry` that isn't a function is a flag for the link's own `retry`\n const retry =\n typeof callRetry === 'function'\n ? (callRetry as RetryFn<TInferrable>)\n : opts.retry;\n const shouldRetry = retry({\n op,\n attempts,\n error,\n });\n if (disposed) {\n return;\n }\n if (!shouldRetry) {\n observer.error(error);\n return;\n }\n const delayMs = opts.retryDelayMs?.(attempts) ?? 0;\n if (disposed) {\n return;\n }\n\n if (delayMs <= 0) {\n attempt(attempts + 1);\n return;\n }\n callNextTimeout = setTimeout(\n () => attempt(attempts + 1),\n delayMs,\n );\n },\n next(envelope) {\n //\n if (\n (!envelope.result.type || envelope.result.type === 'data') &&\n envelope.result.id\n ) {\n //\n lastEventId = envelope.result.id;\n }\n\n observer.next(envelope);\n },\n complete() {\n observer.complete();\n },\n });\n\n // A synchronous error may have already subscribed the next attempt.\n if (disposed) {\n subscription.unsubscribe();\n } else if (currentAttempt === attempts) {\n next$ = subscription;\n }\n }\n return () => {\n disposed = true;\n next$.unsubscribe();\n clearTimeout(callNextTimeout);\n };\n });\n };\n };\n}\n","import {\n getTRPCErrorFromUnknown,\n getTRPCErrorShape,\n isTrackedEnvelope,\n} from '@trpc/server';\nimport {\n behaviorSubject,\n isObservable,\n observable,\n observableToAsyncIterable,\n} from '@trpc/server/observable';\nimport { TRPC_ERROR_CODES_BY_KEY, type TRPCResult } from '@trpc/server/rpc';\nimport {\n callProcedure,\n isAbortError,\n isAsyncIterable,\n iteratorResource,\n makeResource,\n retryableRpcCodes,\n run,\n type AnyRouter,\n type ErrorHandlerOptions,\n type inferClientTypes,\n type inferRouterContext,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId';\nimport {\n abortSignalToPromise,\n raceAbortSignals,\n throwIfAborted,\n} from '../internals/signals';\nimport { getTransformer } from '../internals/transformer';\nimport type { TransformerOptions } from '../internals/transformer';\nimport { isTRPCClientError, TRPCClientError } from '../TRPCClientError';\nimport type { TRPCConnectionState } from './internals/subscriptions';\nimport type { TRPCLink } from './types';\n\n/**\n * Passed to {@link LocalLinkOptions.createContext}.\n */\nexport type LocalLinkCreateContextOptions = {\n /**\n * What tRPC knows about the call, like the `info` that adapters pass to\n * their `createContext`.\n */\n info: {\n /**\n * Aborts when the call is cancelled or unsubscribed. Pass it on to work\n * that creating the context starts, such as `fetch()` calls.\n */\n signal: AbortSignal;\n };\n};\n\n/**\n * Options for {@link localLink}.\n *\n * @see https://trpc.io/docs/client/links/localLink#options\n */\nexport type LocalLinkOptions<TRouter extends AnyRouter> = {\n /**\n * The router to call.\n * @see https://trpc.io/docs/client/links/localLink#router\n */\n router: TRouter;\n /**\n * Creates the context for each call. `info.signal` aborts when the call\n * is cancelled.\n * @see https://trpc.io/docs/client/links/localLink#createcontext\n */\n createContext: (\n opts: LocalLinkCreateContextOptions,\n ) => Promise<inferRouterContext<TRouter>>;\n /**\n * Called when a procedure throws.\n * @see https://trpc.io/docs/client/links/localLink#onerror\n */\n onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;\n} & TransformerOptions<inferClientTypes<TRouter>>;\n\n/**\n * A terminating link that calls procedures on a router in the same process,\n * without HTTP.\n *\n * @see https://trpc.io/docs/client/links/localLink\n */\nexport function localLink<TRouter extends AnyRouter>(\n opts: LocalLinkOptions<TRouter>,\n): TRPCLink<TRouter, { context: {} }> {\n const transformer = getTransformer(opts.transformer);\n\n const transformChunk = (chunk: unknown) => {\n if (opts.transformer) {\n // assume transformer will do the right thing\n return chunk;\n }\n // Special case for undefined, because `JSON.stringify(undefined)` throws\n if (chunk === undefined) {\n return chunk;\n }\n const serialized = JSON.stringify(transformer.input.serialize(chunk));\n const deserialized = JSON.parse(transformer.output.deserialize(serialized));\n return deserialized;\n };\n\n return () =>\n ({ op }) =>\n observable((observer) => {\n let ctx: inferRouterContext<TRouter> | undefined = undefined;\n const ac = new AbortController();\n\n const signal = raceAbortSignals(op.signal, ac.signal);\n const signalPromise = abortSignalToPromise(signal);\n\n signalPromise.catch(() => {\n // prevent unhandled rejection\n });\n\n let input = op.input;\n async function runProcedure(newInput: unknown): Promise<unknown> {\n input = newInput;\n\n // don't start work for a call that was cancelled before it ran\n throwIfAborted(signal);\n ctx = await opts.createContext({ info: { signal } });\n throwIfAborted(signal);\n\n return callProcedure({\n router: opts.router,\n path: op.path,\n getRawInput: async () => newInput,\n ctx,\n type: op.type,\n signal,\n batchIndex: 0,\n });\n }\n\n function onErrorCallback(cause: unknown) {\n if (isAbortError(cause)) {\n return;\n }\n opts.onError?.({\n error: getTRPCErrorFromUnknown(cause),\n type: op.type,\n path: op.path,\n input,\n ctx,\n });\n }\n\n function coerceToTRPCClientError(cause: unknown) {\n if (isTRPCClientError<TRouter>(cause)) {\n return cause;\n }\n const error = getTRPCErrorFromUnknown(cause);\n\n const shape = getTRPCErrorShape({\n config: opts.router._def._config,\n ctx,\n error,\n input,\n path: op.path,\n type: op.type,\n });\n return TRPCClientError.from(\n { error: transformChunk(shape) },\n { cause: cause instanceof Error ? cause : undefined },\n );\n }\n\n run(async () => {\n switch (op.type) {\n case 'query':\n case 'mutation': {\n const result = await Promise.race([\n runProcedure(op.input),\n signalPromise,\n ]);\n if (!isAsyncIterable(result)) {\n observer.next({\n result: { data: transformChunk(result) },\n });\n observer.complete();\n break;\n }\n\n observer.next({\n result: {\n data: (async function* () {\n await using iterator = iteratorResource(result);\n using _finally = makeResource({}, () => {\n observer.complete();\n });\n try {\n while (true) {\n const res = await Promise.race([\n iterator.next(),\n signalPromise,\n ]);\n if (res.done) {\n return transformChunk(res.value);\n }\n yield transformChunk(res.value);\n }\n } catch (cause) {\n onErrorCallback(cause);\n throw coerceToTRPCClientError(cause);\n }\n })(),\n },\n });\n break;\n }\n case 'subscription': {\n const connectionState = behaviorSubject<\n TRPCConnectionState<TRPCClientError<any>>\n >({\n type: 'state',\n state: 'connecting',\n error: null,\n });\n\n const connectionSub = connectionState.subscribe({\n next(state) {\n observer.next({\n result: state,\n });\n },\n });\n let lastEventId: string | undefined = undefined;\n\n using _finally = makeResource({}, async () => {\n connectionState.next({\n type: 'state',\n state: 'idle',\n error: null,\n });\n connectionSub.unsubscribe();\n });\n\n // returning from here means the stream ended, so this completes\n // below - a throw is left to the `.catch()`, which needs the\n // observer to still be open by the time it runs\n await run(async () => {\n while (true) {\n const procedureResult = await runProcedure(\n inputWithTrackedEventId(op.input, lastEventId),\n );\n const result = isObservable(procedureResult)\n ? observableToAsyncIterable(procedureResult, signal)\n : procedureResult;\n if (!isAsyncIterable(result)) {\n throw new Error('Expected an async iterable');\n }\n await using iterator = iteratorResource(result);\n\n observer.next({\n result: {\n type: 'started',\n },\n });\n connectionState.next({\n type: 'state',\n state: 'pending',\n error: null,\n });\n\n // Use a while loop to handle errors and reconnects\n while (true) {\n let res;\n try {\n res = await Promise.race([\n iterator.next(),\n signalPromise,\n ]);\n } catch (cause) {\n if (isAbortError(cause)) {\n return;\n }\n const error = getTRPCErrorFromUnknown(cause);\n\n if (\n !retryableRpcCodes.includes(\n TRPC_ERROR_CODES_BY_KEY[error.code],\n )\n ) {\n throw coerceToTRPCClientError(error);\n }\n\n onErrorCallback(error);\n connectionState.next({\n type: 'state',\n state: 'connecting',\n error: coerceToTRPCClientError(error),\n });\n\n break;\n }\n\n if (res.done) {\n return;\n }\n let chunk: TRPCResult<unknown>;\n if (isTrackedEnvelope(res.value)) {\n lastEventId = res.value[0];\n\n chunk = {\n id: res.value[0],\n data: {\n id: res.value[0],\n data: res.value[1],\n },\n };\n } else {\n chunk = {\n data: res.value,\n };\n }\n\n observer.next({\n result: {\n ...chunk,\n data: transformChunk(chunk.data),\n },\n });\n }\n }\n });\n\n observer.complete();\n break;\n }\n }\n }).catch((cause) => {\n onErrorCallback(cause);\n observer.error(coerceToTRPCClientError(cause));\n });\n\n return () => {\n ac.abort();\n };\n });\n}\n\n/**\n * @deprecated Use {@link localLink} instead.\n * @function\n */\nexport const unstable_localLink = localLink;\n\n/**\n * @deprecated Use {@link localLink} instead. This alias will be removed in a\n * future major release.\n */\nexport const experimental_localLink = localLink;\n","import type { TRPCClientError } from './TRPCClientError';\n\n/**\n * @internal\n */\nexport declare const errorShapeTag: unique symbol;\n\n/**\n * The promise a client's `.query()` or `.mutate()` returns, tagged with\n * the procedure's error shape for `safe()`.\n */\nexport type TRPCTaggedPromise<TData, TErrorShape> = Promise<TData> & {\n readonly [errorShapeTag]: TErrorShape;\n};\n\n/**\n * @internal\n */\nexport type inferSafeError<TErrorShape> = TRPCClientError<{\n errorShape: TErrorShape;\n transformer: boolean;\n}>;\n\n/**\n * What `safe()` resolves to: `[data, undefined]` or `[undefined, error]`.\n * @see https://trpc.io/docs/client/vanilla/error-handling#errors-as-values-with-safe\n */\nexport type SafeResult<TData, TErrorShape> =\n | readonly [data: TData, error: undefined]\n | readonly [data: undefined, error: inferSafeError<TErrorShape>];\n\n/**\n * Awaits a client `.query()` or `.mutate()` call without throwing, and\n * returns a `[data, error]` pair typed with the procedure's error shape.\n *\n * @example\n * ```ts\n * const [post, error] = await safe(client.post.byId.query({ id }));\n * if (error) {\n * console.error(error);\n * }\n *\n * const id = post.id;\n * ```\n * @see https://trpc.io/docs/client/vanilla/error-handling#errors-as-values-with-safe\n */\nexport async function safe<TData, TErrorShape>(\n promise: TRPCTaggedPromise<TData, TErrorShape>,\n): Promise<SafeResult<TData, TErrorShape>> {\n try {\n return [await promise, undefined];\n } catch (cause) {\n return [undefined, cause as inferSafeError<TErrorShape>];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsFA,MAAM,eAA8B;CAClC;CACA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I,MACN;QAEF,IAAI;QACJ,IAAI,kBAAkB,IAAI,KAAK,GAAG;SAChC,cAAc,IAAI,MAAM;SAExB,QAAQ;UACN,IAAI,IAAI,MAAM;UACd,MAAM;WACJ,IAAI,IAAI,MAAM;WACd,MAAM,IAAI,MAAM;UAClB;SACF;QACF,OACE,QAAQ,EACN,MAAM,IAAI,MACZ;QAGF,SAAS,KAAK,EACZ,QAAA,eAAA,eAAA,CAAA,GACK,KAAA,GAAA,CAAA,GAAA,EACH,MAAM,eAAe,MAAM,IAAI,EAAA,CACjC,EACF,CAAC;OACH;;;;;;KAEJ,CAAC;KAED,SAAS,SAAS;KAClB;;;;;;GAEJ;EACF,CAAC,CAAC,CAAC,OAAO,UAAU;GAClB,gBAAgB,KAAK;GACrB,SAAS,MAAM,wBAAwB,KAAK,CAAC;EAC/C,CAAC;EAED,aAAa;GACX,GAAG,MAAM;EACX;CACF,CAAC;AACP;;;;;AAMA,MAAa,qBAAqB;;;;;AAMlC,MAAa,yBAAyB;;;;;;;;;;;;;;;;;ACrTtC,eAAsB,KACpB,SACyC;CACzC,IAAI;EACF,OAAO,CAAC,MAAM,SAAS,KAAA,CAAS;CAClC,SAAS,OAAO;EACd,OAAO,CAAC,KAAA,GAAW,KAAoC;CACzD;AACF"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@trpc/client",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "11.34.0",
5
+ "version": "11.35.1",
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.34.0",
103
+ "@trpc/server": "11.35.1",
104
104
  "typescript": ">=5.7.2"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@tanstack/intent": "0.5.6",
108
- "@trpc/server": "11.34.0",
108
+ "@trpc/server": "11.35.1",
109
109
  "@types/isomorphic-fetch": "^0.0.39",
110
110
  "@types/node": "^24.19.2",
111
111
  "dataloader": "^2.2.3",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: client-setup
3
- description: Create a vanilla tRPC client with createTRPCClient<AppRouter>() and a terminating link such as httpBatchLink, import AppRouter with `import type`, set dynamic auth headers, and put the transformer on links (not the client constructor). Infer types with inferRouterInputs and inferRouterOutputs, handle TRPCClientError with try/catch or safe(), and abort calls with an AbortSignal.
3
+ description: Create a vanilla tRPC client with createTRPCClient, passing the router type as router routerType<AppRouter>() and a terminating link such as httpBatchLink, import AppRouter with `import type`, set dynamic auth headers, and put the transformer on links (not the client constructor). Infer types with inferRouterInputs and inferRouterOutputs, handle TRPCClientError with try/catch or safe(), and abort calls with an AbortSignal.
4
4
  requires:
5
5
  - server-setup
6
6
  sources:
@@ -12,7 +12,7 @@ sources:
12
12
  metadata:
13
13
  type: core
14
14
  library: trpc
15
- library_version: 11.34.0
15
+ library_version: 11.35.1
16
16
  ---
17
17
 
18
18
  <!-- Generated from www/v11/docs/client/vanilla/setup.md by www/build/skills.ts. Edit the docs instead. -->
@@ -43,13 +43,16 @@ import type { AppRouter } from '../server/router';
43
43
 
44
44
  ### 3. Initialize the tRPC client
45
45
 
46
- Create a tRPC client with the `createTRPCClient` method, and add a `links` array with a [terminating link](https://trpc.io/docs/client/links#the-terminating-link) pointing at your API. To learn more about tRPC links, [click here](https://trpc.io/docs/client/links).
46
+ Create a tRPC client with the `createTRPCClient` method. Pass your router's type as `router: routerType<AppRouter>()`, and add a `links` array with a [terminating link](https://trpc.io/docs/client/links#the-terminating-link) pointing at your API. `routerType` does nothing at runtime, so no server code reaches the client. To learn more about tRPC links, [click here](https://trpc.io/docs/client/links).
47
+
48
+ With `router:`, the client also types each call's `context` from what its links read. See [Typing call options](https://trpc.io/docs/client/links#typing-call-options).
47
49
 
48
50
  ```ts no-check title="client.ts"
49
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
51
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
50
52
  import type { AppRouter } from './server';
51
53
 
52
- const client = createTRPCClient<AppRouter>({
54
+ const client = createTRPCClient({
55
+ router: routerType<AppRouter>(),
53
56
  links: [
54
57
  httpBatchLink({
55
58
  url: 'http://localhost:3000/trpc',
@@ -115,7 +118,7 @@ You're all set!
115
118
 
116
119
  ## Common mistakes
117
120
 
118
- - **Leaving out the `AppRouter` type parameter.** `createTRPCClient({ links })` without `<AppRouter>` compiles, but none of your procedures are typed. If the `AppRouter` import doesn't resolve (often a monorepo path or `tsconfig` issue), fix the import rather than reaching for `createTRPCClient<any>`.
121
+ - **Leaving out `router`.** `createTRPCClient({ links })` without `router: routerType<AppRouter>()` compiles, but none of your procedures are typed. If the `AppRouter` import doesn't resolve (often a monorepo path or `tsconfig` issue), fix the import rather than reaching for `routerType<any>()`.
119
122
  - **Importing the router value instead of its type.** `import { appRouter } from '../server/router'` pulls your server code into the client bundle. Export `type AppRouter = typeof appRouter` from the server and import it with `import type`.
120
123
  - **Passing `transformer` to `createTRPCClient`.** The transformer belongs on each terminating link (`httpBatchLink`, `httpLink`, `wsLink`, ...), and TypeScript rejects it on the client itself. See [Data Transformers](https://trpc.io/docs/server/data-transformers).
121
124
  - **Using `createTRPCProxyClient`.** It's the v10 name, kept as a deprecated alias of `createTRPCClient`.
@@ -309,10 +312,11 @@ From https://trpc.io/docs/client/vanilla/aborting-procedure-calls
309
312
  tRPC supports the standard `AbortController`/`AbortSignal` API for aborting procedures. All you have to do is pass an `AbortSignal` to the query or mutation options, and call the `AbortController` instance's `abort` method if you need to cancel the request.
310
313
 
311
314
  ```ts no-check title="utils.ts"
312
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
315
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
313
316
  import type { AppRouter } from './server';
314
317
 
315
- const client = createTRPCClient<AppRouter>({
318
+ const client = createTRPCClient({
319
+ router: routerType<AppRouter>(),
316
320
  links: [
317
321
  httpBatchLink({
318
322
  url: 'http://localhost:3000/trpc',
@@ -339,7 +343,7 @@ The headers option may be used with any of our HTTP links: [`httpBatchLink`](htt
339
343
  `headers` can be both an object or a function. If it's a function it will get called dynamically for every HTTP request.
340
344
 
341
345
  ```ts no-check title="utils/trpc.ts"
342
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
346
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
343
347
  import type { AppRouter } from './server';
344
348
 
345
349
  let token: string;
@@ -352,7 +356,8 @@ export function setToken(newToken: string) {
352
356
  token = newToken;
353
357
  }
354
358
 
355
- export const trpc = createTRPCClient<AppRouter>({
359
+ export const trpc = createTRPCClient({
360
+ router: routerType<AppRouter>(),
356
361
  links: [
357
362
  httpBatchLink({
358
363
  url: 'http://localhost:3000',
@@ -17,7 +17,7 @@ sources:
17
17
  metadata:
18
18
  type: core
19
19
  library: trpc
20
- library_version: 11.34.0
20
+ library_version: 11.35.1
21
21
  ---
22
22
 
23
23
  <!-- Generated from www/v11/docs/client/links.md by www/build/skills.ts. Edit the docs instead. -->
@@ -36,10 +36,11 @@ You can compose links together into an array that you can provide to the tRPC cl
36
36
  </div>
37
37
 
38
38
  ```ts no-check title="utils/trpc.ts"
39
- import { createTRPCClient, httpBatchLink, loggerLink } from '@trpc/client';
39
+ import { createTRPCClient, httpBatchLink, loggerLink, routerType } from '@trpc/client';
40
40
  import type { AppRouter } from './server';
41
41
 
42
- export const trpc = createTRPCClient<AppRouter>({
42
+ export const trpc = createTRPCClient({
43
+ router: routerType<AppRouter>(),
43
44
  links: [
44
45
  loggerLink(),
45
46
  httpBatchLink({
@@ -123,10 +124,12 @@ import {
123
124
  httpSubscriptionLink,
124
125
  loggerLink,
125
126
  splitLink,
127
+ routerType,
126
128
  } from '@trpc/client';
127
129
  import type { AppRouter } from './server';
128
130
 
129
- export const trpc = createTRPCClient<AppRouter>({
131
+ export const trpc = createTRPCClient({
132
+ router: routerType<AppRouter>(),
130
133
  links: [
131
134
  loggerLink(),
132
135
  splitLink({
@@ -176,7 +179,6 @@ await client.greeting.query(undefined, { context: { traceId: 123 } });
176
179
  - Declared fields are type-checked, and always optional.
177
180
  - A link that declares nothing, such as `TRPCLink<AppRouter>`, may read any field, so calls can pass any `context`. Declare `{ context: {} }` for a link that reads none. When every link reads none, passing a field is an error.
178
181
  - Links that hand the operation to your code, such as the HTTP links' `headers` or `retryLink`'s `retry`, declare only the fields added to `OperationContext`.
179
- - With `createTRPCClient<AppRouter>()`, calls take any `context`, as before.
180
182
 
181
183
  To pass a field that such a callback reads, add it to `OperationContext`:
182
184
 
@@ -11,10 +11,11 @@ From https://trpc.io/docs/client/links/httpBatchLink
11
11
  You can import and add the `httpBatchLink` to the `links` array as such:
12
12
 
13
13
  ```ts no-check title="client/index.ts"
14
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
14
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
15
15
  import type { AppRouter } from './server';
16
16
 
17
- const client = createTRPCClient<AppRouter>({
17
+ const client = createTRPCClient({
18
+ router: routerType<AppRouter>(),
18
19
  links: [
19
20
  httpBatchLink({
20
21
  url: 'http://localhost:3000',
@@ -93,10 +94,11 @@ export interface HTTPLinkOptions {
93
94
  When sending batch requests, sometimes the URL can become too large causing HTTP errors like [`413 Payload Too Large`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413), [`414 URI Too Long`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414), and [`404 Not Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404). The `maxURLLength` option will limit the number of requests that can be sent together in a batch.
94
95
 
95
96
  ```ts no-check title="client/index.ts"
96
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
97
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
97
98
  import type { AppRouter } from './server';
98
99
 
99
- const client = createTRPCClient<AppRouter>({
100
+ const client = createTRPCClient({
101
+ router: routerType<AppRouter>(),
100
102
  links: [
101
103
  httpBatchLink({
102
104
  url: 'http://localhost:3000',
@@ -141,10 +143,11 @@ export default createNextApiHandler({
141
143
  Use the `maxItems` option on your batch link to ensure the client doesn't exceed the server's limit. This splits large batches into multiple HTTP requests automatically
142
144
 
143
145
  ```ts title="client/index.ts"
144
- import { createTRPCClient, httpBatchLink } from '@trpc/client';
146
+ import { createTRPCClient, httpBatchLink, routerType } from '@trpc/client';
145
147
  import type { AppRouter } from '../server';
146
148
 
147
- const client = createTRPCClient<AppRouter>({
149
+ const client = createTRPCClient({
150
+ router: routerType<AppRouter>(),
148
151
  links: [
149
152
  httpBatchLink({
150
153
  url: 'http://localhost:3000',
@@ -186,10 +189,11 @@ export default createNextApiHandler({
186
189
  ### 2. Replace `httpBatchLink` with [`httpLink`](https://trpc.io/docs/client/links/httpLink) in your tRPC Client
187
190
 
188
191
  ```ts no-check title="client/index.ts"
189
- import { createTRPCClient, httpLink } from '@trpc/client';
192
+ import { createTRPCClient, httpLink, routerType } from '@trpc/client';
190
193
  import type { AppRouter } from './server';
191
194
 
192
- const client = createTRPCClient<AppRouter>({
195
+ const client = createTRPCClient({
196
+ router: routerType<AppRouter>(),
193
197
  links: [
194
198
  httpLink({
195
199
  url: 'http://localhost:3000',
@@ -25,10 +25,11 @@ Options are identical to [`httpBatchLink options`](https://trpc.io/docs/client/l
25
25
  You can import and add the `httpBatchStreamLink` to the `links` array as such:
26
26
 
27
27
  ```ts no-check title="client/index.ts"
28
- import { createTRPCClient, httpBatchStreamLink } from '@trpc/client';
28
+ import { createTRPCClient, httpBatchStreamLink, routerType } from '@trpc/client';
29
29
  import type { AppRouter } from './server';
30
30
 
31
- const client = createTRPCClient<AppRouter>({
31
+ const client = createTRPCClient({
32
+ router: routerType<AppRouter>(),
32
33
  links: [
33
34
  httpBatchStreamLink({
34
35
  url: 'http://localhost:3000',
@@ -54,10 +55,11 @@ Each procedure still runs its own resolver, so whether this makes one database q
54
55
  When batching requests together, the behavior of a regular `httpBatchLink` is to wait for all requests to finish before sending the response. If you want to send responses as soon as they are ready, you can use `httpBatchStreamLink` instead. This is useful for long-running requests.
55
56
 
56
57
  ```ts no-check title="client/index.ts"
57
- import { createTRPCClient, httpBatchStreamLink } from '@trpc/client';
58
+ import { createTRPCClient, httpBatchStreamLink, routerType } from '@trpc/client';
58
59
  import type { AppRouter } from './server';
59
60
 
60
- const client = createTRPCClient<AppRouter>({
61
+ const client = createTRPCClient({
62
+ router: routerType<AppRouter>(),
61
63
  links: [
62
64
  httpBatchStreamLink({
63
65
  url: 'http://localhost:3000',
@@ -77,10 +79,11 @@ Compared to a regular `httpBatchLink`, a `httpBatchStreamLink` will:
77
79
  You can try this out on the homepage of tRPC.io: [https://trpc.io/?try=minimal#try-it-out](https://trpc.io/?try=minimal#try-it-out)
78
80
 
79
81
  ```ts no-check
80
- import { createTRPCClient, httpBatchStreamLink } from '@trpc/client';
82
+ import { createTRPCClient, httpBatchStreamLink, routerType } from '@trpc/client';
81
83
  import type { AppRouter } from './server';
82
84
 
83
- const trpc = createTRPCClient<AppRouter>({
85
+ const trpc = createTRPCClient({
86
+ router: routerType<AppRouter>(),
84
87
  links: [
85
88
  httpBatchStreamLink({
86
89
  url: 'http://localhost:3000',
@@ -13,10 +13,11 @@ From https://trpc.io/docs/client/links/httpLink
13
13
  You can import and add the `httpLink` to the `links` array as such:
14
14
 
15
15
  ```ts no-check title="client/index.ts"
16
- import { createTRPCClient, httpLink } from '@trpc/client';
16
+ import { createTRPCClient, httpLink, routerType } from '@trpc/client';
17
17
  import type { AppRouter } from './server';
18
18
 
19
- const client = createTRPCClient<AppRouter>({
19
+ const client = createTRPCClient({
20
+ router: routerType<AppRouter>(),
20
21
  links: [
21
22
  httpLink({
22
23
  url: 'http://localhost:3000',
@@ -23,10 +23,12 @@ import {
23
23
  httpSubscriptionLink,
24
24
  loggerLink,
25
25
  splitLink,
26
+ routerType,
26
27
  } from '@trpc/client';
27
28
  import type { AppRouter } from './server';
28
29
 
29
- const trpcClient = createTRPCClient<AppRouter>({
30
+ const trpcClient = createTRPCClient({
31
+ router: routerType<AppRouter>(),
30
32
  /**
31
33
  * @see https://trpc.io/docs/v11/client/links
32
34
  */
@@ -89,12 +91,14 @@ import {
89
91
  httpBatchLink,
90
92
  httpSubscriptionLink,
91
93
  splitLink,
94
+ routerType,
92
95
  } from '@trpc/client';
93
96
  import { EventSourcePolyfill } from 'event-source-polyfill';
94
97
  import type { AppRouter } from './server';
95
98
 
96
99
  // Initialize the tRPC client
97
- const trpc = createTRPCClient<AppRouter>({
100
+ const trpc = createTRPCClient({
101
+ router: routerType<AppRouter>(),
98
102
  links: [
99
103
  splitLink({
100
104
  condition: (op) => op.type === 'subscription',
@@ -140,6 +144,7 @@ import {
140
144
  httpSubscriptionLink,
141
145
  retryLink,
142
146
  splitLink,
147
+ routerType,
143
148
  } from '@trpc/client';
144
149
  import {
145
150
  EventSourcePolyfill,
@@ -148,7 +153,8 @@ import {
148
153
  import type { AppRouter } from './server';
149
154
 
150
155
  // Initialize the tRPC client
151
- const trpc = createTRPCClient<AppRouter>({
156
+ const trpc = createTRPCClient({
157
+ router: routerType<AppRouter>(),
152
158
  links: [
153
159
  splitLink({
154
160
  condition: (op) => op.type === 'subscription',
@@ -220,11 +226,13 @@ import {
220
226
  httpBatchLink,
221
227
  httpSubscriptionLink,
222
228
  splitLink,
229
+ routerType,
223
230
  } from '@trpc/client';
224
231
  import type { AppRouter } from './server';
225
232
 
226
233
  // Initialize the tRPC client
227
- const trpc = createTRPCClient<AppRouter>({
234
+ const trpc = createTRPCClient({
235
+ router: routerType<AppRouter>(),
228
236
  links: [
229
237
  splitLink({
230
238
  condition: (op) => op.type === 'subscription',
@@ -13,11 +13,12 @@ From https://trpc.io/docs/client/links/localLink
13
13
  ## Usage
14
14
 
15
15
  ```tsx no-check
16
- import { createTRPCClient, localLink } from '@trpc/client';
16
+ import { createTRPCClient, localLink, routerType } from '@trpc/client';
17
17
  import type { AppRouter } from './server';
18
18
  import { appRouter } from './server';
19
19
 
20
- const client = createTRPCClient<AppRouter>({
20
+ const client = createTRPCClient({
21
+ router: routerType<AppRouter>(),
21
22
  links: [
22
23
  localLink({
23
24
  router: appRouter,
@@ -11,10 +11,11 @@ From https://trpc.io/docs/client/links/loggerLink
11
11
  You can import and add the `loggerLink` to the `links` array as such:
12
12
 
13
13
  ```ts no-check title="client/index.ts"
14
- import { createTRPCClient, httpBatchLink, loggerLink } from '@trpc/client';
14
+ import { createTRPCClient, httpBatchLink, loggerLink, routerType } from '@trpc/client';
15
15
  import type { AppRouter } from './server';
16
16
 
17
- const client = createTRPCClient<AppRouter>({
17
+ const client = createTRPCClient({
18
+ router: routerType<AppRouter>(),
18
19
  links: [
19
20
  /**
20
21
  * The function passed to enabled is an example in case you want to the link to
@@ -15,10 +15,11 @@ From https://trpc.io/docs/client/links/retryLink
15
15
  You can import and add the `retryLink` to the `links` array when creating your tRPC client. This link can be placed before or after other links in your setup, depending on your requirements.
16
16
 
17
17
  ```ts no-check
18
- import { createTRPCClient, httpBatchLink, retryLink } from '@trpc/client';
18
+ import { createTRPCClient, httpBatchLink, retryLink, routerType } from '@trpc/client';
19
19
  import type { AppRouter } from './server';
20
20
 
21
- const client = createTRPCClient<AppRouter>({
21
+ const client = createTRPCClient({
22
+ router: routerType<AppRouter>(),
22
23
  links: [
23
24
  retryLink({
24
25
  retry(opts) {
@@ -11,14 +11,15 @@ From https://trpc.io/docs/client/links/wsLink
11
11
  To use `wsLink`, you need to pass it a `TRPCWebSocketClient`, which you can create with `createWSClient`:
12
12
 
13
13
  ```ts no-check title="client/index.ts"
14
- import { createTRPCClient, createWSClient, wsLink } from '@trpc/client';
14
+ import { createTRPCClient, createWSClient, wsLink, routerType } from '@trpc/client';
15
15
  import type { AppRouter } from './server';
16
16
 
17
17
  const wsClient = createWSClient({
18
18
  url: 'ws://localhost:3000',
19
19
  });
20
20
 
21
- const trpcClient = createTRPCClient<AppRouter>({
21
+ const trpcClient = createTRPCClient({
22
+ router: routerType<AppRouter>(),
22
23
  links: [wsLink<AppRouter>({ client: wsClient })],
23
24
  });
24
25
  ```
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: composition
11
11
  library: trpc
12
- library_version: 11.34.0
12
+ library_version: 11.35.1
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/data-transformers.md by www/build/skills.ts. Edit the docs instead. -->
@@ -54,11 +54,12 @@ export const t = initTRPC.create({
54
54
  `createTRPCClient()`:
55
55
 
56
56
  ```ts no-check title="src/app/_trpc/client.ts"
57
- import { createTRPCClient, httpLink } from '@trpc/client';
57
+ import { createTRPCClient, httpLink, routerType } from '@trpc/client';
58
58
  import type { AppRouter } from './server';
59
59
  import superjson from 'superjson';
60
60
 
61
- export const client = createTRPCClient<AppRouter>({
61
+ export const client = createTRPCClient({
62
+ router: routerType<AppRouter>(),
62
63
  links: [
63
64
  httpLink({
64
65
  url: 'http://localhost:3000',
@@ -76,11 +77,13 @@ import {
76
77
  httpBatchLink,
77
78
  httpSubscriptionLink,
78
79
  splitLink,
80
+ routerType,
79
81
  } from '@trpc/client';
80
82
  import type { AppRouter } from './server';
81
83
  import superjson from 'superjson';
82
84
 
83
- export const client = createTRPCClient<AppRouter>({
85
+ export const client = createTRPCClient({
86
+ router: routerType<AppRouter>(),
84
87
  links: [
85
88
  splitLink({
86
89
  condition: (op) => op.type === 'subscription',
@@ -149,11 +152,12 @@ export const t = initTRPC.create({
149
152
  `createTRPCClient()`:
150
153
 
151
154
  ```ts no-check title="src/app/_trpc/client.ts"
152
- import { createTRPCClient, httpLink } from '@trpc/client';
155
+ import { createTRPCClient, httpLink, routerType } from '@trpc/client';
153
156
  import type { AppRouter } from './server/routers/_app';
154
157
  import { transformer } from './utils/trpc';
155
158
 
156
- export const client = createTRPCClient<AppRouter>({
159
+ export const client = createTRPCClient({
160
+ router: routerType<AppRouter>(),
157
161
  links: [
158
162
  httpLink({
159
163
  url: 'http://localhost:3000',
@@ -265,6 +265,9 @@ export function createTRPCClient<
265
265
  * const post = await client.post.byId.query({ id: '1' });
266
266
  * ```
267
267
  * @see https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client
268
+ * @deprecated Pass the router's type as `router: routerType<AppRouter>()`
269
+ * instead of a type argument, so the links can type each call's `context`.
270
+ * The type argument form is removed in v12.
268
271
  */
269
272
  // Kept last: `ReturnType<typeof createTRPCClient>` reads the last overload.
270
273
  export function createTRPCClient<TRouter extends AnyRouter>(