@kubb/plugin-svelte-query 0.0.0-canary-20241214150347 → 0.0.0-canary-20250109143608

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 (40) hide show
  1. package/dist/{chunk-YSVAGB5Y.cjs → chunk-5E5RFWUM.cjs} +68 -33
  2. package/dist/chunk-5E5RFWUM.cjs.map +1 -0
  3. package/dist/{chunk-EZRBBWGF.js → chunk-EE3OWZ2P.js} +68 -33
  4. package/dist/chunk-EE3OWZ2P.js.map +1 -0
  5. package/dist/{chunk-BB5SCJJT.js → chunk-KACKUZF2.js} +7 -6
  6. package/dist/chunk-KACKUZF2.js.map +1 -0
  7. package/dist/{chunk-DJNDGHXY.cjs → chunk-L344MSSI.cjs} +14 -13
  8. package/dist/chunk-L344MSSI.cjs.map +1 -0
  9. package/dist/components.cjs +6 -6
  10. package/dist/components.d.cts +2 -1
  11. package/dist/components.d.ts +2 -1
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +4 -4
  14. package/dist/generators.js +2 -2
  15. package/dist/index.cjs +14 -7
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +11 -4
  18. package/dist/index.js.map +1 -1
  19. package/package.json +13 -13
  20. package/src/components/Mutation.tsx +5 -4
  21. package/src/components/Query.tsx +5 -3
  22. package/src/components/QueryOptions.tsx +6 -2
  23. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +10 -5
  24. package/src/generators/__snapshots__/clientGetImportPath.ts +5 -5
  25. package/src/generators/__snapshots__/clientPostImportPath.ts +4 -4
  26. package/src/generators/__snapshots__/findByTags.ts +5 -5
  27. package/src/generators/__snapshots__/findByTagsObject.ts +5 -5
  28. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +5 -5
  29. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +5 -5
  30. package/src/generators/__snapshots__/findByTagsWithZod.ts +5 -5
  31. package/src/generators/__snapshots__/postAsQuery.ts +5 -5
  32. package/src/generators/__snapshots__/updatePetById.ts +4 -4
  33. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +4 -4
  34. package/src/generators/mutationGenerator.tsx +1 -1
  35. package/src/generators/queryGenerator.tsx +2 -2
  36. package/src/plugin.ts +9 -2
  37. package/dist/chunk-BB5SCJJT.js.map +0 -1
  38. package/dist/chunk-DJNDGHXY.cjs.map +0 -1
  39. package/dist/chunk-EZRBBWGF.js.map +0 -1
  40. package/dist/chunk-YSVAGB5Y.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { queryGenerator, mutationGenerator } from './chunk-BB5SCJJT.js';
2
- import { MutationKey, QueryKey } from './chunk-EZRBBWGF.js';
1
+ import { queryGenerator, mutationGenerator } from './chunk-KACKUZF2.js';
2
+ import { MutationKey, QueryKey } from './chunk-EE3OWZ2P.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';
@@ -61,14 +61,21 @@ var pluginSvelteQuery = createPlugin((options) => {
61
61
  if (mode === "single") {
62
62
  return path.resolve(root, output.path);
63
63
  }
64
- if (options2?.group && group) {
64
+ if (group && (options2?.group?.path || options2?.group?.tag)) {
65
65
  const groupName = group?.name ? group.name : (ctx) => {
66
66
  if (group?.type === "path") {
67
67
  return `${ctx.group.split("/")[1]}`;
68
68
  }
69
69
  return `${camelCase(ctx.group)}Controller`;
70
70
  };
71
- return path.resolve(root, output.path, groupName({ group: options2.group }), baseName);
71
+ return path.resolve(
72
+ root,
73
+ output.path,
74
+ groupName({
75
+ group: group.type === "path" ? options2.group.path : options2.group.tag
76
+ }),
77
+ baseName
78
+ );
72
79
  }
73
80
  return path.resolve(root, output.path, baseName);
74
81
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,I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AAqB,GAAA,IAAI,kBAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n parser,\n paramsCasing,\n group,\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?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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 const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\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"]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,IAAA,iBAAA,GAAoB,YAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,YAAA;AAAA,IACA,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QA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CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n parser,\n paramsCasing,\n group,\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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 const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-svelte-query",
3
- "version": "0.0.0-canary-20241214150347",
3
+ "version": "0.0.0-canary-20250109143608",
4
4
  "description": "Generator svelte-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -62,25 +62,25 @@
62
62
  "!/**/__tests__/**"
63
63
  ],
64
64
  "dependencies": {
65
- "remeda": "^2.17.4",
66
- "@kubb/core": "0.0.0-canary-20241214150347",
67
- "@kubb/fs": "0.0.0-canary-20241214150347",
68
- "@kubb/oas": "0.0.0-canary-20241214150347",
69
- "@kubb/plugin-oas": "0.0.0-canary-20241214150347",
70
- "@kubb/plugin-ts": "0.0.0-canary-20241214150347",
71
- "@kubb/plugin-zod": "0.0.0-canary-20241214150347",
72
- "@kubb/react": "0.0.0-canary-20241214150347"
65
+ "remeda": "^2.19.0",
66
+ "@kubb/core": "0.0.0-canary-20250109143608",
67
+ "@kubb/fs": "0.0.0-canary-20250109143608",
68
+ "@kubb/oas": "0.0.0-canary-20250109143608",
69
+ "@kubb/plugin-oas": "0.0.0-canary-20250109143608",
70
+ "@kubb/plugin-ts": "0.0.0-canary-20250109143608",
71
+ "@kubb/plugin-zod": "0.0.0-canary-20250109143608",
72
+ "@kubb/react": "0.0.0-canary-20250109143608"
73
73
  },
74
74
  "devDependencies": {
75
- "@types/react": "^18.3.16",
75
+ "@types/react": "^18.3.18",
76
76
  "react": "^18.3.1",
77
77
  "tsup": "^8.3.5",
78
78
  "typescript": "^5.7.2",
79
- "@kubb/config-ts": "0.0.0-canary-20241214150347",
80
- "@kubb/config-tsup": "0.0.0-canary-20241214150347"
79
+ "@kubb/config-ts": "0.0.0-canary-20250109143608",
80
+ "@kubb/config-tsup": "0.0.0-canary-20250109143608"
81
81
  },
82
82
  "peerDependencies": {
83
- "@kubb/react": "0.0.0-canary-20241214150347"
83
+ "@kubb/react": "0.0.0-canary-20250109143608"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=20"
@@ -34,6 +34,8 @@ type GetParamsProps = {
34
34
 
35
35
  function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {
36
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
37
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
38
+
37
39
  const mutationParams = FunctionParams.factory({
38
40
  ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
39
41
  data: typeSchemas.request?.name
@@ -61,7 +63,7 @@ function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps
61
63
  options: {
62
64
  type: `
63
65
  {
64
- mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(', ')}>,
66
+ mutation?: CreateMutationOptions<${[TData, TError, TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(', ')}>,
65
67
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
66
68
  }
67
69
  `,
@@ -140,9 +142,8 @@ export function Mutation({
140
142
 
141
143
  const TRequest = mutationParams.toConstructor({ valueAsType: true })
142
144
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
143
- const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined]
144
- .filter(Boolean)
145
- .join(', ')
145
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
146
+ const generics = [TData, TError, TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(', ')
146
147
 
147
148
  return (
148
149
  <File.Source name={name} isExportable isIndexable>
@@ -34,6 +34,7 @@ type GetParamsProps = {
34
34
 
35
35
  function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
36
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
37
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
37
38
 
38
39
  if (paramsType === 'object') {
39
40
  return FunctionParams.factory({
@@ -64,7 +65,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
64
65
  options: {
65
66
  type: `
66
67
  {
67
- query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
68
+ query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
68
69
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
69
70
  }
70
71
  `,
@@ -102,7 +103,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
102
103
  options: {
103
104
  type: `
104
105
  {
105
- query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
106
+ query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
106
107
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
107
108
  }
108
109
  `,
@@ -124,7 +125,8 @@ export function Query({
124
125
  operation,
125
126
  }: Props): ReactNode {
126
127
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
127
- const returnType = `CreateQueryResult<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
128
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
129
+ const returnType = `CreateQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`
128
130
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
129
131
 
130
132
  const queryKeyParams = QueryKey.getParams({
@@ -17,6 +17,7 @@ type Props = {
17
17
  paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
18
18
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
19
19
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
20
+ dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
20
21
  }
21
22
 
22
23
  type GetParamsProps = {
@@ -93,7 +94,10 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
93
94
  })
94
95
  }
95
96
 
96
- export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
97
+ export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {
98
+ const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
99
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
100
+
97
101
  const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
98
102
  const clientParams = Client.getParams({
99
103
  paramsType,
@@ -119,7 +123,7 @@ export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, para
119
123
  <Function name={name} export params={params.toConstructor()}>
120
124
  {`
121
125
  const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
122
- return queryOptions({
126
+ return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
123
127
  ${enabledText}
124
128
  queryKey,
125
129
  queryFn: async ({ signal }) => {
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,12 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<
29
+ ResponseConfig<FindPetsByTagsQueryResponse>,
30
+ ResponseErrorConfig<FindPetsByTags400>,
31
+ ResponseConfig<FindPetsByTagsQueryResponse>,
32
+ typeof queryKey
33
+ >({
29
34
  queryKey,
30
35
  queryFn: async ({ signal }) => {
31
36
  config.signal = signal
@@ -47,7 +52,7 @@ export function createFindPetsByTags<
47
52
  headers: FindPetsByTagsHeaderParams,
48
53
  params?: FindPetsByTagsQueryParams,
49
54
  options: {
50
- query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>
55
+ query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
56
  client?: Partial<RequestConfig>
52
57
  } = {},
53
58
  ) {
@@ -58,7 +63,7 @@ export function createFindPetsByTags<
58
63
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
64
  queryKey,
60
65
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
66
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
67
 
63
68
  query.queryKey = queryKey as TQueryKey
64
69
 
@@ -1,6 +1,6 @@
1
1
  import client from 'axios'
2
2
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
3
- import type { RequestConfig } from 'axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from 'axios'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
6
6
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,7 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
29
29
  queryKey,
30
30
  queryFn: async ({ signal }) => {
31
31
  config.signal = signal
@@ -47,7 +47,7 @@ export function createFindPetsByTags<
47
47
  headers: FindPetsByTagsHeaderParams,
48
48
  params?: FindPetsByTagsQueryParams,
49
49
  options: {
50
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
51
  client?: Partial<RequestConfig>
52
52
  } = {},
53
53
  ) {
@@ -58,7 +58,7 @@ export function createFindPetsByTags<
58
58
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
59
  queryKey,
60
60
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
61
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
62
 
63
63
  query.queryKey = queryKey as TQueryKey
64
64
 
@@ -1,6 +1,6 @@
1
1
  import client from 'axios'
2
2
  import type { CreateMutationOptions } from '@tanstack/svelte-query'
3
- import type { RequestConfig } from 'axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from 'axios'
4
4
  import { createMutation } from '@tanstack/svelte-query'
5
5
 
6
6
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
@@ -17,7 +17,7 @@ async function updatePetWithForm(
17
17
  params?: UpdatePetWithFormQueryParams,
18
18
  config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
19
19
  ) {
20
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
20
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationRequest>({
21
21
  method: 'POST',
22
22
  url: `/pet/${petId}`,
23
23
  params,
@@ -35,7 +35,7 @@ export function createUpdatePetWithForm(
35
35
  options: {
36
36
  mutation?: CreateMutationOptions<
37
37
  UpdatePetWithFormMutationResponse,
38
- UpdatePetWithForm405,
38
+ ResponseErrorConfig<UpdatePetWithForm405>,
39
39
  { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
40
40
  >
41
41
  client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
@@ -46,7 +46,7 @@ export function createUpdatePetWithForm(
46
46
 
47
47
  return createMutation<
48
48
  UpdatePetWithFormMutationResponse,
49
- UpdatePetWithForm405,
49
+ ResponseErrorConfig<UpdatePetWithForm405>,
50
50
  { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
51
51
  >({
52
52
  mutationFn: async ({ petId, data, params }) => {
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,7 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
29
29
  queryKey,
30
30
  queryFn: async ({ signal }) => {
31
31
  config.signal = signal
@@ -47,7 +47,7 @@ export function createFindPetsByTags<
47
47
  headers: FindPetsByTagsHeaderParams,
48
48
  params?: FindPetsByTagsQueryParams,
49
49
  options: {
50
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
51
  client?: Partial<RequestConfig>
52
52
  } = {},
53
53
  ) {
@@ -58,7 +58,7 @@ export function createFindPetsByTags<
58
58
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
59
  queryKey,
60
60
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
61
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
62
 
63
63
  query.queryKey = queryKey as TQueryKey
64
64
 
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
@@ -16,7 +16,7 @@ async function findPetsByTags(
16
16
  { headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams },
17
17
  config: Partial<RequestConfig> = {},
18
18
  ) {
19
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
19
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
20
20
  method: 'GET',
21
21
  url: `/pet/findByTags`,
22
22
  params,
@@ -31,7 +31,7 @@ export function findPetsByTagsQueryOptions(
31
31
  config: Partial<RequestConfig> = {},
32
32
  ) {
33
33
  const queryKey = findPetsByTagsQueryKey(params)
34
- return queryOptions({
34
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
35
35
  queryKey,
36
36
  queryFn: async ({ signal }) => {
37
37
  config.signal = signal
@@ -52,7 +52,7 @@ export function createFindPetsByTags<
52
52
  >(
53
53
  { headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams },
54
54
  options: {
55
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
55
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
56
56
  client?: Partial<RequestConfig>
57
57
  } = {},
58
58
  ) {
@@ -63,7 +63,7 @@ export function createFindPetsByTags<
63
63
  ...(findPetsByTagsQueryOptions({ headers, params }, config) as unknown as CreateBaseQueryOptions),
64
64
  queryKey,
65
65
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
66
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
66
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
67
67
 
68
68
  query.queryKey = queryKey as TQueryKey
69
69
 
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,7 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
29
29
  queryKey,
30
30
  queryFn: async ({ signal }) => {
31
31
  config.signal = signal
@@ -47,7 +47,7 @@ export function createFindPetsByTags<
47
47
  headers: FindPetsByTagsHeaderParams,
48
48
  params?: FindPetsByTagsQueryParams,
49
49
  options: {
50
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
51
  client?: Partial<RequestConfig>
52
52
  } = {},
53
53
  ) {
@@ -58,7 +58,7 @@ export function createFindPetsByTags<
58
58
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
59
  queryKey,
60
60
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
61
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
62
 
63
63
  query.queryKey = queryKey as TQueryKey
64
64
 
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/react-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/react-query'
5
5
 
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,7 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
29
29
  queryKey,
30
30
  queryFn: async ({ signal }) => {
31
31
  config.signal = signal
@@ -47,7 +47,7 @@ export function createFindPetsByTags<
47
47
  headers: FindPetsByTagsHeaderParams,
48
48
  params?: FindPetsByTagsQueryParams,
49
49
  options: {
50
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
51
  client?: Partial<RequestConfig>
52
52
  } = {},
53
53
  ) {
@@ -58,7 +58,7 @@ export function createFindPetsByTags<
58
58
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
59
  queryKey,
60
60
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
61
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
62
 
63
63
  query.queryKey = queryKey as TQueryKey
64
64
 
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
4
  import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
@@ -13,7 +13,7 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
16
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
17
17
  method: 'GET',
18
18
  url: `/pet/findByTags`,
19
19
  params,
@@ -25,7 +25,7 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
25
25
 
26
26
  export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
27
  const queryKey = findPetsByTagsQueryKey(params)
28
- return queryOptions({
28
+ return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
29
29
  queryKey,
30
30
  queryFn: async ({ signal }) => {
31
31
  config.signal = signal
@@ -47,7 +47,7 @@ export function createFindPetsByTags<
47
47
  headers: FindPetsByTagsHeaderParams,
48
48
  params?: FindPetsByTagsQueryParams,
49
49
  options: {
50
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>>
51
51
  client?: Partial<RequestConfig>
52
52
  } = {},
53
53
  ) {
@@ -58,7 +58,7 @@ export function createFindPetsByTags<
58
58
  ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
59
  queryKey,
60
60
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
- }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
61
+ }) as CreateQueryResult<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
62
62
 
63
63
  query.queryKey = queryKey as TQueryKey
64
64
 
@@ -1,5 +1,5 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from 'custom-query'
4
4
  import { queryOptions, createQuery } from 'custom-query'
5
5
 
@@ -21,7 +21,7 @@ async function updatePetWithForm(
21
21
  params?: UpdatePetWithFormQueryParams,
22
22
  config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
23
23
  ) {
24
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
24
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationRequest>({
25
25
  method: 'POST',
26
26
  url: `/pet/${petId}`,
27
27
  params,
@@ -38,7 +38,7 @@ export function updatePetWithFormQueryOptions(
38
38
  config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
39
39
  ) {
40
40
  const queryKey = updatePetWithFormQueryKey(petId, data, params)
41
- return queryOptions({
41
+ return queryOptions<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationResponse, typeof queryKey>({
42
42
  enabled: !!petId,
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
@@ -61,7 +61,7 @@ export function createUpdatePetWithForm<
61
61
  data?: UpdatePetWithFormMutationRequest,
62
62
  params?: UpdatePetWithFormQueryParams,
63
63
  options: {
64
- query?: Partial<CreateBaseQueryOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>
64
+ query?: Partial<CreateBaseQueryOptions<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, TData, TQueryData, TQueryKey>>
65
65
  client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
66
66
  } = {},
67
67
  ) {
@@ -72,7 +72,7 @@ export function createUpdatePetWithForm<
72
72
  ...(updatePetWithFormQueryOptions(petId, data, params, config) as unknown as CreateBaseQueryOptions),
73
73
  queryKey,
74
74
  ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
75
- }) as CreateQueryResult<TData, UpdatePetWithForm405> & { queryKey: TQueryKey }
75
+ }) as CreateQueryResult<TData, ResponseErrorConfig<UpdatePetWithForm405>> & { queryKey: TQueryKey }
76
76
 
77
77
  query.queryKey = queryKey as TQueryKey
78
78