@orpc/vue-colada 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
@@ -39,17 +39,19 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
39
39
  queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
40
40
  mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
41
41
  }
42
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
42
+ interface CreateProcedureUtilsOptions {
43
+ path: string[];
44
+ }
45
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
43
46
 
44
47
  type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
45
48
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
46
49
  } & GeneralUtils<unknown>;
47
- /**
48
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
49
- * @param path - The base path for query key, when it it will be prefix to all keys
50
- */
51
- declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
50
+ interface CreateRouterUtilsOptions {
51
+ path?: string[];
52
+ }
53
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
52
54
 
53
55
  declare const createORPCVueColadaUtils: typeof createRouterUtils;
54
56
 
55
- export { type BuildKeyOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
57
+ export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
package/dist/index.d.ts CHANGED
@@ -39,17 +39,19 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
39
39
  queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
40
40
  mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
41
41
  }
42
- declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
42
+ interface CreateProcedureUtilsOptions {
43
+ path: string[];
44
+ }
45
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
43
46
 
44
47
  type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
45
48
  [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
46
49
  } & GeneralUtils<unknown>;
47
- /**
48
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
49
- * @param path - The base path for query key, when it it will be prefix to all keys
50
- */
51
- declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
50
+ interface CreateRouterUtilsOptions {
51
+ path?: string[];
52
+ }
53
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
52
54
 
53
55
  declare const createORPCVueColadaUtils: typeof createRouterUtils;
54
56
 
55
- export { type BuildKeyOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
57
+ export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
package/dist/index.mjs CHANGED
@@ -37,19 +37,19 @@ function unrefDeep(value) {
37
37
  return value;
38
38
  }
39
39
 
40
- function createProcedureUtils(client, path) {
40
+ function createProcedureUtils(client, options) {
41
41
  return {
42
42
  call: client,
43
43
  queryOptions(...[{ input, context, ...rest } = {}]) {
44
44
  return {
45
- key: computed(() => buildKey(path, { input: unrefDeep(input) })),
45
+ key: computed(() => buildKey(options.path, { input: unrefDeep(input) })),
46
46
  query: ({ signal }) => client(unrefDeep(input), { signal, context: unrefDeep(context) }),
47
47
  ...rest
48
48
  };
49
49
  },
50
50
  mutationOptions(...[{ context, ...rest } = {}]) {
51
51
  return {
52
- key: (input) => buildKey(path, { input }),
52
+ key: (input) => buildKey(options.path, { input }),
53
53
  mutation: (input) => client(input, { context: unrefDeep(context) }),
54
54
  ...rest
55
55
  };
@@ -57,9 +57,10 @@ function createProcedureUtils(client, path) {
57
57
  };
58
58
  }
59
59
 
60
- function createRouterUtils(client, path = []) {
60
+ function createRouterUtils(client, options = {}) {
61
+ const path = options.path ?? [];
61
62
  const generalUtils = createGeneralUtils(path);
62
- const procedureUtils = createProcedureUtils(client, path);
63
+ const procedureUtils = createProcedureUtils(client, { path });
63
64
  const recursive = new Proxy({
64
65
  ...generalUtils,
65
66
  ...procedureUtils
@@ -69,7 +70,7 @@ function createRouterUtils(client, path = []) {
69
70
  if (typeof prop !== "string") {
70
71
  return value;
71
72
  }
72
- const nextUtils = createRouterUtils(client[prop], [...path, prop]);
73
+ const nextUtils = createRouterUtils(client[prop], { ...options, path: [...path, prop] });
73
74
  if (typeof value !== "function") {
74
75
  return nextUtils;
75
76
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/vue-colada",
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": {
@@ -32,8 +32,8 @@
32
32
  "vue": ">=3.3.0"
33
33
  },
34
34
  "dependencies": {
35
- "@orpc/client": "0.46.0",
36
- "@orpc/shared": "0.46.0"
35
+ "@orpc/client": "0.47.0",
36
+ "@orpc/shared": "0.47.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "pinia": "^2.3.0"