@orpc/react 0.27.0 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +0,0 @@
1
- import type { PartialDeep, SetOptional } from '@orpc/shared';
2
- import type { CancelOptions, DefaultError, InfiniteData, InvalidateOptions, MutationFilters, MutationObserverOptions, OmitKeyof, QueryClient, QueryKey, QueryObserverOptions, RefetchOptions, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
3
- import type { ORPCInvalidateQueryFilters, ORPCQueryFilters } from './tanstack-query';
4
- import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
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'>) => [
8
- QueryKey,
9
- undefined | InfiniteData<TOutput, InferCursor<TInput>>
10
- ][];
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) => [
13
- QueryKey,
14
- undefined | InfiniteData<TOutput, InferCursor<TInput>>
15
- ][];
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;
22
- isMutating: (filters?: SetOptional<MutationFilters, 'mutationKey'>) => number;
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;
29
- }
30
- export interface CreateGeneralUtilsOptions {
31
- queryClient: QueryClient;
32
- /**
33
- * The path of the router or procedure on server.
34
- *
35
- * @internal
36
- */
37
- path: string[];
38
- }
39
- export declare function createGeneralUtils<TInput, TOutput>(options: CreateGeneralUtilsOptions): GeneralUtils<TInput, TOutput>;
40
- //# sourceMappingURL=general-utils.d.ts.map
@@ -1,9 +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';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- import type { ProcedureHooks } from './procedure-hooks';
2
- import type { ORPCHooks } from './react-hooks';
3
- export declare const orpcPathSymbol: unique symbol;
4
- export declare function getORPCPath(orpc: ORPCHooks<any> | ProcedureHooks<any, any>): string[];
5
- //# sourceMappingURL=orpc-path.d.ts.map
@@ -1,30 +0,0 @@
1
- import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
2
- import { type PartialOnUndefinedDeep, type SetOptional } from '@orpc/shared';
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';
4
- import { type ORPCContext } from './react-context';
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>;
9
- }>) => UseInfiniteQueryResult<USelectData>;
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>;
13
- }>) => UseSuspenseInfiniteQueryResult<USelectData>;
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>;
17
- }>) => void;
18
- useMutation: (options?: SetOptional<UseMutationOptions<TOutput, DefaultError, TInput>, 'mutationFn' | 'mutationKey'>) => UseMutationResult<TOutput, DefaultError, TInput>;
19
- }
20
- export interface CreateProcedureHooksOptions {
21
- context: ORPCContext<any>;
22
- /**
23
- * The path of the procedure on server.
24
- *
25
- * @internal
26
- */
27
- path: string[];
28
- }
29
- export declare function createProcedureHooks<TInput, TOutput>(options: CreateProcedureHooksOptions): ProcedureHooks<TInput, TOutput>;
30
- //# sourceMappingURL=procedure-hooks.d.ts.map
@@ -1,34 +0,0 @@
1
- import type { ProcedureClient } from '@orpc/server';
2
- import type { PartialOnUndefinedDeep, SetOptional } from '@orpc/shared';
3
- import type { DefaultError, EnsureInfiniteQueryDataOptions, EnsureQueryDataOptions, FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, QueryClient, QueryKey, QueryState, SetDataOptions, Updater } from '@tanstack/react-query';
4
- import type { InferCursor, SchemaInputForInfiniteQuery } from './types';
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>;
13
- }>) => Promise<void>;
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;
24
- }
25
- export interface CreateProcedureUtilsOptions<TInput, TOutput> {
26
- client: ProcedureClient<TInput, TOutput, any>;
27
- queryClient: QueryClient;
28
- /**
29
- * The path of procedure on sever
30
- */
31
- path: string[];
32
- }
33
- export declare function createProcedureUtils<TInput, TOutput>(options: CreateProcedureUtilsOptions<TInput, TOutput>): ProcedureUtils<TInput, TOutput>;
34
- //# sourceMappingURL=procedure-utils.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { RouterClient } from '@orpc/server';
2
- import type { QueryClient } from '@tanstack/react-query';
3
- import { type Context } from 'react';
4
- export interface ORPCContextValue<T extends RouterClient<any, any>> {
5
- client: T;
6
- queryClient: QueryClient;
7
- }
8
- export type ORPCContext<T extends RouterClient<any, any>> = Context<ORPCContextValue<T> | undefined>;
9
- export declare function createORPCContext<T extends RouterClient<any, any>>(): ORPCContext<T>;
10
- export declare function useORPCContext<T extends RouterClient<any, any>>(context: ORPCContext<T>): ORPCContextValue<T>;
11
- //# sourceMappingURL=react-context.d.ts.map
@@ -1,18 +0,0 @@
1
- import type { ProcedureClient, RouterClient } from '@orpc/server';
2
- import type { ORPCContext } from './react-context';
3
- import { type GeneralHooks } from './general-hooks';
4
- import { type ProcedureHooks } from './procedure-hooks';
5
- export type ORPCHooks<T extends RouterClient<any, any>> = T extends ProcedureClient<infer TInput, infer TOutput, any> ? ProcedureHooks<TInput, TOutput> & GeneralHooks<TInput, TOutput> : {
6
- [K in keyof T]: T[K] extends RouterClient<any, any> ? ORPCHooks<T[K]> : never;
7
- } & GeneralHooks<unknown, unknown>;
8
- export interface CreateORPCHooksOptions<T extends RouterClient<any, any>> {
9
- context: ORPCContext<T>;
10
- /**
11
- * The path of the router.
12
- *
13
- * @internal
14
- */
15
- path?: string[];
16
- }
17
- export declare function createORPCHooks<T extends RouterClient<any, any>>(options: CreateORPCHooksOptions<T>): ORPCHooks<T>;
18
- //# sourceMappingURL=react-hooks.d.ts.map
@@ -1,18 +0,0 @@
1
- import type { ProcedureClient, RouterClient } from '@orpc/server';
2
- import type { ORPCContextValue } from './react-context';
3
- import { type GeneralUtils } from './general-utils';
4
- import { type ProcedureUtils } from './procedure-utils';
5
- export type ORPCUtils<T extends RouterClient<any, any>> = T extends ProcedureClient<infer TInput, infer TOutput, any> ? ProcedureUtils<TInput, TOutput> & GeneralUtils<TInput, TOutput> : {
6
- [K in keyof T]: T[K] extends RouterClient<any, any> ? ORPCUtils<T[K]> : never;
7
- } & GeneralUtils<unknown, unknown>;
8
- export interface CreateORPCUtilsOptions<T extends RouterClient<any, any>> {
9
- contextValue: ORPCContextValue<T>;
10
- /**
11
- * The path of the router.
12
- *
13
- * @internal
14
- */
15
- path?: string[];
16
- }
17
- export declare function createORPCUtils<T extends RouterClient<any, any>>(options: CreateORPCUtilsOptions<T>): ORPCUtils<T>;
18
- //# sourceMappingURL=react-utils.d.ts.map
@@ -1,15 +0,0 @@
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, any>> = ORPCHooks<T> & {
7
- useContext: () => ORPCContextValue<T>;
8
- useUtils: () => ORPCUtils<T>;
9
- useQueries: UseQueries<T>;
10
- };
11
- export declare function createORPCReact<T extends RouterClient<any, any>>(): {
12
- orpc: ORPCReact<T>;
13
- ORPCContext: ORPCContext<T>;
14
- };
15
- //# sourceMappingURL=react.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { PartialDeep } from '@orpc/shared';
2
- import type { MutationKey, QueryKey } from '@tanstack/react-query';
3
- import type { ProcedureHooks } from './procedure-hooks';
4
- import type { ORPCHooks } from './react-hooks';
5
- export type QueryType = 'query' | 'infinite' | undefined;
6
- export interface GetQueryKeyOptions<TInput> {
7
- input?: TInput;
8
- type?: QueryType;
9
- }
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;
11
- export declare function getQueryKeyFromPath(path: string[], options?: GetQueryKeyOptions<unknown>): QueryKey;
12
- export declare function getMutationKey<T extends ORPCHooks<any> | ProcedureHooks<any, any>>(orpc: T): MutationKey;
13
- export declare function getMutationKeyFromPath(path: string[]): MutationKey;
14
- //# sourceMappingURL=tanstack-key.d.ts.map
@@ -1,19 +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
- }
19
- //# sourceMappingURL=tanstack-query.d.ts.map
@@ -1,5 +0,0 @@
1
- export type SchemaInputForInfiniteQuery<TInput> = Omit<TInput, 'cursor'>;
2
- export type InferCursor<TInput> = TInput extends {
3
- cursor?: any;
4
- } ? TInput['cursor'] : never;
5
- //# sourceMappingURL=types.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { ProcedureClient } from '@orpc/server';
2
- import type { SetOptional } from '@orpc/shared';
3
- import type { DefaultError, OmitKeyof, QueriesPlaceholderDataFunction, QueryKey, UseQueryOptions } from '@tanstack/react-query';
4
- type UseQueryOptionsForUseQueries<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
5
- placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
6
- };
7
- export interface UseQueriesBuilder<TInput, TOutput> {
8
- (input: TInput, options?: SetOptional<UseQueryOptionsForUseQueries<TOutput>, 'queryFn' | 'queryKey'>): UseQueryOptionsForUseQueries<TOutput>;
9
- }
10
- export interface CreateUseQueriesBuilderOptions<TInput, TOutput> {
11
- client: ProcedureClient<TInput, TOutput, any>;
12
- /**
13
- * The path of procedure on server
14
- */
15
- path: string[];
16
- }
17
- export declare function createUseQueriesBuilder<TInput, TOutput>(options: CreateUseQueriesBuilderOptions<TInput, TOutput>): UseQueriesBuilder<TInput, TOutput>;
18
- export {};
19
- //# sourceMappingURL=builder.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { ProcedureClient, RouterClient } from '@orpc/server';
2
- import { type UseQueriesBuilder } from './builder';
3
- export type UseQueriesBuilders<T extends RouterClient<any, any>> = T extends ProcedureClient<infer UInput, infer UOutput, any> ? UseQueriesBuilder<UInput, UOutput> : {
4
- [K in keyof T]: T[K] extends RouterClient<any, any> ? UseQueriesBuilders<T[K]> : never;
5
- };
6
- export interface CreateUseQueriesBuildersOptions<T extends RouterClient<any, any>> {
7
- client: T;
8
- /**
9
- * The path of router on server
10
- */
11
- path?: string[];
12
- }
13
- export declare function createUseQueriesBuilders<T extends RouterClient<any, any>>(options: CreateUseQueriesBuildersOptions<T>): UseQueriesBuilders<T>;
14
- //# sourceMappingURL=builders.d.ts.map
@@ -1,12 +0,0 @@
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, any>> {
6
- <U extends Array<any> = [], UCombinedResult = QueriesResults<U>>(build: (builders: UseQueriesBuilders<T>) => [...QueriesOptions<U>], combine?: (result: QueriesResults<U>) => UCombinedResult): UCombinedResult;
7
- }
8
- export interface UseQueriesFactoryOptions<T extends RouterClient<any, any>> {
9
- context: ORPCContext<T>;
10
- }
11
- export declare function useQueriesFactory<T extends RouterClient<any, any>>(options: UseQueriesFactoryOptions<T>): UseQueries<T>;
12
- //# sourceMappingURL=hook.d.ts.map