@orpc/react 0.0.0-next.ef3ba82 → 0.0.0-next.f47352c
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/README.md +156 -0
- package/dist/hooks/index.d.mts +63 -0
- package/dist/hooks/index.d.ts +63 -0
- package/dist/hooks/index.mjs +65 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.mjs +27 -0
- package/package.json +20 -16
- package/dist/index.js +0 -673
- package/dist/src/general-hooks.d.ts +0 -23
- package/dist/src/general-utils.d.ts +0 -40
- package/dist/src/index.d.ts +0 -8
- package/dist/src/orpc-path.d.ts +0 -4
- package/dist/src/procedure-hooks.d.ts +0 -30
- package/dist/src/procedure-utils.d.ts +0 -34
- package/dist/src/react-context.d.ts +0 -12
- package/dist/src/react-hooks.d.ts +0 -21
- package/dist/src/react-utils.d.ts +0 -21
- package/dist/src/react.d.ts +0 -20
- package/dist/src/tanstack-key.d.ts +0 -14
- package/dist/src/tanstack-query.d.ts +0 -18
- package/dist/src/types.d.ts +0 -4
- package/dist/src/use-queries/builder.d.ts +0 -19
- package/dist/src/use-queries/builders.d.ts +0 -18
- package/dist/src/use-queries/hook.d.ts +0 -15
@@ -1,40 +0,0 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { PartialDeep, SetOptional } from '@orpc/shared';
|
3
|
-
import type { CancelOptions, DefaultError, InfiniteData, InvalidateOptions, MutationFilters, MutationObserverOptions, OmitKeyof, QueryClient, QueryKey, QueryObserverOptions, RefetchOptions, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
4
|
-
import type { ORPCInvalidateQueryFilters, ORPCQueryFilters } from './tanstack-query';
|
5
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
6
|
-
export interface GeneralUtils<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
7
|
-
getQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'queryType'>) => [QueryKey, SchemaOutput<TOutputSchema, TFuncOutput> | undefined][];
|
8
|
-
getInfiniteQueriesData: (filters?: OmitKeyof<ORPCQueryFilters<PartialDeep<SchemaInputForInfiniteQuery<TInputSchema>>>, 'queryType'>) => [
|
9
|
-
QueryKey,
|
10
|
-
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']>
|
11
|
-
][];
|
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>, SchemaInput<TInputSchema>['cursor']> | undefined, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']> | undefined>, options?: SetDataOptions) => [
|
14
|
-
QueryKey,
|
15
|
-
undefined | InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']>
|
16
|
-
][];
|
17
|
-
invalidate: (filters?: ORPCInvalidateQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: InvalidateOptions) => Promise<void>;
|
18
|
-
refetch: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: RefetchOptions) => Promise<void>;
|
19
|
-
cancel: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: CancelOptions) => Promise<void>;
|
20
|
-
remove: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>) => void;
|
21
|
-
reset: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, options?: ResetOptions) => Promise<void>;
|
22
|
-
isFetching: (filters?: ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>) => number;
|
23
|
-
isMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number;
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey'>;
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey'>>, filters?: Pick<ORPCQueryFilters<PartialDeep<SchemaInput<TInputSchema>>>, 'input' | 'queryKey'>) => void;
|
28
|
-
getMutationDefaults: (filters?: Pick<MutationFilters, 'mutationKey'>) => MutationObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>;
|
29
|
-
setMutationDefaults: (options: OmitKeyof<MutationObserverOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>, 'mutationKey'>, filters?: Pick<MutationFilters, 'mutationKey'>) => void;
|
30
|
-
}
|
31
|
-
export interface CreateGeneralUtilsOptions {
|
32
|
-
queryClient: QueryClient;
|
33
|
-
/**
|
34
|
-
* The path of the router or procedure on server.
|
35
|
-
*
|
36
|
-
* @internal
|
37
|
-
*/
|
38
|
-
path: string[];
|
39
|
-
}
|
40
|
-
export declare function createGeneralUtils<TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>>(options: CreateGeneralUtilsOptions): GeneralUtils<TInputSchema, TOutputSchema, TFuncOutput>;
|
package/dist/src/index.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
export * from './general-hooks';
|
2
|
-
export * from './general-utils';
|
3
|
-
export * from './procedure-hooks';
|
4
|
-
export * from './procedure-utils';
|
5
|
-
export * from './react';
|
6
|
-
export * from './react-context';
|
7
|
-
export * from './react-hooks';
|
8
|
-
export * from './react-utils';
|
package/dist/src/orpc-path.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { ProcedureHooks } from './procedure-hooks';
|
2
|
-
import type { ORPCHooksWithContractRouter, ORPCHooksWithRouter } from './react-hooks';
|
3
|
-
export declare const orpcPathSymbol: unique symbol;
|
4
|
-
export declare function getORPCPath(orpc: ORPCHooksWithContractRouter<any> | ORPCHooksWithRouter<any> | ProcedureHooks<any, any, any>): string[];
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
3
|
-
import { type PartialOnUndefinedDeep, type SetOptional } from '@orpc/shared';
|
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
|
-
import { type ORPCContext } from './react-context';
|
6
|
-
export interface ProcedureHooks<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
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>, SchemaInput<TInputSchema>['cursor']>>(options: PartialOnUndefinedDeep<SetOptional<UseInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, SchemaInput<TInputSchema>['cursor']>, 'queryFn' | 'queryKey'> & {
|
9
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
10
|
-
}>) => UseInfiniteQueryResult<USelectData>;
|
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>, SchemaInput<TInputSchema>['cursor']>>(options: PartialOnUndefinedDeep<SetOptional<UseSuspenseInfiniteQueryOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, USelectData, SchemaOutput<TOutputSchema, TFuncOutput>, QueryKey, SchemaInput<TInputSchema>['cursor']>, 'queryFn' | 'queryKey'> & {
|
13
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
14
|
-
}>) => UseSuspenseInfiniteQueryResult<USelectData>;
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey' | 'queryFn'> & {
|
17
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
18
|
-
}>) => void;
|
19
|
-
useMutation: (options?: SetOptional<UseMutationOptions<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>, 'mutationFn' | 'mutationKey'>) => UseMutationResult<SchemaOutput<TOutputSchema, TFuncOutput>, DefaultError, SchemaInput<TInputSchema>>;
|
20
|
-
}
|
21
|
-
export interface CreateProcedureHooksOptions {
|
22
|
-
context: ORPCContext<any>;
|
23
|
-
/**
|
24
|
-
* The path of the procedure on server.
|
25
|
-
*
|
26
|
-
* @internal
|
27
|
-
*/
|
28
|
-
path: string[];
|
29
|
-
}
|
30
|
-
export declare function createProcedureHooks<TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>>(options: CreateProcedureHooksOptions): ProcedureHooks<TInputSchema, TOutputSchema, TFuncOutput>;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import type { ProcedureClient } from '@orpc/client';
|
2
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { PartialOnUndefinedDeep, SetOptional } from '@orpc/shared';
|
4
|
-
import type { DefaultError, EnsureInfiniteQueryDataOptions, EnsureQueryDataOptions, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, QueryClient, QueryKey, QueryState, SetDataOptions, Updater } from '@tanstack/react-query';
|
5
|
-
import type { SchemaInputForInfiniteQuery } from './types';
|
6
|
-
export interface ProcedureUtils<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey' | 'queryFn'> & {
|
9
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
10
|
-
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']>>;
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey' | 'queryFn'> & {
|
13
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
14
|
-
}>) => Promise<void>;
|
15
|
-
getQueryData: (input: SchemaInput<TInputSchema>) => SchemaOutput<TOutputSchema, TFuncOutput> | undefined;
|
16
|
-
getInfiniteQueryData: (input: SchemaInputForInfiniteQuery<TInputSchema>) => InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']> | undefined;
|
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, SchemaInput<TInputSchema>['cursor']>, 'queryKey' | 'queryFn'> & {
|
19
|
-
input: SchemaInputForInfiniteQuery<TInputSchema>;
|
20
|
-
}>) => Promise<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']>>;
|
21
|
-
getQueryState: (input: SchemaInput<TInputSchema>) => QueryState<SchemaOutput<TOutputSchema, TFuncOutput>> | undefined;
|
22
|
-
getInfiniteQueryState: (input: SchemaInputForInfiniteQuery<TInputSchema>) => QueryState<InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']>> | undefined;
|
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>, SchemaInput<TInputSchema>['cursor']> | undefined, InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']> | undefined>, options?: SetDataOptions) => InfiniteData<SchemaOutput<TOutputSchema, TFuncOutput>, SchemaInput<TInputSchema>['cursor']> | undefined;
|
25
|
-
}
|
26
|
-
export interface CreateProcedureUtilsOptions<TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>> {
|
27
|
-
client: ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput>;
|
28
|
-
queryClient: QueryClient;
|
29
|
-
/**
|
30
|
-
* The path of procedure on sever
|
31
|
-
*/
|
32
|
-
path: string[];
|
33
|
-
}
|
34
|
-
export declare function createProcedureUtils<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>>(options: CreateProcedureUtilsOptions<TInputSchema, TOutputSchema, TFuncOutput>): ProcedureUtils<TInputSchema, TOutputSchema, TFuncOutput>;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { RouterClientWithContractRouter, RouterClientWithRouter } from '@orpc/client';
|
2
|
-
import type { ContractRouter } from '@orpc/contract';
|
3
|
-
import type { Router } from '@orpc/server';
|
4
|
-
import type { QueryClient } from '@tanstack/react-query';
|
5
|
-
import { type Context } from 'react';
|
6
|
-
export interface ORPCContextValue<TRouter extends ContractRouter | Router<any>> {
|
7
|
-
client: TRouter extends ContractRouter ? RouterClientWithContractRouter<TRouter> : TRouter extends Router<any> ? RouterClientWithRouter<TRouter> : never;
|
8
|
-
queryClient: QueryClient;
|
9
|
-
}
|
10
|
-
export type ORPCContext<TRouter extends ContractRouter | Router<any>> = Context<ORPCContextValue<TRouter> | undefined>;
|
11
|
-
export declare function createORPCContext<TRouter extends ContractRouter | Router<any>>(): ORPCContext<TRouter>;
|
12
|
-
export declare function useORPCContext<TRouter extends ContractRouter | Router<any>>(context: ORPCContext<TRouter>): ORPCContextValue<TRouter>;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Procedure, Router } from '@orpc/server';
|
3
|
-
import type { ORPCContext } from './react-context';
|
4
|
-
import { type GeneralHooks } from './general-hooks';
|
5
|
-
import { type ProcedureHooks } from './procedure-hooks';
|
6
|
-
export type ORPCHooksWithContractRouter<TRouter extends ContractRouter> = {
|
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
|
-
} & GeneralHooks<undefined, undefined, unknown>;
|
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;
|
11
|
-
} & GeneralHooks<undefined, undefined, unknown>;
|
12
|
-
export interface CreateORPCHooksOptions<TRouter extends ContractRouter | Router<any>> {
|
13
|
-
context: ORPCContext<TRouter>;
|
14
|
-
/**
|
15
|
-
* The path of the router.
|
16
|
-
*
|
17
|
-
* @internal
|
18
|
-
*/
|
19
|
-
path?: string[];
|
20
|
-
}
|
21
|
-
export declare function createORPCHooks<TRouter extends ContractRouter | Router<any>>(options: CreateORPCHooksOptions<TRouter>): TRouter extends Router<any> ? ORPCHooksWithRouter<TRouter> : TRouter extends ContractRouter ? ORPCHooksWithContractRouter<TRouter> : never;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Procedure, Router } from '@orpc/server';
|
3
|
-
import type { ORPCContextValue } from './react-context';
|
4
|
-
import { type GeneralUtils } from './general-utils';
|
5
|
-
import { type ProcedureUtils } from './procedure-utils';
|
6
|
-
export type ORPCUtilsWithContractRouter<TRouter extends ContractRouter> = {
|
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
|
-
} & GeneralUtils<undefined, undefined, unknown>;
|
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;
|
11
|
-
} & GeneralUtils<undefined, undefined, unknown>;
|
12
|
-
export interface CreateORPCUtilsOptions<TRouter extends ContractRouter | Router<any>> {
|
13
|
-
contextValue: ORPCContextValue<TRouter>;
|
14
|
-
/**
|
15
|
-
* The path of the router.
|
16
|
-
*
|
17
|
-
* @internal
|
18
|
-
*/
|
19
|
-
path?: string[];
|
20
|
-
}
|
21
|
-
export declare function createORPCUtils<TRouter extends ContractRouter | Router<any>>(options: CreateORPCUtilsOptions<TRouter>): TRouter extends Router<any> ? ORPCUtilsWithRouter<TRouter> : TRouter extends ContractRouter ? ORPCUtilsWithContractRouter<TRouter> : never;
|
package/dist/src/react.d.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { ContractRouter } from '@orpc/contract';
|
2
|
-
import type { Router } from '@orpc/server';
|
3
|
-
import { type ORPCContext, type ORPCContextValue } from './react-context';
|
4
|
-
import { type ORPCHooksWithContractRouter, type ORPCHooksWithRouter } from './react-hooks';
|
5
|
-
import { type ORPCUtilsWithContractRouter, type ORPCUtilsWithRouter } from './react-utils';
|
6
|
-
import { type UseQueriesWithContractRouter, type UseQueriesWithRouter } from './use-queries/hook';
|
7
|
-
export type ORPCReactWithContractRouter<TRouter extends ContractRouter> = ORPCHooksWithContractRouter<TRouter> & {
|
8
|
-
useContext: () => ORPCContextValue<TRouter>;
|
9
|
-
useUtils: () => ORPCUtilsWithContractRouter<TRouter>;
|
10
|
-
useQueries: UseQueriesWithContractRouter<TRouter>;
|
11
|
-
};
|
12
|
-
export type ORPCReactWithRouter<TRouter extends Router<any>> = ORPCHooksWithRouter<TRouter> & {
|
13
|
-
useContext: () => ORPCContextValue<TRouter>;
|
14
|
-
useUtils: () => ORPCUtilsWithRouter<TRouter>;
|
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>;
|
20
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { SchemaInput } from '@orpc/contract';
|
2
|
-
import type { PartialDeep } from '@orpc/shared';
|
3
|
-
import type { MutationKey, QueryKey } from '@tanstack/react-query';
|
4
|
-
import type { ProcedureHooks } from './procedure-hooks';
|
5
|
-
import type { ORPCHooksWithContractRouter, ORPCHooksWithRouter } from './react-hooks';
|
6
|
-
export type QueryType = 'query' | 'infinite' | undefined;
|
7
|
-
export interface GetQueryKeyOptions<TInput> {
|
8
|
-
input?: TInput;
|
9
|
-
type?: QueryType;
|
10
|
-
}
|
11
|
-
export declare function getQueryKey<T extends ORPCHooksWithContractRouter<any> | ORPCHooksWithRouter<any> | ProcedureHooks<any, any, any>>(orpc: T, options?: GetQueryKeyOptions<T extends ProcedureHooks<infer UInputSchema, any, any> ? PartialDeep<SchemaInput<UInputSchema>> : unknown>): QueryKey;
|
12
|
-
export declare function getQueryKeyFromPath(path: string[], options?: GetQueryKeyOptions<unknown>): QueryKey;
|
13
|
-
export declare function getMutationKey<T extends ORPCHooksWithContractRouter<any> | ORPCHooksWithRouter<any> | ProcedureHooks<any, any, any>>(orpc: T): MutationKey;
|
14
|
-
export declare function getMutationKeyFromPath(path: string[]): MutationKey;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import type { SetOptional } from '@orpc/shared';
|
2
|
-
import type { InvalidateQueryFilters, QueryFilters } from '@tanstack/react-query';
|
3
|
-
import type { QueryType } from './tanstack-key';
|
4
|
-
export interface ORPCAdditionalQueryFilters<TFilterInput> {
|
5
|
-
/**
|
6
|
-
* The type of the query. useQuery=query, useInfiniteQuery=infinite
|
7
|
-
* If not specified, it will match all types.
|
8
|
-
*/
|
9
|
-
queryType?: QueryType;
|
10
|
-
/**
|
11
|
-
* The input of the query. If not specified, it will match all inputs.
|
12
|
-
*/
|
13
|
-
input?: TFilterInput;
|
14
|
-
}
|
15
|
-
export interface ORPCQueryFilters<TFilterInput> extends SetOptional<QueryFilters, 'queryKey'>, ORPCAdditionalQueryFilters<TFilterInput> {
|
16
|
-
}
|
17
|
-
export interface ORPCInvalidateQueryFilters<TFilterInput> extends SetOptional<InvalidateQueryFilters, 'queryKey'>, ORPCAdditionalQueryFilters<TFilterInput> {
|
18
|
-
}
|
package/dist/src/types.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { ProcedureClient } from '@orpc/client';
|
2
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { SetOptional } from '@orpc/shared';
|
4
|
-
import type { DefaultError, OmitKeyof, QueriesPlaceholderDataFunction, QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
5
|
-
type UseQueryOptionsForUseQueries<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
6
|
-
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
7
|
-
};
|
8
|
-
export interface UseQueriesBuilder<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
9
|
-
(input: SchemaInput<TInputSchema>, options?: SetOptional<UseQueryOptionsForUseQueries<SchemaOutput<TOutputSchema, TFuncOutput>>, 'queryFn' | 'queryKey'>): UseQueryOptionsForUseQueries<SchemaOutput<TOutputSchema, TFuncOutput>>;
|
10
|
-
}
|
11
|
-
export interface CreateUseQueriesBuilderOptions<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
12
|
-
client: ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput>;
|
13
|
-
/**
|
14
|
-
* The path of procedure on server
|
15
|
-
*/
|
16
|
-
path: string[];
|
17
|
-
}
|
18
|
-
export declare function createUseQueriesBuilder<TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>>(options: CreateUseQueriesBuilderOptions<TInputSchema, TOutputSchema, TFuncOutput>): UseQueriesBuilder<TInputSchema, TOutputSchema, TFuncOutput>;
|
19
|
-
export {};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import type { RouterClientWithContractRouter, RouterClientWithRouter } from '@orpc/client';
|
2
|
-
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { Procedure, Router } from '@orpc/server';
|
4
|
-
import { type UseQueriesBuilder } from './builder';
|
5
|
-
export type UseQueriesBuildersWithContractRouter<TRouter extends ContractRouter> = {
|
6
|
-
[K in keyof TRouter]: TRouter[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? UseQueriesBuilder<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> : TRouter[K] extends ContractRouter ? UseQueriesBuildersWithContractRouter<TRouter[K]> : never;
|
7
|
-
};
|
8
|
-
export type UseQueriesBuildersWithRouter<TRouter extends Router<any>> = {
|
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
|
-
};
|
11
|
-
export interface CreateUseQueriesBuildersOptions<TRouter extends Router<any> | ContractRouter> {
|
12
|
-
client: TRouter extends Router<any> ? RouterClientWithRouter<TRouter> : TRouter extends ContractRouter ? RouterClientWithContractRouter<TRouter> : never;
|
13
|
-
/**
|
14
|
-
* The path of router on server
|
15
|
-
*/
|
16
|
-
path?: string[];
|
17
|
-
}
|
18
|
-
export declare function createUseQueriesBuilders<TRouter extends Router<any> | ContractRouter>(options: CreateUseQueriesBuildersOptions<TRouter>): TRouter extends Router<any> ? UseQueriesBuildersWithRouter<TRouter> : TRouter extends ContractRouter ? UseQueriesBuildersWithContractRouter<TRouter> : never;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import type { ContractRouter } from '@orpc/contract';
|
2
|
-
import type { Router } from '@orpc/server';
|
3
|
-
import { type QueriesOptions, type QueriesResults } from '@tanstack/react-query';
|
4
|
-
import { type ORPCContext } from '../react-context';
|
5
|
-
import { type UseQueriesBuildersWithContractRouter, type UseQueriesBuildersWithRouter } from './builders';
|
6
|
-
export interface UseQueriesWithContractRouter<TRouter extends ContractRouter> {
|
7
|
-
<T extends Array<any> = [], TCombinedResult = QueriesResults<T>>(build: (builders: UseQueriesBuildersWithContractRouter<TRouter>) => [...QueriesOptions<T>], combine?: (result: QueriesResults<T>) => TCombinedResult): TCombinedResult;
|
8
|
-
}
|
9
|
-
export interface UseQueriesWithRouter<TRouter extends Router<any>> {
|
10
|
-
<T extends Array<any> = [], TCombinedResult = QueriesResults<T>>(build: (builders: UseQueriesBuildersWithRouter<TRouter>) => [...QueriesOptions<T>], combine?: (result: QueriesResults<T>) => TCombinedResult): TCombinedResult;
|
11
|
-
}
|
12
|
-
export interface UseQueriesFactoryOptions<TRouter extends Router<any> | ContractRouter> {
|
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;
|