@orpc/react-query 0.46.0 → 0.47.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.d.mts CHANGED
@@ -47,30 +47,28 @@ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
47
47
  context?: TClientContext;
48
48
  } : {
49
49
  context: TClientContext;
50
- }) & UseMutationOptions<TOutput, TError, TInput, TMutationContext>;
51
- interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
52
- mutationKey: QueryKey;
53
- mutationFn(input: TInput): Promise<TOutput>;
54
- retry?(failureCount: number, error: TError): boolean;
55
- }
50
+ }) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
51
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext> = UseMutationOptions<TOutput, TError, TInput, TMutationContext>;
56
52
 
57
53
  interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
58
54
  call: Client<TClientContext, TInput, TOutput, TError>;
59
55
  queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
60
56
  infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
61
- mutationOptions<U, UMutationContext>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<U & Omit<MutationOptionsBase<TInput, TOutput, TError>, keyof U>>;
57
+ mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
58
+ }
59
+ interface CreateProcedureUtilsOptions {
60
+ path: string[];
62
61
  }
63
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
62
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
64
63
 
65
64
  type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
66
65
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
67
66
  } & GeneralUtils<unknown>;
68
- /**
69
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
70
- * @param path - The base path for query key, when it it will be prefix to all keys
71
- */
72
- declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
67
+ interface CreateRouterUtilsOptions {
68
+ path?: string[];
69
+ }
70
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
73
71
 
74
72
  declare const createORPCReactQueryUtils: typeof createRouterUtils;
75
73
 
76
- export { type BuildKeyOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MutationOptionsBase, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCReactQueryUtils, createProcedureUtils, createRouterUtils };
74
+ export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCReactQueryUtils, createProcedureUtils, createRouterUtils };
package/dist/index.d.ts CHANGED
@@ -47,30 +47,28 @@ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
47
47
  context?: TClientContext;
48
48
  } : {
49
49
  context: TClientContext;
50
- }) & UseMutationOptions<TOutput, TError, TInput, TMutationContext>;
51
- interface MutationOptionsBase<TInput, TOutput, TError extends Error> {
52
- mutationKey: QueryKey;
53
- mutationFn(input: TInput): Promise<TOutput>;
54
- retry?(failureCount: number, error: TError): boolean;
55
- }
50
+ }) & MutationOptions<TInput, TOutput, TError, TMutationContext>;
51
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext> = UseMutationOptions<TOutput, TError, TInput, TMutationContext>;
56
52
 
57
53
  interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
58
54
  call: Client<TClientContext, TInput, TOutput, TError>;
59
55
  queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
60
56
  infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
61
- mutationOptions<U, UMutationContext>(...rest: MaybeOptionalOptions<U & MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<U & Omit<MutationOptionsBase<TInput, TOutput, TError>, keyof U>>;
57
+ mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
58
+ }
59
+ interface CreateProcedureUtilsOptions {
60
+ path: string[];
62
61
  }
63
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
62
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
64
63
 
65
64
  type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
66
65
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
67
66
  } & GeneralUtils<unknown>;
68
- /**
69
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
70
- * @param path - The base path for query key, when it it will be prefix to all keys
71
- */
72
- declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
67
+ interface CreateRouterUtilsOptions {
68
+ path?: string[];
69
+ }
70
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
73
71
 
74
72
  declare const createORPCReactQueryUtils: typeof createRouterUtils;
75
73
 
76
- export { type BuildKeyOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MutationOptionsBase, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCReactQueryUtils, createProcedureUtils, createRouterUtils };
74
+ export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type InfiniteOptionsBase, type InfiniteOptionsIn, type KeyType, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptionsBase, type QueryOptionsIn, type RouterUtils, buildKey, createGeneralUtils, createORPCReactQueryUtils, createProcedureUtils, createRouterUtils };
package/dist/index.mjs CHANGED
@@ -15,38 +15,39 @@ function createGeneralUtils(path) {
15
15
  };
16
16
  }
17
17
 
18
- function createProcedureUtils(client, path) {
18
+ function createProcedureUtils(client, options) {
19
19
  return {
20
20
  call: client,
21
- queryOptions(...[{ input, context, ...rest } = {}]) {
21
+ queryOptions(...[optionsIn = {}]) {
22
22
  return {
23
- queryKey: buildKey(path, { type: "query", input }),
24
- queryFn: ({ signal }) => client(input, { signal, context }),
25
- ...rest
23
+ queryKey: buildKey(options.path, { type: "query", input: optionsIn.input }),
24
+ queryFn: ({ signal }) => client(optionsIn.input, { signal, context: optionsIn.context }),
25
+ ...optionsIn
26
26
  };
27
27
  },
28
- infiniteOptions({ input, context, ...rest }) {
28
+ infiniteOptions(optionsIn) {
29
29
  return {
30
- queryKey: buildKey(path, { type: "infinite", input: input(rest.initialPageParam) }),
30
+ queryKey: buildKey(options.path, { type: "infinite", input: optionsIn.input(optionsIn.initialPageParam) }),
31
31
  queryFn: ({ pageParam, signal }) => {
32
- return client(input(pageParam), { signal, context });
32
+ return client(optionsIn.input(pageParam), { signal, context: optionsIn.context });
33
33
  },
34
- ...rest
34
+ ...optionsIn
35
35
  };
36
36
  },
37
- mutationOptions(...[{ context, ...rest } = {}]) {
37
+ mutationOptions(...[optionsIn = {}]) {
38
38
  return {
39
- mutationKey: buildKey(path, { type: "mutation" }),
40
- mutationFn: (input) => client(input, { context }),
41
- ...rest
39
+ mutationKey: buildKey(options.path, { type: "mutation" }),
40
+ mutationFn: (input) => client(input, { context: optionsIn.context }),
41
+ ...optionsIn
42
42
  };
43
43
  }
44
44
  };
45
45
  }
46
46
 
47
- function createRouterUtils(client, path = []) {
47
+ function createRouterUtils(client, options = {}) {
48
+ const path = options.path ?? [];
48
49
  const generalUtils = createGeneralUtils(path);
49
- const procedureUtils = createProcedureUtils(client, path);
50
+ const procedureUtils = createProcedureUtils(client, { path });
50
51
  const recursive = new Proxy({
51
52
  ...generalUtils,
52
53
  ...procedureUtils
@@ -56,7 +57,7 @@ function createRouterUtils(client, path = []) {
56
57
  if (typeof prop !== "string") {
57
58
  return value;
58
59
  }
59
- const nextUtils = createRouterUtils(client[prop], [...path, prop]);
60
+ const nextUtils = createRouterUtils(client[prop], { ...options, path: [...path, prop] });
60
61
  if (typeof value !== "function") {
61
62
  return nextUtils;
62
63
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/react-query",
3
3
  "type": "module",
4
- "version": "0.46.0",
4
+ "version": "0.47.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,13 +29,13 @@
29
29
  "peerDependencies": {
30
30
  "@tanstack/react-query": ">=5.59.0",
31
31
  "react": ">=18.3.0",
32
- "@orpc/client": "0.46.0"
32
+ "@orpc/client": "0.47.0"
33
33
  },
34
34
  "dependencies": {
35
- "@orpc/shared": "0.46.0"
35
+ "@orpc/shared": "0.47.0"
36
36
  },
37
37
  "devDependencies": {
38
- "zod": "^3.24.1"
38
+ "zod": "^3.24.2"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "unbuild",