@orpc/react-query 0.0.0-next.68378b4 → 0.0.0-next.69674a7

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
@@ -56,17 +56,19 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
56
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>>;
57
57
  mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
58
58
  }
59
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
59
+ interface CreateProcedureUtilsOptions {
60
+ path: string[];
61
+ }
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>;
60
63
 
61
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> : {
62
65
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
63
66
  } & GeneralUtils<unknown>;
64
- /**
65
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
66
- * @param path - The base path for query key, when it it will be prefix to all keys
67
- */
68
- 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>;
69
71
 
70
72
  declare const createORPCReactQueryUtils: typeof createRouterUtils;
71
73
 
72
- export { type BuildKeyOptions, 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 };
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
@@ -56,17 +56,19 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
56
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>>;
57
57
  mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
58
58
  }
59
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
59
+ interface CreateProcedureUtilsOptions {
60
+ path: string[];
61
+ }
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>;
60
63
 
61
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> : {
62
65
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
63
66
  } & GeneralUtils<unknown>;
64
- /**
65
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
66
- * @param path - The base path for query key, when it it will be prefix to all keys
67
- */
68
- 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>;
69
71
 
70
72
  declare const createORPCReactQueryUtils: typeof createRouterUtils;
71
73
 
72
- export { type BuildKeyOptions, 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 };
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(...[options = {}]) {
21
+ queryOptions(...[optionsIn = {}]) {
22
22
  return {
23
- queryKey: buildKey(path, { type: "query", input: options.input }),
24
- queryFn: ({ signal }) => client(options.input, { signal, context: options.context }),
25
- ...options
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(options) {
28
+ infiniteOptions(optionsIn) {
29
29
  return {
30
- queryKey: buildKey(path, { type: "infinite", input: options.input(options.initialPageParam) }),
30
+ queryKey: buildKey(options.path, { type: "infinite", input: optionsIn.input(optionsIn.initialPageParam) }),
31
31
  queryFn: ({ pageParam, signal }) => {
32
- return client(options.input(pageParam), { signal, context: options.context });
32
+ return client(optionsIn.input(pageParam), { signal, context: optionsIn.context });
33
33
  },
34
- ...options
34
+ ...optionsIn
35
35
  };
36
36
  },
37
- mutationOptions(...[options = {}]) {
37
+ mutationOptions(...[optionsIn = {}]) {
38
38
  return {
39
- mutationKey: buildKey(path, { type: "mutation" }),
40
- mutationFn: (input) => client(input, { context: options.context }),
41
- ...options
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.0.0-next.68378b4",
4
+ "version": "0.0.0-next.69674a7",
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.0.0-next.68378b4"
32
+ "@orpc/client": "0.0.0-next.69674a7"
33
33
  },
34
34
  "dependencies": {
35
- "@orpc/shared": "0.0.0-next.68378b4"
35
+ "@orpc/shared": "0.0.0-next.69674a7"
36
36
  },
37
37
  "devDependencies": {
38
- "zod": "^3.24.1"
38
+ "zod": "^3.24.2"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "unbuild",