@trpc/react-query 11.1.3-alpha-tmp-tsdown.23 → 11.1.3-alpha-tmp-tsdown.26
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-CP8onRYT.cjs +104 -0
- package/dist/{internals/getQueryKey.mjs → getQueryKey-Dekty44G.mjs} +1 -1
- package/dist/getQueryKey-Dekty44G.mjs.map +1 -0
- package/dist/getQueryKey.d-C_PnqPni.d.cts +892 -0
- package/dist/getQueryKey.d-C_PnqPni.d.cts.map +1 -0
- package/dist/getQueryKey.d-CruH3ncI.d.mts +892 -0
- package/dist/getQueryKey.d-CruH3ncI.d.mts.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/{utils/createUtilityFunctions.d.mts → index.d.cts} +11 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +30 -5
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +37 -4
- package/dist/index.mjs.map +1 -0
- package/dist/{rsc.js → rsc.cjs} +7 -8
- package/dist/{rsc.d.ts → rsc.d.cts} +2 -3
- package/dist/rsc.d.cts.map +1 -0
- package/dist/rsc.d.mts +1 -2
- package/dist/rsc.d.mts.map +1 -1
- package/dist/rsc.mjs +1 -1
- package/dist/server/{ssgProxy.js → index.cjs} +8 -10
- package/dist/server/{ssgProxy.d.ts → index.d.cts} +2 -4
- package/dist/server/index.d.cts.map +1 -0
- package/dist/server/index.d.mts +31 -2
- package/dist/server/index.d.mts.map +1 -0
- package/dist/server/index.mjs +132 -2
- package/dist/server/index.mjs.map +1 -0
- package/dist/shared/index.cjs +13 -0
- package/dist/shared/index.d.cts +2 -0
- package/dist/shared/index.d.mts +1 -15
- package/dist/shared/index.mjs +2 -7
- package/dist/{shared/hooks/createHooksInternal.mjs → shared-CMPBsqju.mjs} +363 -11
- package/dist/shared-CMPBsqju.mjs.map +1 -0
- package/dist/shared-Doe-Gsbv.cjs +846 -0
- package/package.json +19 -20
- package/rsc/package.json +1 -1
- package/server/package.json +1 -1
- package/shared/package.json +1 -1
- package/dist/_virtual/rolldown_runtime.js +0 -30
- package/dist/createTRPCQueryUtils.d.mts +0 -12
- package/dist/createTRPCQueryUtils.d.mts.map +0 -1
- package/dist/createTRPCQueryUtils.d.ts +0 -12
- package/dist/createTRPCQueryUtils.d.ts.map +0 -1
- package/dist/createTRPCQueryUtils.js +0 -11
- package/dist/createTRPCQueryUtils.mjs +0 -12
- package/dist/createTRPCQueryUtils.mjs.map +0 -1
- package/dist/createTRPCReact.d.mts +0 -143
- package/dist/createTRPCReact.d.mts.map +0 -1
- package/dist/createTRPCReact.d.ts +0 -143
- package/dist/createTRPCReact.d.ts.map +0 -1
- package/dist/createTRPCReact.js +0 -32
- package/dist/createTRPCReact.mjs +0 -32
- package/dist/createTRPCReact.mjs.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -15
- package/dist/internals/context.d.mts +0 -164
- package/dist/internals/context.d.mts.map +0 -1
- package/dist/internals/context.d.ts +0 -164
- package/dist/internals/context.d.ts.map +0 -1
- package/dist/internals/context.js +0 -15
- package/dist/internals/context.mjs +0 -14
- package/dist/internals/context.mjs.map +0 -1
- package/dist/internals/getClientArgs.d.mts +0 -19
- package/dist/internals/getClientArgs.d.mts.map +0 -1
- package/dist/internals/getClientArgs.d.ts +0 -19
- package/dist/internals/getClientArgs.d.ts.map +0 -1
- package/dist/internals/getClientArgs.js +0 -22
- package/dist/internals/getClientArgs.mjs +0 -22
- package/dist/internals/getClientArgs.mjs.map +0 -1
- package/dist/internals/getQueryKey.d.mts +0 -45
- package/dist/internals/getQueryKey.d.mts.map +0 -1
- package/dist/internals/getQueryKey.d.ts +0 -45
- package/dist/internals/getQueryKey.d.ts.map +0 -1
- package/dist/internals/getQueryKey.js +0 -56
- package/dist/internals/getQueryKey.mjs.map +0 -1
- package/dist/internals/trpcResult.js +0 -37
- package/dist/internals/trpcResult.mjs +0 -35
- package/dist/internals/trpcResult.mjs.map +0 -1
- package/dist/internals/useQueries.d.mts +0 -57
- package/dist/internals/useQueries.d.mts.map +0 -1
- package/dist/internals/useQueries.d.ts +0 -57
- package/dist/internals/useQueries.d.ts.map +0 -1
- package/dist/rsc.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.js +0 -3
- package/dist/server/ssgProxy.d.mts +0 -33
- package/dist/server/ssgProxy.d.mts.map +0 -1
- package/dist/server/ssgProxy.d.ts.map +0 -1
- package/dist/server/ssgProxy.mjs +0 -134
- package/dist/server/ssgProxy.mjs.map +0 -1
- package/dist/shared/hooks/createHooksInternal.d.mts +0 -42
- package/dist/shared/hooks/createHooksInternal.d.mts.map +0 -1
- package/dist/shared/hooks/createHooksInternal.d.ts +0 -42
- package/dist/shared/hooks/createHooksInternal.d.ts.map +0 -1
- package/dist/shared/hooks/createHooksInternal.js +0 -432
- package/dist/shared/hooks/createHooksInternal.mjs.map +0 -1
- package/dist/shared/hooks/createRootHooks.js +0 -1
- package/dist/shared/hooks/createRootHooks.mjs +0 -1
- package/dist/shared/hooks/types.d.mts +0 -154
- package/dist/shared/hooks/types.d.mts.map +0 -1
- package/dist/shared/hooks/types.d.ts +0 -154
- package/dist/shared/hooks/types.d.ts.map +0 -1
- package/dist/shared/index.d.ts +0 -16
- package/dist/shared/index.js +0 -18
- package/dist/shared/polymorphism/mutationLike.d.mts +0 -27
- package/dist/shared/polymorphism/mutationLike.d.mts.map +0 -1
- package/dist/shared/polymorphism/mutationLike.d.ts +0 -27
- package/dist/shared/polymorphism/mutationLike.d.ts.map +0 -1
- package/dist/shared/polymorphism/queryLike.d.mts +0 -31
- package/dist/shared/polymorphism/queryLike.d.mts.map +0 -1
- package/dist/shared/polymorphism/queryLike.d.ts +0 -31
- package/dist/shared/polymorphism/queryLike.d.ts.map +0 -1
- package/dist/shared/polymorphism/routerLike.d.mts +0 -19
- package/dist/shared/polymorphism/routerLike.d.mts.map +0 -1
- package/dist/shared/polymorphism/routerLike.d.ts +0 -19
- package/dist/shared/polymorphism/routerLike.d.ts.map +0 -1
- package/dist/shared/polymorphism/utilsLike.d.mts +0 -17
- package/dist/shared/polymorphism/utilsLike.d.mts.map +0 -1
- package/dist/shared/polymorphism/utilsLike.d.ts +0 -17
- package/dist/shared/polymorphism/utilsLike.d.ts.map +0 -1
- package/dist/shared/proxy/decorationProxy.d.mts +0 -19
- package/dist/shared/proxy/decorationProxy.d.mts.map +0 -1
- package/dist/shared/proxy/decorationProxy.d.ts +0 -19
- package/dist/shared/proxy/decorationProxy.d.ts.map +0 -1
- package/dist/shared/proxy/decorationProxy.js +0 -22
- package/dist/shared/proxy/decorationProxy.mjs +0 -22
- package/dist/shared/proxy/decorationProxy.mjs.map +0 -1
- package/dist/shared/proxy/useQueriesProxy.d.mts +0 -24
- package/dist/shared/proxy/useQueriesProxy.d.mts.map +0 -1
- package/dist/shared/proxy/useQueriesProxy.d.ts +0 -24
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +0 -1
- package/dist/shared/proxy/useQueriesProxy.js +0 -29
- package/dist/shared/proxy/useQueriesProxy.mjs +0 -29
- package/dist/shared/proxy/useQueriesProxy.mjs.map +0 -1
- package/dist/shared/proxy/utilsProxy.d.mts +0 -143
- package/dist/shared/proxy/utilsProxy.d.mts.map +0 -1
- package/dist/shared/proxy/utilsProxy.d.ts +0 -143
- package/dist/shared/proxy/utilsProxy.d.ts.map +0 -1
- package/dist/shared/proxy/utilsProxy.js +0 -93
- package/dist/shared/proxy/utilsProxy.mjs +0 -91
- package/dist/shared/proxy/utilsProxy.mjs.map +0 -1
- package/dist/shared/queryClient.d.mts +0 -26
- package/dist/shared/queryClient.d.mts.map +0 -1
- package/dist/shared/queryClient.d.ts +0 -26
- package/dist/shared/queryClient.d.ts.map +0 -1
- package/dist/shared/queryClient.js +0 -11
- package/dist/shared/queryClient.mjs +0 -11
- package/dist/shared/queryClient.mjs.map +0 -1
- package/dist/shared/types.d.mts +0 -99
- package/dist/shared/types.d.mts.map +0 -1
- package/dist/shared/types.d.ts +0 -99
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/utils/createUtilityFunctions.d.mts.map +0 -1
- package/dist/utils/createUtilityFunctions.d.ts +0 -24
- package/dist/utils/createUtilityFunctions.d.ts.map +0 -1
- package/dist/utils/createUtilityFunctions.js +0 -170
- package/dist/utils/createUtilityFunctions.mjs +0 -170
- package/dist/utils/createUtilityFunctions.mjs.map +0 -1
- package/dist/utils/inferReactQueryProcedure.d.mts +0 -30
- package/dist/utils/inferReactQueryProcedure.d.mts.map +0 -1
- package/dist/utils/inferReactQueryProcedure.d.ts +0 -30
- package/dist/utils/inferReactQueryProcedure.d.ts.map +0 -1
- package/rsc/index.d.ts +0 -1
- package/rsc/index.js +0 -1
- package/server/index/package.json +0 -1
- package/server/index.d.ts +0 -1
- package/server/index.js +0 -1
- package/shared/index/package.json +0 -1
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
package/dist/server/index.mjs
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getQueryKeyInternal } from "../getQueryKey-Dekty44G.mjs";
|
|
2
|
+
import { getQueryClient, getQueryType } from "../shared-CMPBsqju.mjs";
|
|
3
|
+
import { TRPCUntypedClient, getUntypedClient } from "@trpc/client";
|
|
4
|
+
import { dehydrate } from "@tanstack/react-query";
|
|
5
|
+
import { callProcedure, createFlatProxy, createRecursiveProxy, run } from "@trpc/server/unstable-core-do-not-import";
|
|
6
|
+
import { getTransformer } from "@trpc/client/unstable-internals";
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
//#region src/server/ssgProxy.ts
|
|
9
|
+
/**
|
|
10
|
+
* Create functions you can use for server-side rendering / static generation
|
|
11
|
+
* @see https://trpc.io/docs/v11/client/nextjs/server-side-helpers
|
|
12
|
+
*/
|
|
13
|
+
function createServerSideHelpers(opts) {
|
|
14
|
+
const queryClient = getQueryClient(opts);
|
|
15
|
+
const transformer = getTransformer(opts.transformer);
|
|
16
|
+
const resolvedOpts = (() => {
|
|
17
|
+
if ("router" in opts) {
|
|
18
|
+
const { ctx, router } = opts;
|
|
19
|
+
return {
|
|
20
|
+
serialize: transformer.output.serialize,
|
|
21
|
+
query: (queryOpts) => {
|
|
22
|
+
return callProcedure({
|
|
23
|
+
router,
|
|
24
|
+
path: queryOpts.path,
|
|
25
|
+
getRawInput: async () => queryOpts.input,
|
|
26
|
+
ctx,
|
|
27
|
+
type: "query",
|
|
28
|
+
signal: void 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const { client } = opts;
|
|
34
|
+
const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
|
|
35
|
+
return {
|
|
36
|
+
query: (queryOpts) => untypedClient.query(queryOpts.path, queryOpts.input),
|
|
37
|
+
serialize: (obj) => transformer.output.serialize(obj)
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
function _dehydrate(opts$1 = { shouldDehydrateQuery(query) {
|
|
41
|
+
if (query.state.status === "pending") return false;
|
|
42
|
+
return true;
|
|
43
|
+
} }) {
|
|
44
|
+
const before = run(() => {
|
|
45
|
+
const dehydrated = dehydrate(queryClient, opts$1);
|
|
46
|
+
return {
|
|
47
|
+
...dehydrated,
|
|
48
|
+
queries: dehydrated.queries.map((query) => {
|
|
49
|
+
if (query.promise) {
|
|
50
|
+
const { promise: _,...rest } = query;
|
|
51
|
+
return rest;
|
|
52
|
+
}
|
|
53
|
+
return query;
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const after = resolvedOpts.serialize(before);
|
|
58
|
+
return after;
|
|
59
|
+
}
|
|
60
|
+
const proxy = createRecursiveProxy((opts$1) => {
|
|
61
|
+
const args = opts$1.args;
|
|
62
|
+
const input = args[0];
|
|
63
|
+
const arrayPath = [...opts$1.path];
|
|
64
|
+
const utilName = arrayPath.pop();
|
|
65
|
+
const queryFn = () => resolvedOpts.query({
|
|
66
|
+
path: arrayPath.join("."),
|
|
67
|
+
input
|
|
68
|
+
});
|
|
69
|
+
const queryKey = getQueryKeyInternal(arrayPath, input, getQueryType(utilName));
|
|
70
|
+
const helperMap = {
|
|
71
|
+
queryOptions: () => {
|
|
72
|
+
const args1 = args[1];
|
|
73
|
+
return {
|
|
74
|
+
...args1,
|
|
75
|
+
queryKey,
|
|
76
|
+
queryFn
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
infiniteQueryOptions: () => {
|
|
80
|
+
const args1 = args[1];
|
|
81
|
+
return {
|
|
82
|
+
...args1,
|
|
83
|
+
queryKey,
|
|
84
|
+
queryFn
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
fetch: () => {
|
|
88
|
+
const args1 = args[1];
|
|
89
|
+
return queryClient.fetchQuery({
|
|
90
|
+
...args1,
|
|
91
|
+
queryKey,
|
|
92
|
+
queryFn
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
fetchInfinite: () => {
|
|
96
|
+
const args1 = args[1];
|
|
97
|
+
return queryClient.fetchInfiniteQuery({
|
|
98
|
+
...args1,
|
|
99
|
+
queryKey,
|
|
100
|
+
queryFn,
|
|
101
|
+
initialPageParam: args1?.initialCursor ?? null
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
prefetch: () => {
|
|
105
|
+
const args1 = args[1];
|
|
106
|
+
return queryClient.prefetchQuery({
|
|
107
|
+
...args1,
|
|
108
|
+
queryKey,
|
|
109
|
+
queryFn
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
prefetchInfinite: () => {
|
|
113
|
+
const args1 = args[1];
|
|
114
|
+
return queryClient.prefetchInfiniteQuery({
|
|
115
|
+
...args1,
|
|
116
|
+
queryKey,
|
|
117
|
+
queryFn,
|
|
118
|
+
initialPageParam: args1?.initialCursor ?? null
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return helperMap[utilName]();
|
|
123
|
+
});
|
|
124
|
+
return createFlatProxy((key) => {
|
|
125
|
+
if (key === "queryClient") return queryClient;
|
|
126
|
+
if (key === "dehydrate") return _dehydrate;
|
|
127
|
+
return proxy[key];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
export { createServerSideHelpers };
|
|
133
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["opts: CreateServerSideHelpersOptions<TRouter>","resolvedOpts: {\n serialize: (obj: unknown) => any;\n query: (queryOpts: { path: string; input: unknown }) => Promise<unknown>;\n }","opts: DehydrateOptions","opts","helperMap: Record<keyof AnyDecoratedProcedure, () => unknown>"],"sources":["../../src/server/ssgProxy.ts"],"sourcesContent":["import type {\n DehydratedState,\n DehydrateOptions,\n QueryClient,\n} from '@tanstack/react-query';\nimport { dehydrate } from '@tanstack/react-query';\nimport type { TRPCClient } from '@trpc/client';\nimport { getUntypedClient, TRPCUntypedClient } from '@trpc/client';\nimport type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';\nimport {\n getTransformer,\n type TransformerOptions,\n} from '@trpc/client/unstable-internals';\nimport type {\n AnyQueryProcedure,\n AnyRootTypes,\n AnyRouter,\n inferClientTypes,\n inferRouterContext,\n Maybe,\n ProtectedIntersection,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport {\n callProcedure,\n createFlatProxy,\n createRecursiveProxy,\n run,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { getQueryKeyInternal } from '../internals/getQueryKey';\nimport type {\n CreateTRPCReactQueryClientConfig,\n DecorateQueryProcedure,\n TRPCFetchInfiniteQueryOptions,\n TRPCFetchQueryOptions,\n} from '../shared';\nimport { getQueryClient, getQueryType } from '../shared';\n\ntype CreateSSGHelpersInternal<TRouter extends AnyRouter> = {\n router: TRouter;\n ctx: inferRouterContext<TRouter>;\n} & TransformerOptions<inferClientTypes<TRouter>>;\n\ninterface CreateSSGHelpersExternal<TRouter extends AnyRouter> {\n client: TRPCClient<TRouter> | TRPCUntypedClient<TRouter>;\n}\n\ntype CreateServerSideHelpersOptions<TRouter extends AnyRouter> =\n CreateTRPCReactQueryClientConfig &\n (CreateSSGHelpersExternal<TRouter> | CreateSSGHelpersInternal<TRouter>);\n\ntype SSGFns =\n | 'queryOptions'\n | 'infiniteQueryOptions'\n | 'fetch'\n | 'fetchInfinite'\n | 'prefetch'\n | 'prefetchInfinite';\n\n/**\n * @internal\n */\ntype DecoratedProcedureSSGRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyQueryProcedure\n ? Pick<DecorateQueryProcedure<TRoot, $Value>, SSGFns>\n : $Value extends RouterRecord\n ? DecoratedProcedureSSGRecord<TRoot, $Value>\n : never\n : never;\n};\n\ntype AnyDecoratedProcedure = Pick<DecorateQueryProcedure<any, any>, SSGFns>;\n\n/**\n * Create functions you can use for server-side rendering / static generation\n * @see https://trpc.io/docs/v11/client/nextjs/server-side-helpers\n */\nexport function createServerSideHelpers<TRouter extends AnyRouter>(\n opts: CreateServerSideHelpersOptions<TRouter>,\n) {\n const queryClient = getQueryClient(opts);\n const transformer = getTransformer(\n (opts as CoercedTransformerParameters).transformer,\n );\n\n const resolvedOpts: {\n serialize: (obj: unknown) => any;\n query: (queryOpts: { path: string; input: unknown }) => Promise<unknown>;\n } = (() => {\n if ('router' in opts) {\n const { ctx, router } = opts;\n return {\n serialize: transformer.output.serialize,\n query: (queryOpts) => {\n return callProcedure({\n router,\n path: queryOpts.path,\n getRawInput: async () => queryOpts.input,\n ctx,\n type: 'query',\n signal: undefined,\n });\n },\n };\n }\n\n const { client } = opts;\n const untypedClient =\n client instanceof TRPCUntypedClient ? client : getUntypedClient(client);\n\n return {\n query: (queryOpts) =>\n untypedClient.query(queryOpts.path, queryOpts.input),\n serialize: (obj) => transformer.output.serialize(obj),\n };\n })();\n\n function _dehydrate(\n opts: DehydrateOptions = {\n shouldDehydrateQuery(query) {\n if (query.state.status === 'pending') {\n return false;\n }\n // makes sure to serialize errors\n return true;\n },\n },\n ): DehydratedState {\n const before = run(() => {\n const dehydrated = dehydrate(queryClient, opts);\n\n return {\n ...dehydrated,\n queries: dehydrated.queries.map((query) => {\n if (query.promise) {\n const { promise: _, ...rest } = query;\n return rest;\n }\n return query;\n }),\n };\n });\n const after = resolvedOpts.serialize(before);\n return after;\n }\n\n type CreateSSGHelpers = ProtectedIntersection<\n {\n queryClient: QueryClient;\n dehydrate: (opts?: DehydrateOptions) => DehydratedState;\n },\n DecoratedProcedureSSGRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >;\n const proxy = createRecursiveProxy<CreateSSGHelpers>((opts) => {\n const args = opts.args;\n const input = args[0];\n const arrayPath = [...opts.path];\n const utilName = arrayPath.pop() as keyof AnyDecoratedProcedure;\n\n const queryFn = () =>\n resolvedOpts.query({ path: arrayPath.join('.'), input });\n\n const queryKey = getQueryKeyInternal(\n arrayPath,\n input,\n getQueryType(utilName),\n );\n\n const helperMap: Record<keyof AnyDecoratedProcedure, () => unknown> = {\n queryOptions: () => {\n const args1 = args[1] as Maybe<any>;\n return { ...args1, queryKey, queryFn };\n },\n infiniteQueryOptions: () => {\n const args1 = args[1] as Maybe<any>;\n return { ...args1, queryKey, queryFn };\n },\n fetch: () => {\n const args1 = args[1] as Maybe<TRPCFetchQueryOptions<any, any>>;\n return queryClient.fetchQuery({ ...args1, queryKey, queryFn });\n },\n fetchInfinite: () => {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n return queryClient.fetchInfiniteQuery({\n ...args1,\n queryKey,\n queryFn,\n initialPageParam: args1?.initialCursor ?? null,\n });\n },\n prefetch: () => {\n const args1 = args[1] as Maybe<TRPCFetchQueryOptions<any, any>>;\n return queryClient.prefetchQuery({ ...args1, queryKey, queryFn });\n },\n prefetchInfinite: () => {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n return queryClient.prefetchInfiniteQuery({\n ...args1,\n queryKey,\n queryFn,\n initialPageParam: args1?.initialCursor ?? null,\n });\n },\n };\n\n return helperMap[utilName]();\n });\n return createFlatProxy<CreateSSGHelpers>((key) => {\n if (key === 'queryClient') return queryClient;\n if (key === 'dehydrate') return _dehydrate;\n return proxy[key];\n });\n}\n"],"mappings":";;;;;;;;;;;;AAiFA,SAAgB,wBACdA,MACA;CACA,MAAM,cAAc,eAAe,KAAK;CACxC,MAAM,cAAc,eACjB,KAAsC,YACxC;CAED,MAAMC,eAGF,CAAC,MAAM;AACT,MAAI,YAAY,MAAM;GACpB,MAAM,EAAE,KAAK,QAAQ,GAAG;AACxB,UAAO;IACL,WAAW,YAAY,OAAO;IAC9B,OAAO,CAAC,cAAc;AACpB,YAAO,cAAc;MACnB;MACA,MAAM,UAAU;MAChB,aAAa,YAAY,UAAU;MACnC;MACA,MAAM;MACN;KACD,EAAC;IACH;GACF;EACF;EAED,MAAM,EAAE,QAAQ,GAAG;EACnB,MAAM,gBACJ,kBAAkB,oBAAoB,SAAS,iBAAiB,OAAO;AAEzE,SAAO;GACL,OAAO,CAAC,cACN,cAAc,MAAM,UAAU,MAAM,UAAU,MAAM;GACtD,WAAW,CAAC,QAAQ,YAAY,OAAO,UAAU,IAAI;EACtD;CACF,IAAG;CAEJ,SAAS,WACPC,SAAyB,EACvB,qBAAqB,OAAO;AAC1B,MAAI,MAAM,MAAM,WAAW,UACzB,QAAO;AAGT,SAAO;CACR,EACF,GACgB;EACjB,MAAM,SAAS,IAAI,MAAM;GACvB,MAAM,aAAa,UAAU,aAAaC,OAAK;AAE/C,UAAO;IACL,GAAG;IACH,SAAS,WAAW,QAAQ,IAAI,CAAC,UAAU;AACzC,SAAI,MAAM,SAAS;MACjB,MAAM,EAAE,SAAS,EAAG,GAAG,MAAM,GAAG;AAChC,aAAO;KACR;AACD,YAAO;IACR,EAAC;GACH;EACF,EAAC;EACF,MAAM,QAAQ,aAAa,UAAU,OAAO;AAC5C,SAAO;CACR;CAYD,MAAM,QAAQ,qBAAuC,CAACA,WAAS;EAC7D,MAAM,OAAOA,OAAK;EAClB,MAAM,QAAQ,KAAK;EACnB,MAAM,YAAY,CAAC,GAAGA,OAAK,IAAK;EAChC,MAAM,WAAW,UAAU,KAAK;EAEhC,MAAM,UAAU,MACd,aAAa,MAAM;GAAE,MAAM,UAAU,KAAK,IAAI;GAAE;EAAO,EAAC;EAE1D,MAAM,WAAW,oBACf,WACA,OACA,aAAa,SAAS,CACvB;EAED,MAAMC,YAAgE;GACpE,cAAc,MAAM;IAClB,MAAM,QAAQ,KAAK;AACnB,WAAO;KAAE,GAAG;KAAO;KAAU;IAAS;GACvC;GACD,sBAAsB,MAAM;IAC1B,MAAM,QAAQ,KAAK;AACnB,WAAO;KAAE,GAAG;KAAO;KAAU;IAAS;GACvC;GACD,OAAO,MAAM;IACX,MAAM,QAAQ,KAAK;AACnB,WAAO,YAAY,WAAW;KAAE,GAAG;KAAO;KAAU;IAAS,EAAC;GAC/D;GACD,eAAe,MAAM;IACnB,MAAM,QAAQ,KAAK;AAGnB,WAAO,YAAY,mBAAmB;KACpC,GAAG;KACH;KACA;KACA,kBAAkB,OAAO,iBAAiB;IAC3C,EAAC;GACH;GACD,UAAU,MAAM;IACd,MAAM,QAAQ,KAAK;AACnB,WAAO,YAAY,cAAc;KAAE,GAAG;KAAO;KAAU;IAAS,EAAC;GAClE;GACD,kBAAkB,MAAM;IACtB,MAAM,QAAQ,KAAK;AAGnB,WAAO,YAAY,sBAAsB;KACvC,GAAG;KACH;KACA;KACA,kBAAkB,OAAO,iBAAiB;IAC3C,EAAC;GACH;EACF;AAED,SAAO,UAAU,WAAW;CAC7B,EAAC;AACF,QAAO,gBAAkC,CAAC,QAAQ;AAChD,MAAI,QAAQ,cAAe,QAAO;AAClC,MAAI,QAAQ,YAAa,QAAO;AAChC,SAAO,MAAM;CACd,EAAC;AACH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require('../getQueryKey-CP8onRYT.cjs');
|
|
2
|
+
const require_shared = require('../shared-Doe-Gsbv.cjs');
|
|
3
|
+
|
|
4
|
+
exports.TRPCContext = require_shared.TRPCContext;
|
|
5
|
+
exports.contextProps = require_shared.contextProps;
|
|
6
|
+
exports.createQueryUtilsProxy = require_shared.createQueryUtilsProxy;
|
|
7
|
+
exports.createReactDecoration = require_shared.createReactDecoration;
|
|
8
|
+
exports.createReactQueryUtils = require_shared.createReactQueryUtils;
|
|
9
|
+
exports.createRootHooks = require_shared.createRootHooks;
|
|
10
|
+
exports.createUseQueries = require_shared.createUseQueries;
|
|
11
|
+
exports.getClientArgs = require_shared.getClientArgs;
|
|
12
|
+
exports.getQueryClient = require_shared.getQueryClient;
|
|
13
|
+
exports.getQueryType = require_shared.getQueryType;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CreateClient, CreateQueryUtils, CreateReactUtils, CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig, DecorateProcedure, DecorateQueryProcedure, DecorateRouterRecord, DecoratedProcedureUtilsRecord, DecoratedTRPCContextProps, DefinedTRPCInfiniteQueryOptionsIn, DefinedTRPCInfiniteQueryOptionsOut, DefinedTRPCQueryOptionsIn, DefinedTRPCQueryOptionsOut, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, ExtractCursorType, InferMutationLikeData, InferMutationLikeInput, InferQueryLikeData, InferQueryLikeInput, MutationLike, OutputWithCursor, QueryLike, RouterLike, RouterLikeInner, SSRState, TRPCContext, TRPCContextProps, TRPCContextPropsBase, TRPCContextState, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions, TRPCHookResult, TRPCProvider, TRPCProviderProps, TRPCQueryBaseOptions, TRPCQueryOptions, TRPCQueryOptionsResult, TRPCQueryUtils, TRPCReactRequestOptions, TRPCSubscriptionBaseResult, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, TRPCUseQueries, TRPCUseQueryBaseOptions, TRPCUseSuspenseQueries, UndefinedTRPCInfiniteQueryOptionsIn, UndefinedTRPCInfiniteQueryOptionsOut, UndefinedTRPCQueryOptionsIn, UndefinedTRPCQueryOptionsOut, UnusedSkipTokenTRPCInfiniteQueryOptionsIn, UnusedSkipTokenTRPCInfiniteQueryOptionsOut, UnusedSkipTokenTRPCQueryOptionsIn, UnusedSkipTokenTRPCQueryOptionsOut, UseMutationOverride, UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCPrefetchInfiniteQueryOptions, UseTRPCPrefetchQueryOptions, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult, UtilsLike, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType } from "../getQueryKey.d-C_PnqPni.cjs";
|
|
2
|
+
export { CreateClient, CreateQueryUtils, CreateReactUtils, CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig, DecorateProcedure, DecorateQueryProcedure, DecorateRouterRecord, DecoratedProcedureUtilsRecord, DecoratedTRPCContextProps, DefinedTRPCInfiniteQueryOptionsIn, DefinedTRPCInfiniteQueryOptionsOut, DefinedTRPCQueryOptionsIn, DefinedTRPCQueryOptionsOut, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, ExtractCursorType, InferMutationLikeData, InferMutationLikeInput, InferQueryLikeData, InferQueryLikeInput, MutationLike, OutputWithCursor, QueryLike, RouterLike, RouterLikeInner, SSRState, TRPCContext, TRPCContextProps, TRPCContextPropsBase, TRPCContextState, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions, TRPCHookResult, TRPCProvider, TRPCProviderProps, TRPCQueryBaseOptions, TRPCQueryOptions, TRPCQueryOptionsResult, TRPCQueryUtils, TRPCReactRequestOptions, TRPCSubscriptionBaseResult, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, TRPCUseQueries, TRPCUseQueryBaseOptions, TRPCUseSuspenseQueries, UndefinedTRPCInfiniteQueryOptionsIn, UndefinedTRPCInfiniteQueryOptionsOut, UndefinedTRPCQueryOptionsIn, UndefinedTRPCQueryOptionsOut, UnusedSkipTokenTRPCInfiniteQueryOptionsIn, UnusedSkipTokenTRPCInfiniteQueryOptionsOut, UnusedSkipTokenTRPCQueryOptionsIn, UnusedSkipTokenTRPCQueryOptionsOut, UseMutationOverride, UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCPrefetchInfiniteQueryOptions, UseTRPCPrefetchQueryOptions, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult, UtilsLike, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType };
|
package/dist/shared/index.d.mts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import { DecoratedTRPCContextProps,
|
|
2
|
-
import { CreateClient, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, ExtractCursorType, OutputWithCursor, TRPCHookResult, TRPCProvider, TRPCProviderProps, TRPCQueryOptions, TRPCReactRequestOptions, TRPCSubscriptionBaseResult, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, TRPCUseQueryBaseOptions, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCPrefetchInfiniteQueryOptions, UseTRPCPrefetchQueryOptions, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult } from "./hooks/types.mjs";
|
|
3
|
-
import { CreateTRPCReactOptions, DefinedTRPCInfiniteQueryOptionsIn, DefinedTRPCInfiniteQueryOptionsOut, DefinedTRPCQueryOptionsIn, DefinedTRPCQueryOptionsOut, TRPCQueryBaseOptions, TRPCQueryOptionsResult, UndefinedTRPCInfiniteQueryOptionsIn, UndefinedTRPCInfiniteQueryOptionsOut, UndefinedTRPCQueryOptionsIn, UndefinedTRPCQueryOptionsOut, UnusedSkipTokenTRPCInfiniteQueryOptionsIn, UnusedSkipTokenTRPCInfiniteQueryOptionsOut, UnusedSkipTokenTRPCQueryOptionsIn, UnusedSkipTokenTRPCQueryOptionsOut, UseMutationOverride } from "./types.mjs";
|
|
4
|
-
import { createRootHooks$1 as createRootHooks } from "./hooks/createHooksInternal.mjs";
|
|
5
|
-
import { createReactDecoration$1 as createReactDecoration } from "./proxy/decorationProxy.mjs";
|
|
6
|
-
import { CreateQueryUtils, CreateReactUtils, DecorateQueryProcedure, DecoratedProcedureUtilsRecord, createQueryUtilsProxy$1 as createQueryUtilsProxy, createReactQueryUtils$1 as createReactQueryUtils, getQueryType$1 as getQueryType } from "./proxy/utilsProxy.mjs";
|
|
7
|
-
import { UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord, createUseQueries$1 as createUseQueries } from "./proxy/useQueriesProxy.mjs";
|
|
8
|
-
import { CreateTRPCReactQueryClientConfig, getQueryClient$1 as getQueryClient } from "./queryClient.mjs";
|
|
9
|
-
import { InferMutationLikeData, InferMutationLikeInput, MutationLike } from "./polymorphism/mutationLike.mjs";
|
|
10
|
-
import { InferQueryLikeData, InferQueryLikeInput, QueryLike } from "./polymorphism/queryLike.mjs";
|
|
11
|
-
import { RouterLike, RouterLikeInner } from "./polymorphism/routerLike.mjs";
|
|
12
|
-
import { UtilsLike } from "./polymorphism/utilsLike.mjs";
|
|
13
|
-
import { getClientArgs$1 as getClientArgs } from "../internals/getClientArgs.mjs";
|
|
14
|
-
import { TRPCUseQueries, TRPCUseSuspenseQueries } from "../internals/useQueries.mjs";
|
|
15
|
-
import { DecorateProcedure, DecorateRouterRecord } from "../createTRPCReact.mjs";
|
|
1
|
+
import { CreateClient, CreateQueryUtils, CreateReactUtils, CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig, DecorateProcedure, DecorateQueryProcedure, DecorateRouterRecord, DecoratedProcedureUtilsRecord, DecoratedTRPCContextProps, DefinedTRPCInfiniteQueryOptionsIn, DefinedTRPCInfiniteQueryOptionsOut, DefinedTRPCQueryOptionsIn, DefinedTRPCQueryOptionsOut, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, ExtractCursorType, InferMutationLikeData, InferMutationLikeInput, InferQueryLikeData, InferQueryLikeInput, MutationLike, OutputWithCursor, QueryLike, RouterLike, RouterLikeInner, SSRState, TRPCContext, TRPCContextProps, TRPCContextPropsBase, TRPCContextState, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions, TRPCHookResult, TRPCProvider, TRPCProviderProps, TRPCQueryBaseOptions, TRPCQueryOptions, TRPCQueryOptionsResult, TRPCQueryUtils, TRPCReactRequestOptions, TRPCSubscriptionBaseResult, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, TRPCUseQueries, TRPCUseQueryBaseOptions, TRPCUseSuspenseQueries, UndefinedTRPCInfiniteQueryOptionsIn, UndefinedTRPCInfiniteQueryOptionsOut, UndefinedTRPCQueryOptionsIn, UndefinedTRPCQueryOptionsOut, UnusedSkipTokenTRPCInfiniteQueryOptionsIn, UnusedSkipTokenTRPCInfiniteQueryOptionsOut, UnusedSkipTokenTRPCQueryOptionsIn, UnusedSkipTokenTRPCQueryOptionsOut, UseMutationOverride, UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCPrefetchInfiniteQueryOptions, UseTRPCPrefetchQueryOptions, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult, UtilsLike, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType } from "../getQueryKey.d-CruH3ncI.mjs";
|
|
16
2
|
export { CreateClient, CreateQueryUtils, CreateReactUtils, CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig, DecorateProcedure, DecorateQueryProcedure, DecorateRouterRecord, DecoratedProcedureUtilsRecord, DecoratedTRPCContextProps, DefinedTRPCInfiniteQueryOptionsIn, DefinedTRPCInfiniteQueryOptionsOut, DefinedTRPCQueryOptionsIn, DefinedTRPCQueryOptionsOut, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, ExtractCursorType, InferMutationLikeData, InferMutationLikeInput, InferQueryLikeData, InferQueryLikeInput, MutationLike, OutputWithCursor, QueryLike, RouterLike, RouterLikeInner, SSRState, TRPCContext, TRPCContextProps, TRPCContextPropsBase, TRPCContextState, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions, TRPCHookResult, TRPCProvider, TRPCProviderProps, TRPCQueryBaseOptions, TRPCQueryOptions, TRPCQueryOptionsResult, TRPCQueryUtils, TRPCReactRequestOptions, TRPCSubscriptionBaseResult, TRPCSubscriptionConnectingResult, TRPCSubscriptionErrorResult, TRPCSubscriptionIdleResult, TRPCSubscriptionPendingResult, TRPCSubscriptionResult, TRPCUseQueries, TRPCUseQueryBaseOptions, TRPCUseSuspenseQueries, UndefinedTRPCInfiniteQueryOptionsIn, UndefinedTRPCInfiniteQueryOptionsOut, UndefinedTRPCQueryOptionsIn, UndefinedTRPCQueryOptionsOut, UnusedSkipTokenTRPCInfiniteQueryOptionsIn, UnusedSkipTokenTRPCInfiniteQueryOptionsOut, UnusedSkipTokenTRPCQueryOptionsIn, UnusedSkipTokenTRPCQueryOptionsOut, UseMutationOverride, UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCPrefetchInfiniteQueryOptions, UseTRPCPrefetchQueryOptions, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult, UtilsLike, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType };
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TRPCContext, contextProps } from "../
|
|
3
|
-
import { createQueryUtilsProxy, createReactQueryUtils, getQueryType } from "./proxy/utilsProxy.mjs";
|
|
4
|
-
import { createUseQueries } from "./proxy/useQueriesProxy.mjs";
|
|
5
|
-
import { getClientArgs } from "../internals/getClientArgs.mjs";
|
|
6
|
-
import { createRootHooks } from "./hooks/createHooksInternal.mjs";
|
|
7
|
-
import { getQueryClient } from "./queryClient.mjs";
|
|
1
|
+
import "../getQueryKey-Dekty44G.mjs";
|
|
2
|
+
import { TRPCContext, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType } from "../shared-CMPBsqju.mjs";
|
|
8
3
|
|
|
9
4
|
export { TRPCContext, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, getClientArgs, getQueryClient, getQueryType };
|
|
@@ -1,15 +1,360 @@
|
|
|
1
|
-
import { getMutationKeyInternal, getQueryKeyInternal } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { TRPCUntypedClient, createTRPCClient, getUntypedClient } from "@trpc/client";
|
|
8
|
-
import { hashKey, skipToken, useInfiniteQuery, useMutation, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useSuspenseInfiniteQuery, useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
|
|
9
|
-
import { isAsyncIterable } from "@trpc/server/unstable-core-do-not-import";
|
|
1
|
+
import { getMutationKeyInternal, getQueryKeyInternal } from "./getQueryKey-Dekty44G.mjs";
|
|
2
|
+
import { TRPCUntypedClient, createTRPCClient, createTRPCClientProxy, getUntypedClient } from "@trpc/client";
|
|
3
|
+
import { QueryClient, hashKey, infiniteQueryOptions, queryOptions, skipToken, useInfiniteQuery, useMutation, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useSuspenseInfiniteQuery, useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
|
|
4
|
+
import { createFlatProxy, createRecursiveProxy, isAsyncIterable } from "@trpc/server/unstable-core-do-not-import";
|
|
5
|
+
import * as React$2 from "react";
|
|
6
|
+
import * as React$1 from "react";
|
|
10
7
|
import * as React from "react";
|
|
11
8
|
import { jsx } from "react/jsx-runtime";
|
|
12
9
|
|
|
10
|
+
//#region src/shared/proxy/decorationProxy.ts
|
|
11
|
+
/**
|
|
12
|
+
* Create proxy for decorating procedures
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
function createReactDecoration(hooks) {
|
|
16
|
+
return createRecursiveProxy(({ path, args }) => {
|
|
17
|
+
const pathCopy = [...path];
|
|
18
|
+
const lastArg = pathCopy.pop();
|
|
19
|
+
if (lastArg === "useMutation") return hooks[lastArg](pathCopy, ...args);
|
|
20
|
+
if (lastArg === "_def") return { path: pathCopy };
|
|
21
|
+
const [input, ...rest] = args;
|
|
22
|
+
const opts = rest[0] ?? {};
|
|
23
|
+
return hooks[lastArg](pathCopy, input, opts);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/internals/context.tsx
|
|
29
|
+
const contextProps = [
|
|
30
|
+
"client",
|
|
31
|
+
"ssrContext",
|
|
32
|
+
"ssrState",
|
|
33
|
+
"abortOnUnmount"
|
|
34
|
+
];
|
|
35
|
+
const TRPCContext = React$2.createContext?.(null);
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/shared/proxy/utilsProxy.ts
|
|
39
|
+
const getQueryType = (utilName) => {
|
|
40
|
+
switch (utilName) {
|
|
41
|
+
case "queryOptions":
|
|
42
|
+
case "fetch":
|
|
43
|
+
case "ensureData":
|
|
44
|
+
case "prefetch":
|
|
45
|
+
case "getData":
|
|
46
|
+
case "setData":
|
|
47
|
+
case "setQueriesData": return "query";
|
|
48
|
+
case "infiniteQueryOptions":
|
|
49
|
+
case "fetchInfinite":
|
|
50
|
+
case "prefetchInfinite":
|
|
51
|
+
case "getInfiniteData":
|
|
52
|
+
case "setInfiniteData": return "infinite";
|
|
53
|
+
case "setMutationDefaults":
|
|
54
|
+
case "getMutationDefaults":
|
|
55
|
+
case "isMutating":
|
|
56
|
+
case "cancel":
|
|
57
|
+
case "invalidate":
|
|
58
|
+
case "refetch":
|
|
59
|
+
case "reset": return "any";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
function createRecursiveUtilsProxy(context) {
|
|
66
|
+
return createRecursiveProxy((opts) => {
|
|
67
|
+
const path = [...opts.path];
|
|
68
|
+
const utilName = path.pop();
|
|
69
|
+
const args = [...opts.args];
|
|
70
|
+
const input = args.shift();
|
|
71
|
+
const queryType = getQueryType(utilName);
|
|
72
|
+
const queryKey = getQueryKeyInternal(path, input, queryType);
|
|
73
|
+
const contextMap = {
|
|
74
|
+
infiniteQueryOptions: () => context.infiniteQueryOptions(path, queryKey, args[0]),
|
|
75
|
+
queryOptions: () => context.queryOptions(path, queryKey, ...args),
|
|
76
|
+
fetch: () => context.fetchQuery(queryKey, ...args),
|
|
77
|
+
fetchInfinite: () => context.fetchInfiniteQuery(queryKey, args[0]),
|
|
78
|
+
prefetch: () => context.prefetchQuery(queryKey, ...args),
|
|
79
|
+
prefetchInfinite: () => context.prefetchInfiniteQuery(queryKey, args[0]),
|
|
80
|
+
ensureData: () => context.ensureQueryData(queryKey, ...args),
|
|
81
|
+
invalidate: () => context.invalidateQueries(queryKey, ...args),
|
|
82
|
+
reset: () => context.resetQueries(queryKey, ...args),
|
|
83
|
+
refetch: () => context.refetchQueries(queryKey, ...args),
|
|
84
|
+
cancel: () => context.cancelQuery(queryKey, ...args),
|
|
85
|
+
setData: () => {
|
|
86
|
+
context.setQueryData(queryKey, args[0], args[1]);
|
|
87
|
+
},
|
|
88
|
+
setQueriesData: () => context.setQueriesData(queryKey, args[0], args[1], args[2]),
|
|
89
|
+
setInfiniteData: () => {
|
|
90
|
+
context.setInfiniteQueryData(queryKey, args[0], args[1]);
|
|
91
|
+
},
|
|
92
|
+
getData: () => context.getQueryData(queryKey),
|
|
93
|
+
getInfiniteData: () => context.getInfiniteQueryData(queryKey),
|
|
94
|
+
setMutationDefaults: () => context.setMutationDefaults(getMutationKeyInternal(path), input),
|
|
95
|
+
getMutationDefaults: () => context.getMutationDefaults(getMutationKeyInternal(path)),
|
|
96
|
+
isMutating: () => context.isMutating({ mutationKey: getMutationKeyInternal(path) })
|
|
97
|
+
};
|
|
98
|
+
return contextMap[utilName]();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function createReactQueryUtils(context) {
|
|
105
|
+
const clientProxy = createTRPCClientProxy(context.client);
|
|
106
|
+
const proxy = createRecursiveUtilsProxy(context);
|
|
107
|
+
return createFlatProxy((key) => {
|
|
108
|
+
const contextName = key;
|
|
109
|
+
if (contextName === "client") return clientProxy;
|
|
110
|
+
if (contextProps.includes(contextName)) return context[contextName];
|
|
111
|
+
return proxy[key];
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
function createQueryUtilsProxy(context) {
|
|
118
|
+
return createRecursiveUtilsProxy(context);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/shared/proxy/useQueriesProxy.ts
|
|
123
|
+
/**
|
|
124
|
+
* Create proxy for `useQueries` options
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
function createUseQueries(client) {
|
|
128
|
+
const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
|
|
129
|
+
return createRecursiveProxy((opts) => {
|
|
130
|
+
const arrayPath = opts.path;
|
|
131
|
+
const dotPath = arrayPath.join(".");
|
|
132
|
+
const [input, _opts] = opts.args;
|
|
133
|
+
const options = {
|
|
134
|
+
queryKey: getQueryKeyInternal(arrayPath, input, "query"),
|
|
135
|
+
queryFn: () => {
|
|
136
|
+
return untypedClient.query(dotPath, input, _opts?.trpc);
|
|
137
|
+
},
|
|
138
|
+
..._opts
|
|
139
|
+
};
|
|
140
|
+
return options;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/internals/getClientArgs.ts
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
function getClientArgs(queryKey, opts, infiniteParams) {
|
|
150
|
+
const path = queryKey[0];
|
|
151
|
+
let input = queryKey[1]?.input;
|
|
152
|
+
if (infiniteParams) input = {
|
|
153
|
+
...input ?? {},
|
|
154
|
+
...infiniteParams.pageParam ? { cursor: infiniteParams.pageParam } : {},
|
|
155
|
+
direction: infiniteParams.direction
|
|
156
|
+
};
|
|
157
|
+
return [
|
|
158
|
+
path.join("."),
|
|
159
|
+
input,
|
|
160
|
+
opts?.trpc
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/internals/trpcResult.ts
|
|
166
|
+
function createTRPCOptionsResult(value) {
|
|
167
|
+
const path = value.path.join(".");
|
|
168
|
+
return { path };
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Makes a stable reference of the `trpc` prop
|
|
172
|
+
*/
|
|
173
|
+
function useHookResult(value) {
|
|
174
|
+
const result = createTRPCOptionsResult(value);
|
|
175
|
+
return React$1.useMemo(() => result, [result]);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
|
|
181
|
+
const queryCache = queryClient.getQueryCache();
|
|
182
|
+
const query = queryCache.build(queryClient, { queryKey });
|
|
183
|
+
query.setState({
|
|
184
|
+
data: [],
|
|
185
|
+
status: "success"
|
|
186
|
+
});
|
|
187
|
+
const aggregate = [];
|
|
188
|
+
for await (const value of asyncIterable) {
|
|
189
|
+
aggregate.push(value);
|
|
190
|
+
query.setState({ data: [...aggregate] });
|
|
191
|
+
}
|
|
192
|
+
return aggregate;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/utils/createUtilityFunctions.ts
|
|
197
|
+
/**
|
|
198
|
+
* Creates a set of utility functions that can be used to interact with `react-query`
|
|
199
|
+
* @param opts the `TRPCClient` and `QueryClient` to use
|
|
200
|
+
* @returns a set of utility functions that can be used to interact with `react-query`
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
function createUtilityFunctions(opts) {
|
|
204
|
+
const { client, queryClient } = opts;
|
|
205
|
+
const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
|
|
206
|
+
return {
|
|
207
|
+
infiniteQueryOptions: (path, queryKey, opts$1) => {
|
|
208
|
+
const inputIsSkipToken = queryKey[1]?.input === skipToken;
|
|
209
|
+
const queryFn = async (queryFnContext) => {
|
|
210
|
+
const actualOpts = {
|
|
211
|
+
...opts$1,
|
|
212
|
+
trpc: {
|
|
213
|
+
...opts$1?.trpc,
|
|
214
|
+
...opts$1?.trpc?.abortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const result = await untypedClient.query(...getClientArgs(queryKey, actualOpts, {
|
|
218
|
+
direction: queryFnContext.direction,
|
|
219
|
+
pageParam: queryFnContext.pageParam
|
|
220
|
+
}));
|
|
221
|
+
return result;
|
|
222
|
+
};
|
|
223
|
+
return Object.assign(infiniteQueryOptions({
|
|
224
|
+
...opts$1,
|
|
225
|
+
initialData: opts$1?.initialData,
|
|
226
|
+
queryKey,
|
|
227
|
+
queryFn: inputIsSkipToken ? skipToken : queryFn,
|
|
228
|
+
initialPageParam: opts$1?.initialCursor ?? null
|
|
229
|
+
}), { trpc: createTRPCOptionsResult({ path }) });
|
|
230
|
+
},
|
|
231
|
+
queryOptions: (path, queryKey, opts$1) => {
|
|
232
|
+
const inputIsSkipToken = queryKey[1]?.input === skipToken;
|
|
233
|
+
const queryFn = async (queryFnContext) => {
|
|
234
|
+
const actualOpts = {
|
|
235
|
+
...opts$1,
|
|
236
|
+
trpc: {
|
|
237
|
+
...opts$1?.trpc,
|
|
238
|
+
...opts$1?.trpc?.abortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const result = await untypedClient.query(...getClientArgs(queryKey, actualOpts));
|
|
242
|
+
if (isAsyncIterable(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
243
|
+
return result;
|
|
244
|
+
};
|
|
245
|
+
return Object.assign(queryOptions({
|
|
246
|
+
...opts$1,
|
|
247
|
+
initialData: opts$1?.initialData,
|
|
248
|
+
queryKey,
|
|
249
|
+
queryFn: inputIsSkipToken ? skipToken : queryFn
|
|
250
|
+
}), { trpc: createTRPCOptionsResult({ path }) });
|
|
251
|
+
},
|
|
252
|
+
fetchQuery: (queryKey, opts$1) => {
|
|
253
|
+
return queryClient.fetchQuery({
|
|
254
|
+
...opts$1,
|
|
255
|
+
queryKey,
|
|
256
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts$1))
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
fetchInfiniteQuery: (queryKey, opts$1) => {
|
|
260
|
+
return queryClient.fetchInfiniteQuery({
|
|
261
|
+
...opts$1,
|
|
262
|
+
queryKey,
|
|
263
|
+
queryFn: ({ pageParam, direction }) => {
|
|
264
|
+
return untypedClient.query(...getClientArgs(queryKey, opts$1, {
|
|
265
|
+
pageParam,
|
|
266
|
+
direction
|
|
267
|
+
}));
|
|
268
|
+
},
|
|
269
|
+
initialPageParam: opts$1?.initialCursor ?? null
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
prefetchQuery: (queryKey, opts$1) => {
|
|
273
|
+
return queryClient.prefetchQuery({
|
|
274
|
+
...opts$1,
|
|
275
|
+
queryKey,
|
|
276
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts$1))
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
prefetchInfiniteQuery: (queryKey, opts$1) => {
|
|
280
|
+
return queryClient.prefetchInfiniteQuery({
|
|
281
|
+
...opts$1,
|
|
282
|
+
queryKey,
|
|
283
|
+
queryFn: ({ pageParam, direction }) => {
|
|
284
|
+
return untypedClient.query(...getClientArgs(queryKey, opts$1, {
|
|
285
|
+
pageParam,
|
|
286
|
+
direction
|
|
287
|
+
}));
|
|
288
|
+
},
|
|
289
|
+
initialPageParam: opts$1?.initialCursor ?? null
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
ensureQueryData: (queryKey, opts$1) => {
|
|
293
|
+
return queryClient.ensureQueryData({
|
|
294
|
+
...opts$1,
|
|
295
|
+
queryKey,
|
|
296
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts$1))
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
invalidateQueries: (queryKey, filters, options) => {
|
|
300
|
+
return queryClient.invalidateQueries({
|
|
301
|
+
...filters,
|
|
302
|
+
queryKey
|
|
303
|
+
}, options);
|
|
304
|
+
},
|
|
305
|
+
resetQueries: (queryKey, filters, options) => {
|
|
306
|
+
return queryClient.resetQueries({
|
|
307
|
+
...filters,
|
|
308
|
+
queryKey
|
|
309
|
+
}, options);
|
|
310
|
+
},
|
|
311
|
+
refetchQueries: (queryKey, filters, options) => {
|
|
312
|
+
return queryClient.refetchQueries({
|
|
313
|
+
...filters,
|
|
314
|
+
queryKey
|
|
315
|
+
}, options);
|
|
316
|
+
},
|
|
317
|
+
cancelQuery: (queryKey, options) => {
|
|
318
|
+
return queryClient.cancelQueries({ queryKey }, options);
|
|
319
|
+
},
|
|
320
|
+
setQueryData: (queryKey, updater, options) => {
|
|
321
|
+
return queryClient.setQueryData(queryKey, updater, options);
|
|
322
|
+
},
|
|
323
|
+
setQueriesData: (queryKey, filters, updater, options) => {
|
|
324
|
+
return queryClient.setQueriesData({
|
|
325
|
+
...filters,
|
|
326
|
+
queryKey
|
|
327
|
+
}, updater, options);
|
|
328
|
+
},
|
|
329
|
+
getQueryData: (queryKey) => {
|
|
330
|
+
return queryClient.getQueryData(queryKey);
|
|
331
|
+
},
|
|
332
|
+
setInfiniteQueryData: (queryKey, updater, options) => {
|
|
333
|
+
return queryClient.setQueryData(queryKey, updater, options);
|
|
334
|
+
},
|
|
335
|
+
getInfiniteQueryData: (queryKey) => {
|
|
336
|
+
return queryClient.getQueryData(queryKey);
|
|
337
|
+
},
|
|
338
|
+
setMutationDefaults: (mutationKey, options) => {
|
|
339
|
+
const path = mutationKey[0];
|
|
340
|
+
const canonicalMutationFn = (input) => {
|
|
341
|
+
return untypedClient.mutation(...getClientArgs([path, { input }], opts));
|
|
342
|
+
};
|
|
343
|
+
return queryClient.setMutationDefaults(mutationKey, typeof options === "function" ? options({ canonicalMutationFn }) : options);
|
|
344
|
+
},
|
|
345
|
+
getMutationDefaults: (mutationKey) => {
|
|
346
|
+
return queryClient.getMutationDefaults(mutationKey);
|
|
347
|
+
},
|
|
348
|
+
isMutating: (filters) => {
|
|
349
|
+
return queryClient.isMutating({
|
|
350
|
+
...filters,
|
|
351
|
+
exact: true
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
13
358
|
//#region src/shared/hooks/createHooksInternal.tsx
|
|
14
359
|
const trackResult = (result, onTrackResult) => {
|
|
15
360
|
const trackedResult = new Proxy(result, { get(target, prop) {
|
|
@@ -428,5 +773,12 @@ function createRootHooks(config) {
|
|
|
428
773
|
}
|
|
429
774
|
|
|
430
775
|
//#endregion
|
|
431
|
-
|
|
432
|
-
|
|
776
|
+
//#region src/shared/queryClient.ts
|
|
777
|
+
/**
|
|
778
|
+
* @internal
|
|
779
|
+
*/
|
|
780
|
+
const getQueryClient = (config) => config.queryClient ?? new QueryClient(config.queryClientConfig);
|
|
781
|
+
|
|
782
|
+
//#endregion
|
|
783
|
+
export { TRPCContext, contextProps, createQueryUtilsProxy, createReactDecoration, createReactQueryUtils, createRootHooks, createUseQueries, createUtilityFunctions, getClientArgs, getQueryClient, getQueryType };
|
|
784
|
+
//# sourceMappingURL=shared-CMPBsqju.mjs.map
|