@kubb/plugin-vue-query 3.0.0-alpha.25 → 3.0.0-alpha.28

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.
Files changed (49) hide show
  1. package/dist/{chunk-FLCTCPR5.cjs → chunk-MR6KOKSU.cjs} +29 -22
  2. package/dist/chunk-MR6KOKSU.cjs.map +1 -0
  3. package/dist/{chunk-3XVQ56WT.js → chunk-MZPX2YE3.js} +16 -9
  4. package/dist/chunk-MZPX2YE3.js.map +1 -0
  5. package/dist/{chunk-UGNGEFWA.js → chunk-O777BWKH.js} +41 -34
  6. package/dist/chunk-O777BWKH.js.map +1 -0
  7. package/dist/{chunk-7KPCYMK3.cjs → chunk-XZCJTQWB.cjs} +41 -34
  8. package/dist/chunk-XZCJTQWB.cjs.map +1 -0
  9. package/dist/components.cjs +8 -8
  10. package/dist/components.d.cts +2 -3
  11. package/dist/components.d.ts +2 -3
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +5 -5
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +5 -4
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +5 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-CXg5kqwt.d.cts → types-toZI_jsT.d.cts} +5 -1
  24. package/dist/{types-CXg5kqwt.d.ts → types-toZI_jsT.d.ts} +5 -1
  25. package/package.json +12 -12
  26. package/src/components/InfiniteQuery.tsx +2 -2
  27. package/src/components/Mutation.tsx +43 -35
  28. package/src/components/Query.tsx +2 -2
  29. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +3 -3
  30. package/src/generators/__snapshots__/clientGetImportPath.ts +3 -3
  31. package/src/generators/__snapshots__/clientPostImportPath.ts +9 -12
  32. package/src/generators/__snapshots__/findByTags.ts +3 -3
  33. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +3 -3
  34. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +3 -3
  35. package/src/generators/__snapshots__/findByTagsWithZod.ts +3 -3
  36. package/src/generators/__snapshots__/findInfiniteByTags.ts +3 -3
  37. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +3 -3
  38. package/src/generators/__snapshots__/postAsQuery.ts +3 -3
  39. package/src/generators/__snapshots__/updatePetById.ts +9 -12
  40. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +9 -12
  41. package/src/generators/infiniteQueryGenerator.tsx +5 -1
  42. package/src/generators/mutationGenerator.tsx +1 -2
  43. package/src/generators/queryGenerator.tsx +1 -1
  44. package/src/plugin.ts +2 -1
  45. package/src/types.ts +5 -1
  46. package/dist/chunk-3XVQ56WT.js.map +0 -1
  47. package/dist/chunk-7KPCYMK3.cjs.map +0 -1
  48. package/dist/chunk-FLCTCPR5.cjs.map +0 -1
  49. package/dist/chunk-UGNGEFWA.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginVueQuery, I as Infinite } from './types-CXg5kqwt.cjs';
4
+ import { P as PluginVueQuery, I as Infinite } from './types-toZI_jsT.cjs';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7
 
@@ -13,13 +13,12 @@ type Props$6 = {
13
13
  typeName: string;
14
14
  clientName: string;
15
15
  mutationKeyName: string;
16
- mutationKeyTypeName: string;
17
16
  typeSchemas: OperationSchemas;
18
17
  operation: Operation;
19
18
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
20
19
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
21
20
  };
22
- declare function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyTypeName, mutationKeyName }: Props$6): ReactNode;
21
+ declare function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$6): ReactNode;
23
22
 
24
23
  type Props$5 = {
25
24
  /**
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginVueQuery, I as Infinite } from './types-CXg5kqwt.js';
4
+ import { P as PluginVueQuery, I as Infinite } from './types-toZI_jsT.js';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7
 
@@ -13,13 +13,12 @@ type Props$6 = {
13
13
  typeName: string;
14
14
  clientName: string;
15
15
  mutationKeyName: string;
16
- mutationKeyTypeName: string;
17
16
  typeSchemas: OperationSchemas;
18
17
  operation: Operation;
19
18
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
20
19
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
21
20
  };
22
- declare function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyTypeName, mutationKeyName }: Props$6): ReactNode;
21
+ declare function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$6): ReactNode;
23
22
 
24
23
  type Props$5 = {
25
24
  /**
@@ -1,3 +1,3 @@
1
- export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions } from './chunk-UGNGEFWA.js';
1
+ export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions } from './chunk-O777BWKH.js';
2
2
  //# sourceMappingURL=components.js.map
3
3
  //# sourceMappingURL=components.js.map
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkFLCTCPR5_cjs = require('./chunk-FLCTCPR5.cjs');
4
- require('./chunk-7KPCYMK3.cjs');
3
+ var chunkMR6KOKSU_cjs = require('./chunk-MR6KOKSU.cjs');
4
+ require('./chunk-XZCJTQWB.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "infiniteQueryGenerator", {
9
9
  enumerable: true,
10
- get: function () { return chunkFLCTCPR5_cjs.infiniteQueryGenerator; }
10
+ get: function () { return chunkMR6KOKSU_cjs.infiniteQueryGenerator; }
11
11
  });
12
12
  Object.defineProperty(exports, "mutationGenerator", {
13
13
  enumerable: true,
14
- get: function () { return chunkFLCTCPR5_cjs.mutationGenerator; }
14
+ get: function () { return chunkMR6KOKSU_cjs.mutationGenerator; }
15
15
  });
16
16
  Object.defineProperty(exports, "queryGenerator", {
17
17
  enumerable: true,
18
- get: function () { return chunkFLCTCPR5_cjs.queryGenerator; }
18
+ get: function () { return chunkMR6KOKSU_cjs.queryGenerator; }
19
19
  });
20
20
  //# sourceMappingURL=generators.cjs.map
21
21
  //# sourceMappingURL=generators.cjs.map
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginVueQuery } from './types-CXg5kqwt.cjs';
2
+ import { P as PluginVueQuery } from './types-toZI_jsT.cjs';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginVueQuery } from './types-CXg5kqwt.js';
2
+ import { P as PluginVueQuery } from './types-toZI_jsT.js';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
 
@@ -1,4 +1,4 @@
1
- export { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './chunk-3XVQ56WT.js';
2
- import './chunk-UGNGEFWA.js';
1
+ export { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './chunk-MZPX2YE3.js';
2
+ import './chunk-O777BWKH.js';
3
3
  //# sourceMappingURL=generators.js.map
4
4
  //# sourceMappingURL=generators.js.map
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkFLCTCPR5_cjs = require('./chunk-FLCTCPR5.cjs');
4
- require('./chunk-7KPCYMK3.cjs');
3
+ var chunkMR6KOKSU_cjs = require('./chunk-MR6KOKSU.cjs');
4
+ require('./chunk-XZCJTQWB.cjs');
5
5
  var path = require('path');
6
6
  var core = require('@kubb/core');
7
7
  var transformers = require('@kubb/core/transformers');
@@ -27,7 +27,8 @@ var pluginVueQuery = core.createPlugin((options) => {
27
27
  transformers: transformers$1 = {},
28
28
  pathParamsType = "inline",
29
29
  mutation = {},
30
- query = {}
30
+ query = {},
31
+ generators = [chunkMR6KOKSU_cjs.queryGenerator, chunkMR6KOKSU_cjs.infiniteQueryGenerator, chunkMR6KOKSU_cjs.mutationGenerator].filter(Boolean)
31
32
  } = options;
32
33
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
33
34
  return {
@@ -115,7 +116,7 @@ var pluginVueQuery = core.createPlugin((options) => {
115
116
  mode
116
117
  }
117
118
  );
118
- const files = await operationGenerator.build(chunkFLCTCPR5_cjs.queryGenerator, chunkFLCTCPR5_cjs.infiniteQueryGenerator, chunkFLCTCPR5_cjs.mutationGenerator);
119
+ const files = await operationGenerator.build(...generators);
119
120
  await this.addFile(...files);
120
121
  if (this.config.output.exportType) {
121
122
  const barrelFiles = await this.fileManager.getBarrelFiles({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator","queryGenerator","infiniteQueryGenerator","mutationGenerator"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA,mBAAA;AAErB,IAAA,cAAA,GAAiBA,iBAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAA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AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,SACF;AAAA,OACF,CAAA;AAEA,MAAA,MAAM,QAAQ,MAAM,kBAAA,CAAmB,KAAM,CAAAC,gCAAA,EAAgBC,0CAAwBC,mCAAiB,CAAA,CAAA;AACtG,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA,CAAA;AAE3B,MAAI,IAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginVueQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA,mBAAA;AAErB,IAAA,cAAA,GAAiBA,iBAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,QAAA;AAAA,kBACAC,iBAAe,EAAC;AAAA,IAChB,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,aAAa,CAACC,gCAAA,EAAgBC,0CAAwBC,mCAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,GACrF,GAAA,OAAA,CAAA;AACJ,EAAA,MAAM,WAAW,KAAO,EAAA,MAAA,GAAS,MAAM,MAAS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IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginVueQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginVueQuery } from './types-CXg5kqwt.cjs';
2
+ import { O as Options, P as PluginVueQuery } from './types-toZI_jsT.cjs';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-oas';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginVueQuery } from './types-CXg5kqwt.js';
2
+ import { O as Options, P as PluginVueQuery } from './types-toZI_jsT.js';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-oas';
5
5
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-3XVQ56WT.js';
2
- import './chunk-UGNGEFWA.js';
1
+ import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-MZPX2YE3.js';
2
+ import './chunk-O777BWKH.js';
3
3
  import path from 'node:path';
4
4
  import { createPlugin, FileManager, PluginManager } from '@kubb/core';
5
5
  import { camelCase, pascalCase } from '@kubb/core/transformers';
@@ -21,7 +21,8 @@ var pluginVueQuery = createPlugin((options) => {
21
21
  transformers = {},
22
22
  pathParamsType = "inline",
23
23
  mutation = {},
24
- query = {}
24
+ query = {},
25
+ generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean)
25
26
  } = options;
26
27
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
27
28
  return {
@@ -109,7 +110,7 @@ var pluginVueQuery = createPlugin((options) => {
109
110
  mode
110
111
  }
111
112
  );
112
- const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator);
113
+ const files = await operationGenerator.build(...generators);
113
114
  await this.addFile(...files);
114
115
  if (this.config.output.exportType) {
115
116
  const barrelFiles = await this.fileManager.getBarrelFiles({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA,mBAAA;AAErB,IAAA,cAAA,GAAiB,YAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,QAAA;AAAA,IACA,eAAe,EAAC;AAAA,IAChB,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,GACP,GAAA,OAAA,CAAA;AACJ,EAAA,MAAM,WAAW,KAAO,EAAA,MAAA,GAAS,MAAM,MAAS,GAAA,CAAA,EAAG,OAAO,IAAI,CAAA,kBAAA,CAAA,CAAA;AAE9D,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,kBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,aAAA;AAAA,QACZ,GAAG,MAAA;AAAA,OACL;AAAA,MACA,OAAS,EAAA,KAAA,CAAA;AAAA,MACT,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,cAAgB,EAAA,QAAA;AAAA,QAChB,GAAG,OAAQ,CAAA,MAAA;AAAA,OACb;AAAA,MACA,UAAU,QACN,GAAA;AAAA,QACE,UAAY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n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginVueQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA,mBAAA;AAErB,IAAA,cAAA,GAAiB,YAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,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AAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,UACnC,OAAA;AAAA,UACA,OAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,SACF;AAAA,OACF,CAAA;AAEA,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA,CAAA;AAE3B,MAAI,IAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginVueQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
@@ -1,6 +1,6 @@
1
1
  import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
2
  import { HttpMethod } from '@kubb/oas';
3
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
4
4
 
5
5
  type Query = {
6
6
  /**
@@ -158,6 +158,10 @@ type Options = {
158
158
  */
159
159
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
160
160
  };
161
+ /**
162
+ * Define some generators next to the vue-query generators
163
+ */
164
+ generators?: Array<Generator<PluginVueQuery>>;
161
165
  };
162
166
  type ResolvedOptions = {
163
167
  output: Output;
@@ -1,6 +1,6 @@
1
1
  import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
2
  import { HttpMethod } from '@kubb/oas';
3
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
4
4
 
5
5
  type Query = {
6
6
  /**
@@ -158,6 +158,10 @@ type Options = {
158
158
  */
159
159
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
160
160
  };
161
+ /**
162
+ * Define some generators next to the vue-query generators
163
+ */
164
+ generators?: Array<Generator<PluginVueQuery>>;
161
165
  };
162
166
  type ResolvedOptions = {
163
167
  output: Output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-vue-query",
3
- "version": "3.0.0-alpha.25",
3
+ "version": "3.0.0-alpha.28",
4
4
  "description": "Generator vue-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -62,24 +62,24 @@
62
62
  "!/**/__tests__/**"
63
63
  ],
64
64
  "dependencies": {
65
- "@kubb/core": "3.0.0-alpha.25",
66
- "@kubb/fs": "3.0.0-alpha.25",
67
- "@kubb/oas": "3.0.0-alpha.25",
68
- "@kubb/plugin-oas": "3.0.0-alpha.25",
69
- "@kubb/plugin-ts": "3.0.0-alpha.25",
70
- "@kubb/plugin-zod": "3.0.0-alpha.25",
71
- "@kubb/react": "3.0.0-alpha.25"
65
+ "@kubb/core": "3.0.0-alpha.28",
66
+ "@kubb/fs": "3.0.0-alpha.28",
67
+ "@kubb/oas": "3.0.0-alpha.28",
68
+ "@kubb/plugin-oas": "3.0.0-alpha.28",
69
+ "@kubb/plugin-ts": "3.0.0-alpha.28",
70
+ "@kubb/plugin-zod": "3.0.0-alpha.28",
71
+ "@kubb/react": "3.0.0-alpha.28"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/react": "^18.3.8",
74
+ "@types/react": "^18.3.9",
75
75
  "react": "^18.3.1",
76
76
  "tsup": "^8.3.0",
77
77
  "typescript": "^5.6.2",
78
- "@kubb/config-ts": "3.0.0-alpha.25",
79
- "@kubb/config-tsup": "3.0.0-alpha.25"
78
+ "@kubb/config-ts": "3.0.0-alpha.28",
79
+ "@kubb/config-tsup": "3.0.0-alpha.28"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/react": "3.0.0-alpha.25"
82
+ "@kubb/react": "3.0.0-alpha.28"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=20"
@@ -85,7 +85,7 @@ export function InfiniteQuery({
85
85
  operation,
86
86
  }: Props): ReactNode {
87
87
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
88
- const returnType = 'ReturnType<typeof query> & { queryKey: TQueryKey }'
88
+ const returnType = `UseInfiniteQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
89
89
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
90
90
 
91
91
  const queryKeyParams = QueryKey.getParams({
@@ -121,7 +121,7 @@ export function InfiniteQuery({
121
121
 
122
122
  const query = useInfiniteQuery({
123
123
  ...${queryOptions},
124
- queryKey,
124
+ queryKey: queryKey as QueryKey,
125
125
  ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
126
126
  }) as ${returnType}
127
127
 
@@ -4,6 +4,7 @@ import { type Operation, isOptional } from '@kubb/oas'
4
4
  import { Client } from '@kubb/plugin-client/components'
5
5
  import type { OperationSchemas } from '@kubb/plugin-oas'
6
6
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
7
+ import type { Params } from '@kubb/react/types'
7
8
  import type { ReactNode } from 'react'
8
9
  import type { PluginVueQuery } from '../types.ts'
9
10
  import { MutationKey } from './MutationKey.tsx'
@@ -16,7 +17,6 @@ type Props = {
16
17
  typeName: string
17
18
  clientName: string
18
19
  mutationKeyName: string
19
- mutationKeyTypeName: string
20
20
  typeSchemas: OperationSchemas
21
21
  operation: Operation
22
22
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
@@ -31,7 +31,7 @@ type GetParamsProps = {
31
31
 
32
32
  function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
33
33
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
34
- const mutateParams = FunctionParams.factory({
34
+ const mutationParams = FunctionParams.factory({
35
35
  ...getPathParams(typeSchemas.pathParams, {
36
36
  typed: true,
37
37
  override(item) {
@@ -60,7 +60,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
60
60
  }
61
61
  : undefined,
62
62
  })
63
- const TRequest = mutateParams.toConstructor({ valueAsType: true })
63
+ const TRequest = mutationParams.toConstructor({ valueAsType: true })
64
64
 
65
65
  return FunctionParams.factory({
66
66
  options: {
@@ -75,9 +75,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
75
75
  })
76
76
  }
77
77
 
78
- export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyTypeName, mutationKeyName }: Props): ReactNode {
79
- const returnType = 'ReturnType<typeof mutation> & { mutationKey: MutationKey }'
80
-
78
+ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
81
79
  const mutationKeyParams = MutationKey.getParams({
82
80
  pathParamsType,
83
81
  typeSchemas,
@@ -95,35 +93,48 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
95
93
  })
96
94
 
97
95
  const mutationParams = FunctionParams.factory({
96
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
97
+ data: typeSchemas.request?.name
98
+ ? {
99
+ type: typeSchemas.request?.name,
100
+ optional: isOptional(typeSchemas.request?.schema),
101
+ }
102
+ : undefined,
103
+ params: typeSchemas.queryParams?.name
104
+ ? {
105
+ type: typeSchemas.queryParams?.name,
106
+ optional: isOptional(typeSchemas.queryParams?.schema),
107
+ }
108
+ : undefined,
109
+ headers: typeSchemas.headerParams?.name
110
+ ? {
111
+ type: typeSchemas.headerParams?.name,
112
+ optional: isOptional(typeSchemas.headerParams?.schema),
113
+ }
114
+ : undefined,
115
+ })
116
+ const dataParams = FunctionParams.factory({
98
117
  data: {
99
118
  // No use of pathParams because useMutation can only take one argument in object form,
100
119
  // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
101
120
  mode: 'object',
102
- //TODO rename with value
103
- children: {
104
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
105
- data: typeSchemas.request?.name
106
- ? {
107
- type: typeSchemas.request?.name,
108
- optional: isOptional(typeSchemas.request?.schema),
109
- }
110
- : undefined,
111
- params: typeSchemas.queryParams?.name
112
- ? {
113
- type: typeSchemas.queryParams?.name,
114
- optional: isOptional(typeSchemas.queryParams?.schema),
115
- }
116
- : undefined,
117
- headers: typeSchemas.headerParams?.name
118
- ? {
119
- type: typeSchemas.headerParams?.name,
120
- optional: isOptional(typeSchemas.headerParams?.schema),
121
- }
122
- : undefined,
123
- },
121
+ children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
122
+ if (value) {
123
+ acc[key] = {
124
+ ...value,
125
+ type: undefined,
126
+ }
127
+ }
128
+
129
+ return acc
130
+ }, {} as Params),
124
131
  },
125
132
  })
126
133
 
134
+ const TRequest = mutationParams.toConstructor({ valueAsType: true })
135
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
136
+ const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')
137
+
127
138
  return (
128
139
  <File.Source name={name} isExportable isIndexable>
129
140
  <Function
@@ -138,16 +149,13 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
138
149
  const { mutation: mutationOptions, client: config = {} } = options ?? {}
139
150
  const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
140
151
 
141
- const mutation = useMutation({
142
- mutationFn: async(${mutationParams.toConstructor()}) => {
152
+ return useMutation<${generics}>({
153
+ mutationFn: async(${dataParams.toConstructor()}) => {
143
154
  return ${clientName}(${clientParams.toCall()})
144
155
  },
156
+ mutationKey,
145
157
  ...mutationOptions
146
- }) as ${returnType}
147
-
148
- mutation.mutationKey = mutationKey as MutationKey
149
-
150
- return mutation
158
+ })
151
159
  `}
152
160
  </Function>
153
161
  </File.Source>
@@ -76,7 +76,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
76
76
 
77
77
  export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
78
78
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
79
- const returnType = 'ReturnType<typeof query> & { queryKey: TQueryKey }'
79
+ const returnType = `UseQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
80
80
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
81
81
 
82
82
  const queryKeyParams = QueryKey.getParams({
@@ -112,7 +112,7 @@ export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
112
112
 
113
113
  const query = useQuery({
114
114
  ...${queryOptions},
115
- queryKey,
115
+ queryKey: queryKey as QueryKey,
116
116
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
117
117
  }) as ${returnType}
118
118
 
@@ -1,6 +1,6 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useQuery, queryOptions } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
@@ -42,9 +42,9 @@ export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResp
42
42
  const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
43
43
  const query = useQuery({
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
- queryKey,
45
+ queryKey: queryKey as QueryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as ReturnType<typeof query> & {
47
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -1,5 +1,5 @@
1
1
  import client from "axios";
2
- import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
2
+ import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
3
3
  import type { RequestConfig } from "axios";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useQuery, queryOptions } from "@tanstack/react-query";
@@ -42,9 +42,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
42
42
  const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
43
43
  const query = useQuery({
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
- queryKey,
45
+ queryKey: queryKey as QueryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as ReturnType<typeof query> & {
47
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -1,5 +1,5 @@
1
1
  import client from "axios";
2
- import type { MutationObserverOptions, MutationKey } from "@tanstack/react-query";
2
+ import type { MutationObserverOptions } from "@tanstack/react-query";
3
3
  import type { RequestConfig } from "axios";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useMutation } from "@tanstack/react-query";
@@ -31,18 +31,15 @@ export function useUpdatePetWithForm(options: {
31
31
  } = {}) {
32
32
  const { mutation: mutationOptions, client: config = {} } = options ?? {};
33
33
  const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
34
- const mutation = useMutation({
35
- mutationFn: async ({ petId, data, params }: {
36
- petId: UpdatePetWithFormPathParams["petId"];
37
- data?: UpdatePetWithFormMutationRequest;
38
- params?: UpdatePetWithFormQueryParams;
39
- }) => {
34
+ return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
35
+ petId: UpdatePetWithFormPathParams["petId"];
36
+ data?: UpdatePetWithFormMutationRequest;
37
+ params?: UpdatePetWithFormQueryParams;
38
+ }>({
39
+ mutationFn: async ({ petId, data, params }) => {
40
40
  return updatePetWithForm(petId, data, params, config);
41
41
  },
42
+ mutationKey,
42
43
  ...mutationOptions
43
- }) as ReturnType<typeof mutation> & {
44
- mutationKey: MutationKey;
45
- };
46
- mutation.mutationKey = mutationKey as MutationKey;
47
- return mutation;
44
+ });
48
45
  }
@@ -1,6 +1,6 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useQuery, queryOptions } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
@@ -42,9 +42,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
42
42
  const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
43
43
  const query = useQuery({
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
- queryKey,
45
+ queryKey: queryKey as QueryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as ReturnType<typeof query> & {
47
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;