@trpc/react-query 11.0.0-next-beta.206 → 11.0.0-next-beta.216

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 (38) hide show
  1. package/dist/bundle-analysis.json +28 -28
  2. package/dist/createTRPCQueryUtils.js +16 -0
  3. package/dist/createTRPCQueryUtils.mjs +14 -0
  4. package/dist/createTRPCReact.js +58 -0
  5. package/dist/createTRPCReact.mjs +36 -0
  6. package/dist/index.js +10 -64
  7. package/dist/index.mjs +3 -40
  8. package/dist/internals/context.js +33 -0
  9. package/dist/internals/context.mjs +11 -0
  10. package/dist/internals/getClientArgs.js +16 -0
  11. package/dist/internals/getClientArgs.mjs +14 -0
  12. package/dist/internals/getQueryKey.js +57 -0
  13. package/dist/internals/getQueryKey.mjs +54 -0
  14. package/dist/internals/useHookResult.js +32 -0
  15. package/dist/internals/useHookResult.mjs +11 -0
  16. package/dist/server/index.js +2 -102
  17. package/dist/server/index.mjs +1 -103
  18. package/dist/server/ssgProxy.js +107 -0
  19. package/dist/server/ssgProxy.mjs +105 -0
  20. package/dist/{createHooksInternal-f77072af.js → shared/hooks/createHooksInternal.js} +28 -183
  21. package/dist/{createHooksInternal-0df35117.mjs → shared/hooks/createHooksInternal.mjs} +8 -158
  22. package/dist/shared/index.js +13 -15
  23. package/dist/shared/index.mjs +7 -7
  24. package/dist/shared/proxy/decorationProxy.js +31 -0
  25. package/dist/shared/proxy/decorationProxy.mjs +29 -0
  26. package/dist/shared/proxy/useQueriesProxy.js +25 -0
  27. package/dist/shared/proxy/useQueriesProxy.mjs +23 -0
  28. package/dist/shared/proxy/utilsProxy.js +89 -0
  29. package/dist/{utilsProxy-12979321.mjs → shared/proxy/utilsProxy.mjs} +3 -63
  30. package/dist/{queryClient-4d766c0c.mjs → shared/queryClient.mjs} +1 -1
  31. package/dist/utils/createUtilityFunctions.js +94 -0
  32. package/dist/utils/createUtilityFunctions.mjs +92 -0
  33. package/package.json +6 -6
  34. package/dist/createHooksInternal-3074c6c4.js +0 -470
  35. package/dist/queryClient-1c8d7d8a.js +0 -8
  36. package/dist/utilsProxy-13814792.js +0 -142
  37. package/dist/utilsProxy-4f6da312.js +0 -173
  38. /package/dist/{queryClient-358a9a75.js → shared/queryClient.js} +0 -0
@@ -1,13 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var core = require('@trpc/core');
4
3
  var reactQuery = require('@tanstack/react-query');
5
4
  var client = require('@trpc/client');
6
5
  var React = require('react');
7
- var utilsProxy = require('./utilsProxy-4f6da312.js');
6
+ var context = require('../../internals/context.js');
7
+ var getClientArgs = require('../../internals/getClientArgs.js');
8
+ var getQueryKey = require('../../internals/getQueryKey.js');
9
+ var useHookResult = require('../../internals/useHookResult.js');
10
+ var createUtilityFunctions = require('../../utils/createUtilityFunctions.js');
11
+ var useQueriesProxy = require('../proxy/useQueriesProxy.js');
8
12
 
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
13
+ function _interopNamespaceDefault(e) {
11
14
  var n = Object.create(null);
12
15
  if (e) {
13
16
  Object.keys(e).forEach(function (k) {
@@ -20,178 +23,24 @@ function _interopNamespace(e) {
20
23
  }
21
24
  });
22
25
  }
23
- n["default"] = e;
26
+ n.default = e;
24
27
  return Object.freeze(n);
25
28
  }
26
29
 
27
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
-
29
- /**
30
- * Create proxy for decorating procedures
31
- * @internal
32
- */ function createReactDecoration(name, hooks) {
33
- return core.createRecursiveProxy(({ path , args })=>{
34
- const pathCopy = [
35
- name,
36
- ...path
37
- ];
38
- // The last arg is for instance `.useMutation` or `.useQuery()`
39
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
- const lastArg = pathCopy.pop();
41
- if (lastArg === 'useMutation') {
42
- return hooks[lastArg](pathCopy, ...args);
43
- }
44
- if (lastArg === '_def') {
45
- return {
46
- path: pathCopy
47
- };
48
- }
49
- const [input, ...rest] = args;
50
- const opts = rest[0] || {};
51
- return hooks[lastArg](pathCopy, input, opts);
52
- });
53
- }
54
-
55
- /**
56
- * Create proxy for `useQueries` options
57
- * @internal
58
- */ function createUseQueries(client) {
59
- return core.createRecursiveProxy((opts)=>{
60
- const arrayPath = opts.path;
61
- const dotPath = arrayPath.join('.');
62
- const [input, _opts] = opts.args;
63
- const options = {
64
- queryKey: utilsProxy.getQueryKeyInternal(arrayPath, input, 'query'),
65
- queryFn: ()=>{
66
- return client.query(dotPath, input, _opts?.trpc);
67
- },
68
- ..._opts
69
- };
70
- return options;
71
- });
72
- }
73
-
74
- /**
75
- * @internal
76
- */ function getClientArgs(queryKey, opts, pageParam) {
77
- const path = queryKey[0];
78
- const input = queryKey[1]?.input;
79
- if (pageParam) input.cursor = pageParam;
80
- return [
81
- path.join('.'),
82
- input,
83
- opts?.trpc
84
- ];
85
- }
86
-
87
- /**
88
- * Makes a stable reference of the `trpc` prop
89
- */ function useHookResult(value) {
90
- const ref = React__namespace.useRef(value);
91
- ref.current.path = value.path;
92
- return ref.current;
93
- }
94
-
95
- /**
96
- * Creates a set of utility functions that can be used to interact with `react-query`
97
- * @param opts the `TRPCClient` and `QueryClient` to use
98
- * @returns a set of utility functions that can be used to interact with `react-query`
99
- * @internal
100
- */ function createUtilityFunctions(opts) {
101
- const { client: client$1 , queryClient } = opts;
102
- const untypedClient = client$1 instanceof client.TRPCUntypedClient ? client$1 : client.getUntypedClient(client$1);
103
- return {
104
- fetchQuery: (queryKey, opts)=>{
105
- return queryClient.fetchQuery({
106
- ...opts,
107
- queryKey,
108
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
109
- });
110
- },
111
- fetchInfiniteQuery: (queryKey, opts)=>{
112
- return queryClient.fetchInfiniteQuery({
113
- ...opts,
114
- queryKey,
115
- queryFn: ({ pageParam })=>{
116
- return untypedClient.query(...getClientArgs(queryKey, opts, pageParam));
117
- },
118
- initialPageParam: opts?.initialCursor ?? null
119
- });
120
- },
121
- prefetchQuery: (queryKey, opts)=>{
122
- return queryClient.prefetchQuery({
123
- ...opts,
124
- queryKey,
125
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
126
- });
127
- },
128
- prefetchInfiniteQuery: (queryKey, opts)=>{
129
- return queryClient.prefetchInfiniteQuery({
130
- ...opts,
131
- queryKey,
132
- queryFn: ({ pageParam })=>{
133
- return untypedClient.query(...getClientArgs(queryKey, opts, pageParam));
134
- },
135
- initialPageParam: opts?.initialCursor ?? null
136
- });
137
- },
138
- ensureQueryData: (queryKey, opts)=>{
139
- return queryClient.ensureQueryData({
140
- ...opts,
141
- queryKey,
142
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
143
- });
144
- },
145
- invalidateQueries: (queryKey, filters, options)=>{
146
- return queryClient.invalidateQueries({
147
- ...filters,
148
- queryKey
149
- }, options);
150
- },
151
- resetQueries: (queryKey, filters, options)=>{
152
- return queryClient.resetQueries({
153
- ...filters,
154
- queryKey
155
- }, options);
156
- },
157
- refetchQueries: (queryKey, filters, options)=>{
158
- return queryClient.refetchQueries({
159
- ...filters,
160
- queryKey
161
- }, options);
162
- },
163
- cancelQuery: (queryKey, options)=>{
164
- return queryClient.cancelQueries({
165
- queryKey
166
- }, options);
167
- },
168
- setQueryData: (queryKey, updater, options)=>{
169
- return queryClient.setQueryData(queryKey, updater, options);
170
- },
171
- getQueryData: (queryKey)=>{
172
- return queryClient.getQueryData(queryKey);
173
- },
174
- setInfiniteQueryData: (queryKey, updater, options)=>{
175
- return queryClient.setQueryData(queryKey, updater, options);
176
- },
177
- getInfiniteQueryData: (queryKey)=>{
178
- return queryClient.getQueryData(queryKey);
179
- }
180
- };
181
- }
30
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
182
31
 
183
32
  /**
184
33
  * @internal
185
34
  */ function createRootHooks(config) {
186
35
  const mutationSuccessOverride = config?.overrides?.useMutation?.onSuccess ?? ((options)=>options.originalFn());
187
- const Context = config?.context ?? utilsProxy.TRPCContext;
36
+ const Context = config?.context ?? context.TRPCContext;
188
37
  const createClient = (opts)=>{
189
38
  return client.createTRPCUntypedClient(opts);
190
39
  };
191
40
  const TRPCProvider = (props)=>{
192
41
  const { abortOnUnmount =false , client , queryClient , ssrContext } = props;
193
42
  const [ssrState, setSSRState] = React__namespace.useState(props.ssrState ?? false);
194
- const fns = React__namespace.useMemo(()=>createUtilityFunctions({
43
+ const fns = React__namespace.useMemo(()=>createUtilityFunctions.createUtilityFunctions({
195
44
  client,
196
45
  queryClient
197
46
  }), [
@@ -244,7 +93,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
244
93
  function useQuery(path, input, opts) {
245
94
  const context = useContext();
246
95
  const { abortOnUnmount , client , ssrState , queryClient , prefetchQuery } = context;
247
- const queryKey = utilsProxy.getQueryKeyInternal(path, input, 'query');
96
+ const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'query');
248
97
  const defaultOpts = queryClient.getQueryDefaults(queryKey);
249
98
  if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && (opts?.enabled ?? defaultOpts?.enabled) !== false && !queryClient.getQueryCache().find({
250
99
  queryKey
@@ -269,17 +118,17 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
269
118
  } : {}
270
119
  }
271
120
  };
272
- return client.query(...getClientArgs(queryKey, actualOpts));
121
+ return client.query(...getClientArgs.getClientArgs(queryKey, actualOpts));
273
122
  }
274
123
  }, queryClient);
275
- hook.trpc = useHookResult({
124
+ hook.trpc = useHookResult.useHookResult({
276
125
  path: path.join('.')
277
126
  });
278
127
  return hook;
279
128
  }
280
129
  function useSuspenseQuery(path, input, opts) {
281
130
  const context = useContext();
282
- const queryKey = utilsProxy.getQueryKeyInternal(path, input, 'query');
131
+ const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'query');
283
132
  const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? config?.abortOnUnmount ?? context.abortOnUnmount;
284
133
  const hook = reactQuery.useSuspenseQuery({
285
134
  ...opts,
@@ -292,10 +141,10 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
292
141
  } : {}
293
142
  }
294
143
  };
295
- return context.client.query(...getClientArgs(queryKey, actualOpts));
144
+ return context.client.query(...getClientArgs.getClientArgs(queryKey, actualOpts));
296
145
  }
297
146
  }, context.queryClient);
298
- hook.trpc = useHookResult({
147
+ hook.trpc = useHookResult.useHookResult({
299
148
  path: path.join('.')
300
149
  });
301
150
  return [
@@ -314,7 +163,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
314
163
  ...opts,
315
164
  mutationKey: mutationKey,
316
165
  mutationFn: (input)=>{
317
- return client.mutation(...getClientArgs([
166
+ return client.mutation(...getClientArgs.getClientArgs([
318
167
  path,
319
168
  {
320
169
  input
@@ -330,14 +179,14 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
330
179
  });
331
180
  }
332
181
  }, queryClient);
333
- hook.trpc = useHookResult({
182
+ hook.trpc = useHookResult.useHookResult({
334
183
  path: path.join('.')
335
184
  });
336
185
  return hook;
337
186
  }
338
187
  /* istanbul ignore next -- @preserve */ function useSubscription(path, input, opts) {
339
188
  const enabled = opts?.enabled ?? true;
340
- const queryKey = reactQuery.hashKey(utilsProxy.getQueryKeyInternal(path, input, 'any'));
189
+ const queryKey = reactQuery.hashKey(getQueryKey.getQueryKeyInternal(path, input, 'any'));
341
190
  const { client } = useContext();
342
191
  const optsRef = React__namespace.useRef(opts);
343
192
  optsRef.current = opts;
@@ -375,7 +224,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
375
224
  }
376
225
  function useInfiniteQuery(path, input, opts) {
377
226
  const { client , ssrState , prefetchInfiniteQuery , queryClient , abortOnUnmount , } = useContext();
378
- const queryKey = utilsProxy.getQueryKeyInternal(path, input, 'infinite');
227
+ const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'infinite');
379
228
  const defaultOpts = queryClient.getQueryDefaults(queryKey);
380
229
  if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && (opts?.enabled ?? defaultOpts?.enabled) !== false && !queryClient.getQueryCache().find({
381
230
  queryKey
@@ -406,17 +255,17 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
406
255
  } : {}
407
256
  }
408
257
  };
409
- return client.query(...getClientArgs(queryKey, actualOpts, queryFunctionContext.pageParam ?? opts.initialCursor));
258
+ return client.query(...getClientArgs.getClientArgs(queryKey, actualOpts, queryFunctionContext.pageParam ?? opts.initialCursor));
410
259
  }
411
260
  }, queryClient);
412
- hook.trpc = useHookResult({
261
+ hook.trpc = useHookResult.useHookResult({
413
262
  path: path.join('.')
414
263
  });
415
264
  return hook;
416
265
  }
417
266
  function useSuspenseInfiniteQuery(path, input, opts) {
418
267
  const context = useContext();
419
- const queryKey = utilsProxy.getQueryKeyInternal(path, input, 'infinite');
268
+ const queryKey = getQueryKey.getQueryKeyInternal(path, input, 'infinite');
420
269
  const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
421
270
  const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, {
422
271
  ...defaultOpts,
@@ -438,10 +287,10 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
438
287
  } : {}
439
288
  }
440
289
  };
441
- return context.client.query(...getClientArgs(queryKey, actualOpts, queryFunctionContext.pageParam ?? opts.initialCursor));
290
+ return context.client.query(...getClientArgs.getClientArgs(queryKey, actualOpts, queryFunctionContext.pageParam ?? opts.initialCursor));
442
291
  }
443
292
  }, context.queryClient);
444
- hook.trpc = useHookResult({
293
+ hook.trpc = useHookResult.useHookResult({
445
294
  path: path.join('.')
446
295
  });
447
296
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -452,7 +301,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
452
301
  }
453
302
  const useQueries = (queriesCallback)=>{
454
303
  const { ssrState , queryClient , prefetchQuery , client } = useContext();
455
- const proxy = createUseQueries(client);
304
+ const proxy = useQueriesProxy.createUseQueries(client);
456
305
  const queries = queriesCallback(proxy);
457
306
  if (typeof window === 'undefined' && ssrState === 'prepass') {
458
307
  for (const query of queries){
@@ -473,7 +322,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
473
322
  };
474
323
  const useSuspenseQueries = (queriesCallback)=>{
475
324
  const { queryClient , client } = useContext();
476
- const proxy = createUseQueries(client);
325
+ const proxy = useQueriesProxy.createUseQueries(client);
477
326
  const queries = queriesCallback(proxy);
478
327
  const hook = reactQuery.useSuspenseQueries({
479
328
  queries: queries.map((query)=>({
@@ -515,8 +364,4 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
515
364
  };
516
365
  }
517
366
 
518
- exports.createReactDecoration = createReactDecoration;
519
367
  exports.createRootHooks = createRootHooks;
520
- exports.createUseQueries = createUseQueries;
521
- exports.createUtilityFunctions = createUtilityFunctions;
522
- exports.getClientArgs = getClientArgs;
@@ -1,162 +1,12 @@
1
- import { createRecursiveProxy } from '@trpc/core';
2
1
  import { useQuery, useSuspenseQuery, useQueryClient, useMutation, hashKey, useInfiniteQuery, useSuspenseInfiniteQuery, useQueries, useSuspenseQueries } from '@tanstack/react-query';
3
- import { TRPCUntypedClient, getUntypedClient, createTRPCUntypedClient } from '@trpc/client';
2
+ import { createTRPCUntypedClient } from '@trpc/client';
4
3
  import * as React from 'react';
5
- import { b as getQueryKeyInternal, T as TRPCContext } from './utilsProxy-12979321.mjs';
6
-
7
- /**
8
- * Create proxy for decorating procedures
9
- * @internal
10
- */ function createReactDecoration(name, hooks) {
11
- return createRecursiveProxy(({ path , args })=>{
12
- const pathCopy = [
13
- name,
14
- ...path
15
- ];
16
- // The last arg is for instance `.useMutation` or `.useQuery()`
17
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
18
- const lastArg = pathCopy.pop();
19
- if (lastArg === 'useMutation') {
20
- return hooks[lastArg](pathCopy, ...args);
21
- }
22
- if (lastArg === '_def') {
23
- return {
24
- path: pathCopy
25
- };
26
- }
27
- const [input, ...rest] = args;
28
- const opts = rest[0] || {};
29
- return hooks[lastArg](pathCopy, input, opts);
30
- });
31
- }
32
-
33
- /**
34
- * Create proxy for `useQueries` options
35
- * @internal
36
- */ function createUseQueries(client) {
37
- return createRecursiveProxy((opts)=>{
38
- const arrayPath = opts.path;
39
- const dotPath = arrayPath.join('.');
40
- const [input, _opts] = opts.args;
41
- const options = {
42
- queryKey: getQueryKeyInternal(arrayPath, input, 'query'),
43
- queryFn: ()=>{
44
- return client.query(dotPath, input, _opts?.trpc);
45
- },
46
- ..._opts
47
- };
48
- return options;
49
- });
50
- }
51
-
52
- /**
53
- * @internal
54
- */ function getClientArgs(queryKey, opts, pageParam) {
55
- const path = queryKey[0];
56
- const input = queryKey[1]?.input;
57
- if (pageParam) input.cursor = pageParam;
58
- return [
59
- path.join('.'),
60
- input,
61
- opts?.trpc
62
- ];
63
- }
64
-
65
- /**
66
- * Makes a stable reference of the `trpc` prop
67
- */ function useHookResult(value) {
68
- const ref = React.useRef(value);
69
- ref.current.path = value.path;
70
- return ref.current;
71
- }
72
-
73
- /**
74
- * Creates a set of utility functions that can be used to interact with `react-query`
75
- * @param opts the `TRPCClient` and `QueryClient` to use
76
- * @returns a set of utility functions that can be used to interact with `react-query`
77
- * @internal
78
- */ function createUtilityFunctions(opts) {
79
- const { client , queryClient } = opts;
80
- const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
81
- return {
82
- fetchQuery: (queryKey, opts)=>{
83
- return queryClient.fetchQuery({
84
- ...opts,
85
- queryKey,
86
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
87
- });
88
- },
89
- fetchInfiniteQuery: (queryKey, opts)=>{
90
- return queryClient.fetchInfiniteQuery({
91
- ...opts,
92
- queryKey,
93
- queryFn: ({ pageParam })=>{
94
- return untypedClient.query(...getClientArgs(queryKey, opts, pageParam));
95
- },
96
- initialPageParam: opts?.initialCursor ?? null
97
- });
98
- },
99
- prefetchQuery: (queryKey, opts)=>{
100
- return queryClient.prefetchQuery({
101
- ...opts,
102
- queryKey,
103
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
104
- });
105
- },
106
- prefetchInfiniteQuery: (queryKey, opts)=>{
107
- return queryClient.prefetchInfiniteQuery({
108
- ...opts,
109
- queryKey,
110
- queryFn: ({ pageParam })=>{
111
- return untypedClient.query(...getClientArgs(queryKey, opts, pageParam));
112
- },
113
- initialPageParam: opts?.initialCursor ?? null
114
- });
115
- },
116
- ensureQueryData: (queryKey, opts)=>{
117
- return queryClient.ensureQueryData({
118
- ...opts,
119
- queryKey,
120
- queryFn: ()=>untypedClient.query(...getClientArgs(queryKey, opts))
121
- });
122
- },
123
- invalidateQueries: (queryKey, filters, options)=>{
124
- return queryClient.invalidateQueries({
125
- ...filters,
126
- queryKey
127
- }, options);
128
- },
129
- resetQueries: (queryKey, filters, options)=>{
130
- return queryClient.resetQueries({
131
- ...filters,
132
- queryKey
133
- }, options);
134
- },
135
- refetchQueries: (queryKey, filters, options)=>{
136
- return queryClient.refetchQueries({
137
- ...filters,
138
- queryKey
139
- }, options);
140
- },
141
- cancelQuery: (queryKey, options)=>{
142
- return queryClient.cancelQueries({
143
- queryKey
144
- }, options);
145
- },
146
- setQueryData: (queryKey, updater, options)=>{
147
- return queryClient.setQueryData(queryKey, updater, options);
148
- },
149
- getQueryData: (queryKey)=>{
150
- return queryClient.getQueryData(queryKey);
151
- },
152
- setInfiniteQueryData: (queryKey, updater, options)=>{
153
- return queryClient.setQueryData(queryKey, updater, options);
154
- },
155
- getInfiniteQueryData: (queryKey)=>{
156
- return queryClient.getQueryData(queryKey);
157
- }
158
- };
159
- }
4
+ import { TRPCContext } from '../../internals/context.mjs';
5
+ import { getClientArgs } from '../../internals/getClientArgs.mjs';
6
+ import { getQueryKeyInternal } from '../../internals/getQueryKey.mjs';
7
+ import { useHookResult } from '../../internals/useHookResult.mjs';
8
+ import { createUtilityFunctions } from '../../utils/createUtilityFunctions.mjs';
9
+ import { createUseQueries } from '../proxy/useQueriesProxy.mjs';
160
10
 
161
11
  /**
162
12
  * @internal
@@ -493,4 +343,4 @@ import { b as getQueryKeyInternal, T as TRPCContext } from './utilsProxy-1297932
493
343
  };
494
344
  }
495
345
 
496
- export { createReactDecoration as a, createUtilityFunctions as b, createRootHooks as c, createUseQueries as d, getClientArgs as g };
346
+ export { createRootHooks };
@@ -1,24 +1,22 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var decorationProxy = require('./proxy/decorationProxy.js');
4
+ var utilsProxy = require('./proxy/utilsProxy.js');
5
+ var useQueriesProxy = require('./proxy/useQueriesProxy.js');
6
+ var createHooksInternal = require('./hooks/createHooksInternal.js');
7
+ var queryClient = require('./queryClient.js');
8
+ var getClientArgs = require('../internals/getClientArgs.js');
9
+ var context = require('../internals/context.js');
4
10
 
5
- var createHooksInternal = require('../createHooksInternal-f77072af.js');
6
- var utilsProxy = require('../utilsProxy-4f6da312.js');
7
- var queryClient = require('../queryClient-358a9a75.js');
8
- require('@trpc/core');
9
- require('@tanstack/react-query');
10
- require('@trpc/client');
11
- require('react');
12
11
 
13
12
 
14
-
15
- exports.createReactDecoration = createHooksInternal.createReactDecoration;
16
- exports.createRootHooks = createHooksInternal.createRootHooks;
17
- exports.createUseQueries = createHooksInternal.createUseQueries;
18
- exports.getClientArgs = createHooksInternal.getClientArgs;
19
- exports.TRPCContext = utilsProxy.TRPCContext;
20
- exports.contextProps = utilsProxy.contextProps;
13
+ exports.createReactDecoration = decorationProxy.createReactDecoration;
21
14
  exports.createQueryUtilsProxy = utilsProxy.createQueryUtilsProxy;
22
15
  exports.createReactQueryUtils = utilsProxy.createReactQueryUtils;
23
16
  exports.getQueryType = utilsProxy.getQueryType;
17
+ exports.createUseQueries = useQueriesProxy.createUseQueries;
18
+ exports.createRootHooks = createHooksInternal.createRootHooks;
24
19
  exports.getQueryClient = queryClient.getQueryClient;
20
+ exports.getClientArgs = getClientArgs.getClientArgs;
21
+ exports.TRPCContext = context.TRPCContext;
22
+ exports.contextProps = context.contextProps;
@@ -1,7 +1,7 @@
1
- export { a as createReactDecoration, c as createRootHooks, d as createUseQueries, g as getClientArgs } from '../createHooksInternal-0df35117.mjs';
2
- export { T as TRPCContext, e as contextProps, a as createQueryUtilsProxy, c as createReactQueryUtils, d as getQueryType } from '../utilsProxy-12979321.mjs';
3
- export { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
4
- import '@trpc/core';
5
- import '@tanstack/react-query';
6
- import '@trpc/client';
7
- import 'react';
1
+ export { createReactDecoration } from './proxy/decorationProxy.mjs';
2
+ export { createQueryUtilsProxy, createReactQueryUtils, getQueryType } from './proxy/utilsProxy.mjs';
3
+ export { createUseQueries } from './proxy/useQueriesProxy.mjs';
4
+ export { createRootHooks } from './hooks/createHooksInternal.mjs';
5
+ export { getQueryClient } from './queryClient.mjs';
6
+ export { getClientArgs } from '../internals/getClientArgs.mjs';
7
+ export { TRPCContext, contextProps } from '../internals/context.mjs';
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var core = require('@trpc/core');
4
+
5
+ /**
6
+ * Create proxy for decorating procedures
7
+ * @internal
8
+ */ function createReactDecoration(name, hooks) {
9
+ return core.createRecursiveProxy(({ path , args })=>{
10
+ const pathCopy = [
11
+ name,
12
+ ...path
13
+ ];
14
+ // The last arg is for instance `.useMutation` or `.useQuery()`
15
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16
+ const lastArg = pathCopy.pop();
17
+ if (lastArg === 'useMutation') {
18
+ return hooks[lastArg](pathCopy, ...args);
19
+ }
20
+ if (lastArg === '_def') {
21
+ return {
22
+ path: pathCopy
23
+ };
24
+ }
25
+ const [input, ...rest] = args;
26
+ const opts = rest[0] || {};
27
+ return hooks[lastArg](pathCopy, input, opts);
28
+ });
29
+ }
30
+
31
+ exports.createReactDecoration = createReactDecoration;
@@ -0,0 +1,29 @@
1
+ import { createRecursiveProxy } from '@trpc/core';
2
+
3
+ /**
4
+ * Create proxy for decorating procedures
5
+ * @internal
6
+ */ function createReactDecoration(name, hooks) {
7
+ return createRecursiveProxy(({ path , args })=>{
8
+ const pathCopy = [
9
+ name,
10
+ ...path
11
+ ];
12
+ // The last arg is for instance `.useMutation` or `.useQuery()`
13
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
+ const lastArg = pathCopy.pop();
15
+ if (lastArg === 'useMutation') {
16
+ return hooks[lastArg](pathCopy, ...args);
17
+ }
18
+ if (lastArg === '_def') {
19
+ return {
20
+ path: pathCopy
21
+ };
22
+ }
23
+ const [input, ...rest] = args;
24
+ const opts = rest[0] || {};
25
+ return hooks[lastArg](pathCopy, input, opts);
26
+ });
27
+ }
28
+
29
+ export { createReactDecoration };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var core = require('@trpc/core');
4
+ var getQueryKey = require('../../internals/getQueryKey.js');
5
+
6
+ /**
7
+ * Create proxy for `useQueries` options
8
+ * @internal
9
+ */ function createUseQueries(client) {
10
+ return core.createRecursiveProxy((opts)=>{
11
+ const arrayPath = opts.path;
12
+ const dotPath = arrayPath.join('.');
13
+ const [input, _opts] = opts.args;
14
+ const options = {
15
+ queryKey: getQueryKey.getQueryKeyInternal(arrayPath, input, 'query'),
16
+ queryFn: ()=>{
17
+ return client.query(dotPath, input, _opts?.trpc);
18
+ },
19
+ ..._opts
20
+ };
21
+ return options;
22
+ });
23
+ }
24
+
25
+ exports.createUseQueries = createUseQueries;
@@ -0,0 +1,23 @@
1
+ import { createRecursiveProxy } from '@trpc/core';
2
+ import { getQueryKeyInternal } from '../../internals/getQueryKey.mjs';
3
+
4
+ /**
5
+ * Create proxy for `useQueries` options
6
+ * @internal
7
+ */ function createUseQueries(client) {
8
+ return createRecursiveProxy((opts)=>{
9
+ const arrayPath = opts.path;
10
+ const dotPath = arrayPath.join('.');
11
+ const [input, _opts] = opts.args;
12
+ const options = {
13
+ queryKey: getQueryKeyInternal(arrayPath, input, 'query'),
14
+ queryFn: ()=>{
15
+ return client.query(dotPath, input, _opts?.trpc);
16
+ },
17
+ ..._opts
18
+ };
19
+ return options;
20
+ });
21
+ }
22
+
23
+ export { createUseQueries };