@orpc/react 0.0.0-next-20241120100614 → 0.0.0-unsafe-pr-9-20241121090958
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/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/general-hooks.d.ts +5 -5
- package/dist/src/general-hooks.d.ts.map +1 -1
- package/dist/src/general-utils.d.ts +17 -17
- package/dist/src/general-utils.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/procedure-hooks.d.ts +11 -11
- package/dist/src/procedure-hooks.d.ts.map +1 -1
- package/dist/src/procedure-utils.d.ts +15 -15
- package/dist/src/procedure-utils.d.ts.map +1 -1
- package/dist/src/react-hooks.d.ts +1 -1
- package/dist/src/react-hooks.d.ts.map +1 -1
- package/dist/src/react-utils.d.ts +1 -1
- package/dist/src/react-utils.d.ts.map +1 -1
- package/dist/src/react.d.ts.map +1 -1
- package/dist/src/tanstack-key.d.ts.map +1 -1
- package/dist/src/tanstack-query.d.ts.map +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/use-queries/builder.d.ts.map +1 -1
- package/dist/src/use-queries/builders.d.ts.map +1 -1
- package/dist/src/use-queries/hook.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/general-hooks.test.tsx +8 -8
- package/src/general-hooks.ts +8 -7
- package/src/general-utils.test-d.ts +7 -7
- package/src/general-utils.test.tsx +25 -25
- package/src/general-utils.ts +67 -71
- package/src/index.ts +1 -1
- package/src/orpc-path.ts +1 -1
- package/src/procedure-hooks.test-d.ts +6 -6
- package/src/procedure-hooks.test.tsx +1 -1
- package/src/procedure-hooks.ts +25 -25
- package/src/procedure-utils.test-d.ts +9 -9
- package/src/procedure-utils.test.tsx +13 -13
- package/src/procedure-utils.ts +46 -49
- package/src/react-hooks.ts +13 -21
- package/src/react-utils.ts +14 -25
- package/src/react.test-d.ts +6 -6
- package/src/react.test.tsx +8 -8
- package/src/react.tsx +5 -4
- package/src/tanstack-key.ts +9 -9
- package/src/tanstack-query.ts +2 -2
- package/src/types.ts +1 -1
- package/src/use-queries/builder.ts +1 -1
- package/src/use-queries/builders.ts +9 -9
- package/src/use-queries/hook.test-d.ts +1 -1
- package/src/use-queries/hook.test.tsx +2 -2
- package/src/use-queries/hook.ts +8 -8
@@ -9,7 +9,7 @@ import type {
|
|
9
9
|
} from '@orpc/contract'
|
10
10
|
import type { Procedure, Router } from '@orpc/server'
|
11
11
|
import type {} from '@tanstack/react-query'
|
12
|
-
import { type UseQueriesBuilder
|
12
|
+
import { createUseQueriesBuilder, type UseQueriesBuilder } from './builder'
|
13
13
|
|
14
14
|
export type UseQueriesBuildersWithContractRouter<
|
15
15
|
TRouter extends ContractRouter,
|
@@ -19,10 +19,10 @@ export type UseQueriesBuildersWithContractRouter<
|
|
19
19
|
infer UOutputSchema
|
20
20
|
>
|
21
21
|
? UseQueriesBuilder<
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
UInputSchema,
|
23
|
+
UOutputSchema,
|
24
|
+
SchemaOutput<UOutputSchema>
|
25
|
+
>
|
26
26
|
: TRouter[K] extends ContractRouter
|
27
27
|
? UseQueriesBuildersWithContractRouter<TRouter[K]>
|
28
28
|
: never
|
@@ -62,10 +62,10 @@ export function createUseQueriesBuilders<
|
|
62
62
|
>(
|
63
63
|
options: CreateUseQueriesBuildersOptions<TRouter>,
|
64
64
|
): TRouter extends Router<any>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
? UseQueriesBuildersWithRouter<TRouter>
|
66
|
+
: TRouter extends ContractRouter
|
67
|
+
? UseQueriesBuildersWithContractRouter<TRouter>
|
68
|
+
: never {
|
69
69
|
const path = options.path ?? []
|
70
70
|
const client = options.client as any
|
71
71
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { SchemaOutput } from '@orpc/contract'
|
2
2
|
import {
|
3
|
+
orpcClient,
|
3
4
|
ORPCContext,
|
4
5
|
type UserListOutputSchema,
|
5
6
|
type UserSchema,
|
6
|
-
orpcClient,
|
7
7
|
} from '../../tests/orpc'
|
8
8
|
import { createUseQueriesBuilders } from './builders'
|
9
9
|
import { useQueriesFactory } from './hook'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { renderHook, waitFor } from '@testing-library/react'
|
2
|
-
import {
|
2
|
+
import { orpcClient, ORPCContext, wrapper } from '../../tests/orpc'
|
3
3
|
import { createUseQueriesBuilders } from './builders'
|
4
4
|
import { useQueriesFactory } from './hook'
|
5
5
|
|
@@ -18,7 +18,7 @@ describe('useQueriesFactory', () => {
|
|
18
18
|
|
19
19
|
return [o.user.find({ id: '123' }), o.user.list({})]
|
20
20
|
}),
|
21
|
-
{ wrapper
|
21
|
+
{ wrapper },
|
22
22
|
)
|
23
23
|
|
24
24
|
await waitFor(() =>
|
package/src/use-queries/hook.ts
CHANGED
@@ -7,9 +7,9 @@ import {
|
|
7
7
|
} from '@tanstack/react-query'
|
8
8
|
import { type ORPCContext, useORPCContext } from '../react-context'
|
9
9
|
import {
|
10
|
+
createUseQueriesBuilders,
|
10
11
|
type UseQueriesBuildersWithContractRouter,
|
11
12
|
type UseQueriesBuildersWithRouter,
|
12
|
-
createUseQueriesBuilders,
|
13
13
|
} from './builders'
|
14
14
|
|
15
15
|
export interface UseQueriesWithContractRouter<TRouter extends ContractRouter> {
|
@@ -39,19 +39,19 @@ export interface UseQueriesFactoryOptions<
|
|
39
39
|
export function useQueriesFactory<TRouter extends Router<any> | ContractRouter>(
|
40
40
|
options: UseQueriesFactoryOptions<TRouter>,
|
41
41
|
): TRouter extends Router<any>
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
const
|
42
|
+
? UseQueriesWithRouter<TRouter>
|
43
|
+
: TRouter extends ContractRouter
|
44
|
+
? UseQueriesWithContractRouter<TRouter>
|
45
|
+
: never {
|
46
|
+
const Hook = (build: any, combine?: any): any => {
|
47
47
|
const orpc = useORPCContext(options.context)
|
48
48
|
const builders = createUseQueriesBuilders({ client: orpc.client as any })
|
49
49
|
|
50
50
|
return useQueries({
|
51
51
|
queries: build(builders),
|
52
|
-
combine
|
52
|
+
combine,
|
53
53
|
})
|
54
54
|
}
|
55
55
|
|
56
|
-
return
|
56
|
+
return Hook as any
|
57
57
|
}
|