@kubb/plugin-svelte-query 3.0.0-alpha.23 → 3.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ANGIDYNO.cjs → chunk-3OCKBXBG.cjs} +44 -20
- package/dist/chunk-3OCKBXBG.cjs.map +1 -0
- package/dist/{chunk-U4GN3WW4.cjs → chunk-6R5UBB6J.cjs} +34 -17
- package/dist/chunk-6R5UBB6J.cjs.map +1 -0
- package/dist/{chunk-JZ7GGAUT.js → chunk-JVK6FU4M.js} +26 -9
- package/dist/chunk-JVK6FU4M.js.map +1 -0
- package/dist/{chunk-R2D7RZVO.js → chunk-YI2745MF.js} +44 -21
- package/dist/chunk-YI2745MF.js.map +1 -0
- package/dist/components.cjs +9 -5
- package/dist/components.d.cts +29 -11
- package/dist/components.d.ts +29 -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 +6 -4
- 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 +6 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-64YHTP7S.d.cts → types-FkBg-Xsz.d.cts} +9 -1
- package/dist/{types-64YHTP7S.d.ts → types-FkBg-Xsz.d.ts} +9 -1
- package/package.json +12 -12
- package/src/components/Mutation.tsx +19 -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 +2 -2
- package/src/generators/__snapshots__/clientGetImportPath.ts +2 -2
- package/src/generators/__snapshots__/clientPostImportPath.ts +12 -3
- package/src/generators/__snapshots__/findByTags.ts +2 -2
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
- package/src/generators/__snapshots__/postAsQuery.ts +2 -2
- package/src/generators/__snapshots__/updatePetById.ts +12 -3
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +12 -3
- package/src/generators/mutationGenerator.tsx +17 -2
- package/src/generators/queryGenerator.tsx +1 -1
- package/src/plugin.ts +3 -1
- package/src/types.ts +9 -1
- package/dist/chunk-ANGIDYNO.cjs.map +0 -1
- package/dist/chunk-JZ7GGAUT.js.map +0 -1
- package/dist/chunk-R2D7RZVO.js.map +0 -1
- package/dist/chunk-U4GN3WW4.cjs.map +0 -1
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"
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator"],"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,IACT,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,GAC7D,GAAA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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 generators = [queryGenerator, mutationGenerator].filter(Boolean),\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(...generators)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
|
package/dist/index.d.cts
CHANGED
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-JVK6FU4M.js';
|
|
2
|
+
import './chunk-YI2745MF.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';
|
|
@@ -20,7 +20,8 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
20
20
|
transformers = {},
|
|
21
21
|
pathParamsType = "inline",
|
|
22
22
|
mutation = {},
|
|
23
|
-
query = {}
|
|
23
|
+
query = {},
|
|
24
|
+
generators = [queryGenerator, mutationGenerator].filter(Boolean)
|
|
24
25
|
} = options;
|
|
25
26
|
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
26
27
|
return {
|
|
@@ -44,6 +45,7 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
44
45
|
...query
|
|
45
46
|
},
|
|
46
47
|
mutation: {
|
|
48
|
+
key: (key) => key,
|
|
47
49
|
methods: ["post", "put", "patch", "delete"],
|
|
48
50
|
importPath: "@tanstack/svelte-query",
|
|
49
51
|
...mutation
|
|
@@ -101,7 +103,7 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
101
103
|
mode
|
|
102
104
|
}
|
|
103
105
|
);
|
|
104
|
-
const files = await operationGenerator.build(
|
|
106
|
+
const files = await operationGenerator.build(...generators);
|
|
105
107
|
await this.addFile(...files);
|
|
106
108
|
if (this.config.output.exportType) {
|
|
107
109
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.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C;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 generators = [queryGenerator, mutationGenerator].filter(Boolean),\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(...generators)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
|
|
2
2
|
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Query = {
|
|
6
6
|
/**
|
|
@@ -22,6 +22,10 @@ type Query = {
|
|
|
22
22
|
importPath?: string;
|
|
23
23
|
};
|
|
24
24
|
type Mutation = {
|
|
25
|
+
/**
|
|
26
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
27
|
+
*/
|
|
28
|
+
key: (key: unknown[]) => unknown[];
|
|
25
29
|
/**
|
|
26
30
|
* Define which HttpMethods can be used for mutations
|
|
27
31
|
* @default ['post', 'put', 'delete']
|
|
@@ -133,6 +137,10 @@ type Options = {
|
|
|
133
137
|
*/
|
|
134
138
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
135
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Define some generators next to the svelte-query generators
|
|
142
|
+
*/
|
|
143
|
+
generators?: Array<Generator<PluginSvelteQuery>>;
|
|
136
144
|
};
|
|
137
145
|
type ResolvedOptions = {
|
|
138
146
|
output: Output;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
|
|
2
2
|
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Query = {
|
|
6
6
|
/**
|
|
@@ -22,6 +22,10 @@ type Query = {
|
|
|
22
22
|
importPath?: string;
|
|
23
23
|
};
|
|
24
24
|
type Mutation = {
|
|
25
|
+
/**
|
|
26
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
27
|
+
*/
|
|
28
|
+
key: (key: unknown[]) => unknown[];
|
|
25
29
|
/**
|
|
26
30
|
* Define which HttpMethods can be used for mutations
|
|
27
31
|
* @default ['post', 'put', 'delete']
|
|
@@ -133,6 +137,10 @@ type Options = {
|
|
|
133
137
|
*/
|
|
134
138
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
135
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Define some generators next to the svelte-query generators
|
|
142
|
+
*/
|
|
143
|
+
generators?: Array<Generator<PluginSvelteQuery>>;
|
|
136
144
|
};
|
|
137
145
|
type ResolvedOptions = {
|
|
138
146
|
output: Output;
|
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.26",
|
|
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.26",
|
|
66
|
+
"@kubb/fs": "3.0.0-alpha.26",
|
|
67
|
+
"@kubb/oas": "3.0.0-alpha.26",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-alpha.26",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-alpha.26",
|
|
70
|
+
"@kubb/plugin-zod": "3.0.0-alpha.26",
|
|
71
|
+
"@kubb/react": "3.0.0-alpha.26"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@types/react": "^18.3.
|
|
74
|
+
"@types/react": "^18.3.9",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsup": "^8.3.0",
|
|
77
77
|
"typescript": "^5.6.2",
|
|
78
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
79
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
78
|
+
"@kubb/config-ts": "3.0.0-alpha.26",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-alpha.26"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-alpha.
|
|
82
|
+
"@kubb/react": "3.0.0-alpha.26"
|
|
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,7 @@ type Props = {
|
|
|
14
15
|
name: string
|
|
15
16
|
typeName: string
|
|
16
17
|
clientName: string
|
|
18
|
+
mutationKeyName: string
|
|
17
19
|
typeSchemas: OperationSchemas
|
|
18
20
|
operation: Operation
|
|
19
21
|
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -27,6 +29,7 @@ type GetParamsProps = {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
32
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
30
33
|
const mutateParams = FunctionParams.factory({
|
|
31
34
|
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
32
35
|
data: typeSchemas.request?.name
|
|
@@ -48,15 +51,13 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
48
51
|
}
|
|
49
52
|
: undefined,
|
|
50
53
|
})
|
|
51
|
-
|
|
52
|
-
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
53
54
|
const TRequest = mutateParams.toConstructor({ valueAsType: true })
|
|
54
55
|
|
|
55
56
|
return FunctionParams.factory({
|
|
56
57
|
options: {
|
|
57
58
|
type: `
|
|
58
59
|
{
|
|
59
|
-
mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || '
|
|
60
|
+
mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')}>,
|
|
60
61
|
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
|
|
61
62
|
}
|
|
62
63
|
`,
|
|
@@ -65,7 +66,14 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
65
66
|
})
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
|
|
69
|
+
export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
|
|
70
|
+
const returnType = 'ReturnType<typeof mutation> & { mutationKey: MutationKey }'
|
|
71
|
+
|
|
72
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
73
|
+
pathParamsType,
|
|
74
|
+
typeSchemas,
|
|
75
|
+
})
|
|
76
|
+
|
|
69
77
|
const params = getParams({
|
|
70
78
|
pathParamsType,
|
|
71
79
|
dataReturnType,
|
|
@@ -119,13 +127,18 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
|
|
|
119
127
|
>
|
|
120
128
|
{`
|
|
121
129
|
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
130
|
+
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
122
131
|
|
|
123
|
-
|
|
132
|
+
const mutation = createMutation({
|
|
124
133
|
mutationFn: async(${mutationParams.toConstructor()}) => {
|
|
125
134
|
return ${clientName}(${clientParams.toCall()})
|
|
126
135
|
},
|
|
127
136
|
...mutationOptions
|
|
128
|
-
})
|
|
137
|
+
}) as ${returnType}
|
|
138
|
+
|
|
139
|
+
mutation.mutationKey = mutationKey as MutationKey
|
|
140
|
+
|
|
141
|
+
return mutation
|
|
129
142
|
`}
|
|
130
143
|
</Function>
|
|
131
144
|
</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;
|
|
@@ -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
|
|
|
@@ -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,8 +1,12 @@
|
|
|
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
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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 "custom-query";
|
|
4
4
|
import { createQuery, queryOptions } from "custom-query";
|
|
5
5
|
|
|
6
6
|
export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
|
|
@@ -40,7 +40,7 @@ export function createUpdatePetWithForm<TData = UpdatePetWithFormMutationRespons
|
|
|
40
40
|
...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as CreateBaseQueryOptions,
|
|
41
41
|
queryKey,
|
|
42
42
|
...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
|
|
43
|
-
}) as
|
|
43
|
+
}) as ReturnType<typeof query> & {
|
|
44
44
|
queryKey: TQueryKey;
|
|
45
45
|
};
|
|
46
46
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { CreateMutationOptions } from "@tanstack/svelte-query";
|
|
3
|
+
import type { CreateMutationOptions, MutationKey } from "@tanstack/svelte-query";
|
|
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
|
|
@@ -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,8 +1,12 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { CreateMutationOptions } from "@tanstack/svelte-query";
|
|
3
|
+
import type { CreateMutationOptions, MutationKey } from "@tanstack/svelte-query";
|
|
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
|
|
@@ -27,7 +31,8 @@ export function createUpdatePetWithForm(options: {
|
|
|
27
31
|
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
|
|
28
32
|
} = {}) {
|
|
29
33
|
const { mutation: mutationOptions, client: config = {} } = options ?? {};
|
|
30
|
-
|
|
34
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
|
|
35
|
+
const mutation = createMutation({
|
|
31
36
|
mutationFn: async ({ petId, data, params }: {
|
|
32
37
|
petId: UpdatePetWithFormPathParams["petId"];
|
|
33
38
|
data?: UpdatePetWithFormMutationRequest;
|
|
@@ -36,5 +41,9 @@ export function createUpdatePetWithForm(options: {
|
|
|
36
41
|
return updatePetWithForm({ petId }, data, params, config);
|
|
37
42
|
},
|
|
38
43
|
...mutationOptions
|
|
39
|
-
})
|
|
44
|
+
}) as ReturnType<typeof mutation> & {
|
|
45
|
+
mutationKey: MutationKey;
|
|
46
|
+
};
|
|
47
|
+
mutation.mutationKey = mutationKey as MutationKey;
|
|
48
|
+
return mutation;
|
|
40
49
|
}
|