{"version":3,"file":"index.mjs","names":[],"sources":["../../src/unstable-handles/entryError.ts","../../src/unstable-handles/handles.ts"],"sourcesContent":["import type { TRPCClientErrorLike } from '@trpc/client';\nimport { isTRPCClientError } from '@trpc/client';\nimport type { TRPC_ERROR_CODE_KEY, TRPCError } from '@trpc/server';\nimport { getTRPCErrorFromUnknown } from '@trpc/server/unstable-core-do-not-import';\nimport type { ResolverDef } from '../internals/types';\n\nexport type ErrorOf<TDef extends ResolverDef> = TRPCClientErrorLike<{\n  transformer: TDef['transformer'];\n  errorShape: TDef['errorShape'];\n}>;\n\n/**\n * What `loadHandles()` rejects with when a fetch or ensure entry fails. It\n * names the entry, and keeps the request's error as `cause`.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#errors-ensure\n */\nexport class TRPCEntryError<\n  TDef extends ResolverDef = ResolverDef,\n> extends Error {\n  /** The entry's key in the object passed to `loadHandles()` */\n  readonly key: string;\n  /** The procedure's path, such as `post.byId` */\n  readonly path: string;\n  /** The tRPC error code, such as `NOT_FOUND`, when the error has one */\n  readonly code: TRPC_ERROR_CODE_KEY | undefined;\n  // oxlint-disable-next-line typescript/ban-ts-comment\n  // @ts-ignore `override` fails where the `lib` has no `Error.cause`\n  /**\n   * The request's error: a `TRPCError` on a proxy created with `router`, a\n   * `TRPCClientError` on one created with `client`.\n   */\n  public override readonly cause: ErrorOf<TDef> | TRPCError;\n\n  constructor(opts: {\n    key: string;\n    path: string;\n    code: TRPC_ERROR_CODE_KEY | undefined;\n    cause: ErrorOf<TDef> | TRPCError;\n  }) {\n    super(`Entry \"${opts.key}\" (${opts.path}) failed: ${opts.cause.message}`);\n    this.name = 'TRPCEntryError';\n    this.cause = opts.cause;\n    this.key = opts.key;\n    this.path = opts.path;\n    this.code = opts.code;\n  }\n}\n\nfunction codeOfShape(data: unknown): TRPC_ERROR_CODE_KEY | undefined {\n  const code = (data as { code?: unknown } | null | undefined)?.code;\n  return typeof code === 'string' ? (code as TRPC_ERROR_CODE_KEY) : undefined;\n}\n\nexport function entryCause(error: unknown) {\n  if (isTRPCClientError(error)) {\n    return { cause: error, code: codeOfShape(error.data) };\n  }\n  const cause = getTRPCErrorFromUnknown(error);\n  return { cause, code: cause.code };\n}\n","import type {\n  FetchQueryOptions,\n  GetNextPageParamFunction,\n  QueryClient,\n  QueryFunction,\n} from '@tanstack/react-query';\nimport { hashKey, isCancelledError } from '@tanstack/react-query';\nimport { isTRPCClientError } from '@trpc/client';\nimport type {\n  DecorateInfiniteQueryProcedure,\n  DecorateQueryProcedure,\n  DecorateRouterKeyable,\n} from '../internals/createOptionsProxy';\nimport type {\n  UnusedSkipTokenTRPCInfiniteQueryOptionsIn,\n  UnusedSkipTokenTRPCInfiniteQueryOptionsOut,\n} from '../internals/infiniteQueryOptions';\nimport type {\n  UnusedSkipTokenTRPCQueryOptionsIn,\n  UnusedSkipTokenTRPCQueryOptionsOut,\n} from '../internals/queryOptions';\nimport type {\n  ExtractCursorType,\n  FeatureFlags,\n  ResolverDef,\n  TRPCInfiniteData,\n  TRPCQueryBaseOptions,\n  TRPCQueryKey,\n} from '../internals/types';\nimport { readQueryKey } from '../internals/utils';\nimport type { ErrorOf } from './entryError';\nimport { entryCause, TRPCEntryError } from './entryError';\n\ndeclare const handleDef: unique symbol;\ndeclare const entryDef: unique symbol;\n\ntype InfiniteHandleInput<TInput> = TInput extends object\n  ? Omit<TInput, 'cursor' | 'direction'>\n  : TInput;\n\n/**\n * A plain tuple typed with the procedure's input. TanStack Router's serializability check\n * rejects `unknown` inputs and `DataTag`-ged keys, so handles in `beforeLoad` need this shape.\n */\ntype HandleQueryKey<\n  TDef extends ResolverDef,\n  TInput,\n  TType extends 'query' | 'infinite',\n> = TDef['featureFlags']['keyPrefix'] extends true\n  ? [prefix: string[], path: string[], opts?: { input?: TInput; type?: TType }]\n  : [path: string[], opts?: { input?: TInput; type?: TType }];\n\n/**\n * A serializable reference to a query, from `loadHandles()`.\n * Pass it to a component and read it with `fromHandle(trpc, handle)`.\n */\nexport interface TRPCQueryHandle<TDef extends ResolverDef = ResolverDef> {\n  /**\n   * Type-only: never present at runtime. Required, so only\n   * `loadHandles` creates handles.\n   */\n  readonly [handleDef]: TDef & { kind: 'query' };\n  readonly queryKey: HandleQueryKey<TDef, TDef['input'], 'query'>;\n  /** The query's input. The key is absent when the input is `undefined`. */\n  readonly input: TDef['input'];\n}\n\n/**\n * A serializable reference to an infinite query, from `loadHandles()`.\n * Read it with `fromHandle(trpc, handle, { getNextPageParam })`.\n */\nexport interface TRPCInfiniteQueryHandle<\n  TDef extends ResolverDef = ResolverDef,\n> {\n  /**\n   * Type-only: never present at runtime. Required, so only\n   * `loadHandles` creates handles.\n   */\n  readonly [handleDef]: TDef & { kind: 'infinite' };\n  readonly queryKey: HandleQueryKey<\n    TDef,\n    InfiniteHandleInput<TDef['input']>,\n    'infinite'\n  >;\n  /** The query's input, without `cursor` and `direction` */\n  readonly input: InfiniteHandleInput<TDef['input']>;\n  readonly initialCursor?: NonNullable<ExtractCursorType<TDef['input']>> | null;\n}\n\n/** Any query or infinite query handle. */\nexport type AnyTRPCHandle = TRPCQueryHandle<any> | TRPCInfiniteQueryHandle<any>;\n\n/**\n * How `loadHandles` starts an entry's query, named after the\n * `QueryClient` method it calls: `prefetchQuery`, `fetchQuery` or `ensureQueryData`.\n */\nexport type TRPCEntryKind = 'prefetch' | 'fetch' | 'ensure';\n\n/**\n * A query for `loadHandles()` to start, from `prefetchEntry`, `fetchEntry` or\n * `ensureEntry`.\n * Creating it starts nothing.\n */\nexport interface TRPCQueryEntry<\n  TDef extends ResolverDef = ResolverDef,\n  TKind extends TRPCEntryKind = TRPCEntryKind,\n> {\n  /** Type-only: never present at runtime. */\n  readonly [entryDef]: { def: TDef; kind: TKind; type: 'query' };\n}\n\n/**\n * An infinite query for `loadHandles()` to start, from `prefetchInfiniteEntry`,\n * `fetchInfiniteEntry` or `ensureInfiniteEntry`. Creating it starts nothing.\n */\nexport interface TRPCInfiniteQueryEntry<\n  TDef extends ResolverDef = ResolverDef,\n  TKind extends TRPCEntryKind = TRPCEntryKind,\n> {\n  /** Type-only: never present at runtime. */\n  readonly [entryDef]: { def: TDef; kind: TKind; type: 'infinite' };\n}\n\n/** Any query or infinite query entry. */\nexport type AnyTRPCEntry =\n  | TRPCQueryEntry<any, any>\n  | TRPCInfiniteQueryEntry<any, any>;\n\ntype HandleOfEntry<TEntry> =\n  TEntry extends TRPCQueryEntry<infer TDef, any>\n    ? TRPCQueryHandle<TDef>\n    : TEntry extends TRPCInfiniteQueryEntry<infer TDef, any>\n      ? TRPCInfiniteQueryHandle<TDef>\n      : never;\n\ntype DataOfEntry<TEntry> =\n  TEntry extends TRPCQueryEntry<infer TDef, any>\n    ? TDef['output']\n    : TEntry extends TRPCInfiniteQueryEntry<infer TDef, any>\n      ? TRPCInfiniteData<TDef['input'], TDef['output']>\n      : never;\n\ntype HandlesOf<TEntries extends Record<string, AnyTRPCEntry>> = {\n  [TKey in keyof TEntries]: HandleOfEntry<TEntries[TKey]>;\n};\n\ntype DefOfEntry<TEntry> = TEntry extends {\n  readonly [entryDef]: { def: infer TDef extends ResolverDef };\n}\n  ? TDef\n  : never;\n\n/** Only fetch and ensure entries are waited for, so only they have data */\ntype WaitedKey<TEntries, TKey extends keyof TEntries> = TEntries[TKey] extends {\n  readonly [entryDef]: { kind: 'fetch' | 'ensure' };\n}\n  ? TKey\n  : never;\n\ntype DataOf<TEntries extends Record<string, AnyTRPCEntry>> = {\n  [TKey in keyof TEntries as WaitedKey<TEntries, TKey>]: DataOfEntry<\n    TEntries[TKey]\n  >;\n};\n\ntype ResultsOf<TEntries extends Record<string, AnyTRPCEntry>> = {\n  [TKey in keyof TEntries as WaitedKey<TEntries, TKey>]: TRPCEntryResult<\n    DefOfEntry<TEntries[TKey]>,\n    DataOfEntry<TEntries[TKey]>\n  >;\n};\n\n/**\n * What `loadHandlesSettled()` has for a fetch or ensure entry: its data, or\n * the error it failed with.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#errors-as-values\n */\nexport type TRPCEntryResult<TDef extends ResolverDef, TData> =\n  | { readonly status: 'success'; readonly data: TData }\n  | { readonly status: 'error'; readonly error: TRPCEntryError<TDef> };\n\n/**\n * What `loadHandles()` resolves to: `[handles, data]`. `handles` has a handle\n * for every entry, by the entry's key; return them from the loader. `data` has the data of\n * every fetch and ensure entry, by the entry's key.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#loader-data\n */\nexport type TRPCLoadedHandles<TEntries extends Record<string, AnyTRPCEntry>> =\n  readonly [handles: HandlesOf<TEntries>, data: DataOf<TEntries>];\n\n/**\n * What `loadHandlesSettled()` resolves to: `[handles, results]`. `results`\n * has a `TRPCEntryResult` for every fetch and ensure entry, by the entry's key.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#errors-as-values\n */\nexport type TRPCSettledHandles<TEntries extends Record<string, AnyTRPCEntry>> =\n  readonly [handles: HandlesOf<TEntries>, results: ResultsOf<TEntries>];\n\n/** Options for an entry */\nexport interface TRPCEntryOptions\n  extends\n    Pick<\n      FetchQueryOptions,\n      'staleTime' | 'retry' | 'retryDelay' | 'gcTime' | 'meta'\n    >,\n    TRPCQueryBaseOptions {}\n\ntype HandleGetNextPageParam<TDef extends ResolverDef> =\n  GetNextPageParamFunction<\n    NonNullable<ExtractCursorType<TDef['input']>> | null,\n    TDef['output']\n  >;\n\n/**\n * Options for an infinite query entry. Pass `pages` and `getNextPageParam`\n * to load several pages up front.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#infinite-queries\n */\nexport type TRPCInfiniteEntryOptions<TDef extends ResolverDef> =\n  TRPCEntryOptions & {\n    initialCursor?: NonNullable<ExtractCursorType<TDef['input']>> | null;\n  } & (\n      | {\n          pages?: never;\n          /**\n           * Without it, refetching a cached query with more than one page\n           * fails on the second page.\n           */\n          getNextPageParam?: HandleGetNextPageParam<TDef>;\n        }\n      | {\n          /** Number of pages to load up front */\n          pages: number;\n          getNextPageParam: HandleGetNextPageParam<TDef>;\n        }\n    );\n\ntype EntryArgs<TDef extends ResolverDef> = undefined extends TDef['input']\n  ? [input?: TDef['input'], opts?: TRPCEntryOptions]\n  : [input: TDef['input'], opts?: TRPCEntryOptions];\n\n/**\n * The handle type of a query procedure, for typing props.\n * @example\n * ```ts\n * type PostHandle = inferQueryHandle<TRPC['post']['byId']>;\n * ```\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#typing-props\n */\nexport type inferQueryHandle<TProcedure extends DecorateQueryProcedure<any>> =\n  TProcedure extends DecorateQueryProcedure<infer TDef>\n    ? TRPCQueryHandle<TDef>\n    : never;\n\n/**\n * The handle type of an infinite query procedure, for typing props.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#typing-props\n */\nexport type inferInfiniteQueryHandle<\n  TProcedure extends DecorateInfiniteQueryProcedure<any>,\n> =\n  TProcedure extends DecorateInfiniteQueryProcedure<infer TDef>\n    ? TRPCInfiniteQueryHandle<TDef>\n    : never;\n\nconst notAHandle = 'Expected a tRPC handle from `loadHandles()`';\n\nfunction readHandle(handle: AnyTRPCHandle, prefix: string | undefined) {\n  const queryKey = handle?.queryKey as unknown as TRPCQueryKey<any> | undefined;\n  if (!Array.isArray(queryKey)) {\n    throw new Error(`${notAHandle}, got ${JSON.stringify(handle)}`);\n  }\n  const data = readQueryKey(queryKey);\n  const type = data.args?.type;\n  if (type !== 'query' && type !== 'infinite') {\n    throw new Error(\n      `${notAHandle}, got a key of type ${String(type)} for \"${data.path.join('.')}\"`,\n    );\n  }\n  if ((data.prefix?.[0] ?? undefined) !== prefix) {\n    throw new Error(\n      `The handle for \"${data.path.join('.')}\" was created with keyPrefix ${JSON.stringify(data.prefix?.[0])}, but this proxy uses ${JSON.stringify(prefix)}`,\n    );\n  }\n  return {\n    type,\n    path: data.path,\n    input: data.args?.input,\n    queryKey,\n  };\n}\n\ntype HandleType = 'query' | 'infinite';\n\nfunction toHandle(options: any, type: HandleType) {\n  const input = readQueryKey(options.queryKey).args?.input;\n  // Next.js rejects `undefined` in `getServerSideProps` / `getStaticProps` props\n  const handle: Record<string, unknown> = {\n    queryKey: options.queryKey,\n    ...(input !== undefined && { input }),\n  };\n  if (type === 'infinite' && options.initialPageParam != null) {\n    handle['initialCursor'] = options.initialPageParam;\n  }\n  return handle;\n}\n\nconst entryState = Symbol('trpc.handleEntry');\n\ninterface EntryState {\n  kind: TRPCEntryKind;\n  type: HandleType;\n  options: any;\n  /** The `QueryClient` of the proxy that built the entry */\n  queryClient: QueryClient;\n}\n\nfunction createEntry(state: EntryState) {\n  return { [entryState]: state };\n}\n\nfunction readEntry(key: string, entry: unknown): EntryState {\n  const state = (entry as { [entryState]?: EntryState } | null)?.[entryState];\n  if (!state) {\n    throw new Error(\n      `Expected an entry from \\`prefetchEntry()\\`, \\`fetchEntry()\\` or \\`ensureEntry()\\` for \"${key}\", got ${JSON.stringify(entry)}`,\n    );\n  }\n  return state;\n}\n\nfunction startEntry(queryClient: QueryClient, state: EntryState) {\n  const { options } = state;\n  if (state.type === 'infinite') {\n    switch (state.kind) {\n      case 'prefetch':\n        return queryClient.prefetchInfiniteQuery(options);\n      case 'ensure':\n        return queryClient.ensureInfiniteQueryData({\n          ...options,\n          revalidateIfStale: true,\n        });\n      case 'fetch':\n        return queryClient.fetchInfiniteQuery(options);\n    }\n  }\n  switch (state.kind) {\n    case 'prefetch':\n      return queryClient.prefetchQuery(options);\n    case 'ensure':\n      return queryClient.ensureQueryData({\n        ...options,\n        revalidateIfStale: true,\n      });\n    case 'fetch':\n      return queryClient.fetchQuery(options);\n  }\n}\n\nfunction toEntryError(key: string, state: EntryState, error: unknown) {\n  if (isCancelledError(error)) {\n    return error;\n  }\n  return new TRPCEntryError({\n    key,\n    path: readQueryKey(state.options.queryKey).path.join('.'),\n    ...entryCause(error),\n  });\n}\n\nfunction settleLoad(promise: Promise<unknown>) {\n  return promise.then(\n    (data) => ({ status: 'success', data }),\n    (error: unknown) => {\n      if (error instanceof TRPCEntryError) {\n        return { status: 'error', error };\n      }\n      throw error;\n    },\n  );\n}\n\nasync function startEntries(opts: {\n  queryClient: QueryClient;\n  entries: Record<string, unknown>;\n  /** Resolve each waited entry to a `TRPCEntryResult` instead of rejecting */\n  settle: boolean;\n}) {\n  const { queryClient, entries } = opts;\n  const states = Object.entries(entries).map(([key, entry]) => {\n    const state = readEntry(key, entry);\n    if (state.queryClient !== queryClient) {\n      throw new Error(\n        `The entry for \"${key}\" was built with a proxy for another QueryClient than the root proxy that loads it`,\n      );\n    }\n    return [key, state] as const;\n  });\n  const loads = states.map(([key, state]) => ({\n    key,\n    state,\n    promise: startEntry(queryClient, state).catch((error: unknown) => {\n      throw toEntryError(key, state, error);\n    }),\n  }));\n  const waited = loads.filter((load) => load.state.kind !== 'prefetch');\n  const results = await Promise.all(\n    waited.map((load) =>\n      opts.settle ? settleLoad(load.promise) : load.promise,\n    ),\n  );\n\n  const handles = Object.fromEntries(\n    loads.map((load) => [\n      load.key,\n      toHandle(load.state.options, load.state.type),\n    ]),\n  );\n  const data = Object.fromEntries(\n    waited.map((load, index) => [load.key, results[index]]),\n  );\n  return [handles, data] as const;\n}\n\nfunction isServerEnvironment() {\n  return typeof window === 'undefined' || 'Deno' in globalThis;\n}\n\nconst warnedNotHydrated = new Set<string>();\n\nfunction warnIfNotHydrated(\n  path: readonly string[],\n  queryFn: QueryFunction<any, any, any>,\n): QueryFunction<any, any, any> {\n  return (context) => {\n    if (isServerEnvironment()) {\n      const queryHash = hashKey(context.queryKey);\n      if (!warnedNotHydrated.has(queryHash)) {\n        warnedNotHydrated.add(queryHash);\n        // oxlint-disable-next-line no-console\n        console.warn(\n          `[@trpc/tanstack-react-query] The handle for \"${path.join('.')}\" is being fetched again during server rendering. ` +\n            `Unless its data is stale, the query it refers to isn't in this QueryClient. ` +\n            `Render the reading component inside <HydrateClient> or <HydrationBoundary>, and don't return handles from server functions or server actions. ` +\n            `See https://trpc.io/docs/client/tanstack-react-query/handles#where-handles-dont-work`,\n        );\n      }\n    }\n    return queryFn(context);\n  };\n}\n\nconst watchedHydrations = new WeakSet<Promise<unknown>>();\n\n/**\n * A query dehydrated as pending that later rejects reaches the browser as a\n * redacted error, before any `retry` from `fromHandle()` applies. Refetch such\n * a query once so error boundaries see a `TRPCClientError` from this client.\n */\nfunction refetchRejectedHydration(\n  queryClient: QueryClient,\n  type: HandleType,\n  options: any,\n) {\n  const enabled =\n    typeof options.enabled === 'function'\n      ? options.enabled\n      : () => options.enabled;\n  if (isServerEnvironment()) {\n    return;\n  }\n  const query = queryClient\n    .getQueryCache()\n    .find({ queryKey: options.queryKey, exact: true });\n  const promise = query?.promise;\n  if (\n    !query ||\n    !promise ||\n    query.state.data !== undefined ||\n    query.state.fetchStatus === 'idle' ||\n    enabled(query) === false ||\n    watchedHydrations.has(promise)\n  ) {\n    return;\n  }\n  watchedHydrations.add(promise);\n  promise.catch((error: unknown) => {\n    if (\n      isTRPCClientError(error) ||\n      isCancelledError(error) ||\n      query.state.fetchStatus !== 'idle' ||\n      enabled(query) === false\n    ) {\n      return;\n    }\n    const defaulted = queryClient.defaultQueryOptions(options);\n    // Older query-core versions take the infinite behavior from the fetch's\n    // options, so `query.fetch` would store a bare page there.\n    // `fetchInfiniteQuery` skips retries unless asked, unlike a query's fetch\n    // in the browser, which retries 3 times by default.\n    const refetch =\n      type === 'infinite'\n        ? queryClient.fetchInfiniteQuery({\n            ...options,\n            retry: defaulted.retry ?? 3,\n          })\n        : query.fetch(defaulted);\n    refetch.catch(() => {\n      // surfaces through the query's state\n    });\n  });\n}\n\nfunction prepareHandleRead<TOptions extends { queryFn?: unknown }>(opts: {\n  queryClient: QueryClient;\n  handle: ReturnType<typeof readHandle>;\n  options: TOptions;\n}): TOptions {\n  const { options } = opts;\n  if (\n    globalThis.process?.env?.['NODE_ENV'] !== 'production' &&\n    typeof options.queryFn === 'function'\n  ) {\n    options.queryFn = warnIfNotHydrated(\n      opts.handle.path,\n      options.queryFn as QueryFunction<any, any, any>,\n    );\n  }\n  refetchRejectedHydration(opts.queryClient, opts.handle.type, options);\n  return options;\n}\n\ninterface ProxyContext {\n  proxy: any;\n  path: string[];\n  prefix: string | undefined;\n}\n\nfunction readProxy(proxy: unknown, fn: string): ProxyContext {\n  const queryKey = (proxy as { queryKey?: unknown } | null)?.queryKey;\n  if (Array.isArray(queryKey)) {\n    throw new Error(\n      `\\`${fn}()\\` expects a tRPC options proxy or one of its procedures, got a handle for \\`${readQueryKey(queryKey as TRPCQueryKey<any>).path.join('.')}\\``,\n    );\n  }\n  if (typeof queryKey !== 'function') {\n    throw new Error(\n      `\\`${fn}()\\` expects a tRPC options proxy or one of its procedures, got ${String(proxy)}`,\n    );\n  }\n  const key = readQueryKey(queryKey());\n  return {\n    proxy,\n    path: key.path,\n    prefix: key.prefix?.[0],\n  };\n}\n\nfunction queryClientOf(ctx: ProxyContext): QueryClient {\n  return ctx.proxy['~queryClient']();\n}\n\nfunction optionsOf(\n  procedure: any,\n  type: HandleType,\n): (input: unknown, opts: unknown) => any {\n  return type === 'infinite'\n    ? procedure.infiniteQueryOptions\n    : procedure.queryOptions;\n}\n\nfunction readRoot(trpc: unknown, fn: string) {\n  const ctx = readProxy(trpc, fn);\n  if (ctx.path.length > 0) {\n    throw new Error(\n      `\\`${fn}()\\` takes the root proxy, \\`trpc\\`, got \\`trpc.${ctx.path.join('.')}\\``,\n    );\n  }\n  return ctx;\n}\n\nfunction entry(opts: {\n  fn: string;\n  type: HandleType;\n  kind: TRPCEntryKind;\n  procedure: unknown;\n  input: unknown;\n  opts: unknown;\n}) {\n  const ctx = readProxy(opts.procedure, opts.fn);\n  return createEntry({\n    type: opts.type,\n    kind: opts.kind,\n    options: optionsOf(ctx.proxy, opts.type)(opts.input, opts.opts),\n    queryClient: queryClientOf(ctx),\n  });\n}\n\n/**\n * Whether `error` is a failed entry from `loadHandles()`. Pass a procedure to\n * check that the entry was for it, which types `error.cause` with its errors.\n * @example\n * ```ts\n * const [handles] = await loadHandles(trpc, {\n *   post: ensureEntry(trpc.post.byId, { id }),\n * }).catch((error: unknown) => {\n *   if (isTRPCEntryError(error, trpc.post.byId) && error.code === 'NOT_FOUND') {\n *     throw notFound();\n *   }\n *   throw error;\n * });\n * ```\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#errors-ensure\n */\nexport function isTRPCEntryError<TDef extends ResolverDef>(\n  error: unknown,\n  procedure: DecorateQueryProcedure<TDef>,\n): error is TRPCEntryError<TDef>;\nexport function isTRPCEntryError(error: unknown): error is TRPCEntryError;\nexport function isTRPCEntryError(error: unknown, procedure?: unknown) {\n  if (!(error instanceof TRPCEntryError)) {\n    return false;\n  }\n  return (\n    procedure === undefined ||\n    error.path === readProxy(procedure, 'isTRPCEntryError').path.join('.')\n  );\n}\n\n/**\n * Starts every entry before it waits for any, so the order of the entries doesn't\n * matter. Resolves to `[handles, data]` once every fetch and ensure entry has data:\n * a handle for every entry, and the data of the fetch and ensure entries. Rejects as\n * soon as a fetch or ensure entry fails. Prefetch entries never make it reject.\n *\n * Takes the root of an options proxy, from `createTRPCOptionsProxy` or `useTRPC()`.\n * Call it in a route loader, a server component or an event handler, not during\n * render: every render would start the entries again.\n * @example\n * ```ts\n * const [handles, data] = await loadHandles(trpc, {\n *   comments: prefetchInfiniteEntry(trpc.post.comments, { postId: id }),\n *   post: ensureEntry(trpc.post.byId, { id }),\n * });\n * if (!data.post.published) throw notFound();\n * return handles;\n * ```\n * @see https://trpc.io/docs/client/tanstack-react-query/handles\n */\nexport function loadHandles<\n  TFeatureFlags extends FeatureFlags,\n  TEntries extends Record<string, AnyTRPCEntry>,\n>(\n  trpc: DecorateRouterKeyable<TFeatureFlags>,\n  entries: TEntries,\n): Promise<TRPCLoadedHandles<TEntries>> {\n  return startEntries({\n    queryClient: queryClientOf(readRoot(trpc, 'loadHandles')),\n    entries,\n    settle: false,\n  }) as Promise<any>;\n}\n\n/**\n * Like `loadHandles()`, but it waits for every fetch and ensure entry to\n * settle and never rejects because one failed. Resolves to `[handles, results]`:\n * `results` has `{ status: 'success', data }` or `{ status: 'error', error }`,\n * with a `TRPCEntryError`, for every fetch and ensure entry.\n *\n * A cancelled query still rejects, as it does with `loadHandles()`.\n * @example\n * ```ts\n * const [handles, results] = await loadHandlesSettled(trpc, {\n *   post: ensureEntry(trpc.post.byId, { id }),\n *   comments: prefetchInfiniteEntry(trpc.post.comments, { postId: id }),\n * });\n * if (results.post.status === 'error') {\n *   if (results.post.error.code === 'NOT_FOUND') throw notFound();\n *   throw results.post.error;\n * }\n * ```\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#errors-as-values\n */\nexport function loadHandlesSettled<\n  TFeatureFlags extends FeatureFlags,\n  TEntries extends Record<string, AnyTRPCEntry>,\n>(\n  trpc: DecorateRouterKeyable<TFeatureFlags>,\n  entries: TEntries,\n): Promise<TRPCSettledHandles<TEntries>> {\n  return startEntries({\n    queryClient: queryClientOf(readRoot(trpc, 'loadHandlesSettled')),\n    entries,\n    settle: true,\n  }) as Promise<any>;\n}\n\n/**\n * An entry for `loadHandles()` that starts the query without waiting, like\n * `queryClient.prefetchQuery`. It never makes the load reject: errors surface where\n * the handle is read. Creating the entry starts nothing.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#prefetch\n */\nexport function prefetchEntry<TDef extends ResolverDef>(\n  procedure: DecorateQueryProcedure<TDef>,\n  ...args: EntryArgs<TDef>\n): TRPCQueryEntry<TDef, 'prefetch'>;\nexport function prefetchEntry(\n  procedure: unknown,\n  input?: unknown,\n  opts?: unknown,\n): unknown {\n  return entry({\n    fn: 'prefetchEntry',\n    type: 'query',\n    kind: 'prefetch',\n    procedure,\n    input,\n    opts,\n  });\n}\n\n/**\n * An entry for `loadHandles()` that waits for fresh data, like `queryClient.fetchQuery`:\n * cached data is used only if it isn't stale. The load rejects if the request fails.\n * Creating the entry starts nothing.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#fetch\n */\nexport function fetchEntry<TDef extends ResolverDef>(\n  procedure: DecorateQueryProcedure<TDef>,\n  ...args: EntryArgs<TDef>\n): TRPCQueryEntry<TDef, 'fetch'>;\nexport function fetchEntry(\n  procedure: unknown,\n  input?: unknown,\n  opts?: unknown,\n): unknown {\n  return entry({\n    fn: 'fetchEntry',\n    type: 'query',\n    kind: 'fetch',\n    procedure,\n    input,\n    opts,\n  });\n}\n\n/**\n * An entry for `loadHandles()` that uses any cached data, even stale, like\n * `queryClient.ensureQueryData({ revalidateIfStale: true })`. It fetches and waits only\n * when the cache has no data, and the load rejects if that request fails. Stale data is\n * refetched in the background. Creating the entry starts nothing.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#ensure\n */\nexport function ensureEntry<TDef extends ResolverDef>(\n  procedure: DecorateQueryProcedure<TDef>,\n  ...args: EntryArgs<TDef>\n): TRPCQueryEntry<TDef, 'ensure'>;\nexport function ensureEntry(\n  procedure: unknown,\n  input?: unknown,\n  opts?: unknown,\n): unknown {\n  return entry({\n    fn: 'ensureEntry',\n    type: 'query',\n    kind: 'ensure',\n    procedure,\n    input,\n    opts,\n  });\n}\n\n/**\n * Like `prefetchEntry`, for an infinite query. Loads the first page unless `pages` is set.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#infinite-queries\n */\nexport function prefetchInfiniteEntry<TDef extends ResolverDef>(\n  procedure: DecorateInfiniteQueryProcedure<TDef>,\n  input: TDef['input'],\n  opts?: TRPCInfiniteEntryOptions<TDef>,\n): TRPCInfiniteQueryEntry<TDef, 'prefetch'> {\n  return entry({\n    fn: 'prefetchInfiniteEntry',\n    type: 'infinite',\n    kind: 'prefetch',\n    procedure,\n    input,\n    opts,\n  }) as any;\n}\n\n/**\n * Like `fetchEntry`, for an infinite query.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#infinite-queries\n */\nexport function fetchInfiniteEntry<TDef extends ResolverDef>(\n  procedure: DecorateInfiniteQueryProcedure<TDef>,\n  input: TDef['input'],\n  opts?: TRPCInfiniteEntryOptions<TDef>,\n): TRPCInfiniteQueryEntry<TDef, 'fetch'> {\n  return entry({\n    fn: 'fetchInfiniteEntry',\n    type: 'infinite',\n    kind: 'fetch',\n    procedure,\n    input,\n    opts,\n  }) as any;\n}\n\n/**\n * Like `ensureEntry`, for an infinite query.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#infinite-queries\n */\nexport function ensureInfiniteEntry<TDef extends ResolverDef>(\n  procedure: DecorateInfiniteQueryProcedure<TDef>,\n  input: TDef['input'],\n  opts?: TRPCInfiniteEntryOptions<TDef>,\n): TRPCInfiniteQueryEntry<TDef, 'ensure'> {\n  return entry({\n    fn: 'ensureInfiniteEntry',\n    type: 'infinite',\n    kind: 'ensure',\n    procedure,\n    input,\n    opts,\n  }) as any;\n}\n\n/**\n * Options for a handle: the same options `trpc.<path>.queryOptions(input)` or\n * `trpc.<path>.infiniteQueryOptions(input, opts)` return for the handle's procedure and\n * input. Pass them to `useQuery`, `useSuspenseQuery`, `useSuspenseInfiniteQuery`, etc.\n * `trpc` is the proxy or a router on the handle's path, usually `useTRPC()`.\n * @see https://trpc.io/docs/client/tanstack-react-query/handles#reading-a-handle\n */\nexport function fromHandle<TDef extends ResolverDef, TData = TDef['output']>(\n  trpc: DecorateRouterKeyable<NoInfer<TDef['featureFlags']>>,\n  handle: TRPCQueryHandle<TDef>,\n  opts?: UnusedSkipTokenTRPCQueryOptionsIn<\n    NoInfer<TDef['output']>,\n    TData,\n    ErrorOf<TDef>,\n    TDef['featureFlags']\n  >,\n): UnusedSkipTokenTRPCQueryOptionsOut<\n  TDef['output'],\n  TData,\n  ErrorOf<TDef>,\n  TDef['featureFlags']\n>;\nexport function fromHandle<TDef extends ResolverDef, TData = TDef['output']>(\n  trpc: DecorateRouterKeyable<NoInfer<TDef['featureFlags']>>,\n  handle: TRPCInfiniteQueryHandle<TDef>,\n  opts: UnusedSkipTokenTRPCInfiniteQueryOptionsIn<\n    TDef['input'],\n    NoInfer<TDef['output']>,\n    TData,\n    ErrorOf<TDef>,\n    TDef['featureFlags']\n  >,\n): UnusedSkipTokenTRPCInfiniteQueryOptionsOut<\n  TDef['input'],\n  TDef['output'],\n  TData,\n  ErrorOf<TDef>,\n  TDef['featureFlags']\n>;\nexport function fromHandle(\n  trpc: unknown,\n  rawHandle: AnyTRPCHandle,\n  opts?: object,\n): unknown {\n  const ctx = readProxy(trpc, 'fromHandle');\n  const handle = readHandle(rawHandle, ctx.prefix);\n  if (!ctx.path.every((segment, index) => handle.path[index] === segment)) {\n    throw new Error(\n      `\\`fromHandle(trpc.${ctx.path.join('.')}, handle)\\` got a handle for \\`${handle.path.join('.')}\\`, which isn't in \\`${ctx.path.join('.')}\\`. Pass the root proxy, \\`trpc\\``,\n    );\n  }\n  const procedure = handle.path\n    .slice(ctx.path.length)\n    .reduce((level, segment) => level[segment], ctx.proxy);\n  const options = optionsOf(procedure, handle.type)(\n    handle.input,\n    handle.type === 'infinite'\n      ? {\n          initialCursor: (rawHandle as TRPCInfiniteQueryHandle).initialCursor,\n          ...opts,\n        }\n      : opts,\n  );\n  return prepareHandleRead({\n    queryClient: queryClientOf(ctx),\n    handle,\n    options,\n  });\n}\n"],"mappings":";;;;;;;;;;AAgBA,IAAa,iBAAb,cAEU,MAAM;CAed,YAAY,MAKT;EACD,MAAM,UAAU,KAAK,IAAI,KAAK,KAAK,KAAK,YAAY,KAAK,MAAM,SAAS;EAnBjE,gBAAA,MAAA,OAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,QAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,QAAA,KAAA,CAAA;EAOgB,gBAAA,MAAA,SAAA,KAAA,CAAA;EASvB,KAAK,OAAO;EACZ,KAAK,QAAQ,KAAK;EAClB,KAAK,MAAM,KAAK;EAChB,KAAK,OAAO,KAAK;EACjB,KAAK,OAAO,KAAK;CACnB;AACF;AAEA,SAAS,YAAY,MAAgD;CACnE,MAAM,OAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAQ,KAAgD;CAC9D,OAAO,OAAO,SAAS,WAAY,OAA+B,KAAA;AACpE;AAEA,SAAgB,WAAW,OAAgB;CACzC,IAAI,kBAAkB,KAAK,GAC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