@trpc/react-query 11.18.1-canary.2 → 11.18.1-canary.30
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/getQueryKey-4D2iXfB-.cjs +193 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs +132 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs.map +1 -0
- package/dist/{getQueryKey.d-CruH3ncI.d.mts → getQueryKey-Bw7DtJ4y.d.cts} +21 -46
- package/dist/getQueryKey-Bw7DtJ4y.d.cts.map +1 -0
- package/dist/{getQueryKey.d-C_PnqPni.d.cts → getQueryKey-Cgg9jecL.d.mts} +21 -46
- package/dist/getQueryKey-Cgg9jecL.d.mts.map +1 -0
- package/dist/index.cjs +16 -17
- package/dist/index.d.cts +3 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -10
- package/dist/index.mjs.map +1 -1
- package/dist/rsc.cjs +49 -17
- package/dist/rsc.d.cts +3 -5
- package/dist/rsc.d.cts.map +1 -1
- package/dist/rsc.d.mts +3 -5
- package/dist/rsc.d.mts.map +1 -1
- package/dist/rsc.mjs +43 -12
- package/dist/rsc.mjs.map +1 -1
- package/dist/server/index.cjs +30 -35
- package/dist/server/index.d.cts +3 -5
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +3 -5
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +20 -25
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.cjs +3 -4
- package/dist/shared/index.d.cts +2 -2
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.mjs +2 -4
- package/dist/{shared-Dt4RsQVp.cjs → shared-BhNi4Oqs.cjs} +210 -237
- package/dist/{shared-JtnEvJvB.mjs → shared-DhkLzxq7.mjs} +131 -160
- package/dist/shared-DhkLzxq7.mjs.map +1 -0
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +1 -2
- package/src/index.ts +1 -0
- package/src/internals/context.tsx +10 -4
- package/src/internals/getQueryKey.ts +1 -3
- package/src/internals/useQueries.ts +9 -3
- package/src/shared/hooks/createHooksInternal.tsx +0 -1
- package/src/shared/hooks/types.ts +37 -20
- package/src/shared/types.ts +31 -12
- package/src/utils/createUtilityFunctions.ts +2 -2
- package/dist/getQueryKey-BY58RNzP.mjs +0 -196
- package/dist/getQueryKey-BY58RNzP.mjs.map +0 -1
- package/dist/getQueryKey-PyKLS56S.cjs +0 -242
- package/dist/getQueryKey.d-C_PnqPni.d.cts.map +0 -1
- package/dist/getQueryKey.d-CruH3ncI.d.mts.map +0 -1
- package/dist/shared-JtnEvJvB.mjs.map +0 -1
package/dist/rsc.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_getQueryKey = require("./getQueryKey-4D2iXfB-.cjs");
|
|
3
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
|
+
let _trpc_server_unstable_core_do_not_import = require("@trpc/server/unstable-core-do-not-import");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_getQueryKey.__toESM(react, 1);
|
|
7
7
|
//#region src/rsc.tsx
|
|
8
|
-
var import_objectSpread2 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2());
|
|
9
8
|
const HELPERS = ["prefetch", "prefetchInfinite"];
|
|
10
9
|
/**
|
|
11
10
|
* @note This requires `@tanstack/react-query@^5.49.0`
|
|
@@ -27,7 +26,7 @@ const HELPERS = ["prefetch", "prefetchInfinite"];
|
|
|
27
26
|
* ```
|
|
28
27
|
*/
|
|
29
28
|
function createHydrationHelpers(caller, getQueryClient) {
|
|
30
|
-
const wrappedProxy = (0,
|
|
29
|
+
const wrappedProxy = (0, _trpc_server_unstable_core_do_not_import.createRecursiveProxy)(async (opts) => {
|
|
31
30
|
const path = [...opts.path];
|
|
32
31
|
const args = [...opts.args];
|
|
33
32
|
const proc = path.reduce((acc, key) => HELPERS.includes(key) ? acc : acc[key], caller);
|
|
@@ -36,7 +35,7 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
36
35
|
const helper = path.pop();
|
|
37
36
|
if (helper === "prefetch") {
|
|
38
37
|
const args1 = args[1];
|
|
39
|
-
return getQueryClient().prefetchQuery(
|
|
38
|
+
return getQueryClient().prefetchQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
40
39
|
queryKey: require_getQueryKey.getQueryKeyInternal(path, input, "query"),
|
|
41
40
|
queryFn: () => promise
|
|
42
41
|
}));
|
|
@@ -44,7 +43,7 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
44
43
|
if (helper === "prefetchInfinite") {
|
|
45
44
|
var _args1$initialCursor;
|
|
46
45
|
const args1 = args[1];
|
|
47
|
-
return getQueryClient().prefetchInfiniteQuery(
|
|
46
|
+
return getQueryClient().prefetchInfiniteQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
48
47
|
queryKey: require_getQueryKey.getQueryKeyInternal(path, input, "infinite"),
|
|
49
48
|
queryFn: () => promise,
|
|
50
49
|
initialPageParam: (_args1$initialCursor = args1 === null || args1 === void 0 ? void 0 : args1.initialCursor) !== null && _args1$initialCursor !== void 0 ? _args1$initialCursor : null
|
|
@@ -53,17 +52,50 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
53
52
|
return promise;
|
|
54
53
|
});
|
|
55
54
|
function HydrateClient(props) {
|
|
56
|
-
const dehydratedState = (0,
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
state: dehydratedState,
|
|
59
|
-
children: props.children
|
|
60
|
-
});
|
|
55
|
+
const dehydratedState = (0, _tanstack_react_query.dehydrate)(getQueryClient());
|
|
56
|
+
return /* @__PURE__ */ react.createElement(_tanstack_react_query.HydrationBoundary, { state: dehydratedState }, props.children);
|
|
61
57
|
}
|
|
62
58
|
return {
|
|
59
|
+
/***
|
|
60
|
+
* Wrapped caller with prefetch helpers
|
|
61
|
+
* Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)
|
|
62
|
+
* or using prefetch helpers to put the promise into the QueryClient cache
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const data = await trpc.post.get("postId");
|
|
66
|
+
*
|
|
67
|
+
* // or
|
|
68
|
+
* void trpc.post.get.prefetch("postId");
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
63
71
|
trpc: wrappedProxy,
|
|
72
|
+
/**
|
|
73
|
+
* HoC to hydrate the query client for a client component
|
|
74
|
+
* to pick up the prefetched promise and skip an initial
|
|
75
|
+
* client-side fetch.
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // MyRSC.tsx
|
|
79
|
+
* const MyRSC = ({ params }) => {
|
|
80
|
+
* void trpc.post.get.prefetch(params.postId);
|
|
81
|
+
*
|
|
82
|
+
* return (
|
|
83
|
+
* <HydrateClient>
|
|
84
|
+
* <MyCC postId={params.postId} />
|
|
85
|
+
* </HydrateClient>
|
|
86
|
+
* );
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* // MyCC.tsx
|
|
90
|
+
* "use client"
|
|
91
|
+
* const MyCC = ({ postId }) => {
|
|
92
|
+
* const { data: post } = trpc.post.get.useQuery(postId);
|
|
93
|
+
* return <div>{post.title}</div>;
|
|
94
|
+
* };
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
64
97
|
HydrateClient
|
|
65
98
|
};
|
|
66
99
|
}
|
|
67
|
-
|
|
68
100
|
//#endregion
|
|
69
|
-
exports.createHydrationHelpers = createHydrationHelpers;
|
|
101
|
+
exports.createHydrationHelpers = createHydrationHelpers;
|
package/dist/rsc.d.cts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions } from "./getQueryKey
|
|
1
|
+
import { Ft as TRPCFetchInfiniteQueryOptions, It as TRPCFetchQueryOptions } from "./getQueryKey-Bw7DtJ4y.cjs";
|
|
2
2
|
import { TRPCClientError } from "@trpc/client";
|
|
3
3
|
import { AnyProcedure, AnyRootTypes, AnyRouter, RouterCaller, RouterRecord, TypeError, inferProcedureInput, inferProcedureOutput, inferRouterRootTypes } from "@trpc/server/unstable-core-do-not-import";
|
|
4
4
|
import { QueryClient } from "@tanstack/react-query";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { inferTransformedProcedureOutput as inferTransformedProcedureOutput$1 } from "@trpc/server";
|
|
7
|
-
|
|
8
7
|
//#region src/rsc.d.ts
|
|
9
8
|
type DecorateProcedure<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = {
|
|
10
9
|
(input: inferProcedureInput<TProcedure>): Promise<inferProcedureOutput<TProcedure>>;
|
|
11
10
|
prefetch: (input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput$1<TRoot, TProcedure>, TRPCClientError<TRoot>>) => Promise<void>;
|
|
12
11
|
prefetchInfinite: (input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput$1<TRoot, TProcedure>, TRPCClientError<TRoot>>) => Promise<void>;
|
|
13
12
|
};
|
|
14
|
-
type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<TRoot, $Value> : $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value> : never : never };
|
|
13
|
+
type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<TRoot, $Value> : $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value> : never : never; };
|
|
15
14
|
type Caller<TRouter extends AnyRouter> = ReturnType<RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>>;
|
|
16
15
|
/**
|
|
17
16
|
* @note This requires `@tanstack/react-query@^5.49.0`
|
|
@@ -32,7 +31,7 @@ type Caller<TRouter extends AnyRouter> = ReturnType<RouterCaller<inferRouterRoot
|
|
|
32
31
|
* });
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
|
-
declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRouter extends TRouter ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'> : Caller<TRouter>, getQueryClient: () => QueryClient): {
|
|
34
|
+
export declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRouter extends TRouter ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'> : Caller<TRouter>, getQueryClient: () => QueryClient): {
|
|
36
35
|
/***
|
|
37
36
|
* Wrapped caller with prefetch helpers
|
|
38
37
|
* Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)
|
|
@@ -76,5 +75,4 @@ declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRo
|
|
|
76
75
|
}) => React.JSX.Element;
|
|
77
76
|
};
|
|
78
77
|
//#endregion
|
|
79
|
-
export { createHydrationHelpers };
|
|
80
78
|
//# sourceMappingURL=rsc.d.cts.map
|
package/dist/rsc.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.d.cts","names":[],"sources":["../src/rsc.tsx"],"
|
|
1
|
+
{"version":3,"file":"rsc.d.cts","names":[],"sources":["../src/rsc.tsx"],"mappings":";;;;;;;KAiCK,kBACH,cAAc,cACd,mBAAmB;GAGjB,OAAO,oBAAoB,cAC1B,QAAQ,qBAAqB;EAChC,WACE,OAAO,oBAAoB,aAC3B,OAAO,sBACL,kCAAgC,OAAO,aACvC,gBAAgB,YAEf;EACL,mBACE,OAAO,oBAAoB,aAC3B,OAAO,8BACL,oBAAoB,aACpB,kCAAgC,OAAO,aACvC,gBAAgB,YAEf;;KAGF,qBACH,cAAc,cACd,gBAAgB,mBAEf,cAAc,UAAU,QAAQ,qBAAoB,UACjD,eAAe,eACb,kBAAkB,OAAO,UACzB,eAAe,eACb,qBAAqB,OAAO;KAKjC,OAAO,gBAAgB,aAAa,WACvC,aAAa,qBAAqB,UAAU;;;;;;;;;;;;;;;;;;;;wBAuB9B,uBAAuB,gBAAgB,WACrD,QAAQ,kBAAkB,UACtB,2EACA,OAAO,UACX,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CQ,gBAAA;IAAE,UAAU,MAAM;QAAW,MAAA,IAAA"}
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions } from "./getQueryKey
|
|
1
|
+
import { Ft as TRPCFetchInfiniteQueryOptions, It as TRPCFetchQueryOptions } from "./getQueryKey-Cgg9jecL.mjs";
|
|
2
2
|
import { TRPCClientError } from "@trpc/client";
|
|
3
3
|
import { QueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { AnyProcedure, AnyRootTypes, AnyRouter, RouterCaller, RouterRecord, TypeError, inferProcedureInput, inferProcedureOutput, inferRouterRootTypes } from "@trpc/server/unstable-core-do-not-import";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { inferTransformedProcedureOutput as inferTransformedProcedureOutput$1 } from "@trpc/server";
|
|
7
|
-
|
|
8
7
|
//#region src/rsc.d.ts
|
|
9
8
|
type DecorateProcedure<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = {
|
|
10
9
|
(input: inferProcedureInput<TProcedure>): Promise<inferProcedureOutput<TProcedure>>;
|
|
11
10
|
prefetch: (input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput$1<TRoot, TProcedure>, TRPCClientError<TRoot>>) => Promise<void>;
|
|
12
11
|
prefetchInfinite: (input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput$1<TRoot, TProcedure>, TRPCClientError<TRoot>>) => Promise<void>;
|
|
13
12
|
};
|
|
14
|
-
type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<TRoot, $Value> : $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value> : never : never };
|
|
13
|
+
type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<TRoot, $Value> : $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value> : never : never; };
|
|
15
14
|
type Caller<TRouter extends AnyRouter> = ReturnType<RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>>;
|
|
16
15
|
/**
|
|
17
16
|
* @note This requires `@tanstack/react-query@^5.49.0`
|
|
@@ -32,7 +31,7 @@ type Caller<TRouter extends AnyRouter> = ReturnType<RouterCaller<inferRouterRoot
|
|
|
32
31
|
* });
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
|
-
declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRouter extends TRouter ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'> : Caller<TRouter>, getQueryClient: () => QueryClient): {
|
|
34
|
+
export declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRouter extends TRouter ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'> : Caller<TRouter>, getQueryClient: () => QueryClient): {
|
|
36
35
|
/***
|
|
37
36
|
* Wrapped caller with prefetch helpers
|
|
38
37
|
* Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)
|
|
@@ -76,5 +75,4 @@ declare function createHydrationHelpers<TRouter extends AnyRouter>(caller: AnyRo
|
|
|
76
75
|
}) => React.JSX.Element;
|
|
77
76
|
};
|
|
78
77
|
//#endregion
|
|
79
|
-
export { createHydrationHelpers };
|
|
80
78
|
//# sourceMappingURL=rsc.d.mts.map
|
package/dist/rsc.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.d.mts","names":[],"sources":["../src/rsc.tsx"],"
|
|
1
|
+
{"version":3,"file":"rsc.d.mts","names":[],"sources":["../src/rsc.tsx"],"mappings":";;;;;;;KAiCK,kBACH,cAAc,cACd,mBAAmB;GAGjB,OAAO,oBAAoB,cAC1B,QAAQ,qBAAqB;EAChC,WACE,OAAO,oBAAoB,aAC3B,OAAO,sBACL,kCAAgC,OAAO,aACvC,gBAAgB,YAEf;EACL,mBACE,OAAO,oBAAoB,aAC3B,OAAO,8BACL,oBAAoB,aACpB,kCAAgC,OAAO,aACvC,gBAAgB,YAEf;;KAGF,qBACH,cAAc,cACd,gBAAgB,mBAEf,cAAc,UAAU,QAAQ,qBAAoB,UACjD,eAAe,eACb,kBAAkB,OAAO,UACzB,eAAe,eACb,qBAAqB,OAAO;KAKjC,OAAO,gBAAgB,aAAa,WACvC,aAAa,qBAAqB,UAAU;;;;;;;;;;;;;;;;;;;;wBAuB9B,uBAAuB,gBAAgB,WACrD,QAAQ,kBAAkB,UACtB,2EACA,OAAO,UACX,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CQ,gBAAA;IAAE,UAAU,MAAM;QAAW,MAAA,IAAA"}
|
package/dist/rsc.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as _objectSpread2, i as getQueryKeyInternal } from "./getQueryKey-B1x5Ak4F.mjs";
|
|
2
2
|
import { HydrationBoundary, dehydrate } from "@tanstack/react-query";
|
|
3
3
|
import { createRecursiveProxy } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
-
import "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
4
|
+
import * as React from "react";
|
|
7
5
|
//#region src/rsc.tsx
|
|
8
|
-
var import_objectSpread2 = __toESM(require_objectSpread2());
|
|
9
6
|
const HELPERS = ["prefetch", "prefetchInfinite"];
|
|
10
7
|
/**
|
|
11
8
|
* @note This requires `@tanstack/react-query@^5.49.0`
|
|
@@ -36,7 +33,7 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
36
33
|
const helper = path.pop();
|
|
37
34
|
if (helper === "prefetch") {
|
|
38
35
|
const args1 = args[1];
|
|
39
|
-
return getQueryClient().prefetchQuery((
|
|
36
|
+
return getQueryClient().prefetchQuery(_objectSpread2(_objectSpread2({}, args1), {}, {
|
|
40
37
|
queryKey: getQueryKeyInternal(path, input, "query"),
|
|
41
38
|
queryFn: () => promise
|
|
42
39
|
}));
|
|
@@ -44,7 +41,7 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
44
41
|
if (helper === "prefetchInfinite") {
|
|
45
42
|
var _args1$initialCursor;
|
|
46
43
|
const args1 = args[1];
|
|
47
|
-
return getQueryClient().prefetchInfiniteQuery((
|
|
44
|
+
return getQueryClient().prefetchInfiniteQuery(_objectSpread2(_objectSpread2({}, args1), {}, {
|
|
48
45
|
queryKey: getQueryKeyInternal(path, input, "infinite"),
|
|
49
46
|
queryFn: () => promise,
|
|
50
47
|
initialPageParam: (_args1$initialCursor = args1 === null || args1 === void 0 ? void 0 : args1.initialCursor) !== null && _args1$initialCursor !== void 0 ? _args1$initialCursor : null
|
|
@@ -54,17 +51,51 @@ function createHydrationHelpers(caller, getQueryClient) {
|
|
|
54
51
|
});
|
|
55
52
|
function HydrateClient(props) {
|
|
56
53
|
const dehydratedState = dehydrate(getQueryClient());
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
state: dehydratedState,
|
|
59
|
-
children: props.children
|
|
60
|
-
});
|
|
54
|
+
return /* @__PURE__ */ React.createElement(HydrationBoundary, { state: dehydratedState }, props.children);
|
|
61
55
|
}
|
|
62
56
|
return {
|
|
57
|
+
/***
|
|
58
|
+
* Wrapped caller with prefetch helpers
|
|
59
|
+
* Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)
|
|
60
|
+
* or using prefetch helpers to put the promise into the QueryClient cache
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const data = await trpc.post.get("postId");
|
|
64
|
+
*
|
|
65
|
+
* // or
|
|
66
|
+
* void trpc.post.get.prefetch("postId");
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
63
69
|
trpc: wrappedProxy,
|
|
70
|
+
/**
|
|
71
|
+
* HoC to hydrate the query client for a client component
|
|
72
|
+
* to pick up the prefetched promise and skip an initial
|
|
73
|
+
* client-side fetch.
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* // MyRSC.tsx
|
|
77
|
+
* const MyRSC = ({ params }) => {
|
|
78
|
+
* void trpc.post.get.prefetch(params.postId);
|
|
79
|
+
*
|
|
80
|
+
* return (
|
|
81
|
+
* <HydrateClient>
|
|
82
|
+
* <MyCC postId={params.postId} />
|
|
83
|
+
* </HydrateClient>
|
|
84
|
+
* );
|
|
85
|
+
* };
|
|
86
|
+
*
|
|
87
|
+
* // MyCC.tsx
|
|
88
|
+
* "use client"
|
|
89
|
+
* const MyCC = ({ postId }) => {
|
|
90
|
+
* const { data: post } = trpc.post.get.useQuery(postId);
|
|
91
|
+
* return <div>{post.title}</div>;
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
64
95
|
HydrateClient
|
|
65
96
|
};
|
|
66
97
|
}
|
|
67
|
-
|
|
68
98
|
//#endregion
|
|
69
99
|
export { createHydrationHelpers };
|
|
100
|
+
|
|
70
101
|
//# sourceMappingURL=rsc.mjs.map
|
package/dist/rsc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.mjs","names":[
|
|
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 * @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 */\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;;;;;;;;;;;;;;;;;;;;AA+D/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/dist/server/index.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_getQueryKey = require("../getQueryKey-4D2iXfB-.cjs");
|
|
3
|
+
const require_shared = require("../shared-BhNi4Oqs.cjs");
|
|
4
|
+
let _trpc_client = require("@trpc/client");
|
|
5
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
|
+
let _trpc_server_unstable_core_do_not_import = require("@trpc/server/unstable-core-do-not-import");
|
|
7
|
+
let _trpc_client_unstable_internals = require("@trpc/client/unstable-internals");
|
|
8
8
|
//#region src/server/ssgProxy.ts
|
|
9
|
-
var import_objectSpread2 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2(), 1);
|
|
10
|
-
var import_objectWithoutProperties = require_getQueryKey.__toESM(require_getQueryKey.require_objectWithoutProperties(), 1);
|
|
11
9
|
const _excluded = ["promise"];
|
|
12
10
|
/**
|
|
13
11
|
* Create functions you can use for server-side rendering / static generation
|
|
@@ -15,14 +13,14 @@ const _excluded = ["promise"];
|
|
|
15
13
|
*/
|
|
16
14
|
function createServerSideHelpers(opts) {
|
|
17
15
|
const queryClient = require_shared.getQueryClient(opts);
|
|
18
|
-
const transformer = (0,
|
|
16
|
+
const transformer = (0, _trpc_client_unstable_internals.getTransformer)(opts.transformer);
|
|
19
17
|
const resolvedOpts = (() => {
|
|
20
18
|
if ("router" in opts) {
|
|
21
19
|
const { ctx, router } = opts;
|
|
22
20
|
return {
|
|
23
21
|
serialize: (obj) => transformer.output.serialize(obj),
|
|
24
22
|
query: (queryOpts) => {
|
|
25
|
-
return (0,
|
|
23
|
+
return (0, _trpc_server_unstable_core_do_not_import.callProcedure)({
|
|
26
24
|
router,
|
|
27
25
|
path: queryOpts.path,
|
|
28
26
|
getRawInput: async () => queryOpts.input,
|
|
@@ -35,57 +33,56 @@ function createServerSideHelpers(opts) {
|
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
35
|
const { client } = opts;
|
|
38
|
-
const untypedClient = client instanceof
|
|
36
|
+
const untypedClient = client instanceof _trpc_client.TRPCUntypedClient ? client : (0, _trpc_client.getUntypedClient)(client);
|
|
39
37
|
return {
|
|
40
38
|
query: (queryOpts) => untypedClient.query(queryOpts.path, queryOpts.input),
|
|
41
39
|
serialize: (obj) => transformer.output.serialize(obj)
|
|
42
40
|
};
|
|
43
41
|
})();
|
|
44
|
-
function _dehydrate(opts
|
|
42
|
+
function _dehydrate(opts = { shouldDehydrateQuery(query) {
|
|
45
43
|
if (query.state.status === "pending") return false;
|
|
46
44
|
return true;
|
|
47
45
|
} }) {
|
|
48
|
-
const before = (0,
|
|
49
|
-
const dehydrated = (0,
|
|
50
|
-
return
|
|
46
|
+
const before = (0, _trpc_server_unstable_core_do_not_import.run)(() => {
|
|
47
|
+
const dehydrated = (0, _tanstack_react_query.dehydrate)(queryClient, opts);
|
|
48
|
+
return require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, dehydrated), {}, { queries: dehydrated.queries.map((query) => {
|
|
51
49
|
if (query.promise) {
|
|
52
|
-
const { promise: _ } = query
|
|
53
|
-
return
|
|
50
|
+
const { promise: _ } = query;
|
|
51
|
+
return require_getQueryKey._objectWithoutProperties(query, _excluded);
|
|
54
52
|
}
|
|
55
53
|
return query;
|
|
56
54
|
}) });
|
|
57
55
|
});
|
|
58
|
-
|
|
59
|
-
return after;
|
|
56
|
+
return resolvedOpts.serialize(before);
|
|
60
57
|
}
|
|
61
|
-
const proxy = (0,
|
|
62
|
-
const args = opts
|
|
58
|
+
const proxy = (0, _trpc_server_unstable_core_do_not_import.createRecursiveProxy)((opts) => {
|
|
59
|
+
const args = opts.args;
|
|
63
60
|
const input = args[0];
|
|
64
|
-
const arrayPath = [...opts
|
|
61
|
+
const arrayPath = [...opts.path];
|
|
65
62
|
const utilName = arrayPath.pop();
|
|
66
63
|
const queryFn = () => resolvedOpts.query({
|
|
67
64
|
path: arrayPath.join("."),
|
|
68
65
|
input
|
|
69
66
|
});
|
|
70
67
|
const queryKey = require_getQueryKey.getQueryKeyInternal(arrayPath, input, require_shared.getQueryType(utilName));
|
|
71
|
-
|
|
68
|
+
return {
|
|
72
69
|
queryOptions: () => {
|
|
73
70
|
const args1 = args[1];
|
|
74
|
-
return
|
|
71
|
+
return require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
75
72
|
queryKey,
|
|
76
73
|
queryFn
|
|
77
74
|
});
|
|
78
75
|
},
|
|
79
76
|
infiniteQueryOptions: () => {
|
|
80
77
|
const args1 = args[1];
|
|
81
|
-
return
|
|
78
|
+
return require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
82
79
|
queryKey,
|
|
83
80
|
queryFn
|
|
84
81
|
});
|
|
85
82
|
},
|
|
86
83
|
fetch: () => {
|
|
87
84
|
const args1 = args[1];
|
|
88
|
-
return queryClient.fetchQuery(
|
|
85
|
+
return queryClient.fetchQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
89
86
|
queryKey,
|
|
90
87
|
queryFn
|
|
91
88
|
}));
|
|
@@ -93,7 +90,7 @@ function createServerSideHelpers(opts) {
|
|
|
93
90
|
fetchInfinite: () => {
|
|
94
91
|
var _args1$initialCursor;
|
|
95
92
|
const args1 = args[1];
|
|
96
|
-
return queryClient.fetchInfiniteQuery(
|
|
93
|
+
return queryClient.fetchInfiniteQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
97
94
|
queryKey,
|
|
98
95
|
queryFn,
|
|
99
96
|
initialPageParam: (_args1$initialCursor = args1 === null || args1 === void 0 ? void 0 : args1.initialCursor) !== null && _args1$initialCursor !== void 0 ? _args1$initialCursor : null
|
|
@@ -101,7 +98,7 @@ function createServerSideHelpers(opts) {
|
|
|
101
98
|
},
|
|
102
99
|
prefetch: () => {
|
|
103
100
|
const args1 = args[1];
|
|
104
|
-
return queryClient.prefetchQuery(
|
|
101
|
+
return queryClient.prefetchQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
105
102
|
queryKey,
|
|
106
103
|
queryFn
|
|
107
104
|
}));
|
|
@@ -109,21 +106,19 @@ function createServerSideHelpers(opts) {
|
|
|
109
106
|
prefetchInfinite: () => {
|
|
110
107
|
var _args1$initialCursor2;
|
|
111
108
|
const args1 = args[1];
|
|
112
|
-
return queryClient.prefetchInfiniteQuery(
|
|
109
|
+
return queryClient.prefetchInfiniteQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, args1), {}, {
|
|
113
110
|
queryKey,
|
|
114
111
|
queryFn,
|
|
115
112
|
initialPageParam: (_args1$initialCursor2 = args1 === null || args1 === void 0 ? void 0 : args1.initialCursor) !== null && _args1$initialCursor2 !== void 0 ? _args1$initialCursor2 : null
|
|
116
113
|
}));
|
|
117
114
|
}
|
|
118
|
-
};
|
|
119
|
-
return helperMap[utilName]();
|
|
115
|
+
}[utilName]();
|
|
120
116
|
});
|
|
121
|
-
return (0,
|
|
117
|
+
return (0, _trpc_server_unstable_core_do_not_import.createFlatProxy)((key) => {
|
|
122
118
|
if (key === "queryClient") return queryClient;
|
|
123
119
|
if (key === "dehydrate") return _dehydrate;
|
|
124
120
|
return proxy[key];
|
|
125
121
|
});
|
|
126
122
|
}
|
|
127
|
-
|
|
128
123
|
//#endregion
|
|
129
|
-
exports.createServerSideHelpers = createServerSideHelpers;
|
|
124
|
+
exports.createServerSideHelpers = createServerSideHelpers;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as DecorateQueryProcedure, b as CreateTRPCReactQueryClientConfig } from "../getQueryKey-Bw7DtJ4y.cjs";
|
|
2
2
|
import { TRPCClient, TRPCUntypedClient } from "@trpc/client";
|
|
3
3
|
import { AnyQueryProcedure, AnyRootTypes, AnyRouter, ProtectedIntersection, RouterRecord, inferClientTypes, inferRouterContext } from "@trpc/server/unstable-core-do-not-import";
|
|
4
4
|
import { DehydrateOptions, DehydratedState, QueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { TransformerOptions } from "@trpc/client/unstable-internals";
|
|
6
|
-
|
|
7
6
|
//#region src/server/ssgProxy.d.ts
|
|
8
7
|
type CreateSSGHelpersInternal<TRouter extends AnyRouter> = {
|
|
9
8
|
router: TRouter;
|
|
@@ -17,15 +16,14 @@ type SSGFns = 'queryOptions' | 'infiniteQueryOptions' | 'fetch' | 'fetchInfinite
|
|
|
17
16
|
/**
|
|
18
17
|
* @internal
|
|
19
18
|
*/
|
|
20
|
-
type DecoratedProcedureSSGRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyQueryProcedure ? Pick<DecorateQueryProcedure<TRoot, $Value>, SSGFns> : $Value extends RouterRecord ? DecoratedProcedureSSGRecord<TRoot, $Value> : never : never };
|
|
19
|
+
type DecoratedProcedureSSGRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyQueryProcedure ? Pick<DecorateQueryProcedure<TRoot, $Value>, SSGFns> : $Value extends RouterRecord ? DecoratedProcedureSSGRecord<TRoot, $Value> : never : never; };
|
|
21
20
|
/**
|
|
22
21
|
* Create functions you can use for server-side rendering / static generation
|
|
23
22
|
* @see https://trpc.io/docs/v11/client/nextjs/server-side-helpers
|
|
24
23
|
*/
|
|
25
|
-
declare function createServerSideHelpers<TRouter extends AnyRouter>(opts: CreateServerSideHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
24
|
+
export declare function createServerSideHelpers<TRouter extends AnyRouter>(opts: CreateServerSideHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
26
25
|
queryClient: QueryClient;
|
|
27
26
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
28
27
|
}, DecoratedProcedureSSGRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>>;
|
|
29
28
|
//#endregion
|
|
30
|
-
export { createServerSideHelpers };
|
|
31
29
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/ssgProxy.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/ssgProxy.ts"],"mappings":";;;;;;KAsCK,yBAAyB,gBAAgB;EAC5C,QAAQ;EACR,KAAK,mBAAmB;IACtB,mBAAmB,iBAAiB;UAE9B,yBAAyB,gBAAgB;EACjD,QAAQ,WAAW,WAAW,kBAAkB;;KAG7C,+BAA+B,gBAAgB,aAClD,oCACG,yBAAyB,WAAW,yBAAyB;KAE7D;;;;KAWA,4BACH,cAAc,cACd,gBAAgB,mBAEf,cAAc,UAAU,QAAQ,qBAAoB,UACjD,eAAe,oBACb,KAAK,uBAAuB,OAAO,SAAS,UAC5C,eAAe,eACb,4BAA4B,OAAO;;;;;wBAW7B,wBAAwB,gBAAgB,WACtD,MAAM,+BAA+B,WAAQ;EAuE5B,aAAA;EACF,YAAC,OAAO,qBAAqB;GAsE7C,4BAAA,sCAAA"}
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as DecorateQueryProcedure, b as CreateTRPCReactQueryClientConfig } from "../getQueryKey-Cgg9jecL.mjs";
|
|
2
2
|
import { TRPCClient, TRPCUntypedClient } from "@trpc/client";
|
|
3
3
|
import { DehydrateOptions, DehydratedState, QueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { AnyQueryProcedure, AnyRootTypes, AnyRouter, ProtectedIntersection, RouterRecord, inferClientTypes, inferRouterContext } from "@trpc/server/unstable-core-do-not-import";
|
|
5
5
|
import { TransformerOptions } from "@trpc/client/unstable-internals";
|
|
6
|
-
|
|
7
6
|
//#region src/server/ssgProxy.d.ts
|
|
8
7
|
type CreateSSGHelpersInternal<TRouter extends AnyRouter> = {
|
|
9
8
|
router: TRouter;
|
|
@@ -17,15 +16,14 @@ type SSGFns = 'queryOptions' | 'infiniteQueryOptions' | 'fetch' | 'fetchInfinite
|
|
|
17
16
|
/**
|
|
18
17
|
* @internal
|
|
19
18
|
*/
|
|
20
|
-
type DecoratedProcedureSSGRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyQueryProcedure ? Pick<DecorateQueryProcedure<TRoot, $Value>, SSGFns> : $Value extends RouterRecord ? DecoratedProcedureSSGRecord<TRoot, $Value> : never : never };
|
|
19
|
+
type DecoratedProcedureSSGRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyQueryProcedure ? Pick<DecorateQueryProcedure<TRoot, $Value>, SSGFns> : $Value extends RouterRecord ? DecoratedProcedureSSGRecord<TRoot, $Value> : never : never; };
|
|
21
20
|
/**
|
|
22
21
|
* Create functions you can use for server-side rendering / static generation
|
|
23
22
|
* @see https://trpc.io/docs/v11/client/nextjs/server-side-helpers
|
|
24
23
|
*/
|
|
25
|
-
declare function createServerSideHelpers<TRouter extends AnyRouter>(opts: CreateServerSideHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
24
|
+
export declare function createServerSideHelpers<TRouter extends AnyRouter>(opts: CreateServerSideHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
26
25
|
queryClient: QueryClient;
|
|
27
26
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
28
27
|
}, DecoratedProcedureSSGRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>>;
|
|
29
28
|
//#endregion
|
|
30
|
-
export { createServerSideHelpers };
|
|
31
29
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/ssgProxy.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/ssgProxy.ts"],"mappings":";;;;;;KAsCK,yBAAyB,gBAAgB;EAC5C,QAAQ;EACR,KAAK,mBAAmB;IACtB,mBAAmB,iBAAiB;UAE9B,yBAAyB,gBAAgB;EACjD,QAAQ,WAAW,WAAW,kBAAkB;;KAG7C,+BAA+B,gBAAgB,aAClD,oCACG,yBAAyB,WAAW,yBAAyB;KAE7D;;;;KAWA,4BACH,cAAc,cACd,gBAAgB,mBAEf,cAAc,UAAU,QAAQ,qBAAoB,UACjD,eAAe,oBACb,KAAK,uBAAuB,OAAO,SAAS,UAC5C,eAAe,eACb,4BAA4B,OAAO;;;;;wBAW7B,wBAAwB,gBAAgB,WACtD,MAAM,+BAA+B,WAAQ;EAuE5B,aAAA;EACF,YAAC,OAAO,qBAAqB;GAsE7C,4BAAA,sCAAA"}
|