@orpc/react 0.0.4 → 0.0.5

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 (53) 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 +5 -5
  5. package/dist/src/general-hooks.d.ts.map +1 -1
  6. package/dist/src/general-utils.d.ts +17 -17
  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 +11 -11
  11. package/dist/src/procedure-hooks.d.ts.map +1 -1
  12. package/dist/src/procedure-utils.d.ts +15 -15
  13. package/dist/src/procedure-utils.d.ts.map +1 -1
  14. package/dist/src/react-hooks.d.ts +1 -1
  15. package/dist/src/react-hooks.d.ts.map +1 -1
  16. package/dist/src/react-utils.d.ts +1 -1
  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.map +1 -1
  23. package/dist/src/use-queries/builders.d.ts.map +1 -1
  24. package/dist/src/use-queries/hook.d.ts.map +1 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +11 -14
  27. package/src/general-hooks.test.tsx +8 -8
  28. package/src/general-hooks.ts +8 -7
  29. package/src/general-utils.test-d.ts +7 -7
  30. package/src/general-utils.test.tsx +25 -25
  31. package/src/general-utils.ts +67 -71
  32. package/src/index.ts +1 -1
  33. package/src/orpc-path.ts +1 -1
  34. package/src/procedure-hooks.test-d.ts +6 -6
  35. package/src/procedure-hooks.test.tsx +1 -1
  36. package/src/procedure-hooks.ts +25 -25
  37. package/src/procedure-utils.test-d.ts +9 -9
  38. package/src/procedure-utils.test.tsx +13 -13
  39. package/src/procedure-utils.ts +46 -49
  40. package/src/react-hooks.ts +13 -21
  41. package/src/react-utils.ts +14 -25
  42. package/src/react.test-d.ts +6 -6
  43. package/src/react.test.tsx +8 -8
  44. package/src/react.tsx +5 -4
  45. package/src/tanstack-key.ts +9 -9
  46. package/src/tanstack-query.ts +2 -2
  47. package/src/types.ts +1 -1
  48. package/src/use-queries/builder.test-d.ts +2 -2
  49. package/src/use-queries/builder.ts +1 -2
  50. package/src/use-queries/builders.ts +9 -9
  51. package/src/use-queries/hook.test-d.ts +1 -1
  52. package/src/use-queries/hook.test.tsx +2 -2
  53. package/src/use-queries/hook.ts +8 -8
@@ -1,5 +1,6 @@
1
1
  import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract'
2
2
  import type { PartialDeep, SetOptional } from '@orpc/shared'
3
+ import type { ORPCQueryFilters } from './tanstack-query'
3
4
  import {
4
5
  type DefaultError,
5
6
  type Mutation,
@@ -11,19 +12,18 @@ import {
11
12
  } from '@tanstack/react-query'
12
13
  import { type ORPCContext, useORPCContext } from './react-context'
13
14
  import { getMutationKeyFromPath, getQueryKeyFromPath } from './tanstack-key'
14
- import type { ORPCQueryFilters } from './tanstack-query'
15
15
 
16
16
  export interface GeneralHooks<
17
17
  TInputSchema extends Schema,
18
18
  TOutputSchema extends Schema,
19
19
  THandlerOutput extends SchemaOutput<TOutputSchema>,
20
20
  > {
21
- useIsFetching(
21
+ useIsFetching: (
22
22
  filers?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
23
- ): number
24
- useIsMutating(filters?: SetOptional<MutationFilters, 'mutationKey'>): number
23
+ ) => number
24
+ useIsMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number
25
25
 
26
- useMutationState<
26
+ useMutationState: <
27
27
  UResult = MutationState<
28
28
  SchemaOutput<TOutputSchema, THandlerOutput>,
29
29
  DefaultError,
@@ -38,7 +38,8 @@ export interface GeneralHooks<
38
38
  SchemaInput<TInputSchema>
39
39
  >,
40
40
  ) => UResult
41
- }): UResult[]
41
+ }
42
+ ) => UResult[]
42
43
  }
43
44
 
44
45
  export interface CreateGeneralHooksOptions {
@@ -56,7 +57,7 @@ export function createGeneralHooks<
56
57
  TInputSchema extends Schema = undefined,
57
58
  TOutputSchema extends Schema = undefined,
58
59
  THandlerOutput extends
59
- SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
60
+ SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
60
61
  >(
61
62
  options: CreateGeneralHooksOptions,
62
63
  ): GeneralHooks<TInputSchema, TOutputSchema, THandlerOutput> {
@@ -2,17 +2,17 @@ import type { SchemaOutput } from '@orpc/contract'
2
2
  import type { Promisable } from '@orpc/shared'
3
3
  import type { InfiniteData } from '@tanstack/react-query'
4
4
  import {
5
+ queryClient,
5
6
  type UserCreateInputSchema,
6
7
  type UserFindInputSchema,
7
8
  type UserListInputSchema,
8
9
  type UserListOutputSchema,
9
10
  type UserSchema,
10
- queryClient,
11
11
  } from '../tests/orpc'
12
12
  import { createGeneralUtils } from './general-utils'
13
13
 
14
14
  const user_utils = createGeneralUtils({
15
- queryClient: queryClient,
15
+ queryClient,
16
16
  path: ['user'],
17
17
  })
18
18
 
@@ -21,7 +21,7 @@ const user_find_utils = createGeneralUtils<
21
21
  typeof UserSchema,
22
22
  SchemaOutput<typeof UserSchema>
23
23
  >({
24
- queryClient: queryClient,
24
+ queryClient,
25
25
  path: ['user', 'find'],
26
26
  })
27
27
 
@@ -30,7 +30,7 @@ const user_list_utils = createGeneralUtils<
30
30
  typeof UserListOutputSchema,
31
31
  SchemaOutput<typeof UserListOutputSchema>
32
32
  >({
33
- queryClient: queryClient,
33
+ queryClient,
34
34
  path: ['user', 'list'],
35
35
  })
36
36
 
@@ -39,7 +39,7 @@ const user_create_utils = createGeneralUtils<
39
39
  typeof UserSchema,
40
40
  SchemaOutput<typeof UserSchema>
41
41
  >({
42
- queryClient: queryClient,
42
+ queryClient,
43
43
  path: ['user', 'create'],
44
44
  })
45
45
 
@@ -121,9 +121,9 @@ describe('setInfiniteQueriesData', () => {
121
121
  user_list_utils.setInfiniteQueriesData({}, (old) => {
122
122
  expectTypeOf(old).toEqualTypeOf<
123
123
  | InfiniteData<
124
- SchemaOutput<typeof UserListOutputSchema>,
124
+ SchemaOutput<typeof UserListOutputSchema>,
125
125
  number | undefined
126
- >
126
+ >
127
127
  | undefined
128
128
  >()
129
129
 
@@ -1,11 +1,4 @@
1
1
  import type { SchemaOutput } from '@orpc/contract'
2
- import {
3
- QueryClient,
4
- useInfiniteQuery,
5
- useMutation,
6
- useQuery,
7
- } from '@tanstack/react-query'
8
- import { renderHook } from '@testing-library/react'
9
2
  import type {
10
3
  UserCreateInputSchema,
11
4
  UserFindInputSchema,
@@ -13,6 +6,13 @@ import type {
13
6
  UserListOutputSchema,
14
7
  UserSchema,
15
8
  } from '../tests/orpc'
9
+ import {
10
+ QueryClient,
11
+ useInfiniteQuery,
12
+ useMutation,
13
+ useQuery,
14
+ } from '@tanstack/react-query'
15
+ import { renderHook } from '@testing-library/react'
16
16
  import { createGeneralUtils } from './general-utils'
17
17
 
18
18
  let qc = new QueryClient()
@@ -299,8 +299,8 @@ describe('refetch', () => {
299
299
  const infiniteQueryKey = [['user', 'list'], { type: 'infinite' }]
300
300
  const queryKey = [['user', 'list'], { type: 'query' }]
301
301
 
302
- const fn1 = vi.fn(() => new Promise((resolve) => setTimeout(resolve, 100)))
303
- const fn2 = vi.fn(() => new Promise((resolve) => setTimeout(resolve, 100)))
302
+ const fn1 = vi.fn(() => new Promise(resolve => setTimeout(resolve, 100)))
303
+ const fn2 = vi.fn(() => new Promise(resolve => setTimeout(resolve, 100)))
304
304
 
305
305
  beforeEach(() => {
306
306
  fn1.mockClear()
@@ -321,7 +321,7 @@ describe('refetch', () => {
321
321
  renderHook(() =>
322
322
  useQuery(
323
323
  {
324
- queryKey: queryKey,
324
+ queryKey,
325
325
  queryFn: fn2,
326
326
  },
327
327
  qc,
@@ -338,7 +338,7 @@ describe('refetch', () => {
338
338
  expect(fn1).toHaveBeenCalledTimes(1)
339
339
  expect(fn2).toHaveBeenCalledTimes(1)
340
340
 
341
- await new Promise((resolve) => setTimeout(resolve, 101))
341
+ await new Promise(resolve => setTimeout(resolve, 101))
342
342
  user_utils.refetch()
343
343
 
344
344
  expect(fn1).toHaveBeenCalledTimes(2)
@@ -350,7 +350,7 @@ describe('refetch', () => {
350
350
  expect(fn1).toHaveBeenCalledTimes(1)
351
351
  expect(fn2).toHaveBeenCalledTimes(1)
352
352
 
353
- await new Promise((resolve) => setTimeout(resolve, 101))
353
+ await new Promise(resolve => setTimeout(resolve, 101))
354
354
  user_utils.refetch({ queryType: 'query' })
355
355
 
356
356
  expect(fn1).toHaveBeenCalledTimes(1)
@@ -363,7 +363,7 @@ describe('refetch', () => {
363
363
  expect(fn1).toHaveBeenCalledTimes(1)
364
364
  expect(fn2).toHaveBeenCalledTimes(1)
365
365
 
366
- await new Promise((resolve) => setTimeout(resolve, 101))
366
+ await new Promise(resolve => setTimeout(resolve, 101))
367
367
  user_list_utils.refetch()
368
368
 
369
369
  expect(fn1).toHaveBeenCalledTimes(2)
@@ -376,7 +376,7 @@ describe('refetch', () => {
376
376
  expect(fn1).toHaveBeenCalledTimes(1)
377
377
  expect(fn2).toHaveBeenCalledTimes(1)
378
378
 
379
- await new Promise((resolve) => setTimeout(resolve, 101))
379
+ await new Promise(resolve => setTimeout(resolve, 101))
380
380
  user_list_utils.refetch({ queryType: 'infinite' })
381
381
 
382
382
  expect(fn1).toHaveBeenCalledTimes(2)
@@ -389,7 +389,7 @@ describe('refetch', () => {
389
389
  expect(fn1).toHaveBeenCalledTimes(1)
390
390
  expect(fn2).toHaveBeenCalledTimes(1)
391
391
 
392
- await new Promise((resolve) => setTimeout(resolve, 101))
392
+ await new Promise(resolve => setTimeout(resolve, 101))
393
393
  user_find_utils.refetch()
394
394
 
395
395
  expect(fn1).toHaveBeenCalledTimes(1)
@@ -407,7 +407,7 @@ describe('cancel', () => {
407
407
  {
408
408
  queryKey: infiniteQueryKey,
409
409
  queryFn: async () =>
410
- await new Promise((resolve) => setTimeout(resolve, 100)),
410
+ await new Promise(resolve => setTimeout(resolve, 100)),
411
411
  getNextPageParam: () => 2,
412
412
  initialPageParam: 1,
413
413
  },
@@ -418,9 +418,9 @@ describe('cancel', () => {
418
418
  renderHook(() =>
419
419
  useQuery(
420
420
  {
421
- queryKey: queryKey,
421
+ queryKey,
422
422
  queryFn: async () =>
423
- await new Promise((resolve) => setTimeout(resolve, 100)),
423
+ await new Promise(resolve => setTimeout(resolve, 100)),
424
424
  },
425
425
  qc,
426
426
  ),
@@ -516,8 +516,8 @@ describe('reset', () => {
516
516
  const infiniteQueryKey = [['user', 'list'], { type: 'infinite' }]
517
517
  const queryKey = [['user', 'list'], { type: 'query' }]
518
518
 
519
- const fn1 = vi.fn(() => new Promise((resolve) => setTimeout(resolve, 100)))
520
- const fn2 = vi.fn(() => new Promise((resolve) => setTimeout(resolve, 100)))
519
+ const fn1 = vi.fn(() => new Promise(resolve => setTimeout(resolve, 100)))
520
+ const fn2 = vi.fn(() => new Promise(resolve => setTimeout(resolve, 100)))
521
521
 
522
522
  beforeEach(() => {
523
523
  fn1.mockClear()
@@ -538,7 +538,7 @@ describe('reset', () => {
538
538
  renderHook(() =>
539
539
  useQuery(
540
540
  {
541
- queryKey: queryKey,
541
+ queryKey,
542
542
  queryFn: fn2,
543
543
  },
544
544
  qc,
@@ -594,7 +594,7 @@ it('isFetching', () => {
594
594
  {
595
595
  queryKey: infiniteQueryKey,
596
596
  queryFn: async () =>
597
- await new Promise((resolve) => setTimeout(resolve, 100)),
597
+ await new Promise(resolve => setTimeout(resolve, 100)),
598
598
  getNextPageParam: () => 2,
599
599
  initialPageParam: 1,
600
600
  },
@@ -605,9 +605,9 @@ it('isFetching', () => {
605
605
  renderHook(() =>
606
606
  useQuery(
607
607
  {
608
- queryKey: queryKey,
608
+ queryKey,
609
609
  queryFn: async () =>
610
- await new Promise((resolve) => setTimeout(resolve, 100)),
610
+ await new Promise(resolve => setTimeout(resolve, 100)),
611
611
  },
612
612
  qc,
613
613
  ),
@@ -630,7 +630,7 @@ it('isMutating', async () => {
630
630
  useMutation(
631
631
  {
632
632
  mutationKey: [['user', 'create']],
633
- mutationFn: () => new Promise((resolve) => setTimeout(resolve, 100)),
633
+ mutationFn: () => new Promise(resolve => setTimeout(resolve, 100)),
634
634
  },
635
635
  qc,
636
636
  ),
@@ -16,41 +16,39 @@ import type {
16
16
  SetDataOptions,
17
17
  Updater,
18
18
  } from '@tanstack/react-query'
19
- import { getMutationKeyFromPath, getQueryKeyFromPath } from './tanstack-key'
20
19
  import type {
21
20
  ORPCInvalidateQueryFilters,
22
21
  ORPCQueryFilters,
23
22
  } from './tanstack-query'
24
23
  import type { SchemaInputForInfiniteQuery } from './types'
24
+ import { getMutationKeyFromPath, getQueryKeyFromPath } from './tanstack-key'
25
25
 
26
26
  export interface GeneralUtils<
27
27
  TInputSchema extends Schema,
28
28
  TOutputSchema extends Schema,
29
29
  THandlerOutput extends SchemaOutput<TOutputSchema>,
30
30
  > {
31
- getQueriesData(
31
+ getQueriesData: (
32
32
  filters?: OmitKeyof<
33
33
  ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
34
34
  'queryType'
35
35
  >,
36
- ): [QueryKey, SchemaOutput<TOutputSchema, THandlerOutput> | undefined][]
37
- getInfiniteQueriesData(
36
+ ) => [QueryKey, SchemaOutput<TOutputSchema, THandlerOutput> | undefined][]
37
+ getInfiniteQueriesData: (
38
38
  filters?: OmitKeyof<
39
39
  ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>,
40
40
  'queryType'
41
41
  >,
42
- ): [
42
+ ) => [
43
43
  QueryKey,
44
- (
45
- | InfiniteData<
46
- SchemaOutput<TOutputSchema, THandlerOutput>,
47
- SchemaInput<TInputSchema>['cursor']
48
- >
49
- | undefined
50
- ),
44
+ | undefined
45
+ | InfiniteData<
46
+ SchemaOutput<TOutputSchema, THandlerOutput>,
47
+ SchemaInput<TInputSchema>['cursor']
48
+ >,
51
49
  ][]
52
50
 
53
- setQueriesData(
51
+ setQueriesData: (
54
52
  filters: OmitKeyof<
55
53
  ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
56
54
  'queryType'
@@ -60,78 +58,76 @@ export interface GeneralUtils<
60
58
  SchemaOutput<TOutputSchema, THandlerOutput> | undefined
61
59
  >,
62
60
  options?: SetDataOptions,
63
- ): [QueryKey, SchemaOutput<TOutputSchema, THandlerOutput> | undefined][]
64
- setInfiniteQueriesData(
61
+ ) => [QueryKey, SchemaOutput<TOutputSchema, THandlerOutput> | undefined][]
62
+ setInfiniteQueriesData: (
65
63
  filters: OmitKeyof<
66
64
  ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>,
67
65
  'queryType'
68
66
  >,
69
67
  updater: Updater<
70
68
  | InfiniteData<
71
- SchemaOutput<TOutputSchema, THandlerOutput>,
72
- SchemaInput<TInputSchema>['cursor']
73
- >
69
+ SchemaOutput<TOutputSchema, THandlerOutput>,
70
+ SchemaInput<TInputSchema>['cursor']
71
+ >
74
72
  | undefined,
75
73
  | InfiniteData<
76
- SchemaOutput<TOutputSchema, THandlerOutput>,
77
- SchemaInput<TInputSchema>['cursor']
78
- >
74
+ SchemaOutput<TOutputSchema, THandlerOutput>,
75
+ SchemaInput<TInputSchema>['cursor']
76
+ >
79
77
  | undefined
80
78
  >,
81
79
  options?: SetDataOptions,
82
- ): [
80
+ ) => [
83
81
  QueryKey,
84
- (
85
- | InfiniteData<
86
- SchemaOutput<TOutputSchema, THandlerOutput>,
87
- SchemaInput<TInputSchema>['cursor']
88
- >
89
- | undefined
90
- ),
82
+ | undefined
83
+ | InfiniteData<
84
+ SchemaOutput<TOutputSchema, THandlerOutput>,
85
+ SchemaInput<TInputSchema>['cursor']
86
+ >,
91
87
  ][]
92
88
 
93
- invalidate(
89
+ invalidate: (
94
90
  filters?: ORPCInvalidateQueryFilters<
95
91
  PartialDeep<SchemaInput<TInputSchema>>
96
92
  >,
97
93
  options?: InvalidateOptions,
98
- ): Promise<void>
99
- refetch(
94
+ ) => Promise<void>
95
+ refetch: (
100
96
  filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
101
97
  options?: RefetchOptions,
102
- ): Promise<void>
103
- cancel(
98
+ ) => Promise<void>
99
+ cancel: (
104
100
  filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
105
101
  options?: CancelOptions,
106
- ): Promise<void>
107
- remove(
102
+ ) => Promise<void>
103
+ remove: (
108
104
  filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
109
- ): void
110
- reset(
105
+ ) => void
106
+ reset: (
111
107
  filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
112
108
  options?: ResetOptions,
113
- ): Promise<void>
109
+ ) => Promise<void>
114
110
 
115
- isFetching(
111
+ isFetching: (
116
112
  filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
117
- ): number
118
- isMutating(filters?: SetOptional<MutationFilters, 'mutationKey'>): number
113
+ ) => number
114
+ isMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number
119
115
 
120
- getQueryDefaults(
116
+ getQueryDefaults: (
121
117
  filters?: Pick<
122
118
  ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
123
119
  'input' | 'queryKey'
124
120
  >,
125
- ): OmitKeyof<
121
+ ) => OmitKeyof<
126
122
  QueryObserverOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
127
123
  'queryKey'
128
124
  >
129
- getInfiniteQueryDefaults(
125
+ getInfiniteQueryDefaults: (
130
126
  filters?: Pick<
131
127
  ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>,
132
128
  'input' | 'queryKey'
133
129
  >,
134
- ): OmitKeyof<
130
+ ) => OmitKeyof<
135
131
  QueryObserverOptions<
136
132
  SchemaOutput<TOutputSchema, THandlerOutput>,
137
133
  DefaultError,
@@ -143,7 +139,7 @@ export interface GeneralUtils<
143
139
  'queryKey'
144
140
  >
145
141
 
146
- setQueryDefaults(
142
+ setQueryDefaults: (
147
143
  options: Partial<
148
144
  OmitKeyof<
149
145
  QueryObserverOptions<SchemaOutput<TOutputSchema, THandlerOutput>>,
@@ -154,8 +150,8 @@ export interface GeneralUtils<
154
150
  ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
155
151
  'input' | 'queryKey'
156
152
  >,
157
- ): void
158
- setInfiniteQueryDefaults(
153
+ ) => void
154
+ setInfiniteQueryDefaults: (
159
155
  options: Partial<
160
156
  OmitKeyof<
161
157
  QueryObserverOptions<
@@ -173,7 +169,7 @@ export interface GeneralUtils<
173
169
  ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>,
174
170
  'input' | 'queryKey'
175
171
  >,
176
- ): void
172
+ ) => void
177
173
 
178
174
  getMutationDefaults: (
179
175
  filters?: Pick<MutationFilters, 'mutationKey'>,
@@ -210,7 +206,7 @@ export function createGeneralUtils<
210
206
  TInputSchema extends Schema = undefined,
211
207
  TOutputSchema extends Schema = undefined,
212
208
  THandlerOutput extends
213
- SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
209
+ SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>,
214
210
  >(
215
211
  options: CreateGeneralUtilsOptions,
216
212
  ): GeneralUtils<TInputSchema, TOutputSchema, THandlerOutput> {
@@ -344,40 +340,40 @@ export function createGeneralUtils<
344
340
 
345
341
  getQueryDefaults(filters) {
346
342
  return options.queryClient.getQueryDefaults(
347
- filters?.queryKey ??
348
- getQueryKeyFromPath(options.path, {
349
- input: filters?.input,
350
- type: 'query',
351
- }),
343
+ filters?.queryKey
344
+ ?? getQueryKeyFromPath(options.path, {
345
+ input: filters?.input,
346
+ type: 'query',
347
+ }),
352
348
  )
353
349
  },
354
350
  getInfiniteQueryDefaults(filters) {
355
351
  return options.queryClient.getQueryDefaults(
356
- filters?.queryKey ??
357
- getQueryKeyFromPath(options.path, {
358
- input: filters?.input,
359
- type: 'infinite',
360
- }),
352
+ filters?.queryKey
353
+ ?? getQueryKeyFromPath(options.path, {
354
+ input: filters?.input,
355
+ type: 'infinite',
356
+ }),
361
357
  ) as any
362
358
  },
363
359
 
364
360
  setQueryDefaults(options_, filters) {
365
361
  return options.queryClient.setQueryDefaults(
366
- filters?.queryKey ??
367
- getQueryKeyFromPath(options.path, {
368
- input: filters?.input,
369
- type: 'query',
370
- }),
362
+ filters?.queryKey
363
+ ?? getQueryKeyFromPath(options.path, {
364
+ input: filters?.input,
365
+ type: 'query',
366
+ }),
371
367
  options_ as any,
372
368
  )
373
369
  },
374
370
  setInfiniteQueryDefaults(options_, filters) {
375
371
  return options.queryClient.setQueryDefaults(
376
- filters?.queryKey ??
377
- getQueryKeyFromPath(options.path, {
378
- input: filters?.input,
379
- type: 'infinite',
380
- }),
372
+ filters?.queryKey
373
+ ?? getQueryKeyFromPath(options.path, {
374
+ input: filters?.input,
375
+ type: 'infinite',
376
+ }),
381
377
  options_ as any,
382
378
  )
383
379
  },
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ export * from './general-hooks'
2
2
  export * from './general-utils'
3
3
  export * from './procedure-hooks'
4
4
  export * from './procedure-utils'
5
+ export * from './react'
5
6
  export * from './react-context'
6
7
  export * from './react-hooks'
7
8
  export * from './react-utils'
8
- export * from './react'
package/src/orpc-path.ts CHANGED
@@ -15,7 +15,7 @@ export function getORPCPath(
15
15
  const val = Reflect.get(orpc, orpcPathSymbol)
16
16
 
17
17
  if (!Array.isArray(val)) {
18
- throw new Error(
18
+ throw new TypeError(
19
19
  'orpcPathSymbol is not implemented, please use getORPCPath with correct instance.',
20
20
  )
21
21
  }
@@ -81,9 +81,9 @@ describe('useInfiniteQuery', () => {
81
81
  expectTypeOf(query.data).toEqualTypeOf<
82
82
  | undefined
83
83
  | InfiniteData<
84
- SchemaOutput<typeof UserListOutputSchema>,
84
+ SchemaOutput<typeof UserListOutputSchema>,
85
85
  number | undefined
86
- >
86
+ >
87
87
  >()
88
88
  })
89
89
 
@@ -111,11 +111,11 @@ describe('useInfiniteQuery', () => {
111
111
  expectTypeOf(query.data).toEqualTypeOf<
112
112
  | undefined
113
113
  | {
114
- select: InfiniteData<
115
- SchemaOutput<typeof UserListOutputSchema>,
114
+ select: InfiniteData<
115
+ SchemaOutput<typeof UserListOutputSchema>,
116
116
  number | undefined
117
- >
118
- }
117
+ >
118
+ }
119
119
  >()
120
120
  })
121
121
  })
@@ -2,12 +2,12 @@ import type { SchemaOutput } from '@orpc/contract'
2
2
  import { renderHook, screen, waitFor } from '@testing-library/react'
3
3
  import {
4
4
  ORPCContext,
5
+ queryClient,
5
6
  type UserCreateInputSchema,
6
7
  type UserFindInputSchema,
7
8
  type UserListInputSchema,
8
9
  type UserListOutputSchema,
9
10
  type UserSchema,
10
- queryClient,
11
11
  wrapper,
12
12
  } from '../tests/orpc'
13
13
  import { createProcedureHooks } from './procedure-hooks'