@trpc/react-query 11.3.1 → 11.3.2-canary.2

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 (129) hide show
  1. package/dist/getQueryKey-CP8onRYT.cjs +104 -0
  2. package/dist/getQueryKey-Dekty44G.mjs +53 -0
  3. package/dist/getQueryKey-Dekty44G.mjs.map +1 -0
  4. package/dist/getQueryKey.d-C_PnqPni.d.cts +892 -0
  5. package/dist/getQueryKey.d-C_PnqPni.d.cts.map +1 -0
  6. package/dist/getQueryKey.d-CruH3ncI.d.mts +892 -0
  7. package/dist/getQueryKey.d-CruH3ncI.d.mts.map +1 -0
  8. package/dist/index.cjs +47 -0
  9. package/dist/index.d.cts +31 -0
  10. package/dist/index.d.cts.map +1 -0
  11. package/dist/index.d.mts +31 -0
  12. package/dist/index.d.mts.map +1 -0
  13. package/dist/index.mjs +40 -4
  14. package/dist/index.mjs.map +1 -0
  15. package/dist/rsc.cjs +69 -0
  16. package/dist/rsc.d.cts +80 -0
  17. package/dist/rsc.d.cts.map +1 -0
  18. package/dist/rsc.d.mts +80 -0
  19. package/dist/rsc.d.mts.map +1 -0
  20. package/dist/rsc.mjs +65 -104
  21. package/dist/rsc.mjs.map +1 -0
  22. package/dist/server/index.cjs +132 -0
  23. package/dist/server/index.d.cts +31 -0
  24. package/dist/server/index.d.cts.map +1 -0
  25. package/dist/server/index.d.mts +31 -0
  26. package/dist/server/index.d.mts.map +1 -0
  27. package/dist/server/index.mjs +133 -1
  28. package/dist/server/index.mjs.map +1 -0
  29. package/dist/shared/index.cjs +13 -0
  30. package/dist/shared/index.d.cts +2 -0
  31. package/dist/shared/index.d.mts +2 -0
  32. package/dist/shared/index.mjs +4 -7
  33. package/dist/shared-CMPBsqju.mjs +784 -0
  34. package/dist/shared-CMPBsqju.mjs.map +1 -0
  35. package/dist/shared-Doe-Gsbv.cjs +846 -0
  36. package/package.json +45 -26
  37. package/rsc/package.json +1 -0
  38. package/server/package.json +1 -0
  39. package/shared/package.json +1 -0
  40. package/dist/createTRPCQueryUtils.d.ts +0 -4
  41. package/dist/createTRPCQueryUtils.d.ts.map +0 -1
  42. package/dist/createTRPCQueryUtils.js +0 -16
  43. package/dist/createTRPCQueryUtils.mjs +0 -14
  44. package/dist/createTRPCReact.d.ts +0 -147
  45. package/dist/createTRPCReact.d.ts.map +0 -1
  46. package/dist/createTRPCReact.js +0 -60
  47. package/dist/createTRPCReact.mjs +0 -38
  48. package/dist/index.d.ts +0 -6
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js +0 -19
  51. package/dist/internals/context.d.ts +0 -157
  52. package/dist/internals/context.d.ts.map +0 -1
  53. package/dist/internals/context.js +0 -33
  54. package/dist/internals/context.mjs +0 -11
  55. package/dist/internals/getClientArgs.d.ts +0 -9
  56. package/dist/internals/getClientArgs.d.ts.map +0 -1
  57. package/dist/internals/getClientArgs.js +0 -24
  58. package/dist/internals/getClientArgs.mjs +0 -22
  59. package/dist/internals/getQueryKey.d.ts +0 -49
  60. package/dist/internals/getQueryKey.d.ts.map +0 -1
  61. package/dist/internals/getQueryKey.js +0 -75
  62. package/dist/internals/getQueryKey.mjs +0 -70
  63. package/dist/internals/trpcResult.d.ts +0 -18
  64. package/dist/internals/trpcResult.d.ts.map +0 -1
  65. package/dist/internals/trpcResult.js +0 -63
  66. package/dist/internals/trpcResult.mjs +0 -40
  67. package/dist/internals/useQueries.d.ts +0 -58
  68. package/dist/internals/useQueries.d.ts.map +0 -1
  69. package/dist/rsc.d.ts +0 -80
  70. package/dist/rsc.d.ts.map +0 -1
  71. package/dist/rsc.js +0 -130
  72. package/dist/server/index.d.ts +0 -2
  73. package/dist/server/index.d.ts.map +0 -1
  74. package/dist/server/index.js +0 -7
  75. package/dist/server/ssgProxy.d.ts +0 -31
  76. package/dist/server/ssgProxy.d.ts.map +0 -1
  77. package/dist/server/ssgProxy.js +0 -141
  78. package/dist/server/ssgProxy.mjs +0 -139
  79. package/dist/shared/hooks/createHooksInternal.d.ts +0 -31
  80. package/dist/shared/hooks/createHooksInternal.d.ts.map +0 -1
  81. package/dist/shared/hooks/createHooksInternal.js +0 -543
  82. package/dist/shared/hooks/createHooksInternal.mjs +0 -522
  83. package/dist/shared/hooks/createRootHooks.d.ts +0 -2
  84. package/dist/shared/hooks/createRootHooks.d.ts.map +0 -1
  85. package/dist/shared/hooks/types.d.ts +0 -157
  86. package/dist/shared/hooks/types.d.ts.map +0 -1
  87. package/dist/shared/index.d.ts +0 -22
  88. package/dist/shared/index.d.ts.map +0 -1
  89. package/dist/shared/index.js +0 -22
  90. package/dist/shared/polymorphism/index.d.ts +0 -5
  91. package/dist/shared/polymorphism/index.d.ts.map +0 -1
  92. package/dist/shared/polymorphism/mutationLike.d.ts +0 -17
  93. package/dist/shared/polymorphism/mutationLike.d.ts.map +0 -1
  94. package/dist/shared/polymorphism/queryLike.d.ts +0 -21
  95. package/dist/shared/polymorphism/queryLike.d.ts.map +0 -1
  96. package/dist/shared/polymorphism/routerLike.d.ts +0 -11
  97. package/dist/shared/polymorphism/routerLike.d.ts.map +0 -1
  98. package/dist/shared/polymorphism/utilsLike.d.ts +0 -7
  99. package/dist/shared/polymorphism/utilsLike.d.ts.map +0 -1
  100. package/dist/shared/proxy/decorationProxy.d.ts +0 -8
  101. package/dist/shared/proxy/decorationProxy.d.ts.map +0 -1
  102. package/dist/shared/proxy/decorationProxy.js +0 -30
  103. package/dist/shared/proxy/decorationProxy.mjs +0 -28
  104. package/dist/shared/proxy/useQueriesProxy.d.ts +0 -25
  105. package/dist/shared/proxy/useQueriesProxy.d.ts.map +0 -1
  106. package/dist/shared/proxy/useQueriesProxy.js +0 -27
  107. package/dist/shared/proxy/useQueriesProxy.mjs +0 -25
  108. package/dist/shared/proxy/utilsProxy.d.ts +0 -141
  109. package/dist/shared/proxy/utilsProxy.d.ts.map +0 -1
  110. package/dist/shared/proxy/utilsProxy.js +0 -106
  111. package/dist/shared/proxy/utilsProxy.mjs +0 -102
  112. package/dist/shared/queryClient.d.ts +0 -17
  113. package/dist/shared/queryClient.d.ts.map +0 -1
  114. package/dist/shared/queryClient.js +0 -9
  115. package/dist/shared/queryClient.mjs +0 -7
  116. package/dist/shared/types.d.ts +0 -98
  117. package/dist/shared/types.d.ts.map +0 -1
  118. package/dist/utils/createUtilityFunctions.d.ts +0 -23
  119. package/dist/utils/createUtilityFunctions.d.ts.map +0 -1
  120. package/dist/utils/createUtilityFunctions.js +0 -196
  121. package/dist/utils/createUtilityFunctions.mjs +0 -194
  122. package/dist/utils/inferReactQueryProcedure.d.ts +0 -25
  123. package/dist/utils/inferReactQueryProcedure.d.ts.map +0 -1
  124. package/rsc/index.d.ts +0 -1
  125. package/rsc/index.js +0 -1
  126. package/server/index.d.ts +0 -1
  127. package/server/index.js +0 -1
  128. package/shared/index.d.ts +0 -1
  129. package/shared/index.js +0 -1
@@ -0,0 +1,104 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const __tanstack_react_query = __toESM(require("@tanstack/react-query"));
25
+ const __trpc_server_unstable_core_do_not_import = __toESM(require("@trpc/server/unstable-core-do-not-import"));
26
+
27
+ //#region src/internals/getQueryKey.ts
28
+ /**
29
+ * To allow easy interactions with groups of related queries, such as
30
+ * invalidating all queries of a router, we use an array as the path when
31
+ * storing in tanstack query.
32
+ **/
33
+ function getQueryKeyInternal(path, input, type) {
34
+ const splitPath = path.flatMap((part) => part.split("."));
35
+ if (!input && (!type || type === "any")) return splitPath.length ? [splitPath] : [];
36
+ if (type === "infinite" && (0, __trpc_server_unstable_core_do_not_import.isObject)(input) && ("direction" in input || "cursor" in input)) {
37
+ const { cursor: _, direction: __,...inputWithoutCursorAndDirection } = input;
38
+ return [splitPath, {
39
+ input: inputWithoutCursorAndDirection,
40
+ type: "infinite"
41
+ }];
42
+ }
43
+ return [splitPath, {
44
+ ...typeof input !== "undefined" && input !== __tanstack_react_query.skipToken && { input },
45
+ ...type && type !== "any" && { type }
46
+ }];
47
+ }
48
+ function getMutationKeyInternal(path) {
49
+ return getQueryKeyInternal(path, void 0, "any");
50
+ }
51
+ /**
52
+ * Method to extract the query key for a procedure
53
+ * @param procedureOrRouter - procedure or AnyRouter
54
+ * @param input - input to procedureOrRouter
55
+ * @param type - defaults to `any`
56
+ * @see https://trpc.io/docs/v11/getQueryKey
57
+ */
58
+ function getQueryKey(procedureOrRouter, ..._params) {
59
+ const [input, type] = _params;
60
+ const path = procedureOrRouter._def().path;
61
+ const queryKey = getQueryKeyInternal(path, input, type ?? "any");
62
+ return queryKey;
63
+ }
64
+ /**
65
+ * Method to extract the mutation key for a procedure
66
+ * @param procedure - procedure
67
+ * @see https://trpc.io/docs/v11/getQueryKey#mutations
68
+ */
69
+ function getMutationKey(procedure) {
70
+ const path = procedure._def().path;
71
+ return getMutationKeyInternal(path);
72
+ }
73
+
74
+ //#endregion
75
+ Object.defineProperty(exports, '__toESM', {
76
+ enumerable: true,
77
+ get: function () {
78
+ return __toESM;
79
+ }
80
+ });
81
+ Object.defineProperty(exports, 'getMutationKey', {
82
+ enumerable: true,
83
+ get: function () {
84
+ return getMutationKey;
85
+ }
86
+ });
87
+ Object.defineProperty(exports, 'getMutationKeyInternal', {
88
+ enumerable: true,
89
+ get: function () {
90
+ return getMutationKeyInternal;
91
+ }
92
+ });
93
+ Object.defineProperty(exports, 'getQueryKey', {
94
+ enumerable: true,
95
+ get: function () {
96
+ return getQueryKey;
97
+ }
98
+ });
99
+ Object.defineProperty(exports, 'getQueryKeyInternal', {
100
+ enumerable: true,
101
+ get: function () {
102
+ return getQueryKeyInternal;
103
+ }
104
+ });
@@ -0,0 +1,53 @@
1
+ import { skipToken } from "@tanstack/react-query";
2
+ import { isObject } from "@trpc/server/unstable-core-do-not-import";
3
+
4
+ //#region src/internals/getQueryKey.ts
5
+ /**
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
+ }];
24
+ }
25
+ function getMutationKeyInternal(path) {
26
+ return getQueryKeyInternal(path, void 0, "any");
27
+ }
28
+ /**
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;
40
+ }
41
+ /**
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);
49
+ }
50
+
51
+ //#endregion
52
+ export { getMutationKey, getMutationKeyInternal, getQueryKey, getQueryKeyInternal };
53
+ //# sourceMappingURL=getQueryKey-Dekty44G.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getQueryKey-Dekty44G.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"}