@orpc/react 0.14.0 → 0.16.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 +16 -16
- 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/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 +7 -7
package/dist/index.js
CHANGED
@@ -275,7 +275,7 @@ function createProcedureHooks(options) {
|
|
275
275
|
return useQuery(
|
276
276
|
{
|
277
277
|
queryKey: getQueryKeyFromPath(options.path, { input, type: "query" }),
|
278
|
-
queryFn: () => client(input),
|
278
|
+
queryFn: ({ signal }) => client(input, { signal }),
|
279
279
|
...options_
|
280
280
|
},
|
281
281
|
context.queryClient
|
@@ -291,7 +291,7 @@ function createProcedureHooks(options) {
|
|
291
291
|
input,
|
292
292
|
type: "infinite"
|
293
293
|
}),
|
294
|
-
queryFn: ({ pageParam }) => client({ ...input, cursor: pageParam }),
|
294
|
+
queryFn: ({ pageParam, signal }) => client({ ...input, cursor: pageParam }, { signal }),
|
295
295
|
...rest
|
296
296
|
},
|
297
297
|
context.queryClient
|
@@ -303,7 +303,7 @@ function createProcedureHooks(options) {
|
|
303
303
|
return useSuspenseQuery(
|
304
304
|
{
|
305
305
|
queryKey: getQueryKeyFromPath(options.path, { input, type: "query" }),
|
306
|
-
queryFn: () => client(input),
|
306
|
+
queryFn: ({ signal }) => client(input, { signal }),
|
307
307
|
...options_
|
308
308
|
},
|
309
309
|
context.queryClient
|
@@ -319,7 +319,7 @@ function createProcedureHooks(options) {
|
|
319
319
|
input,
|
320
320
|
type: "infinite"
|
321
321
|
}),
|
322
|
-
queryFn: ({ pageParam }) => client({ ...input, cursor: pageParam }),
|
322
|
+
queryFn: ({ pageParam, signal }) => client({ ...input, cursor: pageParam }, { signal }),
|
323
323
|
...rest
|
324
324
|
},
|
325
325
|
context.queryClient
|
@@ -331,7 +331,7 @@ function createProcedureHooks(options) {
|
|
331
331
|
return usePrefetchQuery(
|
332
332
|
{
|
333
333
|
queryKey: getQueryKeyFromPath(options.path, { input, type: "query" }),
|
334
|
-
queryFn: () => client(input),
|
334
|
+
queryFn: ({ signal }) => client(input, { signal }),
|
335
335
|
...options_
|
336
336
|
},
|
337
337
|
context.queryClient
|
@@ -347,7 +347,7 @@ function createProcedureHooks(options) {
|
|
347
347
|
input,
|
348
348
|
type: "infinite"
|
349
349
|
}),
|
350
|
-
queryFn: ({ pageParam }) => client({ ...input, cursor: pageParam }),
|
350
|
+
queryFn: ({ pageParam, signal }) => client({ ...input, cursor: pageParam }, { signal }),
|
351
351
|
...rest
|
352
352
|
},
|
353
353
|
context.queryClient
|
@@ -374,7 +374,7 @@ function createProcedureUtils(options) {
|
|
374
374
|
fetchQuery(input, options_) {
|
375
375
|
return options.queryClient.fetchQuery({
|
376
376
|
queryKey: getQueryKeyFromPath(options.path, { input, type: "query" }),
|
377
|
-
queryFn: () => options.client(input),
|
377
|
+
queryFn: ({ signal }) => options.client(input, { signal }),
|
378
378
|
...options_
|
379
379
|
});
|
380
380
|
},
|
@@ -385,8 +385,8 @@ function createProcedureUtils(options) {
|
|
385
385
|
input,
|
386
386
|
type: "infinite"
|
387
387
|
}),
|
388
|
-
queryFn: ({ pageParam }) => {
|
389
|
-
return options.client({ ...input, pageParam });
|
388
|
+
queryFn: ({ pageParam, signal }) => {
|
389
|
+
return options.client({ ...input, pageParam }, { signal });
|
390
390
|
},
|
391
391
|
...rest
|
392
392
|
});
|
@@ -397,7 +397,7 @@ function createProcedureUtils(options) {
|
|
397
397
|
input,
|
398
398
|
type: "query"
|
399
399
|
}),
|
400
|
-
queryFn: () => options.client(input),
|
400
|
+
queryFn: ({ signal }) => options.client(input, { signal }),
|
401
401
|
...options_
|
402
402
|
});
|
403
403
|
},
|
@@ -408,8 +408,8 @@ function createProcedureUtils(options) {
|
|
408
408
|
input,
|
409
409
|
type: "infinite"
|
410
410
|
}),
|
411
|
-
queryFn: ({ pageParam }) => {
|
412
|
-
return options.client({ ...input, cursor: pageParam });
|
411
|
+
queryFn: ({ pageParam, signal }) => {
|
412
|
+
return options.client({ ...input, cursor: pageParam }, { signal });
|
413
413
|
},
|
414
414
|
...rest
|
415
415
|
});
|
@@ -436,7 +436,7 @@ function createProcedureUtils(options) {
|
|
436
436
|
input,
|
437
437
|
type: "query"
|
438
438
|
}),
|
439
|
-
queryFn: () => options.client(input),
|
439
|
+
queryFn: ({ signal }) => options.client(input, { signal }),
|
440
440
|
...options_
|
441
441
|
});
|
442
442
|
},
|
@@ -447,8 +447,8 @@ function createProcedureUtils(options) {
|
|
447
447
|
input,
|
448
448
|
type: "infinite"
|
449
449
|
}),
|
450
|
-
queryFn: ({ pageParam }) => {
|
451
|
-
return options.client({ ...input, pageParam });
|
450
|
+
queryFn: ({ pageParam, signal }) => {
|
451
|
+
return options.client({ ...input, pageParam }, { signal });
|
452
452
|
},
|
453
453
|
...rest
|
454
454
|
});
|
@@ -584,7 +584,7 @@ function createUseQueriesBuilder(options) {
|
|
584
584
|
return (input, options_) => {
|
585
585
|
return {
|
586
586
|
queryKey: getQueryKeyFromPath(options.path, { input, type: "query" }),
|
587
|
-
queryFn: () => options.client(input),
|
587
|
+
queryFn: ({ signal }) => options.client(input, { signal }),
|
588
588
|
...options_
|
589
589
|
};
|
590
590
|
};
|
@@ -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>;
|
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,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.16.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -29,17 +29,17 @@
|
|
29
29
|
"dist"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@tanstack/react-query": ">=5.
|
32
|
+
"@tanstack/react-query": ">=5.55.0",
|
33
33
|
"react": ">=18.3.0",
|
34
|
-
"@orpc/client": "0.
|
35
|
-
"@orpc/server": "0.
|
36
|
-
"@orpc/contract": "0.
|
34
|
+
"@orpc/client": "0.16.0",
|
35
|
+
"@orpc/server": "0.16.0",
|
36
|
+
"@orpc/contract": "0.16.0"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@orpc/shared": "0.
|
39
|
+
"@orpc/shared": "0.16.0"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
|
-
"zod": "^3.
|
42
|
+
"zod": "^3.24.1"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|