@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.
Files changed (161) hide show
  1. package/dist/_virtual/rolldown_runtime.js +30 -0
  2. package/dist/createTRPCQueryUtils.d.mts +12 -0
  3. package/dist/createTRPCQueryUtils.d.mts.map +1 -0
  4. package/dist/createTRPCQueryUtils.d.ts +11 -3
  5. package/dist/createTRPCQueryUtils.d.ts.map +1 -1
  6. package/dist/createTRPCQueryUtils.js +7 -12
  7. package/dist/createTRPCQueryUtils.mjs +7 -9
  8. package/dist/createTRPCQueryUtils.mjs.map +1 -0
  9. package/dist/createTRPCReact.d.mts +143 -0
  10. package/dist/createTRPCReact.d.mts.map +1 -0
  11. package/dist/createTRPCReact.d.ts +92 -96
  12. package/dist/createTRPCReact.d.ts.map +1 -1
  13. package/dist/createTRPCReact.js +26 -54
  14. package/dist/createTRPCReact.mjs +26 -32
  15. package/dist/createTRPCReact.mjs.map +1 -0
  16. package/dist/index.d.mts +6 -0
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +11 -15
  19. package/dist/index.mjs +7 -4
  20. package/dist/internals/context.d.mts +164 -0
  21. package/dist/internals/context.d.mts.map +1 -0
  22. package/dist/internals/context.d.ts +146 -139
  23. package/dist/internals/context.d.ts.map +1 -1
  24. package/dist/internals/context.js +10 -28
  25. package/dist/internals/context.mjs +8 -5
  26. package/dist/internals/context.mjs.map +1 -0
  27. package/dist/internals/getClientArgs.d.mts +19 -0
  28. package/dist/internals/getClientArgs.d.mts.map +1 -0
  29. package/dist/internals/getClientArgs.d.ts +14 -4
  30. package/dist/internals/getClientArgs.d.ts.map +1 -1
  31. package/dist/internals/getClientArgs.js +18 -20
  32. package/dist/internals/getClientArgs.mjs +18 -18
  33. package/dist/internals/getClientArgs.mjs.map +1 -0
  34. package/dist/internals/getQueryKey.d.mts +45 -0
  35. package/dist/internals/getQueryKey.d.mts.map +1 -0
  36. package/dist/internals/getQueryKey.d.ts +22 -26
  37. package/dist/internals/getQueryKey.d.ts.map +1 -1
  38. package/dist/internals/getQueryKey.js +43 -62
  39. package/dist/internals/getQueryKey.mjs +42 -59
  40. package/dist/internals/getQueryKey.mjs.map +1 -0
  41. package/dist/internals/trpcResult.js +27 -53
  42. package/dist/internals/trpcResult.mjs +26 -31
  43. package/dist/internals/trpcResult.mjs.map +1 -0
  44. package/dist/internals/useQueries.d.mts +57 -0
  45. package/dist/internals/useQueries.d.mts.map +1 -0
  46. package/dist/internals/useQueries.d.ts +23 -24
  47. package/dist/internals/useQueries.d.ts.map +1 -1
  48. package/dist/rsc.d.mts +81 -0
  49. package/dist/rsc.d.mts.map +1 -0
  50. package/dist/rsc.d.ts +57 -56
  51. package/dist/rsc.d.ts.map +1 -1
  52. package/dist/rsc.js +66 -126
  53. package/dist/rsc.mjs +65 -104
  54. package/dist/rsc.mjs.map +1 -0
  55. package/dist/server/index.d.mts +2 -0
  56. package/dist/server/index.d.ts +2 -2
  57. package/dist/server/index.js +2 -6
  58. package/dist/server/index.mjs +3 -1
  59. package/dist/server/ssgProxy.d.mts +33 -0
  60. package/dist/server/ssgProxy.d.mts.map +1 -0
  61. package/dist/server/ssgProxy.d.ts +18 -16
  62. package/dist/server/ssgProxy.d.ts.map +1 -1
  63. package/dist/server/ssgProxy.js +130 -137
  64. package/dist/server/ssgProxy.mjs +129 -134
  65. package/dist/server/ssgProxy.mjs.map +1 -0
  66. package/dist/shared/hooks/createHooksInternal.d.mts +42 -0
  67. package/dist/shared/hooks/createHooksInternal.d.mts.map +1 -0
  68. package/dist/shared/hooks/createHooksInternal.d.ts +33 -22
  69. package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
  70. package/dist/shared/hooks/createHooksInternal.js +427 -537
  71. package/dist/shared/hooks/createHooksInternal.mjs +426 -515
  72. package/dist/shared/hooks/createHooksInternal.mjs.map +1 -0
  73. package/dist/shared/hooks/createRootHooks.js +1 -0
  74. package/dist/shared/hooks/createRootHooks.mjs +1 -0
  75. package/dist/shared/hooks/types.d.mts +154 -0
  76. package/dist/shared/hooks/types.d.mts.map +1 -0
  77. package/dist/shared/hooks/types.d.ts +122 -125
  78. package/dist/shared/hooks/types.d.ts.map +1 -1
  79. package/dist/shared/index.d.mts +16 -0
  80. package/dist/shared/index.d.ts +16 -22
  81. package/dist/shared/index.js +17 -21
  82. package/dist/shared/index.mjs +9 -7
  83. package/dist/shared/polymorphism/mutationLike.d.mts +27 -0
  84. package/dist/shared/polymorphism/mutationLike.d.mts.map +1 -0
  85. package/dist/shared/polymorphism/mutationLike.d.ts +16 -6
  86. package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
  87. package/dist/shared/polymorphism/queryLike.d.mts +31 -0
  88. package/dist/shared/polymorphism/queryLike.d.mts.map +1 -0
  89. package/dist/shared/polymorphism/queryLike.d.ts +20 -10
  90. package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
  91. package/dist/shared/polymorphism/routerLike.d.mts +19 -0
  92. package/dist/shared/polymorphism/routerLike.d.mts.map +1 -0
  93. package/dist/shared/polymorphism/routerLike.d.ts +15 -7
  94. package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
  95. package/dist/shared/polymorphism/utilsLike.d.mts +17 -0
  96. package/dist/shared/polymorphism/utilsLike.d.mts.map +1 -0
  97. package/dist/shared/polymorphism/utilsLike.d.ts +13 -3
  98. package/dist/shared/polymorphism/utilsLike.d.ts.map +1 -1
  99. package/dist/shared/proxy/decorationProxy.d.mts +19 -0
  100. package/dist/shared/proxy/decorationProxy.d.mts.map +1 -0
  101. package/dist/shared/proxy/decorationProxy.d.ts +14 -3
  102. package/dist/shared/proxy/decorationProxy.d.ts.map +1 -1
  103. package/dist/shared/proxy/decorationProxy.js +18 -26
  104. package/dist/shared/proxy/decorationProxy.mjs +17 -23
  105. package/dist/shared/proxy/decorationProxy.mjs.map +1 -0
  106. package/dist/shared/proxy/useQueriesProxy.d.mts +24 -0
  107. package/dist/shared/proxy/useQueriesProxy.d.mts.map +1 -0
  108. package/dist/shared/proxy/useQueriesProxy.d.ts +11 -12
  109. package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
  110. package/dist/shared/proxy/useQueriesProxy.js +25 -23
  111. package/dist/shared/proxy/useQueriesProxy.mjs +24 -20
  112. package/dist/shared/proxy/useQueriesProxy.mjs.map +1 -0
  113. package/dist/shared/proxy/utilsProxy.d.mts +143 -0
  114. package/dist/shared/proxy/utilsProxy.d.mts.map +1 -0
  115. package/dist/shared/proxy/utilsProxy.d.ts +123 -121
  116. package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
  117. package/dist/shared/proxy/utilsProxy.js +82 -95
  118. package/dist/shared/proxy/utilsProxy.mjs +81 -92
  119. package/dist/shared/proxy/utilsProxy.mjs.map +1 -0
  120. package/dist/shared/queryClient.d.mts +26 -0
  121. package/dist/shared/queryClient.d.mts.map +1 -0
  122. package/dist/shared/queryClient.d.ts +17 -8
  123. package/dist/shared/queryClient.d.ts.map +1 -1
  124. package/dist/shared/queryClient.js +8 -6
  125. package/dist/shared/queryClient.mjs +7 -3
  126. package/dist/shared/queryClient.mjs.map +1 -0
  127. package/dist/shared/types.d.mts +99 -0
  128. package/dist/shared/types.d.mts.map +1 -0
  129. package/dist/shared/types.d.ts +72 -71
  130. package/dist/shared/types.d.ts.map +1 -1
  131. package/dist/utils/createUtilityFunctions.d.mts +24 -0
  132. package/dist/utils/createUtilityFunctions.d.mts.map +1 -0
  133. package/dist/utils/createUtilityFunctions.d.ts +16 -15
  134. package/dist/utils/createUtilityFunctions.d.ts.map +1 -1
  135. package/dist/utils/createUtilityFunctions.js +166 -192
  136. package/dist/utils/createUtilityFunctions.mjs +165 -189
  137. package/dist/utils/createUtilityFunctions.mjs.map +1 -0
  138. package/dist/utils/inferReactQueryProcedure.d.mts +30 -0
  139. package/dist/utils/inferReactQueryProcedure.d.mts.map +1 -0
  140. package/dist/utils/inferReactQueryProcedure.d.ts +17 -12
  141. package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
  142. package/package.json +48 -28
  143. package/rsc/package.json +1 -0
  144. package/server/index/package.json +1 -0
  145. package/server/package.json +1 -0
  146. package/shared/index/package.json +1 -0
  147. package/shared/package.json +1 -0
  148. package/src/createTRPCReact.tsx +0 -4
  149. package/src/shared/hooks/createHooksInternal.tsx +2 -0
  150. package/src/shared/hooks/types.ts +0 -2
  151. package/src/shared/proxy/decorationProxy.ts +1 -1
  152. package/src/shared/types.ts +2 -2
  153. package/dist/index.d.ts.map +0 -1
  154. package/dist/internals/trpcResult.d.ts +0 -18
  155. package/dist/internals/trpcResult.d.ts.map +0 -1
  156. package/dist/server/index.d.ts.map +0 -1
  157. package/dist/shared/hooks/createRootHooks.d.ts +0 -2
  158. package/dist/shared/hooks/createRootHooks.d.ts.map +0 -1
  159. package/dist/shared/index.d.ts.map +0 -1
  160. package/dist/shared/polymorphism/index.d.ts +0 -5
  161. 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,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,27 +1,24 @@
1
- import { type DeepPartial } from '@trpc/server/unstable-core-do-not-import';
2
- import type { DecoratedMutation, DecoratedQuery } from '../createTRPCReact';
3
- import type { DecorateRouterRecord } from '../shared';
4
- export type QueryType = 'any' | 'infinite' | 'query';
5
- export type TRPCQueryKey = [
6
- readonly string[],
7
- {
8
- input?: unknown;
9
- type?: Exclude<QueryType, 'any'>;
10
- }?
11
- ];
12
- export type TRPCMutationKey = [readonly string[]];
1
+ import { DecorateRouterRecord, DecoratedMutation, 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
- export declare function getQueryKeyInternal(path: readonly string[], input: unknown, type: QueryType): TRPCQueryKey;
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
- export type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {
24
- cursor?: any;
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
- export declare function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(procedureOrRouter: TProcedureOrRouter, ..._params: GetParams<TProcedureOrRouter>): TRPCQueryKey;
35
- export type QueryKeyKnown<TInput, TType extends Exclude<QueryType, 'any'>> = [
36
- string[],
37
- {
38
- input?: GetQueryProcedureInput<TInput>;
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
- export declare function getMutationKey<TProcedure extends DecoratedMutation<any>>(procedure: TProcedure): TRPCMutationKey;
48
- export {};
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","sourceRoot":"","sources":["../../src/internals/getQueryKey.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG;IACzB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AOX,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
- 'use strict';
2
-
3
- var reactQuery = require('@tanstack/react-query');
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
- * 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
- **/ function getQueryKeyInternal(path, input, type) {
11
- // Construct a query key that is easy to destructure and flexible for
12
- // partial selecting etc.
13
- // https://github.com/trpc/trpc/issues/3128
14
- // some parts of the path may be dot-separated, split them up
15
- const splitPath = path.flatMap((part)=>part.split('.'));
16
- if (!input && (!type || type === 'any')) {
17
- // this matches also all mutations (see `getMutationKeyInternal`)
18
- // for `utils.invalidate()` to match all queries (including vanilla react-query)
19
- // we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
20
- return splitPath.length ? [
21
- splitPath
22
- ] : [];
23
- }
24
- if (type === 'infinite' && unstableCoreDoNotImport.isObject(input) && ('direction' in input || 'cursor' in input)) {
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
- return getQueryKeyInternal(path, undefined, 'any');
27
+ return getQueryKeyInternal(path, void 0, "any");
48
28
  }
49
29
  /**
50
- * Method to extract the query key for a procedure
51
- * @param procedureOrRouter - procedure or AnyRouter
52
- * @param input - input to procedureOrRouter
53
- * @param type - defaults to `any`
54
- * @see https://trpc.io/docs/v11/getQueryKey
55
- */ function getQueryKey(procedureOrRouter, ..._params) {
56
- const [input, type] = _params;
57
- // @ts-expect-error - we don't expose _def on the type layer
58
- const path = procedureOrRouter._def().path;
59
- const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
60
- return queryKey;
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
- * Method to extract the mutation key for a procedure
64
- * @param procedure - procedure
65
- * @see https://trpc.io/docs/v11/getQueryKey#mutations
66
- */ function getMutationKey(procedure) {
67
- // @ts-expect-error - we don't expose _def on the type layer
68
- const path = procedure._def().path;
69
- return getMutationKeyInternal(path);
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 '@tanstack/react-query';
2
- import { isObject } from '@trpc/server/unstable-core-do-not-import';
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
- * To allow easy interactions with groups of related queries, such as
6
- * invalidating all queries of a router, we use an array as the path when
7
- * storing in tanstack query.
8
- **/ function getQueryKeyInternal(path, input, type) {
9
- // Construct a query key that is easy to destructure and flexible for
10
- // partial selecting etc.
11
- // https://github.com/trpc/trpc/issues/3128
12
- // some parts of the path may be dot-separated, split them up
13
- const splitPath = path.flatMap((part)=>part.split('.'));
14
- if (!input && (!type || type === 'any')) {
15
- // this matches also all mutations (see `getMutationKeyInternal`)
16
- // for `utils.invalidate()` to match all queries (including vanilla react-query)
17
- // we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
18
- return splitPath.length ? [
19
- splitPath
20
- ] : [];
21
- }
22
- if (type === 'infinite' && isObject(input) && ('direction' in input || 'cursor' in input)) {
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
- return getQueryKeyInternal(path, undefined, 'any');
26
+ return getQueryKeyInternal(path, void 0, "any");
46
27
  }
47
28
  /**
48
- * Method to extract the query key for a procedure
49
- * @param procedureOrRouter - procedure or AnyRouter
50
- * @param input - input to procedureOrRouter
51
- * @param type - defaults to `any`
52
- * @see https://trpc.io/docs/v11/getQueryKey
53
- */ function getQueryKey(procedureOrRouter, ..._params) {
54
- const [input, type] = _params;
55
- // @ts-expect-error - we don't expose _def on the type layer
56
- const path = procedureOrRouter._def().path;
57
- const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
58
- return queryKey;
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
- * Method to extract the mutation key for a procedure
62
- * @param procedure - procedure
63
- * @see https://trpc.io/docs/v11/getQueryKey#mutations
64
- */ function getMutationKey(procedure) {
65
- // @ts-expect-error - we don't expose _def on the type layer
66
- const path = procedure._def().path;
67
- return getMutationKeyInternal(path);
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
- 'use strict';
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
- const path = value.path.join('.');
26
- return {
27
- path
28
- };
6
+ const path = value.path.join(".");
7
+ return { path };
29
8
  }
30
9
  /**
31
- * Makes a stable reference of the `trpc` prop
32
- */ function useHookResult(value) {
33
- const result = createTRPCOptionsResult(value);
34
- return React__namespace.useMemo(()=>result, [
35
- result
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
- * @internal
40
- */ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
41
- const queryCache = queryClient.getQueryCache();
42
- const query = queryCache.build(queryClient, {
43
- queryKey
44
- });
45
- query.setState({
46
- data: [],
47
- status: 'success'
48
- });
49
- const aggregate = [];
50
- for await (const value of asyncIterable){
51
- aggregate.push(value);
52
- query.setState({
53
- data: [
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 'react';
1
+ import * as React from "react";
2
2
 
3
+ //#region src/internals/trpcResult.ts
3
4
  function createTRPCOptionsResult(value) {
4
- const path = value.path.join('.');
5
- return {
6
- path
7
- };
5
+ const path = value.path.join(".");
6
+ return { path };
8
7
  }
9
8
  /**
10
- * Makes a stable reference of the `trpc` prop
11
- */ function useHookResult(value) {
12
- const result = createTRPCOptionsResult(value);
13
- return React.useMemo(()=>result, [
14
- result
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
- * @internal
19
- */ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
20
- const queryCache = queryClient.getQueryCache();
21
- const query = queryCache.build(queryClient, {
22
- queryKey
23
- });
24
- query.setState({
25
- data: [],
26
- status: 'success'
27
- });
28
- const aggregate = [];
29
- for await (const value of asyncIterable){
30
- aggregate.push(value);
31
- query.setState({
32
- data: [
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,KA0BU,qCA1BV,CAAA,OAAA,EAAA,KAAA,EAAA,MAAA,CAAA,GA2BA,gBA3BA,CA4BE,2BA5BF,CA4B8B,OA5B9B,EA4BuC,KA5BvC,EA4B8C,MA5B9C,CAAA,EAAA,UAAA,CAAA;;AADkB;;aAoCA,uCACM,uEAET,kBAAkB,gBAAgB,cAAc,mFAM3D,mCAAmC,QAAQ,eAAe,OAAO,iBArCvE;;;;AAI+B,aAwCX,sBAxCW,CAAA,wBAyCL,oC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