@trpc/react-query 11.23.1-canary.26.b84c927ef → 11.23.1-canary.28.c6a7e7d57

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/rsc.cjs CHANGED
@@ -84,8 +84,8 @@ function createHydrationHelpers(caller, getQueryClient) {
84
84
  * @example
85
85
  * ```tsx
86
86
  * // MyRSC.tsx
87
- * const MyRSC = ({ params }) => {
88
- * void trpc.post.get.prefetch(params.postId);
87
+ * const MyRSC = async ({ params }) => {
88
+ * await trpc.post.get.prefetch(params.postId);
89
89
  *
90
90
  * return (
91
91
  * <HydrateClient>
package/dist/rsc.d.cts CHANGED
@@ -60,8 +60,8 @@ export declare function createHydrationHelpers<TRouter extends AnyRouter>(caller
60
60
  * @example
61
61
  * ```tsx
62
62
  * // MyRSC.tsx
63
- * const MyRSC = ({ params }) => {
64
- * void trpc.post.get.prefetch(params.postId);
63
+ * const MyRSC = async ({ params }) => {
64
+ * await trpc.post.get.prefetch(params.postId);
65
65
  *
66
66
  * return (
67
67
  * <HydrateClient>
package/dist/rsc.d.mts CHANGED
@@ -60,8 +60,8 @@ export declare function createHydrationHelpers<TRouter extends AnyRouter>(caller
60
60
  * @example
61
61
  * ```tsx
62
62
  * // MyRSC.tsx
63
- * const MyRSC = ({ params }) => {
64
- * void trpc.post.get.prefetch(params.postId);
63
+ * const MyRSC = async ({ params }) => {
64
+ * await trpc.post.get.prefetch(params.postId);
65
65
  *
66
66
  * return (
67
67
  * <HydrateClient>
package/dist/rsc.mjs CHANGED
@@ -82,8 +82,8 @@ function createHydrationHelpers(caller, getQueryClient) {
82
82
  * @example
83
83
  * ```tsx
84
84
  * // MyRSC.tsx
85
- * const MyRSC = ({ params }) => {
86
- * void trpc.post.get.prefetch(params.postId);
85
+ * const MyRSC = async ({ params }) => {
86
+ * await trpc.post.get.prefetch(params.postId);
87
87
  *
88
88
  * return (
89
89
  * <HydrateClient>
package/dist/rsc.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.mjs","names":[],"sources":["../src/rsc.tsx"],"sourcesContent":["/// <reference types=\"react/canary\" />\n\nimport {\n dehydrate,\n HydrationBoundary,\n type QueryClient,\n} from '@tanstack/react-query';\nimport type { TRPCClientError } from '@trpc/client';\nimport type { inferTransformedProcedureOutput } from '@trpc/server';\nimport {\n createRecursiveProxy,\n type AnyRouter,\n type inferProcedureInput,\n type RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureOutput,\n inferRouterRootTypes,\n Maybe,\n RouterCaller,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport * as React from 'react';\nimport { getQueryKeyInternal } from './internals/getQueryKey';\nimport type {\n TRPCFetchInfiniteQueryOptions,\n TRPCFetchQueryOptions,\n} from './shared';\n\nconst HELPERS = ['prefetch', 'prefetchInfinite'];\n\ntype DecorateProcedure<\n TRoot extends AnyRootTypes,\n TProcedure extends AnyProcedure,\n> = {\n (\n input: inferProcedureInput<TProcedure>,\n ): Promise<inferProcedureOutput<TProcedure>>;\n prefetch: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchQueryOptions<\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n prefetchInfinite: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchInfiniteQueryOptions<\n inferProcedureInput<TProcedure>,\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n};\n\ntype DecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<TRoot, $Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\ntype Caller<TRouter extends AnyRouter> = ReturnType<\n RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>\n>;\n\n// ts-prune-ignore-next\n/**\n * Creates a server-side caller that can also prefetch queries, plus a\n * `HydrateClient` component that sends the prefetched data to the client.\n *\n * @note This requires `@tanstack/react-query@^5.49.0`\n * @note Make sure to have `dehydrate.serializeData` and `hydrate.deserializeData`\n * set to your data transformer in your `QueryClient` factory.\n * @example\n * ```ts\n * export const createQueryClient = () =>\n * new QueryClient({\n * defaultOptions: {\n * dehydrate: {\n * serializeData: transformer.serialize,\n * },\n * hydrate: {\n * deserializeData: transformer.deserialize,\n * },\n * },\n * });\n * ```\n *\n * @deprecated `@trpc/react-query` only gets bug fixes and will be removed in\n * the next major version. Use `@trpc/tanstack-react-query` instead.\n * @see https://trpc.io/docs/client/tanstack-react-query/migrating\n * @see https://trpc.io/docs/client/react/server-components\n */\nexport function createHydrationHelpers<TRouter extends AnyRouter>(\n caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>,\n getQueryClient: () => QueryClient,\n) {\n type RootTypes = inferRouterRootTypes<TRouter>;\n\n const wrappedProxy = createRecursiveProxy<\n DecorateRouterRecord<RootTypes, TRouter['_def']['record']>\n >(async (opts) => {\n const path = [...opts.path];\n const args = [...opts.args];\n const proc = path.reduce(\n (acc, key) =>\n // @ts-expect-error - ??\n HELPERS.includes(key) ? acc : acc[key],\n caller,\n ) as unknown as DecorateProcedure<RootTypes, AnyProcedure>;\n\n const input = args[0];\n const promise = proc(input);\n\n const helper = path.pop();\n if (helper === 'prefetch') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'query'),\n queryFn: () => promise,\n });\n }\n if (helper === 'prefetchInfinite') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchInfiniteQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'infinite'),\n queryFn: () => promise,\n initialPageParam: args1?.initialCursor ?? null,\n });\n }\n\n return promise;\n });\n\n function HydrateClient(props: { children: React.ReactNode }) {\n const dehydratedState = dehydrate(getQueryClient());\n\n return (\n <HydrationBoundary state={dehydratedState}>\n {props.children}\n </HydrationBoundary>\n );\n }\n\n return {\n /***\n * Wrapped caller with prefetch helpers\n * Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)\n * or using prefetch helpers to put the promise into the QueryClient cache\n * @example\n * ```ts\n * const data = await trpc.post.get(\"postId\");\n *\n * // or\n * void trpc.post.get.prefetch(\"postId\");\n * ```\n */\n trpc: wrappedProxy,\n /**\n * HoC to hydrate the query client for a client component\n * to pick up the prefetched promise and skip an initial\n * client-side fetch.\n * @example\n * ```tsx\n * // MyRSC.tsx\n * const MyRSC = ({ params }) => {\n * void trpc.post.get.prefetch(params.postId);\n *\n * return (\n * <HydrateClient>\n * <MyCC postId={params.postId} />\n * </HydrateClient>\n * );\n * };\n *\n * // MyCC.tsx\n * \"use client\"\n * const MyCC = ({ postId }) => {\n * const { data: post } = trpc.post.get.useQuery(postId);\n * return <div>{post.title}</div>;\n * };\n * ```\n */\n HydrateClient,\n };\n}\n"],"mappings":";;;;;AA+BA,MAAM,UAAU,CAAC,YAAY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuE/C,SAAgB,uBACd,QAGA,gBACA;CAGA,MAAM,eAAe,qBAEnB,OAAO,SAAS;EAChB,MAAM,OAAO,CAAC,GAAG,KAAK,IAAI;EAC1B,MAAM,OAAO,CAAC,GAAG,KAAK,IAAI;EAC1B,MAAM,OAAO,KAAK,QACf,KAAK,QAEJ,QAAQ,SAAS,GAAG,IAAI,MAAM,IAAI,MACpC,MACF;EAEA,MAAM,QAAQ,KAAK;EACnB,MAAM,UAAU,KAAK,KAAK;EAE1B,MAAM,SAAS,KAAK,IAAI;EACxB,IAAI,WAAW,YAAY;GACzB,MAAM,QAAQ,KAAK;GAInB,OAAO,eAAe,CAAC,CAAC,cAAA,eAAA,eAAA,CAAA,GACnB,KAAA,GAAA,CAAA,GAAA;IACH,UAAU,oBAAoB,MAAM,OAAO,OAAO;IAClD,eAAe;GACjB,CAAA,CAAC;EACH;EACA,IAAI,WAAW,oBAAoB;;GACjC,MAAM,QAAQ,KAAK;GAInB,OAAO,eAAe,CAAC,CAAC,sBAAA,eAAA,eAAA,CAAA,GACnB,KAAA,GAAA,CAAA,GAAA;IACH,UAAU,oBAAoB,MAAM,OAAO,UAAU;IACrD,eAAe;IACf,mBAAA,uBAAA,UAAA,QAAA,UAAA,KAAA,IAAA,KAAA,IAAkB,MAAO,mBAAA,QAAA,yBAAA,KAAA,IAAA,uBAAiB;GAC5C,CAAA,CAAC;EACH;EAEA,OAAO;CACT,CAAC;CAED,SAAS,cAAc,OAAsC;EAC3D,MAAM,kBAAkB,UAAU,eAAe,CAAC;EAElD,OACE,sBAAA,cAAC,mBAAD,EAAmB,OAAO,gBAEP,GADhB,MAAM,QACU;CAEvB;CAEA,OAAO;;;;;;;;;;;;;EAaL,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BN;CACF;AACF"}
1
+ {"version":3,"file":"rsc.mjs","names":[],"sources":["../src/rsc.tsx"],"sourcesContent":["/// <reference types=\"react/canary\" />\n\nimport {\n dehydrate,\n HydrationBoundary,\n type QueryClient,\n} from '@tanstack/react-query';\nimport type { TRPCClientError } from '@trpc/client';\nimport type { inferTransformedProcedureOutput } from '@trpc/server';\nimport {\n createRecursiveProxy,\n type AnyRouter,\n type inferProcedureInput,\n type RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureOutput,\n inferRouterRootTypes,\n Maybe,\n RouterCaller,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport * as React from 'react';\nimport { getQueryKeyInternal } from './internals/getQueryKey';\nimport type {\n TRPCFetchInfiniteQueryOptions,\n TRPCFetchQueryOptions,\n} from './shared';\n\nconst HELPERS = ['prefetch', 'prefetchInfinite'];\n\ntype DecorateProcedure<\n TRoot extends AnyRootTypes,\n TProcedure extends AnyProcedure,\n> = {\n (\n input: inferProcedureInput<TProcedure>,\n ): Promise<inferProcedureOutput<TProcedure>>;\n prefetch: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchQueryOptions<\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n prefetchInfinite: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchInfiniteQueryOptions<\n inferProcedureInput<TProcedure>,\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n};\n\ntype DecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<TRoot, $Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\ntype Caller<TRouter extends AnyRouter> = ReturnType<\n RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>\n>;\n\n// ts-prune-ignore-next\n/**\n * Creates a server-side caller that can also prefetch queries, plus a\n * `HydrateClient` component that sends the prefetched data to the client.\n *\n * @note This requires `@tanstack/react-query@^5.49.0`\n * @note Make sure to have `dehydrate.serializeData` and `hydrate.deserializeData`\n * set to your data transformer in your `QueryClient` factory.\n * @example\n * ```ts\n * export const createQueryClient = () =>\n * new QueryClient({\n * defaultOptions: {\n * dehydrate: {\n * serializeData: transformer.serialize,\n * },\n * hydrate: {\n * deserializeData: transformer.deserialize,\n * },\n * },\n * });\n * ```\n *\n * @deprecated `@trpc/react-query` only gets bug fixes and will be removed in\n * the next major version. Use `@trpc/tanstack-react-query` instead.\n * @see https://trpc.io/docs/client/tanstack-react-query/migrating\n * @see https://trpc.io/docs/client/react/server-components\n */\nexport function createHydrationHelpers<TRouter extends AnyRouter>(\n caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>,\n getQueryClient: () => QueryClient,\n) {\n type RootTypes = inferRouterRootTypes<TRouter>;\n\n const wrappedProxy = createRecursiveProxy<\n DecorateRouterRecord<RootTypes, TRouter['_def']['record']>\n >(async (opts) => {\n const path = [...opts.path];\n const args = [...opts.args];\n const proc = path.reduce(\n (acc, key) =>\n // @ts-expect-error - ??\n HELPERS.includes(key) ? acc : acc[key],\n caller,\n ) as unknown as DecorateProcedure<RootTypes, AnyProcedure>;\n\n const input = args[0];\n const promise = proc(input);\n\n const helper = path.pop();\n if (helper === 'prefetch') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'query'),\n queryFn: () => promise,\n });\n }\n if (helper === 'prefetchInfinite') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchInfiniteQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'infinite'),\n queryFn: () => promise,\n initialPageParam: args1?.initialCursor ?? null,\n });\n }\n\n return promise;\n });\n\n function HydrateClient(props: { children: React.ReactNode }) {\n const dehydratedState = dehydrate(getQueryClient());\n\n return (\n <HydrationBoundary state={dehydratedState}>\n {props.children}\n </HydrationBoundary>\n );\n }\n\n return {\n /***\n * Wrapped caller with prefetch helpers\n * Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)\n * or using prefetch helpers to put the promise into the QueryClient cache\n * @example\n * ```ts\n * const data = await trpc.post.get(\"postId\");\n *\n * // or\n * void trpc.post.get.prefetch(\"postId\");\n * ```\n */\n trpc: wrappedProxy,\n /**\n * HoC to hydrate the query client for a client component\n * to pick up the prefetched promise and skip an initial\n * client-side fetch.\n * @example\n * ```tsx\n * // MyRSC.tsx\n * const MyRSC = async ({ params }) => {\n * await trpc.post.get.prefetch(params.postId);\n *\n * return (\n * <HydrateClient>\n * <MyCC postId={params.postId} />\n * </HydrateClient>\n * );\n * };\n *\n * // MyCC.tsx\n * \"use client\"\n * const MyCC = ({ postId }) => {\n * const { data: post } = trpc.post.get.useQuery(postId);\n * return <div>{post.title}</div>;\n * };\n * ```\n */\n HydrateClient,\n };\n}\n"],"mappings":";;;;;AA+BA,MAAM,UAAU,CAAC,YAAY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuE/C,SAAgB,uBACd,QAGA,gBACA;CAGA,MAAM,eAAe,qBAEnB,OAAO,SAAS;EAChB,MAAM,OAAO,CAAC,GAAG,KAAK,IAAI;EAC1B,MAAM,OAAO,CAAC,GAAG,KAAK,IAAI;EAC1B,MAAM,OAAO,KAAK,QACf,KAAK,QAEJ,QAAQ,SAAS,GAAG,IAAI,MAAM,IAAI,MACpC,MACF;EAEA,MAAM,QAAQ,KAAK;EACnB,MAAM,UAAU,KAAK,KAAK;EAE1B,MAAM,SAAS,KAAK,IAAI;EACxB,IAAI,WAAW,YAAY;GACzB,MAAM,QAAQ,KAAK;GAInB,OAAO,eAAe,CAAC,CAAC,cAAA,eAAA,eAAA,CAAA,GACnB,KAAA,GAAA,CAAA,GAAA;IACH,UAAU,oBAAoB,MAAM,OAAO,OAAO;IAClD,eAAe;GACjB,CAAA,CAAC;EACH;EACA,IAAI,WAAW,oBAAoB;;GACjC,MAAM,QAAQ,KAAK;GAInB,OAAO,eAAe,CAAC,CAAC,sBAAA,eAAA,eAAA,CAAA,GACnB,KAAA,GAAA,CAAA,GAAA;IACH,UAAU,oBAAoB,MAAM,OAAO,UAAU;IACrD,eAAe;IACf,mBAAA,uBAAA,UAAA,QAAA,UAAA,KAAA,IAAA,KAAA,IAAkB,MAAO,mBAAA,QAAA,yBAAA,KAAA,IAAA,uBAAiB;GAC5C,CAAA,CAAC;EACH;EAEA,OAAO;CACT,CAAC;CAED,SAAS,cAAc,OAAsC;EAC3D,MAAM,kBAAkB,UAAU,eAAe,CAAC;EAElD,OACE,sBAAA,cAAC,mBAAD,EAAmB,OAAO,gBAEP,GADhB,MAAM,QACU;CAEvB;CAEA,OAAO;;;;;;;;;;;;;EAaL,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BN;CACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trpc/react-query",
3
3
  "type": "module",
4
- "version": "11.23.1-canary.26.b84c927ef",
4
+ "version": "11.23.1-canary.28.c6a7e7d57",
5
5
  "description": "The tRPC React library",
6
6
  "author": "KATT",
7
7
  "license": "MIT",
@@ -76,8 +76,8 @@
76
76
  ],
77
77
  "peerDependencies": {
78
78
  "@tanstack/react-query": "^5.80.3",
79
- "@trpc/client": "11.23.1-canary.26.b84c927ef",
80
- "@trpc/server": "11.23.1-canary.26.b84c927ef",
79
+ "@trpc/client": "11.23.1-canary.28.c6a7e7d57",
80
+ "@trpc/server": "11.23.1-canary.28.c6a7e7d57",
81
81
  "react": ">=18.2.0",
82
82
  "typescript": ">=5.7.2"
83
83
  },
@@ -89,8 +89,8 @@
89
89
  "@testing-library/jest-dom": "^6.9.1",
90
90
  "@testing-library/react": "^16.1.0",
91
91
  "@testing-library/user-event": "^14.4.3",
92
- "@trpc/client": "11.23.1-canary.26.b84c927ef",
93
- "@trpc/server": "11.23.1-canary.26.b84c927ef",
92
+ "@trpc/client": "11.23.1-canary.28.c6a7e7d57",
93
+ "@trpc/server": "11.23.1-canary.28.c6a7e7d57",
94
94
  "@types/express": "^5.0.0",
95
95
  "@types/node": "^24.13.4",
96
96
  "@types/react": "^19.1.0",
@@ -112,5 +112,5 @@
112
112
  "funding": [
113
113
  "https://trpc.io/sponsor"
114
114
  ],
115
- "gitHead": "b84c927ef848d19d7255773d87b3abf853afeec0"
115
+ "gitHead": "c6a7e7d57d9fbb497f17b1d8ca20718094926e76"
116
116
  }
package/src/rsc.tsx CHANGED
@@ -182,8 +182,8 @@ export function createHydrationHelpers<TRouter extends AnyRouter>(
182
182
  * @example
183
183
  * ```tsx
184
184
  * // MyRSC.tsx
185
- * const MyRSC = ({ params }) => {
186
- * void trpc.post.get.prefetch(params.postId);
185
+ * const MyRSC = async ({ params }) => {
186
+ * await trpc.post.get.prefetch(params.postId);
187
187
  *
188
188
  * return (
189
189
  * <HydrateClient>