@orpc/react 0.0.4 → 0.0.6

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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +4970 -39
  3. package/dist/index.js.map +1 -0
  4. package/dist/src/general-hooks.d.ts +8 -8
  5. package/dist/src/general-hooks.d.ts.map +1 -1
  6. package/dist/src/general-utils.d.ts +21 -21
  7. package/dist/src/general-utils.d.ts.map +1 -1
  8. package/dist/src/index.d.ts +1 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/procedure-hooks.d.ts +13 -13
  11. package/dist/src/procedure-hooks.d.ts.map +1 -1
  12. package/dist/src/procedure-utils.d.ts +19 -19
  13. package/dist/src/procedure-utils.d.ts.map +1 -1
  14. package/dist/src/react-hooks.d.ts +2 -2
  15. package/dist/src/react-hooks.d.ts.map +1 -1
  16. package/dist/src/react-utils.d.ts +2 -2
  17. package/dist/src/react-utils.d.ts.map +1 -1
  18. package/dist/src/react.d.ts.map +1 -1
  19. package/dist/src/tanstack-key.d.ts.map +1 -1
  20. package/dist/src/tanstack-query.d.ts.map +1 -1
  21. package/dist/src/types.d.ts.map +1 -1
  22. package/dist/src/use-queries/builder.d.ts +5 -5
  23. package/dist/src/use-queries/builder.d.ts.map +1 -1
  24. package/dist/src/use-queries/builders.d.ts +1 -1
  25. package/dist/src/use-queries/builders.d.ts.map +1 -1
  26. package/dist/src/use-queries/hook.d.ts.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +11 -14
  29. package/src/general-hooks.test.tsx +8 -8
  30. package/src/general-hooks.ts +13 -12
  31. package/src/general-utils.test-d.ts +7 -7
  32. package/src/general-utils.test.tsx +25 -25
  33. package/src/general-utils.ts +82 -86
  34. package/src/index.ts +1 -1
  35. package/src/orpc-path.ts +1 -1
  36. package/src/procedure-hooks.test-d.ts +6 -6
  37. package/src/procedure-hooks.test.tsx +1 -1
  38. package/src/procedure-hooks.ts +41 -41
  39. package/src/procedure-utils.test-d.ts +9 -9
  40. package/src/procedure-utils.test.tsx +13 -13
  41. package/src/procedure-utils.ts +65 -68
  42. package/src/react-hooks.ts +13 -21
  43. package/src/react-utils.ts +14 -25
  44. package/src/react.test-d.ts +6 -6
  45. package/src/react.test.tsx +8 -8
  46. package/src/react.tsx +5 -4
  47. package/src/tanstack-key.ts +9 -9
  48. package/src/tanstack-query.ts +2 -2
  49. package/src/types.ts +1 -1
  50. package/src/use-queries/builder.test-d.ts +2 -2
  51. package/src/use-queries/builder.ts +9 -10
  52. package/src/use-queries/builders.ts +11 -11
  53. package/src/use-queries/hook.test-d.ts +1 -1
  54. package/src/use-queries/hook.test.tsx +2 -2
  55. package/src/use-queries/hook.ts +8 -8
@@ -1,8 +1,9 @@
1
1
  import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract'
2
+ import type { SchemaInputForInfiniteQuery } from './types'
2
3
  import {
4
+ get,
3
5
  type PartialOnUndefinedDeep,
4
6
  type SetOptional,
5
- get,
6
7
  } from '@orpc/shared'
7
8
  import {
8
9
  type DefaultError,
@@ -10,58 +11,57 @@ import {
10
11
  type FetchQueryOptions,
11
12
  type InfiniteData,
12
13
  type QueryKey,
14
+ useInfiniteQuery,
13
15
  type UseInfiniteQueryOptions,
14
16
  type UseInfiniteQueryResult,
17
+ useMutation,
15
18
  type UseMutationOptions,
16
19
  type UseMutationResult,
20
+ usePrefetchInfiniteQuery,
21
+ usePrefetchQuery,
22
+ useQuery,
17
23
  type UseQueryOptions,
18
24
  type UseQueryResult,
25
+ useSuspenseInfiniteQuery,
19
26
  type UseSuspenseInfiniteQueryOptions,
20
27
  type UseSuspenseInfiniteQueryResult,
28
+ useSuspenseQuery,
21
29
  type UseSuspenseQueryOptions,
22
30
  type UseSuspenseQueryResult,
23
- useInfiniteQuery,
24
- useMutation,
25
- usePrefetchInfiniteQuery,
26
- usePrefetchQuery,
27
- useQuery,
28
- useSuspenseInfiniteQuery,
29
- useSuspenseQuery,
30
31
  } from '@tanstack/react-query'
31
32
  import { orpcPathSymbol } from './orpc-path'
32
33
  import { type ORPCContext, useORPCContext } from './react-context'
33
34
  import { getMutationKeyFromPath, getQueryKeyFromPath } from './tanstack-key'
34
- import type { SchemaInputForInfiniteQuery } from './types'
35
35
 
36
36
  export interface ProcedureHooks<
37
37
  TInputSchema extends Schema,
38
38
  TOutputSchema extends Schema,
39
- THandlerOutput extends SchemaOutput<TOutputSchema>,
39
+ TFuncOutput extends SchemaOutput<TOutputSchema>,
40
40
  > {
41
- useQuery<USelectData = SchemaOutput<TOutputSchema, THandlerOutput>>(
41
+ useQuery: <USelectData = SchemaOutput<TOutputSchema, TFuncOutput>>(
42
42
  input: SchemaInput<TInputSchema>,
43
43
  options?: SetOptional<
44
44
  UseQueryOptions<
45
- SchemaOutput<TOutputSchema, THandlerOutput>,
45
+ SchemaOutput<TOutputSchema, TFuncOutput>,
46
46
  DefaultError,
47
47
  USelectData
48
48
  >,
49
49
  'queryFn' | 'queryKey'
50
50
  >,
51
- ): UseQueryResult<USelectData>
52
- useInfiniteQuery<
51
+ ) => UseQueryResult<USelectData>
52
+ useInfiniteQuery: <
53
53
  USelectData = InfiniteData<
54
- SchemaOutput<TOutputSchema, THandlerOutput>,
54
+ SchemaOutput<TOutputSchema, TFuncOutput>,
55
55
  SchemaInput<TInputSchema>['cursor']
56
56
  >,
57
57
  >(
58
58
  options: PartialOnUndefinedDeep<
59
59
  SetOptional<
60
60
  UseInfiniteQueryOptions<
61
- SchemaOutput<TOutputSchema, THandlerOutput>,
61
+ SchemaOutput<TOutputSchema, TFuncOutput>,
62
62
  DefaultError,
63
63
  USelectData,
64
- SchemaOutput<TOutputSchema, THandlerOutput>,
64
+ SchemaOutput<TOutputSchema, TFuncOutput>,
65
65
  QueryKey,
66
66
  SchemaInput<TInputSchema>['cursor']
67
67
  >,
@@ -70,32 +70,32 @@ export interface ProcedureHooks<
70
70
  input: SchemaInputForInfiniteQuery<TInputSchema>
71
71
  }
72
72
  >,
73
- ): UseInfiniteQueryResult<USelectData>
73
+ ) => UseInfiniteQueryResult<USelectData>
74
74
 
75
- useSuspenseQuery<USelectData = SchemaOutput<TOutputSchema, THandlerOutput>>(
75
+ useSuspenseQuery: <USelectData = SchemaOutput<TOutputSchema, TFuncOutput>>(
76
76
  input: SchemaInput<TInputSchema>,
77
77
  options?: SetOptional<
78
78
  UseSuspenseQueryOptions<
79
- SchemaOutput<TOutputSchema, THandlerOutput>,
79
+ SchemaOutput<TOutputSchema, TFuncOutput>,
80
80
  DefaultError,
81
81
  USelectData
82
82
  >,
83
83
  'queryFn' | 'queryKey'
84
84
  >,
85
- ): UseSuspenseQueryResult<USelectData>
86
- useSuspenseInfiniteQuery<
85
+ ) => UseSuspenseQueryResult<USelectData>
86
+ useSuspenseInfiniteQuery: <
87
87
  USelectData = InfiniteData<
88
- SchemaOutput<TOutputSchema, THandlerOutput>,
88
+ SchemaOutput<TOutputSchema, TFuncOutput>,
89
89
  SchemaInput<TInputSchema>['cursor']
90
90
  >,
91
91
  >(
92
92
  options: PartialOnUndefinedDeep<
93
93
  SetOptional<
94
94
  UseSuspenseInfiniteQueryOptions<
95
- SchemaOutput<TOutputSchema, THandlerOutput>,
95
+ SchemaOutput<TOutputSchema, TFuncOutput>,
96
96
  DefaultError,
97
97
  USelectData,
98
- SchemaOutput<TOutputSchema, THandlerOutput>,
98
+ SchemaOutput<TOutputSchema, TFuncOutput>,
99
99
  QueryKey,
100
100
  SchemaInput<TInputSchema>['cursor']
101
101
  >,
@@ -104,19 +104,19 @@ export interface ProcedureHooks<
104
104
  input: SchemaInputForInfiniteQuery<TInputSchema>
105
105
  }
106
106
  >,
107
- ): UseSuspenseInfiniteQueryResult<USelectData>
107
+ ) => UseSuspenseInfiniteQueryResult<USelectData>
108
108
 
109
- usePrefetchQuery(
109
+ usePrefetchQuery: (
110
110
  input: SchemaInput<TInputSchema>,
111
- options?: FetchQueryOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
112
- ): void
113
- usePrefetchInfiniteQuery(
111
+ options?: FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>,
112
+ ) => void
113
+ usePrefetchInfiniteQuery: (
114
114
  options: PartialOnUndefinedDeep<
115
115
  SetOptional<
116
116
  FetchInfiniteQueryOptions<
117
- SchemaOutput<TOutputSchema, THandlerOutput>,
117
+ SchemaOutput<TOutputSchema, TFuncOutput>,
118
118
  DefaultError,
119
- SchemaOutput<TOutputSchema, THandlerOutput>,
119
+ SchemaOutput<TOutputSchema, TFuncOutput>,
120
120
  QueryKey,
121
121
  SchemaInput<TInputSchema>['cursor']
122
122
  >,
@@ -125,19 +125,19 @@ export interface ProcedureHooks<
125
125
  input: SchemaInputForInfiniteQuery<TInputSchema>
126
126
  }
127
127
  >,
128
- ): void
128
+ ) => void
129
129
 
130
- useMutation(
130
+ useMutation: (
131
131
  options?: SetOptional<
132
132
  UseMutationOptions<
133
- SchemaOutput<TOutputSchema, THandlerOutput>,
133
+ SchemaOutput<TOutputSchema, TFuncOutput>,
134
134
  DefaultError,
135
135
  SchemaInput<TInputSchema>
136
136
  >,
137
137
  'mutationFn' | 'mutationKey'
138
138
  >,
139
- ): UseMutationResult<
140
- SchemaOutput<TOutputSchema, THandlerOutput>,
139
+ ) => UseMutationResult<
140
+ SchemaOutput<TOutputSchema, TFuncOutput>,
141
141
  DefaultError,
142
142
  SchemaInput<TInputSchema>
143
143
  >
@@ -157,11 +157,11 @@ export interface CreateProcedureHooksOptions {
157
157
  export function createProcedureHooks<
158
158
  TInputSchema extends Schema = undefined,
159
159
  TOutputSchema extends Schema = undefined,
160
- THandlerOutput extends
161
- SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
160
+ TFuncOutput extends
161
+ SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
162
162
  >(
163
163
  options: CreateProcedureHooksOptions,
164
- ): ProcedureHooks<TInputSchema, TOutputSchema, THandlerOutput> {
164
+ ): ProcedureHooks<TInputSchema, TOutputSchema, TFuncOutput> {
165
165
  return {
166
166
  [orpcPathSymbol as any]: options.path,
167
167
 
@@ -261,7 +261,7 @@ export function createProcedureHooks<
261
261
  return useMutation(
262
262
  {
263
263
  mutationKey: getMutationKeyFromPath(options.path),
264
- mutationFn: (input) => client(input),
264
+ mutationFn: input => client(input),
265
265
  ...options_,
266
266
  },
267
267
  context.queryClient,
@@ -233,9 +233,9 @@ describe('getInfiniteQueryData', () => {
233
233
  expectTypeOf(data).toEqualTypeOf<
234
234
  | undefined
235
235
  | InfiniteData<
236
- SchemaOutput<typeof UserListOutputSchema>,
236
+ SchemaOutput<typeof UserListOutputSchema>,
237
237
  number | undefined
238
- >
238
+ >
239
239
  >()
240
240
  })
241
241
  })
@@ -377,11 +377,11 @@ describe('getInfiniteQueryState', () => {
377
377
  expectTypeOf(data).toEqualTypeOf<
378
378
  | undefined
379
379
  | QueryState<
380
- InfiniteData<
381
- SchemaOutput<typeof UserListOutputSchema>,
380
+ InfiniteData<
381
+ SchemaOutput<typeof UserListOutputSchema>,
382
382
  number | undefined
383
- >
384
383
  >
384
+ >
385
385
  >()
386
386
  })
387
387
  })
@@ -444,9 +444,9 @@ describe('setInfiniteQueryData', () => {
444
444
  expectTypeOf(data).toEqualTypeOf<
445
445
  | undefined
446
446
  | InfiniteData<
447
- SchemaOutput<typeof UserListOutputSchema>,
447
+ SchemaOutput<typeof UserListOutputSchema>,
448
448
  number | undefined
449
- >
449
+ >
450
450
  >()
451
451
 
452
452
  return {
@@ -458,9 +458,9 @@ describe('setInfiniteQueryData', () => {
458
458
  expectTypeOf(data).toEqualTypeOf<
459
459
  | undefined
460
460
  | InfiniteData<
461
- SchemaOutput<typeof UserListOutputSchema>,
461
+ SchemaOutput<typeof UserListOutputSchema>,
462
462
  number | undefined
463
- >
463
+ >
464
464
  >()
465
465
  })
466
466
 
@@ -9,7 +9,7 @@ describe('fetchQuery', () => {
9
9
  const utils = createProcedureUtils({
10
10
  client: orpcClient.user.find,
11
11
  path: ['user', 'find'],
12
- queryClient: queryClient,
12
+ queryClient,
13
13
  })
14
14
 
15
15
  it('on success', async () => {
@@ -40,7 +40,7 @@ describe('fetchInfiniteQuery', () => {
40
40
  const utils = createProcedureUtils({
41
41
  client: orpcClient.user.list,
42
42
  path: ['user', 'list'],
43
- queryClient: queryClient,
43
+ queryClient,
44
44
  })
45
45
 
46
46
  it('on success', async () => {
@@ -76,7 +76,7 @@ describe('prefetchQuery', () => {
76
76
  const utils = createProcedureUtils({
77
77
  client: orpcClient.user.find,
78
78
  path: ['user', 'find'],
79
- queryClient: queryClient,
79
+ queryClient,
80
80
  })
81
81
 
82
82
  it('on success', async () => {
@@ -109,7 +109,7 @@ describe('prefetchInfiniteQuery', () => {
109
109
  const utils = createProcedureUtils({
110
110
  client: orpcClient.user.list,
111
111
  path: ['user', 'list'],
112
- queryClient: queryClient,
112
+ queryClient,
113
113
  })
114
114
 
115
115
  it('on success', async () => {
@@ -144,7 +144,7 @@ describe('ensureQueryData', () => {
144
144
  const utils = createProcedureUtils({
145
145
  client: orpcClient.user.find,
146
146
  path: ['user', 'find'],
147
- queryClient: queryClient,
147
+ queryClient,
148
148
  })
149
149
 
150
150
  it('on success', async () => {
@@ -175,7 +175,7 @@ describe('ensureInfiniteQuery', () => {
175
175
  const utils = createProcedureUtils({
176
176
  client: orpcClient.user.list,
177
177
  path: ['user', 'list'],
178
- queryClient: queryClient,
178
+ queryClient,
179
179
  })
180
180
 
181
181
  it('on success', async () => {
@@ -211,7 +211,7 @@ describe('getQueryData', () => {
211
211
  const utils = createProcedureUtils({
212
212
  client: orpcClient.user.find,
213
213
  path: ['user', 'find'],
214
- queryClient: queryClient,
214
+ queryClient,
215
215
  })
216
216
 
217
217
  it('on success', async () => {
@@ -225,7 +225,7 @@ describe('getInfiniteQueryData', () => {
225
225
  const utils = createProcedureUtils({
226
226
  client: orpcClient.user.list,
227
227
  path: ['user', 'list'],
228
- queryClient: queryClient,
228
+ queryClient,
229
229
  })
230
230
 
231
231
  it('on success', async () => {
@@ -239,7 +239,7 @@ describe('getQueryState', () => {
239
239
  const utils = createProcedureUtils({
240
240
  client: orpcClient.user.find,
241
241
  path: ['user', 'find'],
242
- queryClient: queryClient,
242
+ queryClient,
243
243
  })
244
244
 
245
245
  it('on success', async () => {
@@ -256,7 +256,7 @@ describe('getInfiniteQueryState', () => {
256
256
  const utils = createProcedureUtils({
257
257
  client: orpcClient.user.list,
258
258
  path: ['user', 'list'],
259
- queryClient: queryClient,
259
+ queryClient,
260
260
  })
261
261
 
262
262
  it('on success', async () => {
@@ -273,7 +273,7 @@ describe('setQueryData', () => {
273
273
  const utils = createProcedureUtils({
274
274
  client: orpcClient.user.find,
275
275
  path: ['user', 'find'],
276
- queryClient: queryClient,
276
+ queryClient,
277
277
  })
278
278
 
279
279
  it('on success', async () => {
@@ -299,11 +299,11 @@ describe('setQueryData', () => {
299
299
  })
300
300
  })
301
301
 
302
- describe('getInfiniteQueryData', () => {
302
+ describe('getInfiniteQueryData 2', () => {
303
303
  const utils = createProcedureUtils({
304
304
  client: orpcClient.user.list,
305
305
  path: ['user', 'list'],
306
- queryClient: queryClient,
306
+ queryClient,
307
307
  })
308
308
 
309
309
  it('on success', async () => {
@@ -14,28 +14,28 @@ import type {
14
14
  SetDataOptions,
15
15
  Updater,
16
16
  } from '@tanstack/react-query'
17
- import { getQueryKeyFromPath } from './tanstack-key'
18
17
  import type { SchemaInputForInfiniteQuery } from './types'
18
+ import { getQueryKeyFromPath } from './tanstack-key'
19
19
 
20
20
  export interface ProcedureUtils<
21
21
  TInputSchema extends Schema,
22
22
  TOutputSchema extends Schema,
23
- THandlerOutput extends SchemaOutput<TOutputSchema>,
23
+ TFuncOutput extends SchemaOutput<TOutputSchema>,
24
24
  > {
25
- fetchQuery(
25
+ fetchQuery: (
26
26
  input: SchemaInput<TInputSchema>,
27
27
  options?: SetOptional<
28
- FetchQueryOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
28
+ FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>,
29
29
  'queryKey' | 'queryFn'
30
30
  >,
31
- ): Promise<SchemaOutput<TOutputSchema, THandlerOutput>>
32
- fetchInfiniteQuery(
31
+ ) => Promise<SchemaOutput<TOutputSchema, TFuncOutput>>
32
+ fetchInfiniteQuery: (
33
33
  options: PartialOnUndefinedDeep<
34
34
  SetOptional<
35
35
  FetchInfiniteQueryOptions<
36
- SchemaOutput<TOutputSchema, THandlerOutput>,
36
+ SchemaOutput<TOutputSchema, TFuncOutput>,
37
37
  DefaultError,
38
- SchemaOutput<TOutputSchema, THandlerOutput>,
38
+ SchemaOutput<TOutputSchema, TFuncOutput>,
39
39
  QueryKey,
40
40
  SchemaInput<TInputSchema>['cursor']
41
41
  >,
@@ -44,27 +44,27 @@ export interface ProcedureUtils<
44
44
  input: SchemaInputForInfiniteQuery<TInputSchema>
45
45
  }
46
46
  >,
47
- ): Promise<
47
+ ) => Promise<
48
48
  InfiniteData<
49
- SchemaOutput<TOutputSchema, THandlerOutput>,
49
+ SchemaOutput<TOutputSchema, TFuncOutput>,
50
50
  SchemaInput<TInputSchema>['cursor']
51
51
  >
52
52
  >
53
53
 
54
- prefetchQuery(
54
+ prefetchQuery: (
55
55
  input: SchemaInput<TInputSchema>,
56
56
  options?: SetOptional<
57
- FetchQueryOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
57
+ FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>,
58
58
  'queryKey' | 'queryFn'
59
59
  >,
60
- ): Promise<void>
61
- prefetchInfiniteQuery(
60
+ ) => Promise<void>
61
+ prefetchInfiniteQuery: (
62
62
  options: PartialOnUndefinedDeep<
63
63
  SetOptional<
64
64
  FetchInfiniteQueryOptions<
65
- SchemaOutput<TOutputSchema, THandlerOutput>,
65
+ SchemaOutput<TOutputSchema, TFuncOutput>,
66
66
  DefaultError,
67
- SchemaOutput<TOutputSchema, THandlerOutput>,
67
+ SchemaOutput<TOutputSchema, TFuncOutput>,
68
68
  QueryKey,
69
69
  SchemaInput<TInputSchema>['cursor']
70
70
  >,
@@ -73,34 +73,33 @@ export interface ProcedureUtils<
73
73
  input: SchemaInputForInfiniteQuery<TInputSchema>
74
74
  }
75
75
  >,
76
- ): Promise<void>
76
+ ) => Promise<void>
77
77
 
78
- getQueryData(
78
+ getQueryData: (
79
79
  input: SchemaInput<TInputSchema>,
80
- ): SchemaOutput<TOutputSchema, THandlerOutput> | undefined
81
- getInfiniteQueryData(
80
+ ) => SchemaOutput<TOutputSchema, TFuncOutput> | undefined
81
+ getInfiniteQueryData: (
82
82
  input: SchemaInputForInfiniteQuery<TInputSchema>,
83
- ):
84
- | InfiniteData<
85
- SchemaOutput<TOutputSchema, THandlerOutput>,
86
- SchemaInput<TInputSchema>['cursor']
87
- >
88
- | undefined
83
+ ) => | InfiniteData<
84
+ SchemaOutput<TOutputSchema, TFuncOutput>,
85
+ SchemaInput<TInputSchema>['cursor']
86
+ >
87
+ | undefined
89
88
 
90
- ensureQueryData(
89
+ ensureQueryData: (
91
90
  input: SchemaInput<TInputSchema>,
92
91
  options?: SetOptional<
93
- EnsureQueryDataOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
92
+ EnsureQueryDataOptions<SchemaOutput<TOutputSchema, TFuncOutput>>,
94
93
  'queryFn' | 'queryKey'
95
94
  >,
96
- ): Promise<SchemaOutput<TOutputSchema, THandlerOutput>>
97
- ensureInfiniteQueryData(
95
+ ) => Promise<SchemaOutput<TOutputSchema, TFuncOutput>>
96
+ ensureInfiniteQueryData: (
98
97
  options: PartialOnUndefinedDeep<
99
98
  SetOptional<
100
99
  EnsureInfiniteQueryDataOptions<
101
- SchemaOutput<TOutputSchema, THandlerOutput>,
100
+ SchemaOutput<TOutputSchema, TFuncOutput>,
102
101
  DefaultError,
103
- SchemaOutput<TOutputSchema, THandlerOutput>,
102
+ SchemaOutput<TOutputSchema, TFuncOutput>,
104
103
  QueryKey,
105
104
  SchemaInput<TInputSchema>['cursor']
106
105
  >,
@@ -109,65 +108,63 @@ export interface ProcedureUtils<
109
108
  input: SchemaInputForInfiniteQuery<TInputSchema>
110
109
  }
111
110
  >,
112
- ): Promise<
111
+ ) => Promise<
113
112
  InfiniteData<
114
- SchemaOutput<TOutputSchema, THandlerOutput>,
113
+ SchemaOutput<TOutputSchema, TFuncOutput>,
115
114
  SchemaInput<TInputSchema>['cursor']
116
115
  >
117
116
  >
118
117
 
119
- getQueryState(
118
+ getQueryState: (
120
119
  input: SchemaInput<TInputSchema>,
121
- ): QueryState<SchemaOutput<TOutputSchema, THandlerOutput>> | undefined
122
- getInfiniteQueryState(
120
+ ) => QueryState<SchemaOutput<TOutputSchema, TFuncOutput>> | undefined
121
+ getInfiniteQueryState: (
123
122
  input: SchemaInputForInfiniteQuery<TInputSchema>,
124
- ):
125
- | QueryState<
126
- InfiniteData<
127
- SchemaOutput<TOutputSchema, THandlerOutput>,
128
- SchemaInput<TInputSchema>['cursor']
129
- >
130
- >
131
- | undefined
123
+ ) => | QueryState<
124
+ InfiniteData<
125
+ SchemaOutput<TOutputSchema, TFuncOutput>,
126
+ SchemaInput<TInputSchema>['cursor']
127
+ >
128
+ >
129
+ | undefined
132
130
 
133
- setQueryData(
131
+ setQueryData: (
134
132
  input: SchemaInput<TInputSchema>,
135
133
  updater: Updater<
136
- SchemaOutput<TOutputSchema, THandlerOutput> | undefined,
137
- SchemaOutput<TOutputSchema, THandlerOutput> | undefined
134
+ SchemaOutput<TOutputSchema, TFuncOutput> | undefined,
135
+ SchemaOutput<TOutputSchema, TFuncOutput> | undefined
138
136
  >,
139
137
  options?: SetDataOptions,
140
- ): SchemaOutput<TOutputSchema, THandlerOutput> | undefined
141
- setInfiniteQueryData(
138
+ ) => SchemaOutput<TOutputSchema, TFuncOutput> | undefined
139
+ setInfiniteQueryData: (
142
140
  input: SchemaInputForInfiniteQuery<TInputSchema>,
143
141
  updater: Updater<
144
142
  | InfiniteData<
145
- SchemaOutput<TOutputSchema, THandlerOutput>,
146
- SchemaInput<TInputSchema>['cursor']
147
- >
143
+ SchemaOutput<TOutputSchema, TFuncOutput>,
144
+ SchemaInput<TInputSchema>['cursor']
145
+ >
148
146
  | undefined,
149
147
  | InfiniteData<
150
- SchemaOutput<TOutputSchema, THandlerOutput>,
151
- SchemaInput<TInputSchema>['cursor']
152
- >
148
+ SchemaOutput<TOutputSchema, TFuncOutput>,
149
+ SchemaInput<TInputSchema>['cursor']
150
+ >
153
151
  | undefined
154
152
  >,
155
153
  options?: SetDataOptions,
156
- ):
157
- | InfiniteData<
158
- SchemaOutput<TOutputSchema, THandlerOutput>,
159
- SchemaInput<TInputSchema>['cursor']
160
- >
161
- | undefined
154
+ ) => | InfiniteData<
155
+ SchemaOutput<TOutputSchema, TFuncOutput>,
156
+ SchemaInput<TInputSchema>['cursor']
157
+ >
158
+ | undefined
162
159
  }
163
160
 
164
161
  export interface CreateProcedureUtilsOptions<
165
162
  TInputSchema extends Schema = undefined,
166
163
  TOutputSchema extends Schema = undefined,
167
- THandlerOutput extends
168
- SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
164
+ TFuncOutput extends
165
+ SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
169
166
  > {
170
- client: ProcedureClient<TInputSchema, TOutputSchema, THandlerOutput>
167
+ client: ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput>
171
168
  queryClient: QueryClient
172
169
 
173
170
  /**
@@ -179,14 +176,14 @@ export interface CreateProcedureUtilsOptions<
179
176
  export function createProcedureUtils<
180
177
  TInputSchema extends Schema,
181
178
  TOutputSchema extends Schema,
182
- THandlerOutput extends SchemaOutput<TOutputSchema>,
179
+ TFuncOutput extends SchemaOutput<TOutputSchema>,
183
180
  >(
184
181
  options: CreateProcedureUtilsOptions<
185
182
  TInputSchema,
186
183
  TOutputSchema,
187
- THandlerOutput
184
+ TFuncOutput
188
185
  >,
189
- ): ProcedureUtils<TInputSchema, TOutputSchema, THandlerOutput> {
186
+ ): ProcedureUtils<TInputSchema, TOutputSchema, TFuncOutput> {
190
187
  return {
191
188
  fetchQuery(input, options_) {
192
189
  return options.queryClient.fetchQuery({
@@ -4,33 +4,25 @@ import type {
4
4
  SchemaOutput,
5
5
  } from '@orpc/contract'
6
6
  import type { Procedure, Router } from '@orpc/server'
7
- import { type GeneralHooks, createGeneralHooks } from './general-hooks'
8
- import { orpcPathSymbol } from './orpc-path'
9
- import { type ProcedureHooks, createProcedureHooks } from './procedure-hooks'
10
7
  import type { ORPCContext } from './react-context'
8
+ import { createGeneralHooks, type GeneralHooks } from './general-hooks'
9
+ import { orpcPathSymbol } from './orpc-path'
10
+ import { createProcedureHooks, type ProcedureHooks } from './procedure-hooks'
11
11
 
12
12
  export type ORPCHooksWithContractRouter<TRouter extends ContractRouter> = {
13
13
  [K in keyof TRouter]: TRouter[K] extends ContractProcedure<
14
14
  infer UInputSchema,
15
15
  infer UOutputSchema
16
16
  >
17
- ? ProcedureHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> &
18
- GeneralHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>>
17
+ ? ProcedureHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> & GeneralHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>>
19
18
  : TRouter[K] extends ContractRouter
20
19
  ? ORPCHooksWithContractRouter<TRouter[K]>
21
20
  : never
22
21
  } & GeneralHooks<undefined, undefined, unknown>
23
22
 
24
23
  export type ORPCHooksWithRouter<TRouter extends Router<any>> = {
25
- [K in keyof TRouter]: TRouter[K] extends Procedure<
26
- any,
27
- any,
28
- infer UInputSchema,
29
- infer UOutputSchema,
30
- infer UHandlerOutput
31
- >
32
- ? ProcedureHooks<UInputSchema, UOutputSchema, UHandlerOutput> &
33
- GeneralHooks<UInputSchema, UOutputSchema, UHandlerOutput>
24
+ [K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>
25
+ ? ProcedureHooks<UInputSchema, UOutputSchema, UFuncOutput> & GeneralHooks<UInputSchema, UOutputSchema, UFuncOutput>
34
26
  : TRouter[K] extends Router<any>
35
27
  ? ORPCHooksWithRouter<TRouter[K]>
36
28
  : never
@@ -52,19 +44,19 @@ export interface CreateORPCHooksOptions<
52
44
  export function createORPCHooks<TRouter extends ContractRouter | Router<any>>(
53
45
  options: CreateORPCHooksOptions<TRouter>,
54
46
  ): TRouter extends Router<any>
55
- ? ORPCHooksWithRouter<TRouter>
56
- : TRouter extends ContractRouter
57
- ? ORPCHooksWithContractRouter<TRouter>
58
- : never {
47
+ ? ORPCHooksWithRouter<TRouter>
48
+ : TRouter extends ContractRouter
49
+ ? ORPCHooksWithContractRouter<TRouter>
50
+ : never {
59
51
  const path = options.path ?? []
60
52
  const generalHooks = createGeneralHooks({ context: options.context, path })
61
53
 
62
54
  // for sure root is not procedure, so do not it procedure hooks on root
63
55
  const procedureHooks = path.length
64
56
  ? createProcedureHooks({
65
- context: options.context,
66
- path,
67
- })
57
+ context: options.context,
58
+ path,
59
+ })
68
60
  : {}
69
61
 
70
62
  return new Proxy(