@kubb/plugin-svelte-query 3.0.0-alpha.21 → 3.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TD7H4OF4.cjs → chunk-4H6ZAP5J.cjs} +46 -22
- package/dist/chunk-4H6ZAP5J.cjs.map +1 -0
- package/dist/{chunk-RE36BJQW.cjs → chunk-LKGJSGSX.cjs} +33 -16
- package/dist/chunk-LKGJSGSX.cjs.map +1 -0
- package/dist/{chunk-V5DEG2OQ.js → chunk-PJUWYI34.js} +46 -23
- package/dist/chunk-PJUWYI34.js.map +1 -0
- package/dist/{chunk-QPJYCH77.js → chunk-ZACTVMZV.js} +25 -8
- package/dist/chunk-ZACTVMZV.js.map +1 -0
- package/dist/components.cjs +9 -5
- package/dist/components.d.cts +30 -11
- package/dist/components.d.ts +30 -11
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-64YHTP7S.d.cts → types-CG_oJtJK.d.cts} +4 -0
- package/dist/{types-64YHTP7S.d.ts → types-CG_oJtJK.d.ts} +4 -0
- package/package.json +11 -11
- package/src/components/Mutation.tsx +20 -6
- package/src/components/MutationKey.tsx +48 -0
- package/src/components/Query.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +3 -3
- package/src/generators/__snapshots__/clientGetImportPath.ts +3 -3
- package/src/generators/__snapshots__/clientPostImportPath.ts +13 -4
- package/src/generators/__snapshots__/findByTags.ts +3 -3
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +3 -3
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +3 -3
- package/src/generators/__snapshots__/findByTagsWithZod.ts +3 -3
- package/src/generators/__snapshots__/postAsQuery.ts +3 -3
- package/src/generators/__snapshots__/updatePetById.ts +13 -4
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +13 -4
- package/src/generators/mutationGenerator.tsx +18 -2
- package/src/generators/queryGenerator.tsx +1 -1
- package/src/plugin.ts +1 -0
- package/src/types.ts +4 -0
- package/dist/chunk-QPJYCH77.js.map +0 -1
- package/dist/chunk-RE36BJQW.cjs.map +0 -1
- package/dist/chunk-TD7H4OF4.cjs.map +0 -1
- package/dist/chunk-V5DEG2OQ.js.map +0 -1
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkLKGJSGSX_cjs = require('./chunk-LKGJSGSX.cjs');
|
|
4
|
+
require('./chunk-4H6ZAP5J.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "mutationGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkLKGJSGSX_cjs.mutationGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "queryGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkLKGJSGSX_cjs.queryGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mutationGenerator, queryGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mutationGenerator, queryGenerator } from './chunk-ZACTVMZV.js';
|
|
2
|
+
import './chunk-PJUWYI34.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
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkLKGJSGSX_cjs = require('./chunk-LKGJSGSX.cjs');
|
|
4
|
+
require('./chunk-4H6ZAP5J.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -50,6 +50,7 @@ var pluginSvelteQuery = core.createPlugin((options) => {
|
|
|
50
50
|
...query
|
|
51
51
|
},
|
|
52
52
|
mutation: {
|
|
53
|
+
key: (key) => key,
|
|
53
54
|
methods: ["post", "put", "patch", "delete"],
|
|
54
55
|
importPath: "@tanstack/svelte-query",
|
|
55
56
|
...mutation
|
|
@@ -107,7 +108,7 @@ var pluginSvelteQuery = core.createPlugin((options) => {
|
|
|
107
108
|
mode
|
|
108
109
|
}
|
|
109
110
|
);
|
|
110
|
-
const files = await operationGenerator.build(
|
|
111
|
+
const files = await operationGenerator.build(chunkLKGJSGSX_cjs.queryGenerator, chunkLKGJSGSX_cjs.mutationGenerator);
|
|
111
112
|
await this.addFile(...files);
|
|
112
113
|
if (this.config.output.exportType) {
|
|
113
114
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator","queryGenerator","mutationGenerator"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA,sBAAA;AAExB,IAAA,iBAAA,GAAoBA,iBAAgC,CAAA,CAAC,OAAY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MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAMC,kCAAgBC,mCAAiB,CAAA,CAAA;AAC9E,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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\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: pluginSvelteQueryName,\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 query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-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, 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","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator","queryGenerator","mutationGenerator"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA,sBAAA;AAExB,IAAA,iBAAA,GAAoBA,iBAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,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,kBACTC,iBAAe,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,qBAAA;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;A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ourcesContent":["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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\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: pluginSvelteQueryName,\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 query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-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, 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"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryGenerator, mutationGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { queryGenerator, mutationGenerator } from './chunk-ZACTVMZV.js';
|
|
2
|
+
import './chunk-PJUWYI34.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';
|
|
@@ -44,6 +44,7 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
44
44
|
...query
|
|
45
45
|
},
|
|
46
46
|
mutation: {
|
|
47
|
+
key: (key) => key,
|
|
47
48
|
methods: ["post", "put", "patch", "delete"],
|
|
48
49
|
importPath: "@tanstack/svelte-query",
|
|
49
50
|
...mutation
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA,sBAAA;AAExB,IAAA,iBAAA,GAAoB,YAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,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,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,qBAAA;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,KAAO,EAAA;A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M,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,gBAAgB,iBAAiB,CAAA,CAAA;AAC9E,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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\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: pluginSvelteQueryName,\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 query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-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, 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,qBAAwB,GAAA,sBAAA;AAExB,IAAA,iBAAA,GAAoB,YAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,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,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,E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AA,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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\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: pluginSvelteQueryName,\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 query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-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, 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"]}
|
|
@@ -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']
|
|
@@ -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']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-svelte-query",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.25",
|
|
4
4
|
"description": "Generator svelte-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.
|
|
66
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
67
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
68
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
69
|
-
"@kubb/plugin-ts": "3.0.0-alpha.
|
|
70
|
-
"@kubb/plugin-zod": "3.0.0-alpha.
|
|
71
|
-
"@kubb/react": "3.0.0-alpha.
|
|
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"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.8",
|
|
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.
|
|
79
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
78
|
+
"@kubb/config-ts": "3.0.0-alpha.25",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-alpha.25"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-alpha.
|
|
82
|
+
"@kubb/react": "3.0.0-alpha.25"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
|
@@ -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 { PluginSvelteQuery } from '../types.ts'
|
|
9
|
+
import { MutationKey } from './MutationKey.tsx'
|
|
9
10
|
|
|
10
11
|
type Props = {
|
|
11
12
|
/**
|
|
@@ -14,6 +15,8 @@ type Props = {
|
|
|
14
15
|
name: string
|
|
15
16
|
typeName: string
|
|
16
17
|
clientName: string
|
|
18
|
+
mutationKeyName: string
|
|
19
|
+
mutationKeyTypeName: string
|
|
17
20
|
typeSchemas: OperationSchemas
|
|
18
21
|
operation: Operation
|
|
19
22
|
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -27,6 +30,7 @@ type GetParamsProps = {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
33
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
30
34
|
const mutateParams = FunctionParams.factory({
|
|
31
35
|
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
32
36
|
data: typeSchemas.request?.name
|
|
@@ -48,15 +52,13 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
48
52
|
}
|
|
49
53
|
: undefined,
|
|
50
54
|
})
|
|
51
|
-
|
|
52
|
-
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
53
55
|
const TRequest = mutateParams.toConstructor({ valueAsType: true })
|
|
54
56
|
|
|
55
57
|
return FunctionParams.factory({
|
|
56
58
|
options: {
|
|
57
59
|
type: `
|
|
58
60
|
{
|
|
59
|
-
mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || '
|
|
61
|
+
mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')}>,
|
|
60
62
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
|
|
61
63
|
}
|
|
62
64
|
`,
|
|
@@ -65,7 +67,14 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
65
67
|
})
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
|
|
70
|
+
export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyTypeName, mutationKeyName }: Props): ReactNode {
|
|
71
|
+
const returnType = 'ReturnType<typeof mutation> & { mutationKey: MutationKey }'
|
|
72
|
+
|
|
73
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
74
|
+
pathParamsType,
|
|
75
|
+
typeSchemas,
|
|
76
|
+
})
|
|
77
|
+
|
|
69
78
|
const params = getParams({
|
|
70
79
|
pathParamsType,
|
|
71
80
|
dataReturnType,
|
|
@@ -119,13 +128,18 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
|
|
|
119
128
|
>
|
|
120
129
|
{`
|
|
121
130
|
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
131
|
+
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
122
132
|
|
|
123
|
-
|
|
133
|
+
const mutation = createMutation({
|
|
124
134
|
mutationFn: async(${mutationParams.toConstructor()}) => {
|
|
125
135
|
return ${clientName}(${clientParams.toCall()})
|
|
126
136
|
},
|
|
127
137
|
...mutationOptions
|
|
128
|
-
})
|
|
138
|
+
}) as ${returnType}
|
|
139
|
+
|
|
140
|
+
mutation.mutationKey = mutationKey as MutationKey
|
|
141
|
+
|
|
142
|
+
return mutation
|
|
129
143
|
`}
|
|
130
144
|
</Function>
|
|
131
145
|
</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 { PluginSvelteQuery } from '../types'
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
name: string
|
|
11
|
+
typeName: string
|
|
12
|
+
typeSchemas: OperationSchemas
|
|
13
|
+
operation: Operation
|
|
14
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
|
|
15
|
+
keysFn: ((keys: unknown[]) => unknown[]) | undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type GetParamsProps = {
|
|
19
|
+
pathParamsType: PluginSvelteQuery['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
|
package/src/components/Query.tsx
CHANGED
|
@@ -57,7 +57,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
|
|
|
57
57
|
options: {
|
|
58
58
|
type: `
|
|
59
59
|
{
|
|
60
|
-
query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || '
|
|
60
|
+
query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
|
|
61
61
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
|
|
62
62
|
}
|
|
63
63
|
`,
|
|
@@ -68,7 +68,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
|
|
|
68
68
|
|
|
69
69
|
export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
|
|
70
70
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
71
|
-
const returnType =
|
|
71
|
+
const returnType = 'ReturnType<typeof query> & { queryKey: TQueryKey }'
|
|
72
72
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
73
73
|
|
|
74
74
|
const queryKeyParams = QueryKey.getParams({
|
package/src/components/index.ts
CHANGED
|
@@ -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, CreateBaseQueryOptions
|
|
3
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/svelte-query";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryR
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
|
-
import type { QueryKey, CreateBaseQueryOptions
|
|
2
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/svelte-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return findPetsByTagsQueryResponse.parse(res.data);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQuery
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
|
-
import type { CreateMutationOptions } from "@tanstack/svelte-query";
|
|
2
|
+
import type { CreateMutationOptions, MutationKey } from "@tanstack/svelte-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import { createMutation } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
|
+
export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
|
|
7
|
+
|
|
8
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
11
|
* @summary Updates a pet in the store with form data
|
|
8
12
|
* @link /pet/:petId
|
|
9
13
|
*/
|
|
10
14
|
async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
|
|
11
|
-
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "
|
|
15
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
|
|
12
16
|
return updatePetWithFormMutationResponse.parse(res.data);
|
|
13
17
|
}
|
|
14
18
|
|
|
@@ -25,7 +29,8 @@ export function createUpdatePetWithForm(options: {
|
|
|
25
29
|
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
|
|
26
30
|
} = {}) {
|
|
27
31
|
const { mutation: mutationOptions, client: config = {} } = options ?? {};
|
|
28
|
-
|
|
32
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
|
|
33
|
+
const mutation = createMutation({
|
|
29
34
|
mutationFn: async ({ petId, data, params }: {
|
|
30
35
|
petId: UpdatePetWithFormPathParams["petId"];
|
|
31
36
|
data?: UpdatePetWithFormMutationRequest;
|
|
@@ -34,5 +39,9 @@ export function createUpdatePetWithForm(options: {
|
|
|
34
39
|
return updatePetWithForm(petId, data, params, config);
|
|
35
40
|
},
|
|
36
41
|
...mutationOptions
|
|
37
|
-
})
|
|
42
|
+
}) as ReturnType<typeof mutation> & {
|
|
43
|
+
mutationKey: MutationKey;
|
|
44
|
+
};
|
|
45
|
+
mutation.mutationKey = mutationKey as MutationKey;
|
|
46
|
+
return mutation;
|
|
38
47
|
}
|
|
@@ -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, CreateBaseQueryOptions
|
|
3
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/svelte-query";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return findPetsByTagsQueryResponse.parse(res.data);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQuery
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
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, CreateBaseQueryOptions
|
|
3
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/svelte-query";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return findPetsByTagsQueryResponse.parse(res.data);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQuery
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
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, CreateBaseQueryOptions
|
|
3
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/react-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [test, { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/react-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return findPetsByTagsQueryResponse.parse(res.data);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQuery
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
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, CreateBaseQueryOptions
|
|
3
|
+
import type { QueryKey, CreateBaseQueryOptions } from "@tanstack/svelte-query";
|
|
4
4
|
import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -13,7 +13,7 @@ import { createQuery, queryOptions } from "@tanstack/svelte-query";
|
|
|
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>({ method: "
|
|
16
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
|
|
17
17
|
return findPetsByTagsQueryResponse.parse(res.data);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQuery
|
|
|
42
42
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
|
|
43
43
|
queryKey,
|
|
44
44
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
45
|
-
}) as
|
|
45
|
+
}) as ReturnType<typeof query> & {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
};
|
|
48
48
|
query.queryKey = queryKey as TQueryKey;
|