@trpc/react-query 11.18.1-canary.19 → 11.18.1-canary.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getQueryKey-4D2iXfB-.cjs +193 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs +132 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs.map +1 -0
- package/dist/{getQueryKey.d-CruH3ncI.d.mts → getQueryKey-Bw7DtJ4y.d.cts} +21 -46
- package/dist/getQueryKey-Bw7DtJ4y.d.cts.map +1 -0
- package/dist/{getQueryKey.d-C_PnqPni.d.cts → getQueryKey-Cgg9jecL.d.mts} +21 -46
- package/dist/getQueryKey-Cgg9jecL.d.mts.map +1 -0
- package/dist/index.cjs +16 -17
- package/dist/index.d.cts +3 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -10
- package/dist/index.mjs.map +1 -1
- package/dist/rsc.cjs +49 -17
- package/dist/rsc.d.cts +3 -5
- package/dist/rsc.d.cts.map +1 -1
- package/dist/rsc.d.mts +3 -5
- package/dist/rsc.d.mts.map +1 -1
- package/dist/rsc.mjs +43 -11
- package/dist/rsc.mjs.map +1 -1
- package/dist/server/index.cjs +30 -35
- package/dist/server/index.d.cts +3 -5
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +3 -5
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +20 -25
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.cjs +3 -4
- package/dist/shared/index.d.cts +2 -2
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.mjs +2 -4
- package/dist/{shared-Dt4RsQVp.cjs → shared-BhNi4Oqs.cjs} +210 -237
- package/dist/{shared-JtnEvJvB.mjs → shared-DhkLzxq7.mjs} +131 -160
- package/dist/shared-DhkLzxq7.mjs.map +1 -0
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +1 -2
- package/src/index.ts +1 -0
- package/src/internals/context.tsx +10 -4
- package/src/internals/getQueryKey.ts +1 -3
- package/src/internals/useQueries.ts +9 -3
- package/src/shared/hooks/createHooksInternal.tsx +0 -1
- package/src/shared/hooks/types.ts +37 -20
- package/src/shared/types.ts +31 -12
- package/src/utils/createUtilityFunctions.ts +2 -2
- package/dist/getQueryKey-BY58RNzP.mjs +0 -196
- package/dist/getQueryKey-BY58RNzP.mjs.map +0 -1
- package/dist/getQueryKey-PyKLS56S.cjs +0 -242
- package/dist/getQueryKey.d-C_PnqPni.d.cts.map +0 -1
- package/dist/getQueryKey.d-CruH3ncI.d.mts.map +0 -1
- package/dist/shared-JtnEvJvB.mjs.map +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
const require_getQueryKey = require(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const require_getQueryKey = require("./getQueryKey-4D2iXfB-.cjs");
|
|
2
|
+
let _trpc_client = require("@trpc/client");
|
|
3
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
|
+
let _trpc_server_unstable_core_do_not_import = require("@trpc/server/unstable-core-do-not-import");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_getQueryKey.__toESM(react, 1);
|
|
8
7
|
//#region src/shared/proxy/decorationProxy.ts
|
|
9
8
|
/**
|
|
10
9
|
* Create proxy for decorating procedures
|
|
11
10
|
* @internal
|
|
12
11
|
*/
|
|
13
12
|
function createReactDecoration(hooks) {
|
|
14
|
-
return (0,
|
|
13
|
+
return (0, _trpc_server_unstable_core_do_not_import.createRecursiveProxy)(({ path, args }) => {
|
|
15
14
|
var _rest$;
|
|
16
15
|
const pathCopy = [...path];
|
|
17
16
|
const lastArg = pathCopy.pop();
|
|
@@ -22,7 +21,6 @@ function createReactDecoration(hooks) {
|
|
|
22
21
|
return hooks[lastArg](pathCopy, input, opts);
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
25
|
//#region src/internals/context.tsx
|
|
28
26
|
var _React$createContext;
|
|
@@ -33,7 +31,6 @@ const contextProps = [
|
|
|
33
31
|
"abortOnUnmount"
|
|
34
32
|
];
|
|
35
33
|
const TRPCContext = (_React$createContext = react.createContext) === null || _React$createContext === void 0 ? void 0 : _React$createContext.call(react, null);
|
|
36
|
-
|
|
37
34
|
//#endregion
|
|
38
35
|
//#region src/shared/proxy/utilsProxy.ts
|
|
39
36
|
const getQueryType = (utilName) => {
|
|
@@ -63,16 +60,19 @@ const getQueryType = (utilName) => {
|
|
|
63
60
|
* @internal
|
|
64
61
|
*/
|
|
65
62
|
function createRecursiveUtilsProxy(context) {
|
|
66
|
-
return (0,
|
|
63
|
+
return (0, _trpc_server_unstable_core_do_not_import.createRecursiveProxy)((opts) => {
|
|
67
64
|
const path = [...opts.path];
|
|
68
65
|
const utilName = path.pop();
|
|
69
66
|
const args = [...opts.args];
|
|
70
67
|
const input = args.shift();
|
|
71
68
|
const queryType = getQueryType(utilName);
|
|
72
69
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, queryType);
|
|
73
|
-
|
|
70
|
+
return {
|
|
74
71
|
infiniteQueryOptions: () => context.infiniteQueryOptions(path, queryKey, args[0]),
|
|
75
72
|
queryOptions: () => context.queryOptions(path, queryKey, ...args),
|
|
73
|
+
/**
|
|
74
|
+
* DecorateQueryProcedure
|
|
75
|
+
*/
|
|
76
76
|
fetch: () => context.fetchQuery(queryKey, ...args),
|
|
77
77
|
fetchInfinite: () => context.fetchInfiniteQuery(queryKey, args[0]),
|
|
78
78
|
prefetch: () => context.prefetchQuery(queryKey, ...args),
|
|
@@ -91,20 +91,22 @@ function createRecursiveUtilsProxy(context) {
|
|
|
91
91
|
},
|
|
92
92
|
getData: () => context.getQueryData(queryKey),
|
|
93
93
|
getInfiniteData: () => context.getInfiniteQueryData(queryKey),
|
|
94
|
+
/**
|
|
95
|
+
* DecorateMutationProcedure
|
|
96
|
+
*/
|
|
94
97
|
setMutationDefaults: () => context.setMutationDefaults(require_getQueryKey.getMutationKeyInternal(path), input),
|
|
95
98
|
getMutationDefaults: () => context.getMutationDefaults(require_getQueryKey.getMutationKeyInternal(path)),
|
|
96
99
|
isMutating: () => context.isMutating({ mutationKey: require_getQueryKey.getMutationKeyInternal(path) })
|
|
97
|
-
};
|
|
98
|
-
return contextMap[utilName]();
|
|
100
|
+
}[utilName]();
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* @internal
|
|
103
105
|
*/
|
|
104
106
|
function createReactQueryUtils(context) {
|
|
105
|
-
const clientProxy = (0,
|
|
107
|
+
const clientProxy = (0, _trpc_client.createTRPCClientProxy)(context.client);
|
|
106
108
|
const proxy = createRecursiveUtilsProxy(context);
|
|
107
|
-
return (0,
|
|
109
|
+
return (0, _trpc_server_unstable_core_do_not_import.createFlatProxy)((key) => {
|
|
108
110
|
const contextName = key;
|
|
109
111
|
if (contextName === "client") return clientProxy;
|
|
110
112
|
if (contextProps.includes(contextName)) return context[contextName];
|
|
@@ -117,33 +119,28 @@ function createReactQueryUtils(context) {
|
|
|
117
119
|
function createQueryUtilsProxy(context) {
|
|
118
120
|
return createRecursiveUtilsProxy(context);
|
|
119
121
|
}
|
|
120
|
-
|
|
121
122
|
//#endregion
|
|
122
123
|
//#region src/shared/proxy/useQueriesProxy.ts
|
|
123
|
-
var import_objectSpread2$3 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2(), 1);
|
|
124
124
|
/**
|
|
125
125
|
* Create proxy for `useQueries` options
|
|
126
126
|
* @internal
|
|
127
127
|
*/
|
|
128
128
|
function createUseQueries(client) {
|
|
129
|
-
const untypedClient = client instanceof
|
|
130
|
-
return (0,
|
|
129
|
+
const untypedClient = client instanceof _trpc_client.TRPCUntypedClient ? client : (0, _trpc_client.getUntypedClient)(client);
|
|
130
|
+
return (0, _trpc_server_unstable_core_do_not_import.createRecursiveProxy)((opts) => {
|
|
131
131
|
const arrayPath = opts.path;
|
|
132
132
|
const dotPath = arrayPath.join(".");
|
|
133
133
|
const [input, _opts] = opts.args;
|
|
134
|
-
|
|
134
|
+
return require_getQueryKey._objectSpread2({
|
|
135
135
|
queryKey: require_getQueryKey.getQueryKeyInternal(arrayPath, input, "query"),
|
|
136
136
|
queryFn: () => {
|
|
137
137
|
return untypedClient.query(dotPath, input, _opts === null || _opts === void 0 ? void 0 : _opts.trpc);
|
|
138
138
|
}
|
|
139
139
|
}, _opts);
|
|
140
|
-
return options;
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
|
-
|
|
144
142
|
//#endregion
|
|
145
143
|
//#region src/internals/getClientArgs.ts
|
|
146
|
-
var import_objectSpread2$2 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2(), 1);
|
|
147
144
|
/**
|
|
148
145
|
* @internal
|
|
149
146
|
*/
|
|
@@ -153,7 +150,7 @@ function getClientArgs(queryKey, opts, infiniteParams) {
|
|
|
153
150
|
let input = (_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input;
|
|
154
151
|
if (infiniteParams) {
|
|
155
152
|
var _input;
|
|
156
|
-
input =
|
|
153
|
+
input = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, (_input = input) !== null && _input !== void 0 ? _input : {}), infiniteParams.pageParam ? { cursor: infiniteParams.pageParam } : {}), {}, { direction: infiniteParams.direction });
|
|
157
154
|
}
|
|
158
155
|
return [
|
|
159
156
|
path.join("."),
|
|
@@ -161,60 +158,53 @@ function getClientArgs(queryKey, opts, infiniteParams) {
|
|
|
161
158
|
opts === null || opts === void 0 ? void 0 : opts.trpc
|
|
162
159
|
];
|
|
163
160
|
}
|
|
164
|
-
|
|
165
161
|
//#endregion
|
|
166
|
-
//#region
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
t = "@@asyncIterator", o = "@@iterator";
|
|
174
|
-
}
|
|
175
|
-
throw new TypeError("Object is not async iterable");
|
|
162
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/asyncIterator.js
|
|
163
|
+
function _asyncIterator(r) {
|
|
164
|
+
var n, t, o, e = 2;
|
|
165
|
+
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
|
166
|
+
if (t && null != (n = r[t])) return n.call(r);
|
|
167
|
+
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
168
|
+
t = "@@asyncIterator", o = "@@iterator";
|
|
176
169
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.s = r$1, this.n = r$1.next;
|
|
190
|
-
}, AsyncFromSyncIterator.prototype = {
|
|
191
|
-
s: null,
|
|
192
|
-
n: null,
|
|
193
|
-
next: function next() {
|
|
194
|
-
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
195
|
-
},
|
|
196
|
-
"return": function _return(r$1) {
|
|
197
|
-
var n = this.s["return"];
|
|
198
|
-
return void 0 === n ? Promise.resolve({
|
|
199
|
-
value: r$1,
|
|
200
|
-
done: !0
|
|
201
|
-
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
202
|
-
},
|
|
203
|
-
"throw": function _throw(r$1) {
|
|
204
|
-
var n = this.s["return"];
|
|
205
|
-
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
206
|
-
}
|
|
207
|
-
}, new AsyncFromSyncIterator(r);
|
|
170
|
+
throw new TypeError("Object is not async iterable");
|
|
171
|
+
}
|
|
172
|
+
function AsyncFromSyncIterator(r) {
|
|
173
|
+
function AsyncFromSyncIteratorContinuation(r) {
|
|
174
|
+
if (Object(r) !== r) return Promise.reject(/* @__PURE__ */ new TypeError(r + " is not an object."));
|
|
175
|
+
var n = r.done;
|
|
176
|
+
return Promise.resolve(r.value).then(function(r) {
|
|
177
|
+
return {
|
|
178
|
+
value: r,
|
|
179
|
+
done: n
|
|
180
|
+
};
|
|
181
|
+
});
|
|
208
182
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
183
|
+
return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) {
|
|
184
|
+
this.s = r, this.n = r.next;
|
|
185
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
186
|
+
s: null,
|
|
187
|
+
n: null,
|
|
188
|
+
next: function next() {
|
|
189
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
190
|
+
},
|
|
191
|
+
"return": function _return(r) {
|
|
192
|
+
var n = this.s["return"];
|
|
193
|
+
return void 0 === n ? Promise.resolve({
|
|
194
|
+
value: r,
|
|
195
|
+
done: !0
|
|
196
|
+
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
197
|
+
},
|
|
198
|
+
"throw": function _throw(r) {
|
|
199
|
+
var n = this.s["return"];
|
|
200
|
+
return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
201
|
+
}
|
|
202
|
+
}, new AsyncFromSyncIterator(r);
|
|
203
|
+
}
|
|
212
204
|
//#endregion
|
|
213
205
|
//#region src/internals/trpcResult.ts
|
|
214
|
-
var import_asyncIterator = require_getQueryKey.__toESM(require_asyncIterator(), 1);
|
|
215
206
|
function createTRPCOptionsResult(value) {
|
|
216
|
-
|
|
217
|
-
return { path };
|
|
207
|
+
return { path: value.path.join(".") };
|
|
218
208
|
}
|
|
219
209
|
/**
|
|
220
210
|
* Makes a stable reference of the `trpc` prop
|
|
@@ -227,8 +217,7 @@ function useHookResult(value) {
|
|
|
227
217
|
* @internal
|
|
228
218
|
*/
|
|
229
219
|
async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
|
|
230
|
-
const
|
|
231
|
-
const query = queryCache.build(queryClient, { queryKey });
|
|
220
|
+
const query = queryClient.getQueryCache().build(queryClient, { queryKey });
|
|
232
221
|
query.setState({
|
|
233
222
|
data: [],
|
|
234
223
|
status: "success"
|
|
@@ -238,12 +227,10 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
|
|
|
238
227
|
var _didIteratorError = false;
|
|
239
228
|
var _iteratorError;
|
|
240
229
|
try {
|
|
241
|
-
for (var _iterator = (
|
|
230
|
+
for (var _iterator = _asyncIterator(asyncIterable), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
|
242
231
|
const value = _step.value;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
query.setState({ data: [...aggregate] });
|
|
246
|
-
}
|
|
232
|
+
aggregate.push(value);
|
|
233
|
+
query.setState({ data: [...aggregate] });
|
|
247
234
|
}
|
|
248
235
|
} catch (err) {
|
|
249
236
|
_didIteratorError = true;
|
|
@@ -257,10 +244,8 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
|
|
|
257
244
|
}
|
|
258
245
|
return aggregate;
|
|
259
246
|
}
|
|
260
|
-
|
|
261
247
|
//#endregion
|
|
262
248
|
//#region src/utils/createUtilityFunctions.ts
|
|
263
|
-
var import_objectSpread2$1 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2(), 1);
|
|
264
249
|
/**
|
|
265
250
|
* Creates a set of utility functions that can be used to interact with `react-query`
|
|
266
251
|
* @param opts the `TRPCClient` and `QueryClient` to use
|
|
@@ -269,95 +254,94 @@ var import_objectSpread2$1 = require_getQueryKey.__toESM(require_getQueryKey.req
|
|
|
269
254
|
*/
|
|
270
255
|
function createUtilityFunctions(opts) {
|
|
271
256
|
const { client, queryClient } = opts;
|
|
272
|
-
const untypedClient = client instanceof
|
|
257
|
+
const untypedClient = client instanceof _trpc_client.TRPCUntypedClient ? client : (0, _trpc_client.getUntypedClient)(client);
|
|
273
258
|
return {
|
|
274
|
-
infiniteQueryOptions: (path, queryKey, opts
|
|
259
|
+
infiniteQueryOptions: (path, queryKey, opts) => {
|
|
275
260
|
var _queryKey$, _ref;
|
|
276
|
-
const inputIsSkipToken = ((_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input) ===
|
|
261
|
+
const inputIsSkipToken = ((_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input) === _tanstack_react_query.skipToken;
|
|
277
262
|
const queryFn = async (queryFnContext) => {
|
|
278
263
|
var _opts$trpc;
|
|
279
|
-
const actualOpts =
|
|
280
|
-
|
|
264
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), (opts === null || opts === void 0 || (_opts$trpc = opts.trpc) === null || _opts$trpc === void 0 ? void 0 : _opts$trpc.abortOnUnmount) ? { signal: queryFnContext.signal } : { signal: null }) });
|
|
265
|
+
return await untypedClient.query(...getClientArgs(queryKey, actualOpts, {
|
|
281
266
|
direction: queryFnContext.direction,
|
|
282
267
|
pageParam: queryFnContext.pageParam
|
|
283
268
|
}));
|
|
284
|
-
return result;
|
|
285
269
|
};
|
|
286
|
-
return Object.assign((0,
|
|
287
|
-
initialData: opts
|
|
270
|
+
return Object.assign((0, _tanstack_react_query.infiniteQueryOptions)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
271
|
+
initialData: opts === null || opts === void 0 ? void 0 : opts.initialData,
|
|
288
272
|
queryKey,
|
|
289
|
-
queryFn: inputIsSkipToken ?
|
|
290
|
-
initialPageParam: (_ref = opts
|
|
273
|
+
queryFn: inputIsSkipToken ? _tanstack_react_query.skipToken : queryFn,
|
|
274
|
+
initialPageParam: (_ref = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _ref !== void 0 ? _ref : null
|
|
291
275
|
})), { trpc: createTRPCOptionsResult({ path }) });
|
|
292
276
|
},
|
|
293
|
-
queryOptions: (path, queryKey, opts
|
|
277
|
+
queryOptions: (path, queryKey, opts) => {
|
|
294
278
|
var _queryKey$2;
|
|
295
|
-
const inputIsSkipToken = ((_queryKey$2 = queryKey[1]) === null || _queryKey$2 === void 0 ? void 0 : _queryKey$2.input) ===
|
|
279
|
+
const inputIsSkipToken = ((_queryKey$2 = queryKey[1]) === null || _queryKey$2 === void 0 ? void 0 : _queryKey$2.input) === _tanstack_react_query.skipToken;
|
|
296
280
|
const queryFn = async (queryFnContext) => {
|
|
297
281
|
var _opts$trpc2;
|
|
298
|
-
const actualOpts =
|
|
282
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), (opts === null || opts === void 0 || (_opts$trpc2 = opts.trpc) === null || _opts$trpc2 === void 0 ? void 0 : _opts$trpc2.abortOnUnmount) ? { signal: queryFnContext.signal } : { signal: null }) });
|
|
299
283
|
const result = await untypedClient.query(...getClientArgs(queryKey, actualOpts));
|
|
300
|
-
if ((0,
|
|
284
|
+
if ((0, _trpc_server_unstable_core_do_not_import.isAsyncIterable)(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
301
285
|
return result;
|
|
302
286
|
};
|
|
303
|
-
return Object.assign((0,
|
|
304
|
-
initialData: opts
|
|
287
|
+
return Object.assign((0, _tanstack_react_query.queryOptions)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
288
|
+
initialData: opts === null || opts === void 0 ? void 0 : opts.initialData,
|
|
305
289
|
queryKey,
|
|
306
|
-
queryFn: inputIsSkipToken ?
|
|
290
|
+
queryFn: inputIsSkipToken ? _tanstack_react_query.skipToken : queryFn
|
|
307
291
|
})), { trpc: createTRPCOptionsResult({ path }) });
|
|
308
292
|
},
|
|
309
|
-
fetchQuery: (queryKey, opts
|
|
310
|
-
return queryClient.fetchQuery(
|
|
293
|
+
fetchQuery: (queryKey, opts) => {
|
|
294
|
+
return queryClient.fetchQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
311
295
|
queryKey,
|
|
312
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
296
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
313
297
|
}));
|
|
314
298
|
},
|
|
315
|
-
fetchInfiniteQuery: (queryKey, opts
|
|
299
|
+
fetchInfiniteQuery: (queryKey, opts) => {
|
|
316
300
|
var _opts$initialCursor;
|
|
317
|
-
return queryClient.fetchInfiniteQuery(
|
|
301
|
+
return queryClient.fetchInfiniteQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
318
302
|
queryKey,
|
|
319
303
|
queryFn: ({ pageParam, direction }) => {
|
|
320
|
-
return untypedClient.query(...getClientArgs(queryKey, opts
|
|
304
|
+
return untypedClient.query(...getClientArgs(queryKey, opts, {
|
|
321
305
|
pageParam,
|
|
322
306
|
direction
|
|
323
307
|
}));
|
|
324
308
|
},
|
|
325
|
-
initialPageParam: (_opts$initialCursor = opts
|
|
309
|
+
initialPageParam: (_opts$initialCursor = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _opts$initialCursor !== void 0 ? _opts$initialCursor : null
|
|
326
310
|
}));
|
|
327
311
|
},
|
|
328
|
-
prefetchQuery: (queryKey, opts
|
|
329
|
-
return queryClient.prefetchQuery(
|
|
312
|
+
prefetchQuery: (queryKey, opts) => {
|
|
313
|
+
return queryClient.prefetchQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
330
314
|
queryKey,
|
|
331
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
315
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
332
316
|
}));
|
|
333
317
|
},
|
|
334
|
-
prefetchInfiniteQuery: (queryKey, opts
|
|
318
|
+
prefetchInfiniteQuery: (queryKey, opts) => {
|
|
335
319
|
var _opts$initialCursor2;
|
|
336
|
-
return queryClient.prefetchInfiniteQuery(
|
|
320
|
+
return queryClient.prefetchInfiniteQuery(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
337
321
|
queryKey,
|
|
338
322
|
queryFn: ({ pageParam, direction }) => {
|
|
339
|
-
return untypedClient.query(...getClientArgs(queryKey, opts
|
|
323
|
+
return untypedClient.query(...getClientArgs(queryKey, opts, {
|
|
340
324
|
pageParam,
|
|
341
325
|
direction
|
|
342
326
|
}));
|
|
343
327
|
},
|
|
344
|
-
initialPageParam: (_opts$initialCursor2 = opts
|
|
328
|
+
initialPageParam: (_opts$initialCursor2 = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _opts$initialCursor2 !== void 0 ? _opts$initialCursor2 : null
|
|
345
329
|
}));
|
|
346
330
|
},
|
|
347
|
-
ensureQueryData: (queryKey, opts
|
|
348
|
-
return queryClient.ensureQueryData(
|
|
331
|
+
ensureQueryData: (queryKey, opts) => {
|
|
332
|
+
return queryClient.ensureQueryData(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
349
333
|
queryKey,
|
|
350
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
334
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
351
335
|
}));
|
|
352
336
|
},
|
|
353
337
|
invalidateQueries: (queryKey, filters, options) => {
|
|
354
|
-
return queryClient.invalidateQueries(
|
|
338
|
+
return queryClient.invalidateQueries(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, filters), {}, { queryKey }), options);
|
|
355
339
|
},
|
|
356
340
|
resetQueries: (queryKey, filters, options) => {
|
|
357
|
-
return queryClient.resetQueries(
|
|
341
|
+
return queryClient.resetQueries(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, filters), {}, { queryKey }), options);
|
|
358
342
|
},
|
|
359
343
|
refetchQueries: (queryKey, filters, options) => {
|
|
360
|
-
return queryClient.refetchQueries(
|
|
344
|
+
return queryClient.refetchQueries(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, filters), {}, { queryKey }), options);
|
|
361
345
|
},
|
|
362
346
|
cancelQuery: (queryKey, options) => {
|
|
363
347
|
return queryClient.cancelQueries({ queryKey }, options);
|
|
@@ -366,7 +350,7 @@ function createUtilityFunctions(opts) {
|
|
|
366
350
|
return queryClient.setQueryData(queryKey, updater, options);
|
|
367
351
|
},
|
|
368
352
|
setQueriesData: (queryKey, filters, updater, options) => {
|
|
369
|
-
return queryClient.setQueriesData(
|
|
353
|
+
return queryClient.setQueriesData(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, filters), {}, { queryKey }), updater, options);
|
|
370
354
|
},
|
|
371
355
|
getQueryData: (queryKey) => {
|
|
372
356
|
return queryClient.getQueryData(queryKey);
|
|
@@ -388,39 +372,36 @@ function createUtilityFunctions(opts) {
|
|
|
388
372
|
return queryClient.getMutationDefaults(mutationKey);
|
|
389
373
|
},
|
|
390
374
|
isMutating: (filters) => {
|
|
391
|
-
return queryClient.isMutating(
|
|
375
|
+
return queryClient.isMutating(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, filters), {}, { exact: true }));
|
|
392
376
|
}
|
|
393
377
|
};
|
|
394
378
|
}
|
|
395
|
-
|
|
396
379
|
//#endregion
|
|
397
380
|
//#region src/shared/hooks/createHooksInternal.tsx
|
|
398
|
-
var import_objectSpread2 = require_getQueryKey.__toESM(require_getQueryKey.require_objectSpread2());
|
|
399
381
|
const trackResult = (result, onTrackResult) => {
|
|
400
|
-
|
|
382
|
+
return new Proxy(result, { get(target, prop) {
|
|
401
383
|
onTrackResult(prop);
|
|
402
384
|
return target[prop];
|
|
403
385
|
} });
|
|
404
|
-
return trackedResult;
|
|
405
386
|
};
|
|
406
387
|
/**
|
|
407
388
|
* @internal
|
|
408
389
|
*/
|
|
409
390
|
function createRootHooks(config) {
|
|
410
391
|
var _config$overrides$use, _config$overrides, _config$context;
|
|
411
|
-
const mutationSuccessOverride = (_config$overrides$use = config === null || config === void 0 || (_config$overrides = config.overrides) === null || _config$overrides === void 0 || (_config$overrides = _config$overrides.useMutation) === null || _config$overrides === void 0 ? void 0 : _config$overrides.onSuccess) !== null && _config$overrides$use !== void 0 ? _config$overrides$use : (options) => options.originalFn();
|
|
392
|
+
const mutationSuccessOverride = (_config$overrides$use = config === null || config === void 0 || (_config$overrides = config.overrides) === null || _config$overrides === void 0 || (_config$overrides = _config$overrides.useMutation) === null || _config$overrides === void 0 ? void 0 : _config$overrides.onSuccess) !== null && _config$overrides$use !== void 0 ? _config$overrides$use : ((options) => options.originalFn());
|
|
412
393
|
const Context = (_config$context = config === null || config === void 0 ? void 0 : config.context) !== null && _config$context !== void 0 ? _config$context : TRPCContext;
|
|
413
|
-
const createClient =
|
|
394
|
+
const createClient = _trpc_client.createTRPCClient;
|
|
414
395
|
const TRPCProvider = (props) => {
|
|
415
396
|
var _props$ssrState;
|
|
416
397
|
const { abortOnUnmount = false, queryClient, ssrContext } = props;
|
|
417
398
|
const [ssrState, setSSRState] = react.useState((_props$ssrState = props.ssrState) !== null && _props$ssrState !== void 0 ? _props$ssrState : false);
|
|
418
|
-
const client = props.client instanceof
|
|
399
|
+
const client = props.client instanceof _trpc_client.TRPCUntypedClient ? props.client : (0, _trpc_client.getUntypedClient)(props.client);
|
|
419
400
|
const fns = react.useMemo(() => createUtilityFunctions({
|
|
420
401
|
client,
|
|
421
402
|
queryClient
|
|
422
403
|
}), [client, queryClient]);
|
|
423
|
-
const contextValue = react.useMemo(() =>
|
|
404
|
+
const contextValue = react.useMemo(() => require_getQueryKey._objectSpread2({
|
|
424
405
|
abortOnUnmount,
|
|
425
406
|
queryClient,
|
|
426
407
|
client,
|
|
@@ -437,10 +418,7 @@ function createRootHooks(config) {
|
|
|
437
418
|
react.useEffect(() => {
|
|
438
419
|
setSSRState((state) => state ? "mounted" : false);
|
|
439
420
|
}, []);
|
|
440
|
-
return /* @__PURE__ */
|
|
441
|
-
value: contextValue,
|
|
442
|
-
children: props.children
|
|
443
|
-
});
|
|
421
|
+
return /* @__PURE__ */ react.createElement(Context.Provider, { value: contextValue }, props.children);
|
|
444
422
|
};
|
|
445
423
|
function useContext() {
|
|
446
424
|
const context = react.useContext(Context);
|
|
@@ -454,24 +432,23 @@ function createRootHooks(config) {
|
|
|
454
432
|
function useSSRQueryOptionsIfNeeded(queryKey, opts) {
|
|
455
433
|
var _queryClient$getQuery;
|
|
456
434
|
const { queryClient, ssrState } = useContext();
|
|
457
|
-
return ssrState && ssrState !== "mounted" && ((_queryClient$getQuery = queryClient.getQueryCache().find({ queryKey })) === null || _queryClient$getQuery === void 0 ? void 0 : _queryClient$getQuery.state.status) === "error" ?
|
|
435
|
+
return ssrState && ssrState !== "mounted" && ((_queryClient$getQuery = queryClient.getQueryCache().find({ queryKey })) === null || _queryClient$getQuery === void 0 ? void 0 : _queryClient$getQuery.state.status) === "error" ? require_getQueryKey._objectSpread2({ retryOnMount: false }, opts) : opts;
|
|
458
436
|
}
|
|
459
437
|
function useQuery(path, input, opts) {
|
|
460
438
|
var _opts$trpc, _opts$enabled, _ref, _opts$trpc$abortOnUnm, _opts$trpc2;
|
|
461
|
-
const
|
|
462
|
-
const { abortOnUnmount, client, ssrState, queryClient, prefetchQuery } = context;
|
|
439
|
+
const { abortOnUnmount, client, ssrState, queryClient, prefetchQuery } = useContext();
|
|
463
440
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "query");
|
|
464
441
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
465
|
-
const isInputSkipToken = input ===
|
|
442
|
+
const isInputSkipToken = input === _tanstack_react_query.skipToken;
|
|
466
443
|
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc = opts.trpc) === null || _opts$trpc === void 0 ? void 0 : _opts$trpc.ssr) !== false && ((_opts$enabled = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled !== void 0 ? _opts$enabled : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchQuery(queryKey, opts);
|
|
467
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey,
|
|
444
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, defaultOpts), opts));
|
|
468
445
|
const shouldAbortOnUnmount = (_ref = (_opts$trpc$abortOnUnm = opts === null || opts === void 0 || (_opts$trpc2 = opts.trpc) === null || _opts$trpc2 === void 0 ? void 0 : _opts$trpc2.abortOnUnmount) !== null && _opts$trpc$abortOnUnm !== void 0 ? _opts$trpc$abortOnUnm : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref !== void 0 ? _ref : abortOnUnmount;
|
|
469
|
-
const hook = (0,
|
|
446
|
+
const hook = (0, _tanstack_react_query.useQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, {
|
|
470
447
|
queryKey,
|
|
471
448
|
queryFn: isInputSkipToken ? input : async (queryFunctionContext) => {
|
|
472
|
-
const actualOpts =
|
|
449
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
473
450
|
const result = await client.query(...getClientArgs(queryKey, actualOpts));
|
|
474
|
-
if ((0,
|
|
451
|
+
if ((0, _trpc_server_unstable_core_do_not_import.isAsyncIterable)(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
475
452
|
return result;
|
|
476
453
|
}
|
|
477
454
|
}), queryClient);
|
|
@@ -482,12 +459,12 @@ function createRootHooks(config) {
|
|
|
482
459
|
var _ref2, _opts$trpc$abortOnUnm2, _opts$trpc3;
|
|
483
460
|
const context = useContext();
|
|
484
461
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "query");
|
|
485
|
-
const isInputSkipToken = input ===
|
|
462
|
+
const isInputSkipToken = input === _tanstack_react_query.skipToken;
|
|
486
463
|
const shouldAbortOnUnmount = (_ref2 = (_opts$trpc$abortOnUnm2 = opts === null || opts === void 0 || (_opts$trpc3 = opts.trpc) === null || _opts$trpc3 === void 0 ? void 0 : _opts$trpc3.abortOnUnmount) !== null && _opts$trpc$abortOnUnm2 !== void 0 ? _opts$trpc$abortOnUnm2 : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref2 !== void 0 ? _ref2 : context.abortOnUnmount;
|
|
487
|
-
(0,
|
|
464
|
+
(0, _tanstack_react_query.usePrefetchQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
488
465
|
queryKey,
|
|
489
466
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
490
|
-
const actualOpts = { trpc:
|
|
467
|
+
const actualOpts = { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) };
|
|
491
468
|
return context.client.query(...getClientArgs(queryKey, actualOpts));
|
|
492
469
|
}
|
|
493
470
|
}));
|
|
@@ -497,10 +474,10 @@ function createRootHooks(config) {
|
|
|
497
474
|
const context = useContext();
|
|
498
475
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "query");
|
|
499
476
|
const shouldAbortOnUnmount = (_ref3 = (_opts$trpc$abortOnUnm3 = opts === null || opts === void 0 || (_opts$trpc4 = opts.trpc) === null || _opts$trpc4 === void 0 ? void 0 : _opts$trpc4.abortOnUnmount) !== null && _opts$trpc$abortOnUnm3 !== void 0 ? _opts$trpc$abortOnUnm3 : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref3 !== void 0 ? _ref3 : context.abortOnUnmount;
|
|
500
|
-
const hook = (0,
|
|
477
|
+
const hook = (0, _tanstack_react_query.useSuspenseQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
501
478
|
queryKey,
|
|
502
479
|
queryFn: (queryFunctionContext) => {
|
|
503
|
-
const actualOpts =
|
|
480
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
504
481
|
return context.client.query(...getClientArgs(queryKey, actualOpts));
|
|
505
482
|
}
|
|
506
483
|
}), context.queryClient);
|
|
@@ -511,7 +488,7 @@ function createRootHooks(config) {
|
|
|
511
488
|
const { client, queryClient } = useContext();
|
|
512
489
|
const mutationKey = require_getQueryKey.getMutationKeyInternal(path);
|
|
513
490
|
const defaultOpts = queryClient.defaultMutationOptions(queryClient.getMutationDefaults(mutationKey));
|
|
514
|
-
const hook = (0,
|
|
491
|
+
const hook = (0, _tanstack_react_query.useMutation)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
515
492
|
mutationKey,
|
|
516
493
|
mutationFn: (input) => {
|
|
517
494
|
return client.mutation(...getClientArgs([path, { input }], opts));
|
|
@@ -545,14 +522,14 @@ function createRootHooks(config) {
|
|
|
545
522
|
/* istanbul ignore next -- @preserve */
|
|
546
523
|
function useSubscription(path, input, opts) {
|
|
547
524
|
var _opts$enabled2;
|
|
548
|
-
const enabled = (_opts$enabled2 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled2 !== void 0 ? _opts$enabled2 : input !==
|
|
549
|
-
const queryKey = (0,
|
|
525
|
+
const enabled = (_opts$enabled2 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled2 !== void 0 ? _opts$enabled2 : input !== _tanstack_react_query.skipToken;
|
|
526
|
+
const queryKey = (0, _tanstack_react_query.hashKey)(require_getQueryKey.getQueryKeyInternal(path, input, "any"));
|
|
550
527
|
const { client } = useContext();
|
|
551
528
|
const optsRef = react.useRef(opts);
|
|
552
529
|
react.useEffect(() => {
|
|
553
530
|
optsRef.current = opts;
|
|
554
531
|
});
|
|
555
|
-
const [trackedProps] = react.useState(new Set([]));
|
|
532
|
+
const [trackedProps] = react.useState(/* @__PURE__ */ new Set([]));
|
|
556
533
|
const addTrackedProp = react.useCallback((key) => {
|
|
557
534
|
trackedProps.add(key);
|
|
558
535
|
}, [trackedProps]);
|
|
@@ -571,15 +548,15 @@ function createRootHooks(config) {
|
|
|
571
548
|
var _currentSubscriptionR;
|
|
572
549
|
(_currentSubscriptionR = currentSubscriptionRef.current) === null || _currentSubscriptionR === void 0 || _currentSubscriptionR.unsubscribe();
|
|
573
550
|
if (!enabled) {
|
|
574
|
-
updateState(() =>
|
|
551
|
+
updateState(() => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, initialStateIdle), {}, { reset }));
|
|
575
552
|
return;
|
|
576
553
|
}
|
|
577
|
-
updateState(() =>
|
|
554
|
+
updateState(() => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, initialStateConnecting), {}, { reset }));
|
|
578
555
|
const subscription = client.subscription(path.join("."), input !== null && input !== void 0 ? input : void 0, {
|
|
579
556
|
onStarted: () => {
|
|
580
557
|
var _optsRef$current$onSt, _optsRef$current;
|
|
581
558
|
(_optsRef$current$onSt = (_optsRef$current = optsRef.current).onStarted) === null || _optsRef$current$onSt === void 0 || _optsRef$current$onSt.call(_optsRef$current);
|
|
582
|
-
updateState((prev) =>
|
|
559
|
+
updateState((prev) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
583
560
|
status: "pending",
|
|
584
561
|
error: null
|
|
585
562
|
}));
|
|
@@ -587,7 +564,7 @@ function createRootHooks(config) {
|
|
|
587
564
|
onData: (data) => {
|
|
588
565
|
var _optsRef$current$onDa, _optsRef$current2;
|
|
589
566
|
(_optsRef$current$onDa = (_optsRef$current2 = optsRef.current).onData) === null || _optsRef$current$onDa === void 0 || _optsRef$current$onDa.call(_optsRef$current2, data);
|
|
590
|
-
updateState((prev) =>
|
|
567
|
+
updateState((prev) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
591
568
|
status: "pending",
|
|
592
569
|
data,
|
|
593
570
|
error: null
|
|
@@ -596,7 +573,7 @@ function createRootHooks(config) {
|
|
|
596
573
|
onError: (error) => {
|
|
597
574
|
var _optsRef$current$onEr, _optsRef$current3;
|
|
598
575
|
(_optsRef$current$onEr = (_optsRef$current3 = optsRef.current).onError) === null || _optsRef$current$onEr === void 0 || _optsRef$current$onEr.call(_optsRef$current3, error);
|
|
599
|
-
updateState((prev) =>
|
|
576
|
+
updateState((prev) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
600
577
|
status: "error",
|
|
601
578
|
error
|
|
602
579
|
}));
|
|
@@ -604,12 +581,12 @@ function createRootHooks(config) {
|
|
|
604
581
|
onConnectionStateChange: (result) => {
|
|
605
582
|
updateState((prev) => {
|
|
606
583
|
switch (result.state) {
|
|
607
|
-
case "idle": return
|
|
584
|
+
case "idle": return require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
608
585
|
status: result.state,
|
|
609
586
|
error: null,
|
|
610
587
|
data: void 0
|
|
611
588
|
});
|
|
612
|
-
case "connecting": return
|
|
589
|
+
case "connecting": return require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
613
590
|
error: result.error,
|
|
614
591
|
status: result.state
|
|
615
592
|
});
|
|
@@ -620,7 +597,7 @@ function createRootHooks(config) {
|
|
|
620
597
|
onComplete: () => {
|
|
621
598
|
var _optsRef$current$onCo, _optsRef$current4;
|
|
622
599
|
(_optsRef$current$onCo = (_optsRef$current4 = optsRef.current).onComplete) === null || _optsRef$current$onCo === void 0 || _optsRef$current$onCo.call(_optsRef$current4);
|
|
623
|
-
updateState((prev) =>
|
|
600
|
+
updateState((prev) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, prev), {}, {
|
|
624
601
|
status: "idle",
|
|
625
602
|
error: null,
|
|
626
603
|
data: void 0
|
|
@@ -641,7 +618,7 @@ function createRootHooks(config) {
|
|
|
641
618
|
(_currentSubscriptionR2 = currentSubscriptionRef.current) === null || _currentSubscriptionR2 === void 0 || _currentSubscriptionR2.unsubscribe();
|
|
642
619
|
};
|
|
643
620
|
}, [reset]);
|
|
644
|
-
const resultRef = react.useRef(enabled ?
|
|
621
|
+
const resultRef = react.useRef(enabled ? require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, initialStateConnecting), {}, { reset }) : require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, initialStateIdle), {}, { reset }));
|
|
645
622
|
const [state, setState] = react.useState(trackResult(resultRef.current, addTrackedProp));
|
|
646
623
|
return state;
|
|
647
624
|
}
|
|
@@ -650,17 +627,17 @@ function createRootHooks(config) {
|
|
|
650
627
|
const { client, ssrState, prefetchInfiniteQuery, queryClient, abortOnUnmount } = useContext();
|
|
651
628
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "infinite");
|
|
652
629
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
653
|
-
const isInputSkipToken = input ===
|
|
654
|
-
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc5 = opts.trpc) === null || _opts$trpc5 === void 0 ? void 0 : _opts$trpc5.ssr) !== false && ((_opts$enabled3 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled3 !== void 0 ? _opts$enabled3 : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchInfiniteQuery(queryKey,
|
|
655
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey,
|
|
630
|
+
const isInputSkipToken = input === _tanstack_react_query.skipToken;
|
|
631
|
+
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc5 = opts.trpc) === null || _opts$trpc5 === void 0 ? void 0 : _opts$trpc5.ssr) !== false && ((_opts$enabled3 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled3 !== void 0 ? _opts$enabled3 : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchInfiniteQuery(queryKey, require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, defaultOpts), opts));
|
|
632
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, defaultOpts), opts));
|
|
656
633
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm4 = opts === null || opts === void 0 || (_opts$trpc6 = opts.trpc) === null || _opts$trpc6 === void 0 ? void 0 : _opts$trpc6.abortOnUnmount) !== null && _opts$trpc$abortOnUnm4 !== void 0 ? _opts$trpc$abortOnUnm4 : abortOnUnmount;
|
|
657
|
-
const hook = (0,
|
|
634
|
+
const hook = (0, _tanstack_react_query.useInfiniteQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, {
|
|
658
635
|
initialPageParam: (_opts$initialCursor = opts.initialCursor) !== null && _opts$initialCursor !== void 0 ? _opts$initialCursor : null,
|
|
659
636
|
persister: opts.persister,
|
|
660
637
|
queryKey,
|
|
661
638
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
662
639
|
var _queryFunctionContext;
|
|
663
|
-
const actualOpts =
|
|
640
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
664
641
|
return client.query(...getClientArgs(queryKey, actualOpts, {
|
|
665
642
|
pageParam: (_queryFunctionContext = queryFunctionContext.pageParam) !== null && _queryFunctionContext !== void 0 ? _queryFunctionContext : opts.initialCursor,
|
|
666
643
|
direction: queryFunctionContext.direction
|
|
@@ -675,15 +652,15 @@ function createRootHooks(config) {
|
|
|
675
652
|
const context = useContext();
|
|
676
653
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "infinite");
|
|
677
654
|
const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
|
|
678
|
-
const isInputSkipToken = input ===
|
|
679
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey,
|
|
655
|
+
const isInputSkipToken = input === _tanstack_react_query.skipToken;
|
|
656
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, defaultOpts), opts));
|
|
680
657
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm5 = opts === null || opts === void 0 || (_opts$trpc7 = opts.trpc) === null || _opts$trpc7 === void 0 ? void 0 : _opts$trpc7.abortOnUnmount) !== null && _opts$trpc$abortOnUnm5 !== void 0 ? _opts$trpc$abortOnUnm5 : context.abortOnUnmount;
|
|
681
|
-
(0,
|
|
658
|
+
(0, _tanstack_react_query.usePrefetchInfiniteQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
682
659
|
initialPageParam: (_opts$initialCursor2 = opts.initialCursor) !== null && _opts$initialCursor2 !== void 0 ? _opts$initialCursor2 : null,
|
|
683
660
|
queryKey,
|
|
684
661
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
685
662
|
var _queryFunctionContext2;
|
|
686
|
-
const actualOpts =
|
|
663
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) });
|
|
687
664
|
return context.client.query(...getClientArgs(queryKey, actualOpts, {
|
|
688
665
|
pageParam: (_queryFunctionContext2 = queryFunctionContext.pageParam) !== null && _queryFunctionContext2 !== void 0 ? _queryFunctionContext2 : opts.initialCursor,
|
|
689
666
|
direction: queryFunctionContext.direction
|
|
@@ -696,14 +673,14 @@ function createRootHooks(config) {
|
|
|
696
673
|
const context = useContext();
|
|
697
674
|
const queryKey = require_getQueryKey.getQueryKeyInternal(path, input, "infinite");
|
|
698
675
|
const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
|
|
699
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey,
|
|
676
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, defaultOpts), opts));
|
|
700
677
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm6 = opts === null || opts === void 0 || (_opts$trpc8 = opts.trpc) === null || _opts$trpc8 === void 0 ? void 0 : _opts$trpc8.abortOnUnmount) !== null && _opts$trpc$abortOnUnm6 !== void 0 ? _opts$trpc$abortOnUnm6 : context.abortOnUnmount;
|
|
701
|
-
const hook = (0,
|
|
678
|
+
const hook = (0, _tanstack_react_query.useSuspenseInfiniteQuery)(require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, opts), {}, {
|
|
702
679
|
initialPageParam: (_opts$initialCursor3 = opts.initialCursor) !== null && _opts$initialCursor3 !== void 0 ? _opts$initialCursor3 : null,
|
|
703
680
|
queryKey,
|
|
704
681
|
queryFn: (queryFunctionContext) => {
|
|
705
682
|
var _queryFunctionContext3;
|
|
706
|
-
const actualOpts =
|
|
683
|
+
const actualOpts = require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts), {}, { trpc: require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) });
|
|
707
684
|
return context.client.query(...getClientArgs(queryKey, actualOpts, {
|
|
708
685
|
pageParam: (_queryFunctionContext3 = queryFunctionContext.pageParam) !== null && _queryFunctionContext3 !== void 0 ? _queryFunctionContext3 : opts.initialCursor,
|
|
709
686
|
direction: queryFunctionContext.direction
|
|
@@ -715,23 +692,21 @@ function createRootHooks(config) {
|
|
|
715
692
|
}
|
|
716
693
|
const useQueries = (queriesCallback, options) => {
|
|
717
694
|
const { ssrState, queryClient, prefetchQuery, client } = useContext();
|
|
718
|
-
const
|
|
719
|
-
const queries = queriesCallback(proxy);
|
|
695
|
+
const queries = queriesCallback(createUseQueries(client));
|
|
720
696
|
if (typeof window === "undefined" && ssrState === "prepass") for (const query of queries) {
|
|
721
697
|
var _queryOption$trpc;
|
|
722
698
|
const queryOption = query;
|
|
723
699
|
if (((_queryOption$trpc = queryOption.trpc) === null || _queryOption$trpc === void 0 ? void 0 : _queryOption$trpc.ssr) !== false && !queryClient.getQueryCache().find({ queryKey: queryOption.queryKey })) prefetchQuery(queryOption.queryKey, queryOption);
|
|
724
700
|
}
|
|
725
|
-
return (0,
|
|
726
|
-
queries: queries.map((query) =>
|
|
701
|
+
return (0, _tanstack_react_query.useQueries)({
|
|
702
|
+
queries: queries.map((query) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, query), {}, { queryKey: query.queryKey })),
|
|
727
703
|
combine: options === null || options === void 0 ? void 0 : options.combine
|
|
728
704
|
}, queryClient);
|
|
729
705
|
};
|
|
730
706
|
const useSuspenseQueries = (queriesCallback) => {
|
|
731
707
|
const { queryClient, client } = useContext();
|
|
732
|
-
const
|
|
733
|
-
const
|
|
734
|
-
const hook = (0, __tanstack_react_query.useSuspenseQueries)({ queries: queries.map((query) => (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, query), {}, {
|
|
708
|
+
const queries = queriesCallback(createUseQueries(client));
|
|
709
|
+
const hook = (0, _tanstack_react_query.useSuspenseQueries)({ queries: queries.map((query) => require_getQueryKey._objectSpread2(require_getQueryKey._objectSpread2({}, query), {}, {
|
|
735
710
|
queryFn: query.queryFn,
|
|
736
711
|
queryKey: query.queryKey
|
|
737
712
|
})) }, queryClient);
|
|
@@ -754,7 +729,6 @@ function createRootHooks(config) {
|
|
|
754
729
|
useSuspenseInfiniteQuery
|
|
755
730
|
};
|
|
756
731
|
}
|
|
757
|
-
|
|
758
732
|
//#endregion
|
|
759
733
|
//#region src/shared/queryClient.ts
|
|
760
734
|
/**
|
|
@@ -762,73 +736,72 @@ function createRootHooks(config) {
|
|
|
762
736
|
*/
|
|
763
737
|
const getQueryClient = (config) => {
|
|
764
738
|
var _config$queryClient;
|
|
765
|
-
return (_config$queryClient = config.queryClient) !== null && _config$queryClient !== void 0 ? _config$queryClient : new
|
|
739
|
+
return (_config$queryClient = config.queryClient) !== null && _config$queryClient !== void 0 ? _config$queryClient : new _tanstack_react_query.QueryClient(config.queryClientConfig);
|
|
766
740
|
};
|
|
767
|
-
|
|
768
741
|
//#endregion
|
|
769
|
-
Object.defineProperty(exports,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
742
|
+
Object.defineProperty(exports, "TRPCContext", {
|
|
743
|
+
enumerable: true,
|
|
744
|
+
get: function() {
|
|
745
|
+
return TRPCContext;
|
|
746
|
+
}
|
|
774
747
|
});
|
|
775
|
-
Object.defineProperty(exports,
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
748
|
+
Object.defineProperty(exports, "contextProps", {
|
|
749
|
+
enumerable: true,
|
|
750
|
+
get: function() {
|
|
751
|
+
return contextProps;
|
|
752
|
+
}
|
|
780
753
|
});
|
|
781
|
-
Object.defineProperty(exports,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
754
|
+
Object.defineProperty(exports, "createQueryUtilsProxy", {
|
|
755
|
+
enumerable: true,
|
|
756
|
+
get: function() {
|
|
757
|
+
return createQueryUtilsProxy;
|
|
758
|
+
}
|
|
786
759
|
});
|
|
787
|
-
Object.defineProperty(exports,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
760
|
+
Object.defineProperty(exports, "createReactDecoration", {
|
|
761
|
+
enumerable: true,
|
|
762
|
+
get: function() {
|
|
763
|
+
return createReactDecoration;
|
|
764
|
+
}
|
|
792
765
|
});
|
|
793
|
-
Object.defineProperty(exports,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
766
|
+
Object.defineProperty(exports, "createReactQueryUtils", {
|
|
767
|
+
enumerable: true,
|
|
768
|
+
get: function() {
|
|
769
|
+
return createReactQueryUtils;
|
|
770
|
+
}
|
|
798
771
|
});
|
|
799
|
-
Object.defineProperty(exports,
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
772
|
+
Object.defineProperty(exports, "createRootHooks", {
|
|
773
|
+
enumerable: true,
|
|
774
|
+
get: function() {
|
|
775
|
+
return createRootHooks;
|
|
776
|
+
}
|
|
804
777
|
});
|
|
805
|
-
Object.defineProperty(exports,
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
778
|
+
Object.defineProperty(exports, "createUseQueries", {
|
|
779
|
+
enumerable: true,
|
|
780
|
+
get: function() {
|
|
781
|
+
return createUseQueries;
|
|
782
|
+
}
|
|
810
783
|
});
|
|
811
|
-
Object.defineProperty(exports,
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
784
|
+
Object.defineProperty(exports, "createUtilityFunctions", {
|
|
785
|
+
enumerable: true,
|
|
786
|
+
get: function() {
|
|
787
|
+
return createUtilityFunctions;
|
|
788
|
+
}
|
|
816
789
|
});
|
|
817
|
-
Object.defineProperty(exports,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
790
|
+
Object.defineProperty(exports, "getClientArgs", {
|
|
791
|
+
enumerable: true,
|
|
792
|
+
get: function() {
|
|
793
|
+
return getClientArgs;
|
|
794
|
+
}
|
|
822
795
|
});
|
|
823
|
-
Object.defineProperty(exports,
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
796
|
+
Object.defineProperty(exports, "getQueryClient", {
|
|
797
|
+
enumerable: true,
|
|
798
|
+
get: function() {
|
|
799
|
+
return getQueryClient;
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
Object.defineProperty(exports, "getQueryType", {
|
|
803
|
+
enumerable: true,
|
|
804
|
+
get: function() {
|
|
805
|
+
return getQueryType;
|
|
806
|
+
}
|
|
828
807
|
});
|
|
829
|
-
Object.defineProperty(exports, 'getQueryType', {
|
|
830
|
-
enumerable: true,
|
|
831
|
-
get: function () {
|
|
832
|
-
return getQueryType;
|
|
833
|
-
}
|
|
834
|
-
});
|