@kubb/plugin-vue-query 3.0.0-alpha.23 → 3.0.0-alpha.26

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 (51) hide show
  1. package/dist/{chunk-OJJHU4GI.js → chunk-ECTNESSL.js} +27 -17
  2. package/dist/chunk-ECTNESSL.js.map +1 -0
  3. package/dist/{chunk-GER2VAF7.js → chunk-GL6WLGO3.js} +52 -29
  4. package/dist/chunk-GL6WLGO3.js.map +1 -0
  5. package/dist/{chunk-6JBAYYZS.cjs → chunk-N4EZ7N3M.cjs} +39 -29
  6. package/dist/chunk-N4EZ7N3M.cjs.map +1 -0
  7. package/dist/{chunk-VWXCJPSA.cjs → chunk-WOSAUHMD.cjs} +52 -28
  8. package/dist/chunk-WOSAUHMD.cjs.map +1 -0
  9. package/dist/components.cjs +11 -7
  10. package/dist/components.d.cts +42 -24
  11. package/dist/components.d.ts +42 -24
  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 +6 -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 +6 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-CmetQDTc.d.cts → types-toZI_jsT.d.cts} +9 -1
  24. package/dist/{types-CmetQDTc.d.ts → types-toZI_jsT.d.ts} +9 -1
  25. package/package.json +12 -12
  26. package/src/components/InfiniteQuery.tsx +2 -2
  27. package/src/components/Mutation.tsx +19 -6
  28. package/src/components/MutationKey.tsx +48 -0
  29. package/src/components/Query.tsx +2 -2
  30. package/src/components/index.ts +1 -0
  31. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -2
  32. package/src/generators/__snapshots__/clientGetImportPath.ts +2 -2
  33. package/src/generators/__snapshots__/clientPostImportPath.ts +13 -4
  34. package/src/generators/__snapshots__/findByTags.ts +2 -2
  35. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -2
  36. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
  37. package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
  38. package/src/generators/__snapshots__/findInfiniteByTags.ts +2 -2
  39. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +2 -2
  40. package/src/generators/__snapshots__/postAsQuery.ts +2 -2
  41. package/src/generators/__snapshots__/updatePetById.ts +13 -4
  42. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +13 -4
  43. package/src/generators/infiniteQueryGenerator.tsx +1 -5
  44. package/src/generators/mutationGenerator.tsx +17 -2
  45. package/src/generators/queryGenerator.tsx +1 -1
  46. package/src/plugin.ts +3 -1
  47. package/src/types.ts +9 -1
  48. package/dist/chunk-6JBAYYZS.cjs.map +0 -1
  49. package/dist/chunk-GER2VAF7.js.map +0 -1
  50. package/dist/chunk-OJJHU4GI.js.map +0 -1
  51. package/dist/chunk-VWXCJPSA.cjs.map +0 -1
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-CmetQDTc.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-OJJHU4GI.js';
2
- import './chunk-GER2VAF7.js';
1
+ import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-ECTNESSL.js';
2
+ import './chunk-GL6WLGO3.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 {
@@ -51,6 +52,7 @@ var pluginVueQuery = createPlugin((options) => {
51
52
  ...query
52
53
  },
53
54
  mutation: {
55
+ key: (key) => key,
54
56
  methods: ["post", "put", "patch", "delete"],
55
57
  importPath: "@tanstack/vue-query",
56
58
  ...mutation
@@ -108,7 +110,7 @@ var pluginVueQuery = createPlugin((options) => {
108
110
  mode
109
111
  }
110
112
  );
111
- const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator);
113
+ const files = await operationGenerator.build(...generators);
112
114
  await this.addFile(...files);
113
115
  if (this.config.output.exportType) {
114
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,OA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;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 } = 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 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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AAA;AAChE,MAAA,MAAM,OAAU,GAAA,MAAM,aAAc,CAAA,OAAA,CAAQ,UAAW,EAAA,CAAA;AAEvD,MAAA,MAAM,qBAAqB,IAAI,kBAAA;AAAA,QAC7B;AAAA,UACE,GAAG,KAAK,MAAO,CAAA,OAAA;AAAA,UACf,OAAA;AAAA,SACF;AAAA,QACA;AAAA,UACE,GAAA;AAAA,UACA,eAAe,IAAK,CAAA,aAAA;AAAA,UACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,UACb,WAAA,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
  /**
@@ -22,6 +22,10 @@ type Query = {
22
22
  importPath?: string;
23
23
  };
24
24
  type Mutation = {
25
+ /**
26
+ * Customize the queryKey, here you can specify a suffix.
27
+ */
28
+ key: (key: unknown[]) => unknown[];
25
29
  /**
26
30
  * Define which HttpMethods can be used for mutations
27
31
  * @default ['post', 'put', 'delete']
@@ -154,6 +158,10 @@ type Options = {
154
158
  */
155
159
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
156
160
  };
161
+ /**
162
+ * Define some generators next to the vue-query generators
163
+ */
164
+ generators?: Array<Generator<PluginVueQuery>>;
157
165
  };
158
166
  type ResolvedOptions = {
159
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
  /**
@@ -22,6 +22,10 @@ type Query = {
22
22
  importPath?: string;
23
23
  };
24
24
  type Mutation = {
25
+ /**
26
+ * Customize the queryKey, here you can specify a suffix.
27
+ */
28
+ key: (key: unknown[]) => unknown[];
25
29
  /**
26
30
  * Define which HttpMethods can be used for mutations
27
31
  * @default ['post', 'put', 'delete']
@@ -154,6 +158,10 @@ type Options = {
154
158
  */
155
159
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
156
160
  };
161
+ /**
162
+ * Define some generators next to the vue-query generators
163
+ */
164
+ generators?: Array<Generator<PluginVueQuery>>;
157
165
  };
158
166
  type ResolvedOptions = {
159
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.23",
3
+ "version": "3.0.0-alpha.26",
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.23",
66
- "@kubb/fs": "3.0.0-alpha.23",
67
- "@kubb/oas": "3.0.0-alpha.23",
68
- "@kubb/plugin-oas": "3.0.0-alpha.23",
69
- "@kubb/plugin-ts": "3.0.0-alpha.23",
70
- "@kubb/plugin-zod": "3.0.0-alpha.23",
71
- "@kubb/react": "3.0.0-alpha.23"
65
+ "@kubb/core": "3.0.0-alpha.26",
66
+ "@kubb/fs": "3.0.0-alpha.26",
67
+ "@kubb/oas": "3.0.0-alpha.26",
68
+ "@kubb/plugin-oas": "3.0.0-alpha.26",
69
+ "@kubb/plugin-ts": "3.0.0-alpha.26",
70
+ "@kubb/plugin-zod": "3.0.0-alpha.26",
71
+ "@kubb/react": "3.0.0-alpha.26"
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.23",
79
- "@kubb/config-tsup": "3.0.0-alpha.23"
78
+ "@kubb/config-ts": "3.0.0-alpha.26",
79
+ "@kubb/config-tsup": "3.0.0-alpha.26"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/react": "3.0.0-alpha.23"
82
+ "@kubb/react": "3.0.0-alpha.26"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=20"
@@ -65,7 +65,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
65
65
  options: {
66
66
  type: `
67
67
  {
68
- query?: Partial<InfiniteQueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
68
+ query?: Partial<InfiniteQueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
69
69
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
70
70
  }
71
71
  `,
@@ -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 = `UseInfiniteQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}> & { queryKey: TQueryKey }`
88
+ const returnType = 'ReturnType<typeof query> & { queryKey: TQueryKey }'
89
89
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
90
90
 
91
91
  const queryKeyParams = QueryKey.getParams({
@@ -6,6 +6,7 @@ import type { OperationSchemas } from '@kubb/plugin-oas'
6
6
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
7
7
  import type { ReactNode } from 'react'
8
8
  import type { PluginVueQuery } from '../types.ts'
9
+ import { MutationKey } from './MutationKey.tsx'
9
10
 
10
11
  type Props = {
11
12
  /**
@@ -14,6 +15,7 @@ type Props = {
14
15
  name: string
15
16
  typeName: string
16
17
  clientName: string
18
+ mutationKeyName: string
17
19
  typeSchemas: OperationSchemas
18
20
  operation: Operation
19
21
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
@@ -27,6 +29,7 @@ type GetParamsProps = {
27
29
  }
28
30
 
29
31
  function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
32
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
30
33
  const mutateParams = FunctionParams.factory({
31
34
  ...getPathParams(typeSchemas.pathParams, {
32
35
  typed: true,
@@ -56,15 +59,13 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
56
59
  }
57
60
  : undefined,
58
61
  })
59
-
60
- const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
61
62
  const TRequest = mutateParams.toConstructor({ valueAsType: true })
62
63
 
63
64
  return FunctionParams.factory({
64
65
  options: {
65
66
  type: `
66
67
  {
67
- mutation?: UseMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', `{${TRequest}`].join(', ')}>,
68
+ mutation?: MutationObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')}>,
68
69
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
69
70
  }
70
71
  `,
@@ -73,7 +74,14 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
73
74
  })
74
75
  }
75
76
 
76
- export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
77
+ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
78
+ const returnType = 'ReturnType<typeof mutation> & { mutationKey: MutationKey }'
79
+
80
+ const mutationKeyParams = MutationKey.getParams({
81
+ pathParamsType,
82
+ typeSchemas,
83
+ })
84
+
77
85
  const params = getParams({
78
86
  pathParamsType,
79
87
  dataReturnType,
@@ -127,13 +135,18 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
127
135
  >
128
136
  {`
129
137
  const { mutation: mutationOptions, client: config = {} } = options ?? {}
138
+ const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
130
139
 
131
- return useMutation({
140
+ const mutation = useMutation({
132
141
  mutationFn: async(${mutationParams.toConstructor()}) => {
133
142
  return ${clientName}(${clientParams.toCall()})
134
143
  },
135
144
  ...mutationOptions
136
- })
145
+ }) as ${returnType}
146
+
147
+ mutation.mutationKey = mutationKey as MutationKey
148
+
149
+ return mutation
137
150
  `}
138
151
  </Function>
139
152
  </File.Source>
@@ -0,0 +1,48 @@
1
+ import { URLPath } from '@kubb/core/utils'
2
+ import { File, Function, FunctionParams, Type } from '@kubb/react'
3
+
4
+ import type { Operation } from '@kubb/oas'
5
+ import type { OperationSchemas } from '@kubb/plugin-oas'
6
+ import type { ReactNode } from 'react'
7
+ import type { PluginVueQuery } from '../types'
8
+
9
+ type Props = {
10
+ name: string
11
+ typeName: string
12
+ typeSchemas: OperationSchemas
13
+ operation: Operation
14
+ pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
15
+ keysFn: ((keys: unknown[]) => unknown[]) | undefined
16
+ }
17
+
18
+ type GetParamsProps = {
19
+ pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
20
+ typeSchemas: OperationSchemas
21
+ }
22
+
23
+ function getParams({}: GetParamsProps) {
24
+ return FunctionParams.factory({})
25
+ }
26
+
27
+ export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {
28
+ const path = new URLPath(operation.path)
29
+ const params = getParams({ pathParamsType, typeSchemas })
30
+ const keys = [JSON.stringify({ url: path.path })].filter(Boolean)
31
+
32
+ return (
33
+ <>
34
+ <File.Source name={name} isExportable isIndexable>
35
+ <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
36
+ {`[${keysFn(keys).join(', ')}] as const`}
37
+ </Function.Arrow>
38
+ </File.Source>
39
+ <File.Source name={typeName} isExportable isIndexable isTypeOnly>
40
+ <Type name={typeName} export>
41
+ {`ReturnType<typeof ${name}>`}
42
+ </Type>
43
+ </File.Source>
44
+ </>
45
+ )
46
+ }
47
+
48
+ MutationKey.getParams = getParams
@@ -65,7 +65,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
65
65
  options: {
66
66
  type: `
67
67
  {
68
- query?: Partial<QueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
68
+ query?: Partial<QueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
69
69
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
70
70
  }
71
71
  `,
@@ -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 = `UseQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}> & { queryKey: TQueryKey }`
79
+ const returnType = 'ReturnType<typeof query> & { queryKey: TQueryKey }'
80
80
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
81
81
 
82
82
  const queryKeyParams = QueryKey.getParams({
@@ -4,3 +4,4 @@ export { QueryKey } from './QueryKey.tsx'
4
4
  export { QueryOptions } from './QueryOptions.tsx'
5
5
  export { InfiniteQueryOptions } from './InfiniteQueryOptions.tsx'
6
6
  export { InfiniteQuery } from './InfiniteQuery.tsx'
7
+ export { MutationKey } from './MutationKey.tsx'
@@ -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, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResp
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
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, UseQueryReturnType } from "@tanstack/react-query";
2
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -1,9 +1,13 @@
1
1
  import client from "axios";
2
- import type { UseMutationOptions } from "@tanstack/react-query";
2
+ import type { MutationObserverOptions, MutationKey } 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";
6
6
 
7
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
+
9
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
10
+
7
11
  /**
8
12
  * @summary Updates a pet in the store with form data
9
13
  * @link /pet/:petId
@@ -18,7 +22,7 @@ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], da
18
22
  * @link /pet/:petId
19
23
  */
20
24
  export function useUpdatePetWithForm(options: {
21
- mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
+ mutation?: MutationObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
22
26
  petId: MaybeRef<UpdatePetWithFormPathParams["petId"]>;
23
27
  data?: MaybeRef<UpdatePetWithFormMutationRequest>;
24
28
  params?: MaybeRef<UpdatePetWithFormQueryParams>;
@@ -26,7 +30,8 @@ export function useUpdatePetWithForm(options: {
26
30
  client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
27
31
  } = {}) {
28
32
  const { mutation: mutationOptions, client: config = {} } = options ?? {};
29
- return useMutation({
33
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
34
+ const mutation = useMutation({
30
35
  mutationFn: async ({ petId, data, params }: {
31
36
  petId: UpdatePetWithFormPathParams["petId"];
32
37
  data?: UpdatePetWithFormMutationRequest;
@@ -35,5 +40,9 @@ export function useUpdatePetWithForm(options: {
35
40
  return updatePetWithForm(petId, data, params, config);
36
41
  },
37
42
  ...mutationOptions
38
- });
43
+ }) as ReturnType<typeof mutation> & {
44
+ mutationKey: MutationKey;
45
+ };
46
+ mutation.mutationKey = mutationKey as MutationKey;
47
+ return mutation;
39
48
  }
@@ -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, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -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, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -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, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -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, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, QueryObserverOptions } 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";
@@ -44,7 +44,7 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
44
44
  ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
45
45
  queryKey,
46
46
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryReturnType<TData, FindPetsByTags400> & {
47
+ }) as ReturnType<typeof query> & {
48
48
  queryKey: TQueryKey;
49
49
  };
50
50
  query.queryKey = queryKey as TQueryKey;
@@ -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, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, InfiniteQueryObserverOptions } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
6
6
 
@@ -49,7 +49,7 @@ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, T
49
49
  ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
50
  queryKey,
51
51
  ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
- }) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & {
52
+ }) as ReturnType<typeof query> & {
53
53
  queryKey: TQueryKey;
54
54
  };
55
55
  query.queryKey = queryKey as TQueryKey;
@@ -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, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
3
+ import type { QueryKey, InfiniteQueryObserverOptions } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
6
6
 
@@ -49,7 +49,7 @@ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, T
49
49
  ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
50
  queryKey,
51
51
  ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
- }) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & {
52
+ }) as ReturnType<typeof query> & {
53
53
  queryKey: TQueryKey;
54
54
  };
55
55
  query.queryKey = queryKey as TQueryKey;
@@ -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, UseQueryReturnType } from "custom-query";
3
+ import type { QueryKey, QueryObserverOptions } from "custom-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useQuery, queryOptions } from "custom-query";
6
6
  import { unref } from "vue";
@@ -42,7 +42,7 @@ export function useUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse,
42
42
  ...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions,
43
43
  queryKey,
44
44
  ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
45
- }) as UseQueryReturnType<TData, UpdatePetWithForm405> & {
45
+ }) as ReturnType<typeof query> & {
46
46
  queryKey: TQueryKey;
47
47
  };
48
48
  query.queryKey = queryKey as TQueryKey;
@@ -1,9 +1,13 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { UseMutationOptions } from "@tanstack/react-query";
3
+ import type { MutationObserverOptions, MutationKey } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
5
  import { useMutation } from "@tanstack/react-query";
6
6
 
7
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
+
9
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
10
+
7
11
  /**
8
12
  * @summary Updates a pet in the store with form data
9
13
  * @link /pet/:petId
@@ -18,7 +22,7 @@ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], da
18
22
  * @link /pet/:petId
19
23
  */
20
24
  export function useUpdatePetWithForm(options: {
21
- mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
+ mutation?: MutationObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
22
26
  petId: MaybeRef<UpdatePetWithFormPathParams["petId"]>;
23
27
  data?: MaybeRef<UpdatePetWithFormMutationRequest>;
24
28
  params?: MaybeRef<UpdatePetWithFormQueryParams>;
@@ -26,7 +30,8 @@ export function useUpdatePetWithForm(options: {
26
30
  client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
27
31
  } = {}) {
28
32
  const { mutation: mutationOptions, client: config = {} } = options ?? {};
29
- return useMutation({
33
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
34
+ const mutation = useMutation({
30
35
  mutationFn: async ({ petId, data, params }: {
31
36
  petId: UpdatePetWithFormPathParams["petId"];
32
37
  data?: UpdatePetWithFormMutationRequest;
@@ -35,5 +40,9 @@ export function useUpdatePetWithForm(options: {
35
40
  return updatePetWithForm(petId, data, params, config);
36
41
  },
37
42
  ...mutationOptions
38
- });
43
+ }) as ReturnType<typeof mutation> & {
44
+ mutationKey: MutationKey;
45
+ };
46
+ mutation.mutationKey = mutationKey as MutationKey;
47
+ return mutation;
39
48
  }