vovk 3.0.0-draft.340 → 3.0.0-draft.341

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.
@@ -83,16 +83,17 @@ const createRPC = (schema, segmentName, rpcModuleName, fetcher = fetcher_js_1.fe
83
83
  handler.isRPC = true;
84
84
  handler.path = [segmentNamePath, controllerPrefix, path].filter(Boolean).join('/');
85
85
  // React Query integration
86
- handler.queryKey = () => [
86
+ handler.queryKey = (key) => [
87
87
  handler.segmentSchema.segmentName,
88
88
  handler.controllerSchema.prefix ?? '',
89
89
  handler.controllerSchema.rpcModuleName,
90
90
  handler.schema.path,
91
91
  handler.schema.httpMethod,
92
+ ...(key ?? []),
92
93
  ];
93
- handler.mutationKey = handler.queryKey;
94
+ handler.mutationKey = (key) => ['mutation', ...handler.queryKey(key)];
94
95
  handler.queryOptions = ((input, opts) => {
95
- const queryKey = handler.queryKey();
96
+ const queryKey = handler.queryKey([input]);
96
97
  return {
97
98
  queryFn: async ({ client }) => {
98
99
  const result = await handler(input);
@@ -60,8 +60,8 @@ export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownA
60
60
  segmentSchema: VovkSegmentSchema;
61
61
  fullSchema: VovkSchema;
62
62
  path: string;
63
- queryKey: () => string[];
64
- mutationKey: () => string[];
63
+ queryKey: (key?: unknown[]) => unknown[];
64
+ mutationKey: (key?: unknown[]) => ['mutation', ...unknown[]];
65
65
  queryOptions<R>(input?: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>, opts?: Partial<Omit<UseQueryOptions<Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException>, 'queryFn'>>): UseQueryOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException>;
66
66
  mutationOptions<R>(opts?: Partial<Omit<UseMutationOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException, Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>>, 'mutationFn'>>): UseMutationOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException, Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>>;
67
67
  __types: T['__types'];
@@ -77,16 +77,17 @@ export const createRPC = (schema, segmentName, rpcModuleName, fetcher = defaultF
77
77
  handler.isRPC = true;
78
78
  handler.path = [segmentNamePath, controllerPrefix, path].filter(Boolean).join('/');
79
79
  // React Query integration
80
- handler.queryKey = () => [
80
+ handler.queryKey = (key) => [
81
81
  handler.segmentSchema.segmentName,
82
82
  handler.controllerSchema.prefix ?? '',
83
83
  handler.controllerSchema.rpcModuleName,
84
84
  handler.schema.path,
85
85
  handler.schema.httpMethod,
86
+ ...(key ?? []),
86
87
  ];
87
- handler.mutationKey = handler.queryKey;
88
+ handler.mutationKey = (key) => ['mutation', ...handler.queryKey(key)];
88
89
  handler.queryOptions = ((input, opts) => {
89
- const queryKey = handler.queryKey();
90
+ const queryKey = handler.queryKey([input]);
90
91
  return {
91
92
  queryFn: async ({ client }) => {
92
93
  const result = await handler(input);
@@ -60,8 +60,8 @@ export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownA
60
60
  segmentSchema: VovkSegmentSchema;
61
61
  fullSchema: VovkSchema;
62
62
  path: string;
63
- queryKey: () => string[];
64
- mutationKey: () => string[];
63
+ queryKey: (key?: unknown[]) => unknown[];
64
+ mutationKey: (key?: unknown[]) => ['mutation', ...unknown[]];
65
65
  queryOptions<R>(input?: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>, opts?: Partial<Omit<UseQueryOptions<Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException>, 'queryFn'>>): UseQueryOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException>;
66
66
  mutationOptions<R>(opts?: Partial<Omit<UseMutationOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException, Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>>, 'mutationFn'>>): UseMutationOptions<Awaited<ClientMethodReturn<T, STREAM, R>> extends VovkStreamAsyncIterable<infer U> ? U[] : Awaited<ClientMethodReturn<T, STREAM, R>>, HttpException, Prettify<StaticMethodInput<T> & StaticMethodOptions<T, OPTS, STREAM, R, VovkDefaultFetcherOptions<OPTS>>>>;
67
67
  __types: T['__types'];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vovk",
3
3
  "type": "module",
4
- "version": "3.0.0-draft.340",
4
+ "version": "3.0.0-draft.341",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./mjs/index.js",
7
7
  "types": "./mjs/index.d.ts",