@orpc/react 0.0.0-next-20241126071108 → 0.0.0-next.18dacf3
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 +42 -4940
- package/dist/src/general-utils.d.ts +6 -6
- package/dist/src/procedure-hooks.d.ts +4 -4
- package/dist/src/procedure-utils.d.ts +12 -12
- package/dist/src/react-context.d.ts +2 -2
- package/dist/src/react-hooks.d.ts +2 -2
- package/dist/src/react-utils.d.ts +2 -2
- package/dist/src/types.d.ts +4 -3
- package/dist/src/use-queries/builder.d.ts +2 -2
- package/dist/src/use-queries/builders.d.ts +2 -2
- package/package.json +17 -21
- package/dist/index.js.map +0 -1
- package/dist/src/general-hooks.d.ts.map +0 -1
- package/dist/src/general-utils.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/orpc-path.d.ts.map +0 -1
- package/dist/src/procedure-hooks.d.ts.map +0 -1
- package/dist/src/procedure-utils.d.ts.map +0 -1
- package/dist/src/react-context.d.ts.map +0 -1
- package/dist/src/react-hooks.d.ts.map +0 -1
- package/dist/src/react-utils.d.ts.map +0 -1
- package/dist/src/react.d.ts.map +0 -1
- package/dist/src/tanstack-key.d.ts.map +0 -1
- package/dist/src/tanstack-query.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/use-queries/builder.d.ts.map +0 -1
- package/dist/src/use-queries/builders.d.ts.map +0 -1
- package/dist/src/use-queries/hook.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/general-hooks.test-d.ts +0 -151
- package/src/general-hooks.test.tsx +0 -232
- package/src/general-hooks.ts +0 -101
- package/src/general-utils.test-d.ts +0 -454
- package/src/general-utils.test.tsx +0 -818
- package/src/general-utils.ts +0 -393
- package/src/index.ts +0 -8
- package/src/orpc-path.test-d.ts +0 -13
- package/src/orpc-path.test.ts +0 -12
- package/src/orpc-path.ts +0 -24
- package/src/procedure-hooks.test-d.ts +0 -321
- package/src/procedure-hooks.test.tsx +0 -388
- package/src/procedure-hooks.ts +0 -271
- package/src/procedure-utils.test-d.ts +0 -476
- package/src/procedure-utils.test.tsx +0 -330
- package/src/procedure-utils.ts +0 -312
- package/src/react-context.ts +0 -43
- package/src/react-hooks.ts +0 -94
- package/src/react-utils.ts +0 -99
- package/src/react.test-d.ts +0 -89
- package/src/react.test.tsx +0 -102
- package/src/react.tsx +0 -81
- package/src/tanstack-key.test-d.ts +0 -35
- package/src/tanstack-key.test.ts +0 -62
- package/src/tanstack-key.ts +0 -64
- package/src/tanstack-query.ts +0 -27
- package/src/types.ts +0 -7
- package/src/use-queries/builder.test-d.ts +0 -29
- package/src/use-queries/builder.test.ts +0 -25
- package/src/use-queries/builder.ts +0 -71
- package/src/use-queries/builders.test-d.ts +0 -30
- package/src/use-queries/builders.test.tsx +0 -29
- package/src/use-queries/builders.ts +0 -101
- package/src/use-queries/hook.test-d.ts +0 -64
- package/src/use-queries/hook.test.tsx +0 -89
- package/src/use-queries/hook.ts +0 -57
|
@@ -2,17 +2,17 @@ import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
|
|
2
2
|
import type { PartialDeep, SetOptional } from '@orpc/shared';
|
|
3
3
|
import type { CancelOptions, DefaultError, InfiniteData, InvalidateOptions, MutationFilters, MutationObserverOptions, OmitKeyof, QueryClient, QueryKey, QueryObserverOptions, RefetchOptions, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
|
4
4
|
import type { ORPCInvalidateQueryFilters, ORPCQueryFilters } from './tanstack-query';
|
|
5
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
|
5
|
+
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
|
6
6
|
export interface GeneralUtils<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
|
7
7
|
getQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'queryType'>) => [QueryKey, SchemaOutput<TOutputSchema, TFuncOutput> | undefined][];
|
|
8
8
|
getInfiniteQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'queryType'>) => [
|
|
9
9
|
QueryKey,
|
|
10
|
-
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
10
|
+
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>
|
|
11
11
|
][];
|
|
12
12
|
setQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'queryType'>, updater: Updater<SchemaOutput<TOutputSchema, TFuncOutput> | undefined, SchemaOutput<TOutputSchema, TFuncOutput> | undefined>, options?: SetDataOptions) => [QueryKey, SchemaOutput<TOutputSchema, TFuncOutput> | undefined][];
|
|
13
|
-
setInfiniteQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'queryType'>, updater: Updater<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
13
|
+
setInfiniteQueriesData: (filters: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'queryType'>, updater: Updater<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined>, options?: SetDataOptions) => [
|
|
14
14
|
QueryKey,
|
|
15
|
-
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
15
|
+
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>
|
|
16
16
|
][];
|
|
17
17
|
invalidate: (filters?: ORPCInvalidateQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: InvalidateOptions) => Promise<void>;
|
|
18
18
|
refetch: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: RefetchOptions) => Promise<void>;
|
|
@@ -22,9 +22,9 @@ export interface GeneralUtils<TInputSchema extends Schema, TOutputSchema extends
|
|
|
22
22
|
isFetching: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>) => number;
|
|
23
23
|
isMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number;
|
|
24
24
|
getQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'input' | 'queryKey'>) => OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryKey'>;
|
|
25
|
-
getInfiniteQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'input' | 'queryKey'>) => OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>>, QueryKey,
|
|
25
|
+
getInfiniteQueryDefaults: (filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'input' | 'queryKey'>) => OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>>, QueryKey, InferCursor<TInputSchema>>, 'queryKey'>;
|
|
26
26
|
setQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryKey'>>, filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'input' | 'queryKey'>) => void;
|
|
27
|
-
setInfiniteQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>>, QueryKey,
|
|
27
|
+
setInfiniteQueryDefaults: (options: Partial<OmitKeyof<QueryObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>>, QueryKey, InferCursor<TInputSchema>>, 'queryKey'>>, filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'input' | 'queryKey'>) => void;
|
|
28
28
|
getMutationDefaults: (filters?: Pick<MutationFilters, 'mutationKey'>) => MutationObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>;
|
|
29
29
|
setMutationDefaults: (options: OmitKeyof<MutationObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>, 'mutationKey'>, filters?: Pick<MutationFilters, 'mutationKey'>) => void;
|
|
30
30
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
|
2
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
|
2
|
+
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
|
3
3
|
import { type PartialOnUndefinedDeep, type SetOptional } from '@orpc/shared';
|
|
4
4
|
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
5
|
import { type ORPCContext } from './react-context';
|
|
6
6
|
export interface ProcedureHooks<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
|
7
7
|
useQuery: <USelectData = SchemaOutput<TOutputSchema, TFuncOutput>>(input: SchemaInput<TInputSchema>, options?: SetOptional<UseQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData>, 'queryFn' | 'queryKey'>) => UseQueryResult<USelectData>;
|
|
8
|
-
useInfiniteQuery: <USelectData = InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
8
|
+
useInfiniteQuery: <USelectData = InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>>(options: PartialOnUndefinedDeep<SetOptional<UseInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryFn' | 'queryKey'> & {
|
|
9
9
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
10
10
|
}>) => UseInfiniteQueryResult<USelectData>;
|
|
11
11
|
useSuspenseQuery: <USelectData = SchemaOutput<TOutputSchema, TFuncOutput>>(input: SchemaInput<TInputSchema>, options?: SetOptional<UseSuspenseQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData>, 'queryFn' | 'queryKey'>) => UseSuspenseQueryResult<USelectData>;
|
|
12
|
-
useSuspenseInfiniteQuery: <USelectData = InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
12
|
+
useSuspenseInfiniteQuery: <USelectData = InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>>(options: PartialOnUndefinedDeep<SetOptional<UseSuspenseInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryFn' | 'queryKey'> & {
|
|
13
13
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
14
14
|
}>) => UseSuspenseInfiniteQueryResult<USelectData>;
|
|
15
15
|
usePrefetchQuery: (input: SchemaInput<TInputSchema>, options?: FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>) => void;
|
|
16
|
-
usePrefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey,
|
|
16
|
+
usePrefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryKey' | 'queryFn'> & {
|
|
17
17
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
18
18
|
}>) => void;
|
|
19
19
|
useMutation: (options?: SetOptional<UseMutationOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>, 'mutationFn' | 'mutationKey'>) => UseMutationResult<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import type { ProcedureClient } from '@orpc/client';
|
|
2
1
|
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
|
2
|
+
import type { Caller } from '@orpc/server';
|
|
3
3
|
import type { PartialOnUndefinedDeep, SetOptional } from '@orpc/shared';
|
|
4
4
|
import type { DefaultError, EnsureInfiniteQueryDataOptions, EnsureQueryDataOptions, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, QueryClient, QueryKey, QueryState, SetDataOptions, Updater } from '@tanstack/react-query';
|
|
5
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
|
5
|
+
import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
|
|
6
6
|
export interface ProcedureUtils<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
|
7
7
|
fetchQuery: (input: SchemaInput<TInputSchema>, options?: SetOptional<FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryKey' | 'queryFn'>) => Promise<SchemaOutput<TOutputSchema, TFuncOutput>>;
|
|
8
|
-
fetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey,
|
|
8
|
+
fetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryKey' | 'queryFn'> & {
|
|
9
9
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
10
|
-
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
10
|
+
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>>;
|
|
11
11
|
prefetchQuery: (input: SchemaInput<TInputSchema>, options?: SetOptional<FetchQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryKey' | 'queryFn'>) => Promise<void>;
|
|
12
|
-
prefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey,
|
|
12
|
+
prefetchInfiniteQuery: (options: PartialOnUndefinedDeep<SetOptional<FetchInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryKey' | 'queryFn'> & {
|
|
13
13
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
14
14
|
}>) => Promise<void>;
|
|
15
15
|
getQueryData: (input: SchemaInput<TInputSchema>) => SchemaOutput<TOutputSchema, TFuncOutput> | undefined;
|
|
16
|
-
getInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInputSchema>) => InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
16
|
+
getInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInputSchema>) => InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined;
|
|
17
17
|
ensureQueryData: (input: SchemaInput<TInputSchema>, options?: SetOptional<EnsureQueryDataOptions<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryFn' | 'queryKey'>) => Promise<SchemaOutput<TOutputSchema, TFuncOutput>>;
|
|
18
|
-
ensureInfiniteQueryData: (options: PartialOnUndefinedDeep<SetOptional<EnsureInfiniteQueryDataOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey,
|
|
18
|
+
ensureInfiniteQueryData: (options: PartialOnUndefinedDeep<SetOptional<EnsureInfiniteQueryDataOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, InferCursor<TInputSchema>>, 'queryKey' | 'queryFn'> & {
|
|
19
19
|
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
|
20
|
-
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
20
|
+
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>>;
|
|
21
21
|
getQueryState: (input: SchemaInput<TInputSchema>) => QueryState<SchemaOutput<TOutputSchema, TFuncOutput>> | undefined;
|
|
22
|
-
getInfiniteQueryState: (input: SchemaInputForInfiniteQuery<TInputSchema>) => QueryState<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
22
|
+
getInfiniteQueryState: (input: SchemaInputForInfiniteQuery<TInputSchema>) => QueryState<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>>> | undefined;
|
|
23
23
|
setQueryData: (input: SchemaInput<TInputSchema>, updater: Updater<SchemaOutput<TOutputSchema, TFuncOutput> | undefined, SchemaOutput<TOutputSchema, TFuncOutput> | undefined>, options?: SetDataOptions) => SchemaOutput<TOutputSchema, TFuncOutput> | undefined;
|
|
24
|
-
setInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInputSchema>, updater: Updater<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>,
|
|
24
|
+
setInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInputSchema>, updater: Updater<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined>, options?: SetDataOptions) => InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, InferCursor<TInputSchema>> | undefined;
|
|
25
25
|
}
|
|
26
|
-
export interface CreateProcedureUtilsOptions<TInputSchema extends Schema
|
|
27
|
-
client:
|
|
26
|
+
export interface CreateProcedureUtilsOptions<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput> {
|
|
27
|
+
client: Caller<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, TFuncOutput>>;
|
|
28
28
|
queryClient: QueryClient;
|
|
29
29
|
/**
|
|
30
30
|
* The path of procedure on sever
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouterClient } from '@orpc/client';
|
|
2
2
|
import type { ContractRouter } from '@orpc/contract';
|
|
3
3
|
import type { Router } from '@orpc/server';
|
|
4
4
|
import type { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
import { type Context } from 'react';
|
|
6
6
|
export interface ORPCContextValue<TRouter extends ContractRouter | Router<any>> {
|
|
7
|
-
client:
|
|
7
|
+
client: RouterClient<TRouter>;
|
|
8
8
|
queryClient: QueryClient;
|
|
9
9
|
}
|
|
10
10
|
export type ORPCContext<TRouter extends ContractRouter | Router<any>> = Context<ORPCContextValue<TRouter> | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
|
2
|
-
import type { Procedure, Router } from '@orpc/server';
|
|
2
|
+
import type { Lazy, Procedure, Router } from '@orpc/server';
|
|
3
3
|
import type { ORPCContext } from './react-context';
|
|
4
4
|
import { type GeneralHooks } from './general-hooks';
|
|
5
5
|
import { type ProcedureHooks } from './procedure-hooks';
|
|
@@ -7,7 +7,7 @@ export type ORPCHooksWithContractRouter<TRouter extends ContractRouter> = {
|
|
|
7
7
|
[K in keyof TRouter]: TRouter[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> & GeneralHooks<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> : TRouter[K] extends ContractRouter ? ORPCHooksWithContractRouter<TRouter[K]> : never;
|
|
8
8
|
} & GeneralHooks<undefined, undefined, unknown>;
|
|
9
9
|
export type ORPCHooksWithRouter<TRouter extends Router<any>> = {
|
|
10
|
-
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? ProcedureHooks<UInputSchema, UOutputSchema, UFuncOutput> & GeneralHooks<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? ORPCHooksWithRouter<TRouter[K]> : never;
|
|
10
|
+
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>> ? ProcedureHooks<UInputSchema, UOutputSchema, UFuncOutput> & GeneralHooks<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? ORPCHooksWithRouter<TRouter[K]> : never;
|
|
11
11
|
} & GeneralHooks<undefined, undefined, unknown>;
|
|
12
12
|
export interface CreateORPCHooksOptions<TRouter extends ContractRouter | Router<any>> {
|
|
13
13
|
context: ORPCContext<TRouter>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
|
2
|
-
import type { Procedure, Router } from '@orpc/server';
|
|
2
|
+
import type { Lazy, Procedure, Router } from '@orpc/server';
|
|
3
3
|
import type { ORPCContextValue } from './react-context';
|
|
4
4
|
import { type GeneralUtils } from './general-utils';
|
|
5
5
|
import { type ProcedureUtils } from './procedure-utils';
|
|
@@ -7,7 +7,7 @@ export type ORPCUtilsWithContractRouter<TRouter extends ContractRouter> = {
|
|
|
7
7
|
[K in keyof TRouter]: TRouter[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureUtils<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> & GeneralUtils<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> : TRouter[K] extends ContractRouter ? ORPCUtilsWithContractRouter<TRouter[K]> : never;
|
|
8
8
|
} & GeneralUtils<undefined, undefined, unknown>;
|
|
9
9
|
export type ORPCUtilsWithRouter<TRouter extends Router<any>> = {
|
|
10
|
-
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? ProcedureUtils<UInputSchema, UOutputSchema, UFuncOutput> & GeneralUtils<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? ORPCUtilsWithRouter<TRouter[K]> : never;
|
|
10
|
+
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>> ? ProcedureUtils<UInputSchema, UOutputSchema, UFuncOutput> & GeneralUtils<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? ORPCUtilsWithRouter<TRouter[K]> : never;
|
|
11
11
|
} & GeneralUtils<undefined, undefined, unknown>;
|
|
12
12
|
export interface CreateORPCUtilsOptions<TRouter extends ContractRouter | Router<any>> {
|
|
13
13
|
contextValue: ORPCContextValue<TRouter>;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Schema, SchemaInput } from '@orpc/contract';
|
|
2
|
-
export type SchemaInputForInfiniteQuery<TInputSchema extends Schema> = Omit<SchemaInput<TInputSchema>, 'cursor'
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export type SchemaInputForInfiniteQuery<TInputSchema extends Schema> = Omit<SchemaInput<TInputSchema>, 'cursor'>;
|
|
3
|
+
export type InferCursor<TInputSchema extends Schema> = SchemaInput<TInputSchema> extends {
|
|
4
|
+
cursor?: any;
|
|
5
|
+
} ? SchemaInput<TInputSchema>['cursor'] : never;
|
|
5
6
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ProcedureClient } from '@orpc/client';
|
|
2
1
|
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
|
2
|
+
import type { Caller } from '@orpc/server';
|
|
3
3
|
import type { SetOptional } from '@orpc/shared';
|
|
4
4
|
import type { DefaultError, OmitKeyof, QueriesPlaceholderDataFunction, QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
|
5
5
|
type UseQueryOptionsForUseQueries<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
|
@@ -9,7 +9,7 @@ export interface UseQueriesBuilder<TInputSchema extends Schema, TOutputSchema ex
|
|
|
9
9
|
(input: SchemaInput<TInputSchema>, options?: SetOptional<UseQueryOptionsForUseQueries<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryFn' | 'queryKey'>): UseQueryOptionsForUseQueries<SchemaOutput<TOutputSchema, TFuncOutput>>;
|
|
10
10
|
}
|
|
11
11
|
export interface CreateUseQueriesBuilderOptions<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
|
12
|
-
client:
|
|
12
|
+
client: Caller<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, TFuncOutput>>;
|
|
13
13
|
/**
|
|
14
14
|
* The path of procedure on server
|
|
15
15
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouterClient } from '@orpc/client';
|
|
2
2
|
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
|
3
3
|
import type { Procedure, Router } from '@orpc/server';
|
|
4
4
|
import { type UseQueriesBuilder } from './builder';
|
|
@@ -9,7 +9,7 @@ export type UseQueriesBuildersWithRouter<TRouter extends Router<any>> = {
|
|
|
9
9
|
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? UseQueriesBuilder<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? UseQueriesBuildersWithRouter<TRouter[K]> : never;
|
|
10
10
|
};
|
|
11
11
|
export interface CreateUseQueriesBuildersOptions<TRouter extends Router<any> | ContractRouter> {
|
|
12
|
-
client:
|
|
12
|
+
client: RouterClient<TRouter>;
|
|
13
13
|
/**
|
|
14
14
|
* The path of router on server
|
|
15
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "unnoq",
|
|
7
|
-
"email": "contact@unnoq.com",
|
|
8
|
-
"url": "https://unnoq.com"
|
|
9
|
-
},
|
|
4
|
+
"version": "0.0.0-next.18dacf3",
|
|
10
5
|
"license": "MIT",
|
|
11
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://orpc.unnoq.com",
|
|
12
7
|
"repository": {
|
|
13
8
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/unnoq/orpc.git",
|
|
9
|
+
"url": "git+https://github.com/unnoq/orpc.git",
|
|
15
10
|
"directory": "packages/react"
|
|
16
11
|
},
|
|
17
12
|
"keywords": [
|
|
18
|
-
"unnoq"
|
|
13
|
+
"unnoq",
|
|
14
|
+
"orpc"
|
|
19
15
|
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
16
|
"exports": {
|
|
24
17
|
".": {
|
|
25
18
|
"types": "./dist/src/index.d.ts",
|
|
@@ -31,19 +24,22 @@
|
|
|
31
24
|
}
|
|
32
25
|
},
|
|
33
26
|
"files": [
|
|
34
|
-
"
|
|
35
|
-
"
|
|
27
|
+
"!**/*.map",
|
|
28
|
+
"!**/*.tsbuildinfo",
|
|
29
|
+
"dist"
|
|
36
30
|
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@tanstack/react-query": ">=5.55.0",
|
|
33
|
+
"react": ">=18.3.0",
|
|
34
|
+
"@orpc/contract": "0.0.0-next.18dacf3",
|
|
35
|
+
"@orpc/server": "0.0.0-next.18dacf3",
|
|
36
|
+
"@orpc/client": "0.0.0-next.18dacf3"
|
|
37
|
+
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@orpc/
|
|
39
|
-
"@orpc/shared": "0.0.0-next-20241126071108"
|
|
39
|
+
"@orpc/shared": "0.0.0-next.18dacf3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"react": "^18.3.1",
|
|
44
|
-
"zod": "^3.23.8",
|
|
45
|
-
"@orpc/contract": "0.0.0-next-20241126071108",
|
|
46
|
-
"@orpc/server": "0.0.0-next-20241126071108"
|
|
42
|
+
"zod": "^3.24.1"
|
|
47
43
|
},
|
|
48
44
|
"scripts": {
|
|
49
45
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|