@orpc/react 0.16.0 → 0.17.0
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 +3 -5
- package/dist/src/general-hooks.d.ts +5 -6
- package/dist/src/general-utils.d.ts +20 -21
- package/dist/src/orpc-path.d.ts +2 -2
- package/dist/src/procedure-hooks.d.ts +12 -13
- package/dist/src/procedure-utils.d.ts +22 -23
- package/dist/src/react-context.d.ts +6 -8
- package/dist/src/react-hooks.d.ts +7 -11
- package/dist/src/react-utils.d.ts +7 -11
- package/dist/src/react.d.ts +12 -18
- package/dist/src/tanstack-key.d.ts +3 -4
- package/dist/src/types.d.ts +3 -4
- package/dist/src/use-queries/builder.d.ts +6 -7
- package/dist/src/use-queries/builders.d.ts +6 -11
- package/dist/src/use-queries/hook.d.ts +9 -13
- package/package.json +5 -5
package/dist/index.js
CHANGED
@@ -496,10 +496,10 @@ function createProcedureUtils(options) {
|
|
496
496
|
function createORPCHooks(options) {
|
497
497
|
const path = options.path ?? [];
|
498
498
|
const generalHooks = createGeneralHooks({ context: options.context, path });
|
499
|
-
const procedureHooks =
|
499
|
+
const procedureHooks = createProcedureHooks({
|
500
500
|
context: options.context,
|
501
501
|
path
|
502
|
-
})
|
502
|
+
});
|
503
503
|
return new Proxy(
|
504
504
|
{
|
505
505
|
[orpcPathSymbol]: path,
|
@@ -575,9 +575,7 @@ function createORPCUtils(options) {
|
|
575
575
|
}
|
576
576
|
|
577
577
|
// src/use-queries/hook.ts
|
578
|
-
import {
|
579
|
-
useQueries
|
580
|
-
} from "@tanstack/react-query";
|
578
|
+
import { useQueries } from "@tanstack/react-query";
|
581
579
|
|
582
580
|
// src/use-queries/builder.ts
|
583
581
|
function createUseQueriesBuilder(options) {
|
@@ -1,14 +1,13 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
1
|
import type { PartialDeep, SetOptional } from '@orpc/shared';
|
3
2
|
import type { ORPCQueryFilters } from './tanstack-query';
|
4
3
|
import { type DefaultError, type Mutation, type MutationFilters, type MutationState } from '@tanstack/react-query';
|
5
4
|
import { type ORPCContext } from './react-context';
|
6
|
-
export interface GeneralHooks<
|
7
|
-
useIsFetching: (filers?: ORPCQueryFilters<PartialDeep<
|
5
|
+
export interface GeneralHooks<TInput, TOutput> {
|
6
|
+
useIsFetching: (filers?: ORPCQueryFilters<PartialDeep<TInput>>) => number;
|
8
7
|
useIsMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number;
|
9
|
-
useMutationState: <UResult = MutationState<
|
8
|
+
useMutationState: <UResult = MutationState<TOutput, DefaultError, TInput>>(options?: {
|
10
9
|
filters?: SetOptional<MutationFilters, 'mutationKey'>;
|
11
|
-
select?: (mutation: Mutation<
|
10
|
+
select?: (mutation: Mutation<TOutput, DefaultError, TInput>) => UResult;
|
12
11
|
}) => UResult[];
|
13
12
|
}
|
14
13
|
export interface CreateGeneralHooksOptions {
|
@@ -20,5 +19,5 @@ export interface CreateGeneralHooksOptions {
|
|
20
19
|
*/
|
21
20
|
path: string[];
|
22
21
|
}
|
23
|
-
export declare function createGeneralHooks<
|
22
|
+
export declare function createGeneralHooks<TInput, TOutput>(options: CreateGeneralHooksOptions): GeneralHooks<TInput, TOutput>;
|
24
23
|
//# sourceMappingURL=general-hooks.d.ts.map
|
@@ -1,32 +1,31 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
1
|
import type { PartialDeep, SetOptional } from '@orpc/shared';
|
3
2
|
import type { CancelOptions, DefaultError, InfiniteData, InvalidateOptions, MutationFilters, MutationObserverOptions, OmitKeyof, QueryClient, QueryKey, QueryObserverOptions, RefetchOptions, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
4
3
|
import type { ORPCInvalidateQueryFilters, ORPCQueryFilters } from './tanstack-query';
|
5
4
|
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
6
|
-
export interface GeneralUtils<
|
7
|
-
getQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<
|
8
|
-
getInfiniteQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<
|
5
|
+
export interface GeneralUtils<TInput, TOutput> {
|
6
|
+
getQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<TInput>>, 'queryType'>) => [QueryKey, TOutput | undefined][];
|
7
|
+
getInfiniteQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInput>>>, 'queryType'>) => [
|
9
8
|
QueryKey,
|
10
|
-
undefined | InfiniteData<
|
9
|
+
undefined | InfiniteData<TOutput, InferCursor<TInput>>
|
11
10
|
][];
|
12
|
-
setQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<
|
13
|
-
setInfiniteQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<
|
11
|
+
setQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<TInput>>, 'queryType'>, updater: Updater<TOutput | undefined, TOutput | undefined>, options?: SetDataOptions) => [QueryKey, TOutput | undefined][];
|
12
|
+
setInfiniteQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInput>>>, 'queryType'>, updater: Updater<InfiniteData<TOutput, InferCursor<TInput>> | undefined, InfiniteData<TOutput, InferCursor<TInput>> | undefined>, options?: SetDataOptions) => [
|
14
13
|
QueryKey,
|
15
|
-
undefined | InfiniteData<
|
14
|
+
undefined | InfiniteData<TOutput, InferCursor<TInput>>
|
16
15
|
][];
|
17
|
-
invalidate: (filters?: ORPCInvalidateQueryFilters<PartialDeep<
|
18
|
-
refetch: (filters?: ORPCQueryFilters<PartialDeep<
|
19
|
-
cancel: (filters?: ORPCQueryFilters<PartialDeep<
|
20
|
-
remove: (filters?: ORPCQueryFilters<PartialDeep<
|
21
|
-
reset: (filters?: ORPCQueryFilters<PartialDeep<
|
22
|
-
isFetching: (filters?: ORPCQueryFilters<PartialDeep<
|
16
|
+
invalidate: (filters?: ORPCInvalidateQueryFilters<PartialDeep<TInput>>, options?: InvalidateOptions) => Promise<void>;
|
17
|
+
refetch: (filters?: ORPCQueryFilters<PartialDeep<TInput>>, options?: RefetchOptions) => Promise<void>;
|
18
|
+
cancel: (filters?: ORPCQueryFilters<PartialDeep<TInput>>, options?: CancelOptions) => Promise<void>;
|
19
|
+
remove: (filters?: ORPCQueryFilters<PartialDeep<TInput>>) => void;
|
20
|
+
reset: (filters?: ORPCQueryFilters<PartialDeep<TInput>>, options?: ResetOptions) => Promise<void>;
|
21
|
+
isFetching: (filters?: ORPCQueryFilters<PartialDeep<TInput>>) => number;
|
23
22
|
isMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number;
|
24
|
-
getQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<
|
25
|
-
getInfiniteQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<
|
26
|
-
setQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<
|
27
|
-
setInfiniteQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<
|
28
|
-
getMutationDefaults: (filters?: Pick<MutationFilters, 'mutationKey'>) => MutationObserverOptions<
|
29
|
-
setMutationDefaults: (options: OmitKeyof<MutationObserverOptions<
|
23
|
+
getQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<TInput>>, 'input' | 'queryKey'>) => OmitKeyof<QueryObserverOptions<TOutput>, 'queryKey'>;
|
24
|
+
getInfiniteQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInput>>>, 'input' | 'queryKey'>) => OmitKeyof<QueryObserverOptions<TOutput, DefaultError, TOutput, InfiniteData<TOutput>, QueryKey, InferCursor<TInput>>, 'queryKey'>;
|
25
|
+
setQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<TOutput>, 'queryKey'>>, filters?: Pick<ORPCQueryFilters<PartialDeep<TInput>>, 'input' | 'queryKey'>) => void;
|
26
|
+
setInfiniteQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<TOutput, DefaultError, TOutput, InfiniteData<TOutput>, QueryKey, InferCursor<TInput>>, 'queryKey'>>, filters?: Pick<ORPCQueryFilters<PartialDeep<TInput>>, 'input' | 'queryKey'>) => void;
|
27
|
+
getMutationDefaults: (filters?: Pick<MutationFilters, 'mutationKey'>) => MutationObserverOptions<TOutput, DefaultError, TInput>;
|
28
|
+
setMutationDefaults: (options: OmitKeyof<MutationObserverOptions<TOutput, DefaultError, TInput>, 'mutationKey'>, filters?: Pick<MutationFilters, 'mutationKey'>) => void;
|
30
29
|
}
|
31
30
|
export interface CreateGeneralUtilsOptions {
|
32
31
|
queryClient: QueryClient;
|
@@ -37,5 +36,5 @@ export interface CreateGeneralUtilsOptions {
|
|
37
36
|
*/
|
38
37
|
path: string[];
|
39
38
|
}
|
40
|
-
export declare function createGeneralUtils<
|
39
|
+
export declare function createGeneralUtils<TInput, TOutput>(options: CreateGeneralUtilsOptions): GeneralUtils<TInput, TOutput>;
|
41
40
|
//# sourceMappingURL=general-utils.d.ts.map
|
package/dist/src/orpc-path.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ProcedureHooks } from './procedure-hooks';
|
2
|
-
import type {
|
2
|
+
import type { ORPCHooks } from './react-hooks';
|
3
3
|
export declare const orpcPathSymbol: unique symbol;
|
4
|
-
export declare function getORPCPath(orpc:
|
4
|
+
export declare function getORPCPath(orpc: ORPCHooks<any> | ProcedureHooks<any, any>): string[];
|
5
5
|
//# sourceMappingURL=orpc-path.d.ts.map
|
@@ -1,22 +1,21 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
1
|
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
3
2
|
import { type PartialOnUndefinedDeep, type SetOptional } from '@orpc/shared';
|
4
3
|
import { type DefaultError, type FetchInfiniteQueryOptions, type FetchQueryOptions, type InfiniteData, type QueryKey, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, type UseSuspenseInfiniteQueryOptions, type UseSuspenseInfiniteQueryResult, type UseSuspenseQueryOptions, type UseSuspenseQueryResult } from '@tanstack/react-query';
|
5
4
|
import { type ORPCContext } from './react-context';
|
6
|
-
export interface ProcedureHooks<
|
7
|
-
useQuery: <USelectData =
|
8
|
-
useInfiniteQuery: <USelectData = InfiniteData<
|
9
|
-
input: SchemaInputForInfiniteQuery<
|
5
|
+
export interface ProcedureHooks<TInput, TOutput> {
|
6
|
+
useQuery: <USelectData = TOutput>(input: TInput, options?: SetOptional<UseQueryOptions<TOutput, DefaultError, USelectData>, 'queryFn' | 'queryKey'>) => UseQueryResult<USelectData>;
|
7
|
+
useInfiniteQuery: <USelectData = InfiniteData<TOutput, InferCursor<TInput>>>(options: PartialOnUndefinedDeep<SetOptional<UseInfiniteQueryOptions<TOutput, DefaultError, USelectData, TOutput, QueryKey, InferCursor<TInput>>, 'queryFn' | 'queryKey'> & {
|
8
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
10
9
|
}>) => UseInfiniteQueryResult<USelectData>;
|
11
|
-
useSuspenseQuery: <USelectData =
|
12
|
-
useSuspenseInfiniteQuery: <USelectData = InfiniteData<
|
13
|
-
input: SchemaInputForInfiniteQuery<
|
10
|
+
useSuspenseQuery: <USelectData = TOutput>(input: TInput, options?: SetOptional<UseSuspenseQueryOptions<TOutput, DefaultError, USelectData>, 'queryFn' | 'queryKey'>) => UseSuspenseQueryResult<USelectData>;
|
11
|
+
useSuspenseInfiniteQuery: <USelectData = InfiniteData<TOutput, InferCursor<TInput>>>(options: PartialOnUndefinedDeep<SetOptional<UseSuspenseInfiniteQueryOptions<TOutput, DefaultError, USelectData, TOutput, QueryKey, InferCursor<TInput>>, 'queryFn' | 'queryKey'> & {
|
12
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
14
13
|
}>) => UseSuspenseInfiniteQueryResult<USelectData>;
|
15
|
-
usePrefetchQuery: (input:
|
16
|
-
usePrefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<
|
17
|
-
input: SchemaInputForInfiniteQuery<
|
14
|
+
usePrefetchQuery: (input: TInput, options?: FetchQueryOptions<TOutput>) => void;
|
15
|
+
usePrefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<TOutput, DefaultError, TOutput, QueryKey, InferCursor<TInput>>, 'queryKey' | 'queryFn'> & {
|
16
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
18
17
|
}>) => void;
|
19
|
-
useMutation: (options?: SetOptional<UseMutationOptions<
|
18
|
+
useMutation: (options?: SetOptional<UseMutationOptions<TOutput, DefaultError, TInput>, 'mutationFn' | 'mutationKey'>) => UseMutationResult<TOutput, DefaultError, TInput>;
|
20
19
|
}
|
21
20
|
export interface CreateProcedureHooksOptions {
|
22
21
|
context: ORPCContext<any>;
|
@@ -27,5 +26,5 @@ export interface CreateProcedureHooksOptions {
|
|
27
26
|
*/
|
28
27
|
path: string[];
|
29
28
|
}
|
30
|
-
export declare function createProcedureHooks<
|
29
|
+
export declare function createProcedureHooks<TInput, TOutput>(options: CreateProcedureHooksOptions): ProcedureHooks<TInput, TOutput>;
|
31
30
|
//# sourceMappingURL=procedure-hooks.d.ts.map
|
@@ -1,35 +1,34 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Caller } from '@orpc/server';
|
1
|
+
import type { ProcedureClient } from '@orpc/server';
|
3
2
|
import type { PartialOnUndefinedDeep, SetOptional } from '@orpc/shared';
|
4
3
|
import type { DefaultError, EnsureInfiniteQueryDataOptions, EnsureQueryDataOptions, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, QueryClient, QueryKey, QueryState, SetDataOptions, Updater } from '@tanstack/react-query';
|
5
4
|
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
6
|
-
export interface ProcedureUtils<
|
7
|
-
fetchQuery: (input:
|
8
|
-
fetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<
|
9
|
-
input: SchemaInputForInfiniteQuery<
|
10
|
-
}>) => Promise<InfiniteData<
|
11
|
-
prefetchQuery: (input:
|
12
|
-
prefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<
|
13
|
-
input: SchemaInputForInfiniteQuery<
|
5
|
+
export interface ProcedureUtils<TInput, TOutput> {
|
6
|
+
fetchQuery: (input: TInput, options?: SetOptional<FetchQueryOptions<TOutput>, 'queryKey' | 'queryFn'>) => Promise<TOutput>;
|
7
|
+
fetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<TOutput, DefaultError, TOutput, QueryKey, InferCursor<TInput>>, 'queryKey' | 'queryFn'> & {
|
8
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
9
|
+
}>) => Promise<InfiniteData<TOutput, InferCursor<TInput>>>;
|
10
|
+
prefetchQuery: (input: TInput, options?: SetOptional<FetchQueryOptions<TOutput>, 'queryKey' | 'queryFn'>) => Promise<void>;
|
11
|
+
prefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<TOutput, DefaultError, TOutput, QueryKey, InferCursor<TInput>>, 'queryKey' | 'queryFn'> & {
|
12
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
14
13
|
}>) => Promise<void>;
|
15
|
-
getQueryData: (input:
|
16
|
-
getInfiniteQueryData: (input: SchemaInputForInfiniteQuery<
|
17
|
-
ensureQueryData: (input:
|
18
|
-
ensureInfiniteQueryData: (options: PartialOnUndefinedDeep<SetOptional<EnsureInfiniteQueryDataOptions<
|
19
|
-
input: SchemaInputForInfiniteQuery<
|
20
|
-
}>) => Promise<InfiniteData<
|
21
|
-
getQueryState: (input:
|
22
|
-
getInfiniteQueryState: (input: SchemaInputForInfiniteQuery<
|
23
|
-
setQueryData: (input:
|
24
|
-
setInfiniteQueryData: (input: SchemaInputForInfiniteQuery<
|
14
|
+
getQueryData: (input: TInput) => TOutput | undefined;
|
15
|
+
getInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInput>) => InfiniteData<TOutput, InferCursor<TInput>> | undefined;
|
16
|
+
ensureQueryData: (input: TInput, options?: SetOptional<EnsureQueryDataOptions<TOutput>, 'queryFn' | 'queryKey'>) => Promise<TOutput>;
|
17
|
+
ensureInfiniteQueryData: (options: PartialOnUndefinedDeep<SetOptional<EnsureInfiniteQueryDataOptions<TOutput, DefaultError, TOutput, QueryKey, InferCursor<TInput>>, 'queryKey' | 'queryFn'> & {
|
18
|
+
input: SchemaInputForInfiniteQuery<TInput>;
|
19
|
+
}>) => Promise<InfiniteData<TOutput, InferCursor<TInput>>>;
|
20
|
+
getQueryState: (input: TInput) => QueryState<TOutput> | undefined;
|
21
|
+
getInfiniteQueryState: (input: SchemaInputForInfiniteQuery<TInput>) => QueryState<InfiniteData<TOutput, InferCursor<TInput>>> | undefined;
|
22
|
+
setQueryData: (input: TInput, updater: Updater<TOutput | undefined, TOutput | undefined>, options?: SetDataOptions) => TOutput | undefined;
|
23
|
+
setInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInput>, updater: Updater<InfiniteData<TOutput, InferCursor<TInput>> | undefined, InfiniteData<TOutput, InferCursor<TInput>> | undefined>, options?: SetDataOptions) => InfiniteData<TOutput, InferCursor<TInput>> | undefined;
|
25
24
|
}
|
26
|
-
export interface CreateProcedureUtilsOptions<
|
27
|
-
client:
|
25
|
+
export interface CreateProcedureUtilsOptions<TInput, TOutput> {
|
26
|
+
client: ProcedureClient<TInput, TOutput>;
|
28
27
|
queryClient: QueryClient;
|
29
28
|
/**
|
30
29
|
* The path of procedure on sever
|
31
30
|
*/
|
32
31
|
path: string[];
|
33
32
|
}
|
34
|
-
export declare function createProcedureUtils<
|
33
|
+
export declare function createProcedureUtils<TInput, TOutput>(options: CreateProcedureUtilsOptions<TInput, TOutput>): ProcedureUtils<TInput, TOutput>;
|
35
34
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import type { RouterClient } from '@orpc/
|
2
|
-
import type { ContractRouter } from '@orpc/contract';
|
3
|
-
import type { Router } from '@orpc/server';
|
1
|
+
import type { RouterClient } from '@orpc/server';
|
4
2
|
import type { QueryClient } from '@tanstack/react-query';
|
5
3
|
import { type Context } from 'react';
|
6
|
-
export interface ORPCContextValue<
|
7
|
-
client:
|
4
|
+
export interface ORPCContextValue<T extends RouterClient<any>> {
|
5
|
+
client: T;
|
8
6
|
queryClient: QueryClient;
|
9
7
|
}
|
10
|
-
export type ORPCContext<
|
11
|
-
export declare function createORPCContext<
|
12
|
-
export declare function useORPCContext<
|
8
|
+
export type ORPCContext<T extends RouterClient<any>> = Context<ORPCContextValue<T> | undefined>;
|
9
|
+
export declare function createORPCContext<T extends RouterClient<any>>(): ORPCContext<T>;
|
10
|
+
export declare function useORPCContext<T extends RouterClient<any>>(context: ORPCContext<T>): ORPCContextValue<T>;
|
13
11
|
//# sourceMappingURL=react-context.d.ts.map
|
@@ -1,16 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Lazy, Procedure, Router } from '@orpc/server';
|
1
|
+
import type { ProcedureClient, RouterClient } from '@orpc/server';
|
3
2
|
import type { ORPCContext } from './react-context';
|
4
3
|
import { type GeneralHooks } from './general-hooks';
|
5
4
|
import { type ProcedureHooks } from './procedure-hooks';
|
6
|
-
export type
|
7
|
-
[K in keyof
|
8
|
-
} & GeneralHooks<
|
9
|
-
export
|
10
|
-
|
11
|
-
} & GeneralHooks<undefined, undefined, unknown>;
|
12
|
-
export interface CreateORPCHooksOptions<TRouter extends ContractRouter | Router<any>> {
|
13
|
-
context: ORPCContext<TRouter>;
|
5
|
+
export type ORPCHooks<T extends RouterClient<any>> = T extends ProcedureClient<infer TInput, infer TOutput> ? ProcedureHooks<TInput, TOutput> & GeneralHooks<TInput, TOutput> : {
|
6
|
+
[K in keyof T]: T[K] extends RouterClient<any> ? ORPCHooks<T[K]> : never;
|
7
|
+
} & GeneralHooks<unknown, unknown>;
|
8
|
+
export interface CreateORPCHooksOptions<T extends RouterClient<any>> {
|
9
|
+
context: ORPCContext<T>;
|
14
10
|
/**
|
15
11
|
* The path of the router.
|
16
12
|
*
|
@@ -18,5 +14,5 @@ export interface CreateORPCHooksOptions<TRouter extends ContractRouter | Router<
|
|
18
14
|
*/
|
19
15
|
path?: string[];
|
20
16
|
}
|
21
|
-
export declare function createORPCHooks<
|
17
|
+
export declare function createORPCHooks<T extends RouterClient<any>>(options: CreateORPCHooksOptions<T>): ORPCHooks<T>;
|
22
18
|
//# sourceMappingURL=react-hooks.d.ts.map
|
@@ -1,16 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Lazy, Procedure, Router } from '@orpc/server';
|
1
|
+
import type { ProcedureClient, RouterClient } from '@orpc/server';
|
3
2
|
import type { ORPCContextValue } from './react-context';
|
4
3
|
import { type GeneralUtils } from './general-utils';
|
5
4
|
import { type ProcedureUtils } from './procedure-utils';
|
6
|
-
export type
|
7
|
-
[K in keyof
|
8
|
-
} & GeneralUtils<
|
9
|
-
export
|
10
|
-
|
11
|
-
} & GeneralUtils<undefined, undefined, unknown>;
|
12
|
-
export interface CreateORPCUtilsOptions<TRouter extends ContractRouter | Router<any>> {
|
13
|
-
contextValue: ORPCContextValue<TRouter>;
|
5
|
+
export type ORPCUtils<T extends RouterClient<any>> = T extends ProcedureClient<infer TInput, infer TOutput> ? ProcedureUtils<TInput, TOutput> & GeneralUtils<TInput, TOutput> : {
|
6
|
+
[K in keyof T]: T[K] extends RouterClient<any> ? ORPCUtils<T[K]> : never;
|
7
|
+
} & GeneralUtils<unknown, unknown>;
|
8
|
+
export interface CreateORPCUtilsOptions<T extends RouterClient<any>> {
|
9
|
+
contextValue: ORPCContextValue<T>;
|
14
10
|
/**
|
15
11
|
* The path of the router.
|
16
12
|
*
|
@@ -18,5 +14,5 @@ export interface CreateORPCUtilsOptions<TRouter extends ContractRouter | Router<
|
|
18
14
|
*/
|
19
15
|
path?: string[];
|
20
16
|
}
|
21
|
-
export declare function createORPCUtils<
|
17
|
+
export declare function createORPCUtils<T extends RouterClient<any>>(options: CreateORPCUtilsOptions<T>): ORPCUtils<T>;
|
22
18
|
//# sourceMappingURL=react-utils.d.ts.map
|
package/dist/src/react.d.ts
CHANGED
@@ -1,21 +1,15 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
useQueries: UseQueriesWithContractRouter<TRouter>;
|
1
|
+
import type { RouterClient } from '@orpc/server';
|
2
|
+
import type { ORPCContext, ORPCContextValue } from './react-context';
|
3
|
+
import type { ORPCHooks } from './react-hooks';
|
4
|
+
import type { ORPCUtils } from './react-utils';
|
5
|
+
import type { UseQueries } from './use-queries/hook';
|
6
|
+
export type ORPCReact<T extends RouterClient<any>> = ORPCHooks<T> & {
|
7
|
+
useContext: () => ORPCContextValue<T>;
|
8
|
+
useUtils: () => ORPCUtils<T>;
|
9
|
+
useQueries: UseQueries<T>;
|
11
10
|
};
|
12
|
-
export
|
13
|
-
|
14
|
-
|
15
|
-
useQueries: UseQueriesWithRouter<TRouter>;
|
16
|
-
};
|
17
|
-
export declare function createORPCReact<TRouter extends ContractRouter | Router<any>>(): {
|
18
|
-
orpc: TRouter extends Router<any> ? ORPCReactWithRouter<TRouter> : TRouter extends ContractRouter ? ORPCReactWithContractRouter<TRouter> : never;
|
19
|
-
ORPCContext: ORPCContext<TRouter>;
|
11
|
+
export declare function createORPCReact<T extends RouterClient<any>>(): {
|
12
|
+
orpc: ORPCReact<T>;
|
13
|
+
ORPCContext: ORPCContext<T>;
|
20
14
|
};
|
21
15
|
//# sourceMappingURL=react.d.ts.map
|
@@ -1,15 +1,14 @@
|
|
1
|
-
import type { SchemaInput } from '@orpc/contract';
|
2
1
|
import type { PartialDeep } from '@orpc/shared';
|
3
2
|
import type { MutationKey, QueryKey } from '@tanstack/react-query';
|
4
3
|
import type { ProcedureHooks } from './procedure-hooks';
|
5
|
-
import type {
|
4
|
+
import type { ORPCHooks } from './react-hooks';
|
6
5
|
export type QueryType = 'query' | 'infinite' | undefined;
|
7
6
|
export interface GetQueryKeyOptions<TInput> {
|
8
7
|
input?: TInput;
|
9
8
|
type?: QueryType;
|
10
9
|
}
|
11
|
-
export declare function getQueryKey<T extends
|
10
|
+
export declare function getQueryKey<T extends ORPCHooks<any> | ProcedureHooks<any, any>>(orpc: T, options?: GetQueryKeyOptions<T extends ProcedureHooks<infer UInput, any> ? PartialDeep<UInput> : unknown>): QueryKey;
|
12
11
|
export declare function getQueryKeyFromPath(path: string[], options?: GetQueryKeyOptions<unknown>): QueryKey;
|
13
|
-
export declare function getMutationKey<T extends
|
12
|
+
export declare function getMutationKey<T extends ORPCHooks<any> | ProcedureHooks<any, any>>(orpc: T): MutationKey;
|
14
13
|
export declare function getMutationKeyFromPath(path: string[]): MutationKey;
|
15
14
|
//# sourceMappingURL=tanstack-key.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
export type
|
3
|
-
export type InferCursor<TInputSchema extends Schema> = SchemaInput<TInputSchema> extends {
|
1
|
+
export type SchemaInputForInfiniteQuery<TInput> = Omit<TInput, 'cursor'>;
|
2
|
+
export type InferCursor<TInput> = TInput extends {
|
4
3
|
cursor?: any;
|
5
|
-
} ?
|
4
|
+
} ? TInput['cursor'] : never;
|
6
5
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,20 +1,19 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Caller } from '@orpc/server';
|
1
|
+
import type { ProcedureClient } from '@orpc/server';
|
3
2
|
import type { SetOptional } from '@orpc/shared';
|
4
3
|
import type { DefaultError, OmitKeyof, QueriesPlaceholderDataFunction, QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
5
4
|
type UseQueryOptionsForUseQueries<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
6
5
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
7
6
|
};
|
8
|
-
export interface UseQueriesBuilder<
|
9
|
-
(input:
|
7
|
+
export interface UseQueriesBuilder<TInput, TOutput> {
|
8
|
+
(input: TInput, options?: SetOptional<UseQueryOptionsForUseQueries<TOutput>, 'queryFn' | 'queryKey'>): UseQueryOptionsForUseQueries<TOutput>;
|
10
9
|
}
|
11
|
-
export interface CreateUseQueriesBuilderOptions<
|
12
|
-
client:
|
10
|
+
export interface CreateUseQueriesBuilderOptions<TInput, TOutput> {
|
11
|
+
client: ProcedureClient<TInput, TOutput>;
|
13
12
|
/**
|
14
13
|
* The path of procedure on server
|
15
14
|
*/
|
16
15
|
path: string[];
|
17
16
|
}
|
18
|
-
export declare function createUseQueriesBuilder<
|
17
|
+
export declare function createUseQueriesBuilder<TInput, TOutput>(options: CreateUseQueriesBuilderOptions<TInput, TOutput>): UseQueriesBuilder<TInput, TOutput>;
|
19
18
|
export {};
|
20
19
|
//# sourceMappingURL=builder.d.ts.map
|
@@ -1,19 +1,14 @@
|
|
1
|
-
import type { RouterClient } from '@orpc/
|
2
|
-
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { Procedure, Router } from '@orpc/server';
|
1
|
+
import type { ProcedureClient, RouterClient } from '@orpc/server';
|
4
2
|
import { type UseQueriesBuilder } from './builder';
|
5
|
-
export type
|
6
|
-
[K in keyof
|
3
|
+
export type UseQueriesBuilders<T extends RouterClient<any>> = T extends ProcedureClient<infer UInput, infer UOutput> ? UseQueriesBuilder<UInput, UOutput> : {
|
4
|
+
[K in keyof T]: T[K] extends RouterClient<any> ? UseQueriesBuilders<T[K]> : never;
|
7
5
|
};
|
8
|
-
export
|
9
|
-
|
10
|
-
};
|
11
|
-
export interface CreateUseQueriesBuildersOptions<TRouter extends Router<any> | ContractRouter> {
|
12
|
-
client: RouterClient<TRouter>;
|
6
|
+
export interface CreateUseQueriesBuildersOptions<T extends RouterClient<any>> {
|
7
|
+
client: T;
|
13
8
|
/**
|
14
9
|
* The path of router on server
|
15
10
|
*/
|
16
11
|
path?: string[];
|
17
12
|
}
|
18
|
-
export declare function createUseQueriesBuilders<
|
13
|
+
export declare function createUseQueriesBuilders<T extends RouterClient<any>>(options: CreateUseQueriesBuildersOptions<T>): UseQueriesBuilders<T>;
|
19
14
|
//# sourceMappingURL=builders.d.ts.map
|
@@ -1,16 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
<T extends Array<any> = [], TCombinedResult = QueriesResults<T>>(build: (builders: UseQueriesBuildersWithContractRouter<TRouter>) => [...QueriesOptions<T>], combine?: (result: QueriesResults<T>) => TCombinedResult): TCombinedResult;
|
1
|
+
import type { RouterClient } from '@orpc/server';
|
2
|
+
import type { QueriesOptions, QueriesResults } from '@tanstack/react-query';
|
3
|
+
import type { ORPCContext } from '../react-context';
|
4
|
+
import type { UseQueriesBuilders } from './builders';
|
5
|
+
export interface UseQueries<T extends RouterClient<any>> {
|
6
|
+
<U extends Array<any> = [], UCombinedResult = QueriesResults<U>>(build: (builders: UseQueriesBuilders<T>) => [...QueriesOptions<U>], combine?: (result: QueriesResults<U>) => UCombinedResult): UCombinedResult;
|
8
7
|
}
|
9
|
-
export interface
|
10
|
-
|
8
|
+
export interface UseQueriesFactoryOptions<T extends RouterClient<any>> {
|
9
|
+
context: ORPCContext<T>;
|
11
10
|
}
|
12
|
-
export
|
13
|
-
context: ORPCContext<TRouter>;
|
14
|
-
}
|
15
|
-
export declare function useQueriesFactory<TRouter extends Router<any> | ContractRouter>(options: UseQueriesFactoryOptions<TRouter>): TRouter extends Router<any> ? UseQueriesWithRouter<TRouter> : TRouter extends ContractRouter ? UseQueriesWithContractRouter<TRouter> : never;
|
11
|
+
export declare function useQueriesFactory<T extends RouterClient<any>>(options: UseQueriesFactoryOptions<T>): UseQueries<T>;
|
16
12
|
//# sourceMappingURL=hook.d.ts.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.17.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -31,12 +31,12 @@
|
|
31
31
|
"peerDependencies": {
|
32
32
|
"@tanstack/react-query": ">=5.55.0",
|
33
33
|
"react": ">=18.3.0",
|
34
|
-
"@orpc/
|
35
|
-
"@orpc/
|
36
|
-
"@orpc/contract": "0.
|
34
|
+
"@orpc/server": "0.17.0",
|
35
|
+
"@orpc/client": "0.17.0",
|
36
|
+
"@orpc/contract": "0.17.0"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@orpc/shared": "0.
|
39
|
+
"@orpc/shared": "0.17.0"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
42
|
"zod": "^3.24.1"
|