@orpc/react 0.14.0 → 0.15.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 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
  };
@@ -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 { 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
5
  import type { SchemaInputForInfiniteQuery } from './types';
@@ -24,7 +24,7 @@ export interface ProcedureUtils<TInputSchema extends Schema, TOutputSchema exten
24
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
25
  }
26
26
  export interface CreateProcedureUtilsOptions<TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaOutput<TOutputSchema> = SchemaOutput<TOutputSchema>> {
27
- client: ProcedureClient<TInputSchema, TOutputSchema, 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 { RouterClientWithContractRouter, RouterClientWithRouter } from '@orpc/client';
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: TRouter extends ContractRouter ? RouterClientWithContractRouter<TRouter> : TRouter extends Router<any> ? RouterClientWithRouter<TRouter> : never;
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
- 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: ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput>;
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 { RouterClientWithContractRouter, RouterClientWithRouter } from '@orpc/client';
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: TRouter extends Router<any> ? RouterClientWithRouter<TRouter> : TRouter extends ContractRouter ? RouterClientWithContractRouter<TRouter> : never;
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.14.0",
4
+ "version": "0.15.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.59.0",
32
+ "@tanstack/react-query": ">=5.55.0",
33
33
  "react": ">=18.3.0",
34
- "@orpc/client": "0.14.0",
35
- "@orpc/server": "0.14.0",
36
- "@orpc/contract": "0.14.0"
34
+ "@orpc/client": "0.15.0",
35
+ "@orpc/contract": "0.15.0",
36
+ "@orpc/server": "0.15.0"
37
37
  },
38
38
  "dependencies": {
39
- "@orpc/shared": "0.14.0"
39
+ "@orpc/shared": "0.15.0"
40
40
  },
41
41
  "devDependencies": {
42
- "zod": "^3.23.8"
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'",