@trpc/react-query 11.1.2 → 11.1.3-alpha-tmp-tsdown.23
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/_virtual/rolldown_runtime.js +30 -0
- package/dist/createTRPCQueryUtils.d.mts +12 -0
- package/dist/createTRPCQueryUtils.d.mts.map +1 -0
- package/dist/createTRPCQueryUtils.d.ts +11 -3
- package/dist/createTRPCQueryUtils.d.ts.map +1 -1
- package/dist/createTRPCQueryUtils.js +7 -12
- package/dist/createTRPCQueryUtils.mjs +7 -9
- package/dist/createTRPCQueryUtils.mjs.map +1 -0
- package/dist/createTRPCReact.d.mts +143 -0
- package/dist/createTRPCReact.d.mts.map +1 -0
- package/dist/createTRPCReact.d.ts +92 -96
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/createTRPCReact.js +26 -54
- package/dist/createTRPCReact.mjs +26 -32
- package/dist/createTRPCReact.mjs.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -15
- package/dist/index.mjs +7 -4
- package/dist/internals/context.d.mts +164 -0
- package/dist/internals/context.d.mts.map +1 -0
- package/dist/internals/context.d.ts +146 -139
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/context.js +10 -28
- package/dist/internals/context.mjs +8 -5
- package/dist/internals/context.mjs.map +1 -0
- package/dist/internals/getClientArgs.d.mts +19 -0
- package/dist/internals/getClientArgs.d.mts.map +1 -0
- package/dist/internals/getClientArgs.d.ts +14 -4
- package/dist/internals/getClientArgs.d.ts.map +1 -1
- package/dist/internals/getClientArgs.js +18 -20
- package/dist/internals/getClientArgs.mjs +18 -18
- package/dist/internals/getClientArgs.mjs.map +1 -0
- package/dist/internals/getQueryKey.d.mts +45 -0
- package/dist/internals/getQueryKey.d.mts.map +1 -0
- package/dist/internals/getQueryKey.d.ts +22 -26
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/internals/getQueryKey.js +43 -62
- package/dist/internals/getQueryKey.mjs +42 -59
- package/dist/internals/getQueryKey.mjs.map +1 -0
- package/dist/internals/trpcResult.js +27 -53
- package/dist/internals/trpcResult.mjs +26 -31
- package/dist/internals/trpcResult.mjs.map +1 -0
- package/dist/internals/useQueries.d.mts +57 -0
- package/dist/internals/useQueries.d.mts.map +1 -0
- package/dist/internals/useQueries.d.ts +23 -24
- package/dist/internals/useQueries.d.ts.map +1 -1
- package/dist/rsc.d.mts +81 -0
- package/dist/rsc.d.mts.map +1 -0
- package/dist/rsc.d.ts +57 -56
- package/dist/rsc.d.ts.map +1 -1
- package/dist/rsc.js +66 -126
- package/dist/rsc.mjs +65 -104
- package/dist/rsc.mjs.map +1 -0
- package/dist/server/index.d.mts +2 -0
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -6
- package/dist/server/index.mjs +3 -1
- package/dist/server/ssgProxy.d.mts +33 -0
- package/dist/server/ssgProxy.d.mts.map +1 -0
- package/dist/server/ssgProxy.d.ts +18 -16
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/server/ssgProxy.js +130 -137
- package/dist/server/ssgProxy.mjs +129 -134
- package/dist/server/ssgProxy.mjs.map +1 -0
- package/dist/shared/hooks/createHooksInternal.d.mts +42 -0
- package/dist/shared/hooks/createHooksInternal.d.mts.map +1 -0
- package/dist/shared/hooks/createHooksInternal.d.ts +33 -22
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/hooks/createHooksInternal.js +427 -537
- package/dist/shared/hooks/createHooksInternal.mjs +426 -515
- package/dist/shared/hooks/createHooksInternal.mjs.map +1 -0
- package/dist/shared/hooks/createRootHooks.js +1 -0
- package/dist/shared/hooks/createRootHooks.mjs +1 -0
- package/dist/shared/hooks/types.d.mts +154 -0
- package/dist/shared/hooks/types.d.mts.map +1 -0
- package/dist/shared/hooks/types.d.ts +122 -125
- package/dist/shared/hooks/types.d.ts.map +1 -1
- package/dist/shared/index.d.mts +16 -0
- package/dist/shared/index.d.ts +16 -22
- package/dist/shared/index.js +17 -21
- package/dist/shared/index.mjs +9 -7
- package/dist/shared/polymorphism/mutationLike.d.mts +27 -0
- package/dist/shared/polymorphism/mutationLike.d.mts.map +1 -0
- package/dist/shared/polymorphism/mutationLike.d.ts +16 -6
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.mts +31 -0
- package/dist/shared/polymorphism/queryLike.d.mts.map +1 -0
- package/dist/shared/polymorphism/queryLike.d.ts +20 -10
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.mts +19 -0
- package/dist/shared/polymorphism/routerLike.d.mts.map +1 -0
- package/dist/shared/polymorphism/routerLike.d.ts +15 -7
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/utilsLike.d.mts +17 -0
- package/dist/shared/polymorphism/utilsLike.d.mts.map +1 -0
- package/dist/shared/polymorphism/utilsLike.d.ts +13 -3
- package/dist/shared/polymorphism/utilsLike.d.ts.map +1 -1
- package/dist/shared/proxy/decorationProxy.d.mts +19 -0
- package/dist/shared/proxy/decorationProxy.d.mts.map +1 -0
- package/dist/shared/proxy/decorationProxy.d.ts +14 -3
- package/dist/shared/proxy/decorationProxy.d.ts.map +1 -1
- package/dist/shared/proxy/decorationProxy.js +18 -26
- package/dist/shared/proxy/decorationProxy.mjs +17 -23
- package/dist/shared/proxy/decorationProxy.mjs.map +1 -0
- package/dist/shared/proxy/useQueriesProxy.d.mts +24 -0
- package/dist/shared/proxy/useQueriesProxy.d.mts.map +1 -0
- package/dist/shared/proxy/useQueriesProxy.d.ts +11 -12
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/useQueriesProxy.js +25 -23
- package/dist/shared/proxy/useQueriesProxy.mjs +24 -20
- package/dist/shared/proxy/useQueriesProxy.mjs.map +1 -0
- package/dist/shared/proxy/utilsProxy.d.mts +143 -0
- package/dist/shared/proxy/utilsProxy.d.mts.map +1 -0
- package/dist/shared/proxy/utilsProxy.d.ts +123 -121
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.js +82 -95
- package/dist/shared/proxy/utilsProxy.mjs +81 -92
- package/dist/shared/proxy/utilsProxy.mjs.map +1 -0
- package/dist/shared/queryClient.d.mts +26 -0
- package/dist/shared/queryClient.d.mts.map +1 -0
- package/dist/shared/queryClient.d.ts +17 -8
- package/dist/shared/queryClient.d.ts.map +1 -1
- package/dist/shared/queryClient.js +8 -6
- package/dist/shared/queryClient.mjs +7 -3
- package/dist/shared/queryClient.mjs.map +1 -0
- package/dist/shared/types.d.mts +99 -0
- package/dist/shared/types.d.mts.map +1 -0
- package/dist/shared/types.d.ts +72 -71
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/utils/createUtilityFunctions.d.mts +24 -0
- package/dist/utils/createUtilityFunctions.d.mts.map +1 -0
- package/dist/utils/createUtilityFunctions.d.ts +16 -15
- package/dist/utils/createUtilityFunctions.d.ts.map +1 -1
- package/dist/utils/createUtilityFunctions.js +166 -192
- package/dist/utils/createUtilityFunctions.mjs +165 -189
- package/dist/utils/createUtilityFunctions.mjs.map +1 -0
- package/dist/utils/inferReactQueryProcedure.d.mts +30 -0
- package/dist/utils/inferReactQueryProcedure.d.mts.map +1 -0
- package/dist/utils/inferReactQueryProcedure.d.ts +17 -12
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +48 -28
- package/rsc/package.json +1 -0
- package/server/index/package.json +1 -0
- package/server/package.json +1 -0
- package/shared/index/package.json +1 -0
- package/shared/package.json +1 -0
- package/src/createTRPCReact.tsx +0 -4
- package/src/shared/hooks/createHooksInternal.tsx +2 -0
- package/src/shared/hooks/types.ts +0 -2
- package/src/shared/proxy/decorationProxy.ts +1 -1
- package/src/shared/types.ts +2 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/internals/trpcResult.d.ts +0 -18
- package/dist/internals/trpcResult.d.ts.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/shared/hooks/createRootHooks.d.ts +0 -2
- package/dist/shared/hooks/createRootHooks.d.ts.map +0 -1
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/polymorphism/index.d.ts +0 -5
- package/dist/shared/polymorphism/index.d.ts.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DecorateRouterRecord, DecoratedMutation, DecoratedQuery } from "../createTRPCReact.mjs";
|
|
2
|
+
import { DeepPartial } from "@trpc/server/unstable-core-do-not-import";
|
|
3
|
+
|
|
4
|
+
//#region src/internals/getQueryKey.d.ts
|
|
5
|
+
type QueryType = 'any' | 'infinite' | 'query';
|
|
6
|
+
type TRPCQueryKey = [readonly string[], {
|
|
7
|
+
input?: unknown;
|
|
8
|
+
type?: Exclude<QueryType, 'any'>;
|
|
9
|
+
}?];
|
|
10
|
+
type TRPCMutationKey = [readonly string[]];
|
|
11
|
+
type ProcedureOrRouter = DecoratedMutation<any> | DecoratedQuery<any> | DecorateRouterRecord<any, any>;
|
|
12
|
+
/**
|
|
13
|
+
* To allow easy interactions with groups of related queries, such as
|
|
14
|
+
* invalidating all queries of a router, we use an array as the path when
|
|
15
|
+
* storing in tanstack query.
|
|
16
|
+
**/
|
|
17
|
+
|
|
18
|
+
type GetInfiniteQueryInput<TProcedureInput, TInputWithoutCursorAndDirection = Omit<TProcedureInput, 'cursor' | 'direction'>> = keyof TInputWithoutCursorAndDirection extends never ? undefined : DeepPartial<TInputWithoutCursorAndDirection> | undefined;
|
|
19
|
+
/** @internal */
|
|
20
|
+
type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {
|
|
21
|
+
cursor?: any;
|
|
22
|
+
} ? GetInfiniteQueryInput<TProcedureInput> : DeepPartial<TProcedureInput> | undefined;
|
|
23
|
+
type GetParams<TProcedureOrRouter extends ProcedureOrRouter> = TProcedureOrRouter extends DecoratedQuery<infer $Def> ? [input?: GetQueryProcedureInput<$Def['input']>, type?: QueryType] : [];
|
|
24
|
+
/**
|
|
25
|
+
* Method to extract the query key for a procedure
|
|
26
|
+
* @param procedureOrRouter - procedure or AnyRouter
|
|
27
|
+
* @param input - input to procedureOrRouter
|
|
28
|
+
* @param type - defaults to `any`
|
|
29
|
+
* @see https://trpc.io/docs/v11/getQueryKey
|
|
30
|
+
*/
|
|
31
|
+
declare function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(procedureOrRouter: TProcedureOrRouter, ..._params: GetParams<TProcedureOrRouter>): TRPCQueryKey;
|
|
32
|
+
type QueryKeyKnown<TInput, TType extends Exclude<QueryType, 'any'>> = [string[], {
|
|
33
|
+
input?: GetQueryProcedureInput<TInput>;
|
|
34
|
+
type: TType;
|
|
35
|
+
}?];
|
|
36
|
+
/**
|
|
37
|
+
* Method to extract the mutation key for a procedure
|
|
38
|
+
* @param procedure - procedure
|
|
39
|
+
* @see https://trpc.io/docs/v11/getQueryKey#mutations
|
|
40
|
+
*/
|
|
41
|
+
declare function getMutationKey<TProcedure extends DecoratedMutation<any>>(procedure: TProcedure): TRPCMutationKey;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { QueryKeyKnown, QueryType, TRPCMutationKey, TRPCQueryKey, getMutationKey as getMutationKey$1, getQueryKey as getQueryKey$1 };
|
|
45
|
+
//# sourceMappingURL=getQueryKey.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getQueryKey.d.mts","names":[],"sources":["../../src/internals/getQueryKey.ts"],"sourcesContent":[],"mappings":";;;;KAQY,SAAA;AAAA,KAEA,YAAA,GAFS,CAET,SAAA,MAAY,EAAA,EAAA;EAEY,KAAA,CAAA,EAAA,OAAA;EAAR,IAAA,CAAA,EAAA,OAAA,CAAQ,SAAR,EAAA,KAAA,CAAA;AAAO,CAAA,CAAA,CAGnC;AAEK,KAFO,eAAA,GAEU,CAAA,SAAA,MAAA,EAAA,CAAA;KAAjB,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ratedMutation, DecoratedQuery } from "../createTRPCReact.js";
|
|
2
|
+
import { DeepPartial } from "@trpc/server/unstable-core-do-not-import";
|
|
3
|
+
|
|
4
|
+
//#region src/internals/getQueryKey.d.ts
|
|
5
|
+
type QueryType = 'any' | 'infinite' | 'query';
|
|
6
|
+
type TRPCQueryKey = [readonly string[], {
|
|
7
|
+
input?: unknown;
|
|
8
|
+
type?: Exclude<QueryType, 'any'>;
|
|
9
|
+
}?];
|
|
10
|
+
type TRPCMutationKey = [readonly string[]];
|
|
13
11
|
type ProcedureOrRouter = DecoratedMutation<any> | DecoratedQuery<any> | DecorateRouterRecord<any, any>;
|
|
14
12
|
/**
|
|
15
13
|
* To allow easy interactions with groups of related queries, such as
|
|
16
14
|
* invalidating all queries of a router, we use an array as the path when
|
|
17
15
|
* storing in tanstack query.
|
|
18
16
|
**/
|
|
19
|
-
|
|
20
|
-
export declare function getMutationKeyInternal(path: readonly string[]): TRPCMutationKey;
|
|
17
|
+
|
|
21
18
|
type GetInfiniteQueryInput<TProcedureInput, TInputWithoutCursorAndDirection = Omit<TProcedureInput, 'cursor' | 'direction'>> = keyof TInputWithoutCursorAndDirection extends never ? undefined : DeepPartial<TInputWithoutCursorAndDirection> | undefined;
|
|
22
19
|
/** @internal */
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {
|
|
21
|
+
cursor?: any;
|
|
25
22
|
} ? GetInfiniteQueryInput<TProcedureInput> : DeepPartial<TProcedureInput> | undefined;
|
|
26
23
|
type GetParams<TProcedureOrRouter extends ProcedureOrRouter> = TProcedureOrRouter extends DecoratedQuery<infer $Def> ? [input?: GetQueryProcedureInput<$Def['input']>, type?: QueryType] : [];
|
|
27
24
|
/**
|
|
@@ -31,19 +28,18 @@ type GetParams<TProcedureOrRouter extends ProcedureOrRouter> = TProcedureOrRoute
|
|
|
31
28
|
* @param type - defaults to `any`
|
|
32
29
|
* @see https://trpc.io/docs/v11/getQueryKey
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: TType;
|
|
40
|
-
}?
|
|
41
|
-
];
|
|
31
|
+
declare function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(procedureOrRouter: TProcedureOrRouter, ..._params: GetParams<TProcedureOrRouter>): TRPCQueryKey;
|
|
32
|
+
type QueryKeyKnown<TInput, TType extends Exclude<QueryType, 'any'>> = [string[], {
|
|
33
|
+
input?: GetQueryProcedureInput<TInput>;
|
|
34
|
+
type: TType;
|
|
35
|
+
}?];
|
|
42
36
|
/**
|
|
43
37
|
* Method to extract the mutation key for a procedure
|
|
44
38
|
* @param procedure - procedure
|
|
45
39
|
* @see https://trpc.io/docs/v11/getQueryKey#mutations
|
|
46
40
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
declare function getMutationKey<TProcedure extends DecoratedMutation<any>>(procedure: TProcedure): TRPCMutationKey;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { QueryKeyKnown, QueryType, TRPCMutationKey, TRPCQueryKey, getMutationKey, getQueryKey };
|
|
49
45
|
//# sourceMappingURL=getQueryKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQueryKey.d.ts","
|
|
1
|
+
{"version":3,"file":"getQueryKey.d.ts","names":[],"sources":["../../src/internals/getQueryKey.ts"],"sourcesContent":[],"mappings":";;;;KAQY,SAAA;AAAA,KAEA,YAAA,GAFS,CAET,SAAA,MAAY,EAAA,EAAA;EAEY,KAAA,CAAA,EAAA,OAAA;EAAR,IAAA,CAAA,EAAA,OAAA,CAAQ,SAAR,EAAA,KAAA,CAAA;AAAO,CAAA,CAAA,CAGnC;AAEK,KAFO,eAAA,GAEU,CAAA,SAAA,MAAA,EAAA,CAAA;KAAjB,iBAAA,GACD,iBADkB,CAAA,GAAA,CAAA,GAElB,cAFkB,CAAA,GAAA,CAAA,GAGlB,oBAHkB,CAAA,GAAA,EAAA,GAAA,CAAA;;;;AAGE;AAyDvB;;KAEI,qBAE+B,CAAA,eAAA,EAAA,kCAAA,IAAA,CAChC,eADgC,EAAA,QAAA,GAAA,WAAA,CAAA,CAAA,GAAA,MAI1B,+BAJ0B,SAAA,KAAA,GAAA,SAAA,GAMhC,WANgC,CAMpB,+BANoB,CAAA,GAAA,SAAA;;AAMpB,KAGJ,sBAHI,CAAA,eAAA,CAAA,GAGsC,eAHtC,SAAA;EAA+B,MAA3C,CAAA,EAAA,GAAA;AAAW,CAAA,GAMX,qBANW,CAMW,eANX,CAAA,GAOX,WAPW,CAOC,eAPD,CAAA,GAAA,SAAA;KASV,qCAAqC,qBACxC,2BAA2B,sCACd,uBAAuB,uBAAuB;AAR7D;;;;;;;AAIe,iBAcC,WAdD,CAAA,2BAcwC,iBAdxC,CAAA,CAAA,iBAAA,EAeM,kBAfN,EAAA,GAAA,OAAA,EAgBD,SAhBC,CAgBS,kBAhBT,CAAA,CAAA,EAgB4B,YAhB5B;AAEV,KAyBO,aAzBE,CAAA,MAAA,EAAA,cAyBkC,OAzBlC,CAyB0C,SAzB1C,EAAA,KAAA,CAAA,CAAA,GAAA,CAAA,MAAA,EAAA,EAAA;EACZ,KAAA,CAAA,EA0BU,sBA1BV,CA0BiC,MA1BjC,CAAA;EAA2B,IAAA,EA0BqB,KA1BrB;AAAc,CAAA,CAAA,CACD;;AAA4B;;;;iBAiCtD,kCAAkC,mCACrC,aAAU"}
|
|
@@ -1,75 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const __tanstack_react_query = require_rolldown_runtime.__toESM(require("@tanstack/react-query"));
|
|
3
|
+
const __trpc_server_unstable_core_do_not_import = require_rolldown_runtime.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
|
5
4
|
|
|
5
|
+
//#region src/internals/getQueryKey.ts
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const { cursor: _, direction: __, ...inputWithoutCursorAndDirection } = input;
|
|
26
|
-
return [
|
|
27
|
-
splitPath,
|
|
28
|
-
{
|
|
29
|
-
input: inputWithoutCursorAndDirection,
|
|
30
|
-
type: 'infinite'
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
return [
|
|
35
|
-
splitPath,
|
|
36
|
-
{
|
|
37
|
-
...typeof input !== 'undefined' && input !== reactQuery.skipToken && {
|
|
38
|
-
input: input
|
|
39
|
-
},
|
|
40
|
-
...type && type !== 'any' && {
|
|
41
|
-
type: type
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
];
|
|
7
|
+
* To allow easy interactions with groups of related queries, such as
|
|
8
|
+
* invalidating all queries of a router, we use an array as the path when
|
|
9
|
+
* storing in tanstack query.
|
|
10
|
+
**/
|
|
11
|
+
function getQueryKeyInternal(path, input, type) {
|
|
12
|
+
const splitPath = path.flatMap((part) => part.split("."));
|
|
13
|
+
if (!input && (!type || type === "any")) return splitPath.length ? [splitPath] : [];
|
|
14
|
+
if (type === "infinite" && (0, __trpc_server_unstable_core_do_not_import.isObject)(input) && ("direction" in input || "cursor" in input)) {
|
|
15
|
+
const { cursor: _, direction: __,...inputWithoutCursorAndDirection } = input;
|
|
16
|
+
return [splitPath, {
|
|
17
|
+
input: inputWithoutCursorAndDirection,
|
|
18
|
+
type: "infinite"
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
21
|
+
return [splitPath, {
|
|
22
|
+
...typeof input !== "undefined" && input !== __tanstack_react_query.skipToken && { input },
|
|
23
|
+
...type && type !== "any" && { type }
|
|
24
|
+
}];
|
|
45
25
|
}
|
|
46
26
|
function getMutationKeyInternal(path) {
|
|
47
|
-
|
|
27
|
+
return getQueryKeyInternal(path, void 0, "any");
|
|
48
28
|
}
|
|
49
29
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
30
|
+
* Method to extract the query key for a procedure
|
|
31
|
+
* @param procedureOrRouter - procedure or AnyRouter
|
|
32
|
+
* @param input - input to procedureOrRouter
|
|
33
|
+
* @param type - defaults to `any`
|
|
34
|
+
* @see https://trpc.io/docs/v11/getQueryKey
|
|
35
|
+
*/
|
|
36
|
+
function getQueryKey(procedureOrRouter, ..._params) {
|
|
37
|
+
const [input, type] = _params;
|
|
38
|
+
const path = procedureOrRouter._def().path;
|
|
39
|
+
const queryKey = getQueryKeyInternal(path, input, type ?? "any");
|
|
40
|
+
return queryKey;
|
|
61
41
|
}
|
|
62
42
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
43
|
+
* Method to extract the mutation key for a procedure
|
|
44
|
+
* @param procedure - procedure
|
|
45
|
+
* @see https://trpc.io/docs/v11/getQueryKey#mutations
|
|
46
|
+
*/
|
|
47
|
+
function getMutationKey(procedure) {
|
|
48
|
+
const path = procedure._def().path;
|
|
49
|
+
return getMutationKeyInternal(path);
|
|
70
50
|
}
|
|
71
51
|
|
|
52
|
+
//#endregion
|
|
72
53
|
exports.getMutationKey = getMutationKey;
|
|
73
54
|
exports.getMutationKeyInternal = getMutationKeyInternal;
|
|
74
55
|
exports.getQueryKey = getQueryKey;
|
|
75
|
-
exports.getQueryKeyInternal = getQueryKeyInternal;
|
|
56
|
+
exports.getQueryKeyInternal = getQueryKeyInternal;
|
|
@@ -1,70 +1,53 @@
|
|
|
1
|
-
import { skipToken } from
|
|
2
|
-
import { isObject } from
|
|
1
|
+
import { skipToken } from "@tanstack/react-query";
|
|
2
|
+
import { isObject } from "@trpc/server/unstable-core-do-not-import";
|
|
3
3
|
|
|
4
|
+
//#region src/internals/getQueryKey.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const { cursor: _, direction: __, ...inputWithoutCursorAndDirection } = input;
|
|
24
|
-
return [
|
|
25
|
-
splitPath,
|
|
26
|
-
{
|
|
27
|
-
input: inputWithoutCursorAndDirection,
|
|
28
|
-
type: 'infinite'
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
return [
|
|
33
|
-
splitPath,
|
|
34
|
-
{
|
|
35
|
-
...typeof input !== 'undefined' && input !== skipToken && {
|
|
36
|
-
input: input
|
|
37
|
-
},
|
|
38
|
-
...type && type !== 'any' && {
|
|
39
|
-
type: type
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
];
|
|
6
|
+
* To allow easy interactions with groups of related queries, such as
|
|
7
|
+
* invalidating all queries of a router, we use an array as the path when
|
|
8
|
+
* storing in tanstack query.
|
|
9
|
+
**/
|
|
10
|
+
function getQueryKeyInternal(path, input, type) {
|
|
11
|
+
const splitPath = path.flatMap((part) => part.split("."));
|
|
12
|
+
if (!input && (!type || type === "any")) return splitPath.length ? [splitPath] : [];
|
|
13
|
+
if (type === "infinite" && isObject(input) && ("direction" in input || "cursor" in input)) {
|
|
14
|
+
const { cursor: _, direction: __,...inputWithoutCursorAndDirection } = input;
|
|
15
|
+
return [splitPath, {
|
|
16
|
+
input: inputWithoutCursorAndDirection,
|
|
17
|
+
type: "infinite"
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
return [splitPath, {
|
|
21
|
+
...typeof input !== "undefined" && input !== skipToken && { input },
|
|
22
|
+
...type && type !== "any" && { type }
|
|
23
|
+
}];
|
|
43
24
|
}
|
|
44
25
|
function getMutationKeyInternal(path) {
|
|
45
|
-
|
|
26
|
+
return getQueryKeyInternal(path, void 0, "any");
|
|
46
27
|
}
|
|
47
28
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
29
|
+
* Method to extract the query key for a procedure
|
|
30
|
+
* @param procedureOrRouter - procedure or AnyRouter
|
|
31
|
+
* @param input - input to procedureOrRouter
|
|
32
|
+
* @param type - defaults to `any`
|
|
33
|
+
* @see https://trpc.io/docs/v11/getQueryKey
|
|
34
|
+
*/
|
|
35
|
+
function getQueryKey(procedureOrRouter, ..._params) {
|
|
36
|
+
const [input, type] = _params;
|
|
37
|
+
const path = procedureOrRouter._def().path;
|
|
38
|
+
const queryKey = getQueryKeyInternal(path, input, type ?? "any");
|
|
39
|
+
return queryKey;
|
|
59
40
|
}
|
|
60
41
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
* Method to extract the mutation key for a procedure
|
|
43
|
+
* @param procedure - procedure
|
|
44
|
+
* @see https://trpc.io/docs/v11/getQueryKey#mutations
|
|
45
|
+
*/
|
|
46
|
+
function getMutationKey(procedure) {
|
|
47
|
+
const path = procedure._def().path;
|
|
48
|
+
return getMutationKeyInternal(path);
|
|
68
49
|
}
|
|
69
50
|
|
|
51
|
+
//#endregion
|
|
70
52
|
export { getMutationKey, getMutationKeyInternal, getQueryKey, getQueryKeyInternal };
|
|
53
|
+
//# sourceMappingURL=getQueryKey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getQueryKey.mjs","names":["path: readonly string[]","input: unknown","type: QueryType","procedureOrRouter: TProcedureOrRouter","procedure: TProcedure"],"sources":["../../src/internals/getQueryKey.ts"],"sourcesContent":["import { skipToken } from '@tanstack/react-query';\nimport {\n isObject,\n type DeepPartial,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type { DecoratedMutation, DecoratedQuery } from '../createTRPCReact';\nimport type { DecorateRouterRecord } from '../shared';\n\nexport type QueryType = 'any' | 'infinite' | 'query';\n\nexport type TRPCQueryKey = [\n readonly string[],\n { input?: unknown; type?: Exclude<QueryType, 'any'> }?,\n];\n\nexport type TRPCMutationKey = [readonly string[]]; // = [TRPCQueryKey[0]]\n\ntype ProcedureOrRouter =\n | DecoratedMutation<any>\n | DecoratedQuery<any>\n | DecorateRouterRecord<any, any>;\n\n/**\n * To allow easy interactions with groups of related queries, such as\n * invalidating all queries of a router, we use an array as the path when\n * storing in tanstack query.\n **/\nexport function getQueryKeyInternal(\n path: readonly string[],\n input: unknown,\n type: QueryType,\n): TRPCQueryKey {\n // Construct a query key that is easy to destructure and flexible for\n // partial selecting etc.\n // https://github.com/trpc/trpc/issues/3128\n\n // some parts of the path may be dot-separated, split them up\n const splitPath = path.flatMap((part) => part.split('.'));\n\n if (!input && (!type || type === 'any')) {\n // this matches also all mutations (see `getMutationKeyInternal`)\n\n // for `utils.invalidate()` to match all queries (including vanilla react-query)\n // we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`\n return splitPath.length ? [splitPath] : ([] as unknown as TRPCQueryKey);\n }\n\n if (\n type === 'infinite' &&\n isObject(input) &&\n ('direction' in input || 'cursor' in input)\n ) {\n const {\n cursor: _,\n direction: __,\n ...inputWithoutCursorAndDirection\n } = input;\n return [\n splitPath,\n {\n input: inputWithoutCursorAndDirection,\n type: 'infinite',\n },\n ];\n }\n return [\n splitPath,\n {\n ...(typeof input !== 'undefined' &&\n input !== skipToken && { input: input }),\n ...(type && type !== 'any' && { type: type }),\n },\n ];\n}\n\nexport function getMutationKeyInternal(path: readonly string[]) {\n return getQueryKeyInternal(path, undefined, 'any') as TRPCMutationKey;\n}\n\ntype GetInfiniteQueryInput<\n TProcedureInput,\n TInputWithoutCursorAndDirection = Omit<\n TProcedureInput,\n 'cursor' | 'direction'\n >,\n> = keyof TInputWithoutCursorAndDirection extends never\n ? undefined\n : DeepPartial<TInputWithoutCursorAndDirection> | undefined;\n\n/** @internal */\nexport type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {\n cursor?: any;\n}\n ? GetInfiniteQueryInput<TProcedureInput>\n : DeepPartial<TProcedureInput> | undefined;\n\ntype GetParams<TProcedureOrRouter extends ProcedureOrRouter> =\n TProcedureOrRouter extends DecoratedQuery<infer $Def>\n ? [input?: GetQueryProcedureInput<$Def['input']>, type?: QueryType]\n : [];\n\n/**\n * Method to extract the query key for a procedure\n * @param procedureOrRouter - procedure or AnyRouter\n * @param input - input to procedureOrRouter\n * @param type - defaults to `any`\n * @see https://trpc.io/docs/v11/getQueryKey\n */\nexport function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(\n procedureOrRouter: TProcedureOrRouter,\n ..._params: GetParams<TProcedureOrRouter>\n) {\n const [input, type] = _params;\n\n // @ts-expect-error - we don't expose _def on the type layer\n const path = procedureOrRouter._def().path as string[];\n const queryKey = getQueryKeyInternal(path, input, type ?? 'any');\n return queryKey;\n}\n\n// TODO: look over if we can't use a single type\nexport type QueryKeyKnown<TInput, TType extends Exclude<QueryType, 'any'>> = [\n string[],\n { input?: GetQueryProcedureInput<TInput>; type: TType }?,\n];\n\n/**\n * Method to extract the mutation key for a procedure\n * @param procedure - procedure\n * @see https://trpc.io/docs/v11/getQueryKey#mutations\n */\nexport function getMutationKey<TProcedure extends DecoratedMutation<any>>(\n procedure: TProcedure,\n) {\n // @ts-expect-error - we don't expose _def on the type layer\n const path = procedure._def().path as string[];\n return getMutationKeyInternal(path);\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,oBACdA,MACAC,OACAC,MACc;CAMd,MAAM,YAAY,KAAK,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,CAAC;AAEzD,MAAK,WAAW,QAAQ,SAAS,OAK/B,QAAO,UAAU,SAAS,CAAC,SAAU,IAAI,CAAE;AAG7C,KACE,SAAS,cACT,SAAS,MAAM,KACd,eAAe,SAAS,YAAY,QACrC;EACA,MAAM,EACJ,QAAQ,GACR,WAAW,GACX,GAAG,gCACJ,GAAG;AACJ,SAAO,CACL,WACA;GACE,OAAO;GACP,MAAM;EACP,CACF;CACF;AACD,QAAO,CACL,WACA;EACE,UAAW,UAAU,eACnB,UAAU,aAAa,EAAS,MAAO;EACzC,GAAI,QAAQ,SAAS,SAAS,EAAQ,KAAM;CAC7C,CACF;AACF;AAED,SAAgB,uBAAuBF,MAAyB;AAC9D,QAAO,oBAAoB,cAAiB,MAAM;AACnD;;;;;;;;AA+BD,SAAgB,YACdG,mBACA,GAAG,SACH;CACA,MAAM,CAAC,OAAO,KAAK,GAAG;CAGtB,MAAM,OAAO,kBAAkB,MAAM,CAAC;CACtC,MAAM,WAAW,oBAAoB,MAAM,OAAO,QAAQ,MAAM;AAChE,QAAO;AACR;;;;;;AAaD,SAAgB,eACdC,WACA;CAEA,MAAM,OAAO,UAAU,MAAM,CAAC;AAC9B,QAAO,uBAAuB,KAAK;AACpC"}
|
|
@@ -1,63 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
var n = Object.create(null);
|
|
7
|
-
if (e) {
|
|
8
|
-
Object.keys(e).forEach(function (k) {
|
|
9
|
-
if (k !== 'default') {
|
|
10
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return e[k]; }
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
23
3
|
|
|
4
|
+
//#region src/internals/trpcResult.ts
|
|
24
5
|
function createTRPCOptionsResult(value) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
path
|
|
28
|
-
};
|
|
6
|
+
const path = value.path.join(".");
|
|
7
|
+
return { path };
|
|
29
8
|
}
|
|
30
9
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]);
|
|
10
|
+
* Makes a stable reference of the `trpc` prop
|
|
11
|
+
*/
|
|
12
|
+
function useHookResult(value) {
|
|
13
|
+
const result = createTRPCOptionsResult(value);
|
|
14
|
+
return react.useMemo(() => result, [result]);
|
|
37
15
|
}
|
|
38
16
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...aggregate
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return aggregate;
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
|
|
20
|
+
const queryCache = queryClient.getQueryCache();
|
|
21
|
+
const query = queryCache.build(queryClient, { queryKey });
|
|
22
|
+
query.setState({
|
|
23
|
+
data: [],
|
|
24
|
+
status: "success"
|
|
25
|
+
});
|
|
26
|
+
const aggregate = [];
|
|
27
|
+
for await (const value of asyncIterable) {
|
|
28
|
+
aggregate.push(value);
|
|
29
|
+
query.setState({ data: [...aggregate] });
|
|
30
|
+
}
|
|
31
|
+
return aggregate;
|
|
59
32
|
}
|
|
60
33
|
|
|
34
|
+
//#endregion
|
|
61
35
|
exports.buildQueryFromAsyncIterable = buildQueryFromAsyncIterable;
|
|
62
36
|
exports.createTRPCOptionsResult = createTRPCOptionsResult;
|
|
63
|
-
exports.useHookResult = useHookResult;
|
|
37
|
+
exports.useHookResult = useHookResult;
|
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
|
+
//#region src/internals/trpcResult.ts
|
|
3
4
|
function createTRPCOptionsResult(value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
path
|
|
7
|
-
};
|
|
5
|
+
const path = value.path.join(".");
|
|
6
|
+
return { path };
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
]);
|
|
9
|
+
* Makes a stable reference of the `trpc` prop
|
|
10
|
+
*/
|
|
11
|
+
function useHookResult(value) {
|
|
12
|
+
const result = createTRPCOptionsResult(value);
|
|
13
|
+
return React.useMemo(() => result, [result]);
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...aggregate
|
|
34
|
-
]
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return aggregate;
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
|
|
19
|
+
const queryCache = queryClient.getQueryCache();
|
|
20
|
+
const query = queryCache.build(queryClient, { queryKey });
|
|
21
|
+
query.setState({
|
|
22
|
+
data: [],
|
|
23
|
+
status: "success"
|
|
24
|
+
});
|
|
25
|
+
const aggregate = [];
|
|
26
|
+
for await (const value of asyncIterable) {
|
|
27
|
+
aggregate.push(value);
|
|
28
|
+
query.setState({ data: [...aggregate] });
|
|
29
|
+
}
|
|
30
|
+
return aggregate;
|
|
38
31
|
}
|
|
39
32
|
|
|
33
|
+
//#endregion
|
|
40
34
|
export { buildQueryFromAsyncIterable, createTRPCOptionsResult, useHookResult };
|
|
35
|
+
//# sourceMappingURL=trpcResult.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trpcResult.mjs","names":["value: {\n path: readonly string[];\n}","asyncIterable: AsyncIterable<unknown>","queryClient: QueryClient","queryKey: TRPCQueryKey","aggregate: unknown[]"],"sources":["../../src/internals/trpcResult.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/react-query';\nimport * as React from 'react';\nimport type { TRPCQueryOptionsResult } from '../shared';\nimport type { TRPCHookResult } from '../shared/hooks/types';\nimport type { TRPCQueryKey } from './getQueryKey';\n\nexport function createTRPCOptionsResult(value: {\n path: readonly string[];\n}): TRPCQueryOptionsResult['trpc'] {\n const path = value.path.join('.');\n\n return {\n path,\n };\n}\n\n/**\n * Makes a stable reference of the `trpc` prop\n */\nexport function useHookResult(value: {\n path: readonly string[];\n}): TRPCHookResult['trpc'] {\n const result = createTRPCOptionsResult(value);\n return React.useMemo(() => result, [result]);\n}\n\n/**\n * @internal\n */\nexport async function buildQueryFromAsyncIterable(\n asyncIterable: AsyncIterable<unknown>,\n queryClient: QueryClient,\n queryKey: TRPCQueryKey,\n) {\n const queryCache = queryClient.getQueryCache();\n\n const query = queryCache.build(queryClient, {\n queryKey,\n });\n\n query.setState({\n data: [],\n status: 'success',\n });\n\n const aggregate: unknown[] = [];\n for await (const value of asyncIterable) {\n aggregate.push(value);\n\n query.setState({\n data: [...aggregate],\n });\n }\n return aggregate;\n}\n"],"mappings":";;;AAMA,SAAgB,wBAAwBA,OAEL;CACjC,MAAM,OAAO,MAAM,KAAK,KAAK,IAAI;AAEjC,QAAO,EACL,KACD;AACF;;;;AAKD,SAAgB,cAAcA,OAEH;CACzB,MAAM,SAAS,wBAAwB,MAAM;AAC7C,QAAO,MAAM,QAAQ,MAAM,QAAQ,CAAC,MAAO,EAAC;AAC7C;;;;AAKD,eAAsB,4BACpBC,eACAC,aACAC,UACA;CACA,MAAM,aAAa,YAAY,eAAe;CAE9C,MAAM,QAAQ,WAAW,MAAM,aAAa,EAC1C,SACD,EAAC;AAEF,OAAM,SAAS;EACb,MAAM,CAAE;EACR,QAAQ;CACT,EAAC;CAEF,MAAMC,YAAuB,CAAE;AAC/B,YAAW,MAAM,SAAS,eAAe;AACvC,YAAU,KAAK,MAAM;AAErB,QAAM,SAAS,EACb,MAAM,CAAC,GAAG,SAAU,EACrB,EAAC;CACH;AACD,QAAO;AACR"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCSuspenseQueryOptions } from "../shared/hooks/types.mjs";
|
|
2
|
+
import { UseQueriesProcedureRecord, UseSuspenseQueriesProcedureRecord } from "../shared/proxy/useQueriesProxy.mjs";
|
|
3
|
+
import { QueryKey, UseQueryOptions, UseSuspenseQueryOptions, UseSuspenseQueryResult } from "@tanstack/react-query";
|
|
4
|
+
import { AnyRouter, DistributiveOmit } from "@trpc/server/unstable-core-do-not-import";
|
|
5
|
+
|
|
6
|
+
//#region src/internals/useQueries.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = DistributiveOmit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'>;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
type UseQueryOptionsForUseSuspenseQueries<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = DistributiveOmit<UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
type TrpcQueryOptionsForUseQueries<TOutput, TData, TError> = DistributiveOmit<UseTRPCQueryOptions<TOutput, TData, TError>, 'queryKey'>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
type TrpcQueryOptionsForUseSuspenseQueries<TOutput, TData, TError> = DistributiveOmit<UseTRPCSuspenseQueryOptions<TOutput, TData, TError>, 'queryKey'>;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare type QueriesResults<TQueriesOptions extends UseQueryOptionsForUseQueries<any, any, any, any>[]> = { [TKey in keyof TQueriesOptions]: TQueriesOptions[TKey] extends UseQueryOptionsForUseQueries<infer TQueryFnData, infer TError, infer TData, any> ? UseTRPCQueryResult<unknown extends TData ? TQueryFnData : TData, TError> : never };
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
declare type SuspenseQueriesResults<TQueriesOptions extends UseQueryOptionsForUseSuspenseQueries<any, any, any, any>[]> = [{ [TKey in keyof TQueriesOptions]: TQueriesOptions[TKey] extends UseQueryOptionsForUseSuspenseQueries<infer TQueryFnData, any, infer TData, any> ? unknown extends TData ? TQueryFnData : TData : never }, { [TKey in keyof TQueriesOptions]: TQueriesOptions[TKey] extends UseQueryOptionsForUseSuspenseQueries<infer TQueryFnData, infer TError, infer TData, any> ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError> : never }];
|
|
34
|
+
type GetOptions<TQueryOptions> = TQueryOptions extends UseQueryOptionsForUseQueries<any, any, any, any> ? TQueryOptions : never;
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
type QueriesOptions<TQueriesOptions extends any[], TResult extends any[] = []> = TQueriesOptions extends [] ? [] : TQueriesOptions extends [infer Head] ? [...TResult, GetOptions<Head>] : TQueriesOptions extends [infer Head, ...infer Tail] ? QueriesOptions<Tail, [...TResult, GetOptions<Head>]> : unknown[] extends TQueriesOptions ? TQueriesOptions : TQueriesOptions extends UseQueryOptionsForUseQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>[] ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData, TQueryKey>[] : UseQueryOptionsForUseQueries[];
|
|
39
|
+
type GetSuspenseOptions<TQueryOptions> = TQueryOptions extends UseQueryOptionsForUseSuspenseQueries<any, any, any, any> ? TQueryOptions : never;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
type SuspenseQueriesOptions<TQueriesOptions extends any[], TResult extends any[] = []> = TQueriesOptions extends [] ? [] : TQueriesOptions extends [infer Head] ? [...TResult, GetSuspenseOptions<Head>] : TQueriesOptions extends [infer Head, ...infer Tail] ? SuspenseQueriesOptions<Tail, [...TResult, GetSuspenseOptions<Head>]> : unknown[] extends TQueriesOptions ? TQueriesOptions : TQueriesOptions extends UseQueryOptionsForUseSuspenseQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>[] ? UseQueryOptionsForUseSuspenseQueries<TQueryFnData, TError, TData, TQueryKey>[] : UseQueryOptionsForUseSuspenseQueries[];
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
type TRPCUseQueries<TRouter extends AnyRouter> = <TQueryOptions extends UseQueryOptionsForUseQueries<any, any, any, any>[], TCombinedResult = QueriesResults<TQueryOptions>>(queriesCallback: (t: UseQueriesProcedureRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>) => readonly [...QueriesOptions<TQueryOptions>], options?: {
|
|
48
|
+
combine?: (results: QueriesResults<TQueryOptions>) => TCombinedResult;
|
|
49
|
+
}) => TCombinedResult;
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
type TRPCUseSuspenseQueries<TRouter extends AnyRouter> = <TQueryOptions extends UseQueryOptionsForUseSuspenseQueries<any, any, any, any>[]>(queriesCallback: (t: UseSuspenseQueriesProcedureRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>) => readonly [...SuspenseQueriesOptions<TQueryOptions>]) => SuspenseQueriesResults<TQueryOptions>;
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { TRPCUseQueries, TRPCUseSuspenseQueries, TrpcQueryOptionsForUseQueries, TrpcQueryOptionsForUseSuspenseQueries };
|
|
57
|
+
//# sourceMappingURL=useQueries.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQueries.d.mts","names":[],"sources":["../../src/internals/useQueries.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAqBY,+EAGF,gCACU,WAAW,YAC3B,iBACF,gBAAgB,cAAc,QAAQ,OAAO;;;AAN/C;AAAwC,KAa5B,oCAb4B,CAAA,eAAA,OAAA,EAAA,SAAA,OAAA,EAAA,QAgB9B,YAhB8B,EAAA,kBAiBpB,QAjBoB,GAiBT,QAjBS,CAAA,GAkBpC,gBAlBoC,CAmBtC,uBAnBsC,CAmBd,YAnBc,EAmBA,MAnBA,EAmBQ,KAnBR,EAmBe,SAnBf,CAAA,EAAA,UAAA,CAAA;;;;AAMtB,KAoBN,6BApBM,CAAA,OAAA,EAAA,KAAA,EAAA,MAAA,CAAA,GAqBhB,gBArBgB,CAqBC,mBArBD,CAqBqB,OArBrB,EAqB8B,KArB9B,EAqBqC,MArBrC,CAAA,EAAA,UAAA,CAAA;;;;AAAhB,KA0B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