@kubb/plugin-swr 3.1.0 → 3.3.0
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-23A6KPTG.js → chunk-4EFF327C.js} +10 -3
- package/dist/chunk-4EFF327C.js.map +1 -0
- package/dist/{chunk-ZO4CRCE6.cjs → chunk-4ZIGOWYH.cjs} +15 -8
- package/dist/chunk-4ZIGOWYH.cjs.map +1 -0
- package/dist/{chunk-HOCARL2F.js → chunk-7ELDJ4IB.js} +33 -24
- package/dist/chunk-7ELDJ4IB.js.map +1 -0
- package/dist/{chunk-442Q5BKM.cjs → chunk-DJ57MWSH.cjs} +33 -24
- package/dist/chunk-DJ57MWSH.cjs.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +15 -8
- package/dist/components.d.ts +15 -8
- 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 +8 -6
- 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-C68y96t2.d.cts → types-CwvU4w1t.d.cts} +14 -0
- package/dist/{types-C68y96t2.d.ts → types-CwvU4w1t.d.ts} +14 -0
- package/package.json +12 -12
- package/src/components/Mutation.tsx +7 -2
- package/src/components/MutationKey.tsx +5 -4
- package/src/components/Query.tsx +9 -3
- package/src/components/QueryKey.tsx +9 -6
- package/src/components/QueryOptions.tsx +8 -5
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +32 -33
- package/src/generators/__snapshots__/clientGetImportPath.ts +32 -33
- package/src/generators/__snapshots__/clientPostImportPath.ts +29 -20
- package/src/generators/__snapshots__/findByTags.ts +32 -33
- package/src/generators/__snapshots__/findByTagsObject.ts +32 -33
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +32 -33
- package/src/generators/__snapshots__/findByTagsWithZod.ts +32 -33
- package/src/generators/__snapshots__/getAsMutation.ts +2 -2
- package/src/generators/__snapshots__/postAsQuery.ts +39 -36
- package/src/generators/__snapshots__/updatePetById.ts +29 -20
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +33 -24
- package/src/generators/mutationGenerator.tsx +3 -0
- package/src/generators/queryGenerator.tsx +4 -0
- package/src/plugin.ts +3 -1
- package/src/types.ts +7 -0
- package/dist/chunk-23A6KPTG.js.map +0 -1
- package/dist/chunk-442Q5BKM.cjs.map +0 -1
- package/dist/chunk-HOCARL2F.js.map +0 -1
- package/dist/chunk-ZO4CRCE6.cjs.map +0 -1
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 { MutationKey, QueryKey } from './chunk-
|
|
1
|
+
import { queryGenerator, mutationGenerator } from './chunk-4EFF327C.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-7ELDJ4IB.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';
|
|
@@ -24,14 +24,15 @@ var pluginSwr = createPlugin((options) => {
|
|
|
24
24
|
pathParamsType = "inline",
|
|
25
25
|
mutationKey = MutationKey.getTransformer,
|
|
26
26
|
queryKey = QueryKey.getTransformer,
|
|
27
|
-
generators = [queryGenerator, mutationGenerator].filter(Boolean)
|
|
27
|
+
generators = [queryGenerator, mutationGenerator].filter(Boolean),
|
|
28
|
+
paramsCasing
|
|
28
29
|
} = options;
|
|
29
30
|
return {
|
|
30
31
|
name: pluginSwrName,
|
|
31
32
|
options: {
|
|
32
33
|
output,
|
|
33
34
|
client: {
|
|
34
|
-
importPath: "@kubb/plugin-client/
|
|
35
|
+
importPath: "@kubb/plugin-client/clients/axios",
|
|
35
36
|
dataReturnType: "data",
|
|
36
37
|
...client
|
|
37
38
|
},
|
|
@@ -50,6 +51,7 @@ var pluginSwr = createPlugin((options) => {
|
|
|
50
51
|
parser,
|
|
51
52
|
paramsType,
|
|
52
53
|
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
54
|
+
paramsCasing,
|
|
53
55
|
group
|
|
54
56
|
},
|
|
55
57
|
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAY,YAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,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,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAAC,cAAA,EAAgB,iBAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAY,YAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY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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 as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\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\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<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(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 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"]}
|
|
@@ -6,6 +6,7 @@ import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSch
|
|
|
6
6
|
type TransformerProps$1 = {
|
|
7
7
|
operation: Operation;
|
|
8
8
|
schemas: OperationSchemas;
|
|
9
|
+
casing: 'camelcase' | undefined;
|
|
9
10
|
};
|
|
10
11
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
11
12
|
type Suspense = object;
|
|
@@ -86,6 +87,11 @@ type Options$1 = {
|
|
|
86
87
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
87
88
|
*/
|
|
88
89
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
90
|
+
/**
|
|
91
|
+
* How to style your params, by default no casing is applied
|
|
92
|
+
* - 'camelcase' will use camelcase for the params names
|
|
93
|
+
*/
|
|
94
|
+
paramsCasing?: 'camelcase';
|
|
89
95
|
/**
|
|
90
96
|
* How to pass your params
|
|
91
97
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -142,6 +148,7 @@ type ResolvedOptions$1 = {
|
|
|
142
148
|
};
|
|
143
149
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
144
150
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
151
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
145
152
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
146
153
|
/**
|
|
147
154
|
* Only used of infinite
|
|
@@ -158,6 +165,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
158
165
|
type TransformerProps = {
|
|
159
166
|
operation: Operation;
|
|
160
167
|
schemas: OperationSchemas;
|
|
168
|
+
casing: 'camelcase' | undefined;
|
|
161
169
|
};
|
|
162
170
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
163
171
|
/**
|
|
@@ -225,6 +233,11 @@ type Options = {
|
|
|
225
233
|
query?: Query | false;
|
|
226
234
|
mutationKey?: MutationKey;
|
|
227
235
|
mutation?: Mutation | false;
|
|
236
|
+
/**
|
|
237
|
+
* How to style your params, by default no casing is applied
|
|
238
|
+
* - 'camelcase' will use camelcase for the params names
|
|
239
|
+
*/
|
|
240
|
+
paramsCasing?: 'camelcase';
|
|
228
241
|
/**
|
|
229
242
|
* How to pass your params
|
|
230
243
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -265,6 +278,7 @@ type ResolvedOptions = {
|
|
|
265
278
|
query: NonNullable<Required<Query>> | false;
|
|
266
279
|
mutationKey: MutationKey | undefined;
|
|
267
280
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
281
|
+
paramsCasing: Options['paramsCasing'];
|
|
268
282
|
paramsType: NonNullable<Options['paramsType']>;
|
|
269
283
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
270
284
|
group: Options['group'];
|
|
@@ -6,6 +6,7 @@ import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSch
|
|
|
6
6
|
type TransformerProps$1 = {
|
|
7
7
|
operation: Operation;
|
|
8
8
|
schemas: OperationSchemas;
|
|
9
|
+
casing: 'camelcase' | undefined;
|
|
9
10
|
};
|
|
10
11
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
11
12
|
type Suspense = object;
|
|
@@ -86,6 +87,11 @@ type Options$1 = {
|
|
|
86
87
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
87
88
|
*/
|
|
88
89
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
90
|
+
/**
|
|
91
|
+
* How to style your params, by default no casing is applied
|
|
92
|
+
* - 'camelcase' will use camelcase for the params names
|
|
93
|
+
*/
|
|
94
|
+
paramsCasing?: 'camelcase';
|
|
89
95
|
/**
|
|
90
96
|
* How to pass your params
|
|
91
97
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -142,6 +148,7 @@ type ResolvedOptions$1 = {
|
|
|
142
148
|
};
|
|
143
149
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
144
150
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
151
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
145
152
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
146
153
|
/**
|
|
147
154
|
* Only used of infinite
|
|
@@ -158,6 +165,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
158
165
|
type TransformerProps = {
|
|
159
166
|
operation: Operation;
|
|
160
167
|
schemas: OperationSchemas;
|
|
168
|
+
casing: 'camelcase' | undefined;
|
|
161
169
|
};
|
|
162
170
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
163
171
|
/**
|
|
@@ -225,6 +233,11 @@ type Options = {
|
|
|
225
233
|
query?: Query | false;
|
|
226
234
|
mutationKey?: MutationKey;
|
|
227
235
|
mutation?: Mutation | false;
|
|
236
|
+
/**
|
|
237
|
+
* How to style your params, by default no casing is applied
|
|
238
|
+
* - 'camelcase' will use camelcase for the params names
|
|
239
|
+
*/
|
|
240
|
+
paramsCasing?: 'camelcase';
|
|
228
241
|
/**
|
|
229
242
|
* How to pass your params
|
|
230
243
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -265,6 +278,7 @@ type ResolvedOptions = {
|
|
|
265
278
|
query: NonNullable<Required<Query>> | false;
|
|
266
279
|
mutationKey: MutationKey | undefined;
|
|
267
280
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
281
|
+
paramsCasing: Options['paramsCasing'];
|
|
268
282
|
paramsType: NonNullable<Options['paramsType']>;
|
|
269
283
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
270
284
|
group: Options['group'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-swr",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Generator plugin-swr",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -64,22 +64,22 @@
|
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"remeda": "^2.17.4",
|
|
67
|
-
"@kubb/core": "3.
|
|
68
|
-
"@kubb/fs": "3.
|
|
69
|
-
"@kubb/oas": "3.
|
|
70
|
-
"@kubb/plugin-client": "3.
|
|
71
|
-
"@kubb/plugin-oas": "3.
|
|
72
|
-
"@kubb/plugin-ts": "3.
|
|
73
|
-
"@kubb/plugin-zod": "3.
|
|
74
|
-
"@kubb/react": "3.
|
|
67
|
+
"@kubb/core": "3.3.0",
|
|
68
|
+
"@kubb/fs": "3.3.0",
|
|
69
|
+
"@kubb/oas": "3.3.0",
|
|
70
|
+
"@kubb/plugin-client": "3.3.0",
|
|
71
|
+
"@kubb/plugin-oas": "3.3.0",
|
|
72
|
+
"@kubb/plugin-ts": "3.3.0",
|
|
73
|
+
"@kubb/plugin-zod": "3.3.0",
|
|
74
|
+
"@kubb/react": "3.3.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@types/react": "^18.3.
|
|
77
|
+
"@types/react": "^18.3.16",
|
|
78
78
|
"react": "^18.3.1",
|
|
79
79
|
"tsup": "^8.3.5",
|
|
80
80
|
"typescript": "^5.7.2",
|
|
81
|
-
"@kubb/config-ts": "3.
|
|
82
|
-
"@kubb/config-tsup": "3.
|
|
81
|
+
"@kubb/config-ts": "3.3.0",
|
|
82
|
+
"@kubb/config-tsup": "3.3.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@kubb/react": "^3.0.0"
|
|
@@ -19,25 +19,27 @@ type Props = {
|
|
|
19
19
|
mutationKeyTypeName: string
|
|
20
20
|
typeSchemas: OperationSchemas
|
|
21
21
|
operation: Operation
|
|
22
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
22
23
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
23
24
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
type GetParamsProps = {
|
|
29
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
28
30
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
30
32
|
typeSchemas: OperationSchemas
|
|
31
33
|
mutationKeyTypeName: string
|
|
32
34
|
}
|
|
33
35
|
// TODO add same logic as being done for react-query mutations
|
|
34
|
-
function getParams({ pathParamsType, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {
|
|
36
|
+
function getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {
|
|
35
37
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
36
38
|
|
|
37
39
|
return FunctionParams.factory({
|
|
38
40
|
pathParams: {
|
|
39
41
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
40
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
42
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
41
43
|
},
|
|
42
44
|
params: typeSchemas.queryParams?.name
|
|
43
45
|
? {
|
|
@@ -70,6 +72,7 @@ export function Mutation({
|
|
|
70
72
|
mutationKeyName,
|
|
71
73
|
mutationKeyTypeName,
|
|
72
74
|
paramsType,
|
|
75
|
+
paramsCasing,
|
|
73
76
|
pathParamsType,
|
|
74
77
|
dataReturnType,
|
|
75
78
|
typeSchemas,
|
|
@@ -89,6 +92,7 @@ export function Mutation({
|
|
|
89
92
|
})
|
|
90
93
|
|
|
91
94
|
const params = getParams({
|
|
95
|
+
paramsCasing,
|
|
92
96
|
pathParamsType,
|
|
93
97
|
dataReturnType,
|
|
94
98
|
typeSchemas,
|
|
@@ -96,6 +100,7 @@ export function Mutation({
|
|
|
96
100
|
})
|
|
97
101
|
|
|
98
102
|
const clientParams = Client.getParams({
|
|
103
|
+
paramsCasing,
|
|
99
104
|
paramsType,
|
|
100
105
|
typeSchemas,
|
|
101
106
|
pathParamsType,
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
typeName: string
|
|
12
12
|
typeSchemas: OperationSchemas
|
|
13
13
|
operation: Operation
|
|
14
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
14
15
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
15
16
|
transformer: Transformer | undefined
|
|
16
17
|
}
|
|
@@ -24,15 +25,15 @@ function getParams({}: GetParamsProps) {
|
|
|
24
25
|
return FunctionParams.factory({})
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const getTransformer: Transformer = ({ operation }) => {
|
|
28
|
-
const path = new URLPath(operation.path)
|
|
28
|
+
const getTransformer: Transformer = ({ operation, casing }) => {
|
|
29
|
+
const path = new URLPath(operation.path, { casing })
|
|
29
30
|
|
|
30
31
|
return [JSON.stringify({ url: path.path })].filter(Boolean)
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
34
|
+
export function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
34
35
|
const params = getParams({ pathParamsType, typeSchemas })
|
|
35
|
-
const keys = transformer({ operation, schemas: typeSchemas })
|
|
36
|
+
const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
39
|
<>
|
package/src/components/Query.tsx
CHANGED
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
queryKeyName: string
|
|
19
19
|
queryKeyTypeName: string
|
|
20
20
|
typeSchemas: OperationSchemas
|
|
21
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
@@ -25,6 +26,7 @@ type Props = {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
type GetParamsProps = {
|
|
29
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
28
30
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
29
31
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
30
32
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
@@ -32,7 +34,7 @@ type GetParamsProps = {
|
|
|
32
34
|
typeSchemas: OperationSchemas
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: GetParamsProps) {
|
|
37
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: GetParamsProps) {
|
|
36
38
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
37
39
|
|
|
38
40
|
if (paramsType === 'object') {
|
|
@@ -40,7 +42,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas, qu
|
|
|
40
42
|
data: {
|
|
41
43
|
mode: 'object',
|
|
42
44
|
children: {
|
|
43
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
45
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
44
46
|
data: typeSchemas.request?.name
|
|
45
47
|
? {
|
|
46
48
|
type: typeSchemas.request?.name,
|
|
@@ -78,7 +80,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas, qu
|
|
|
78
80
|
pathParams: typeSchemas.pathParams?.name
|
|
79
81
|
? {
|
|
80
82
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
81
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
83
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
82
84
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
83
85
|
}
|
|
84
86
|
: undefined,
|
|
@@ -122,6 +124,7 @@ export function Query({
|
|
|
122
124
|
operation,
|
|
123
125
|
dataReturnType,
|
|
124
126
|
paramsType,
|
|
127
|
+
paramsCasing,
|
|
125
128
|
pathParamsType,
|
|
126
129
|
}: Props): ReactNode {
|
|
127
130
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
@@ -130,8 +133,10 @@ export function Query({
|
|
|
130
133
|
const queryKeyParams = QueryKey.getParams({
|
|
131
134
|
pathParamsType,
|
|
132
135
|
typeSchemas,
|
|
136
|
+
paramsCasing,
|
|
133
137
|
})
|
|
134
138
|
const params = getParams({
|
|
139
|
+
paramsCasing,
|
|
135
140
|
paramsType,
|
|
136
141
|
pathParamsType,
|
|
137
142
|
dataReturnType,
|
|
@@ -140,6 +145,7 @@ export function Query({
|
|
|
140
145
|
})
|
|
141
146
|
|
|
142
147
|
const queryOptionsParams = QueryOptions.getParams({
|
|
148
|
+
paramsCasing,
|
|
143
149
|
paramsType,
|
|
144
150
|
pathParamsType,
|
|
145
151
|
typeSchemas,
|
|
@@ -12,20 +12,22 @@ type Props = {
|
|
|
12
12
|
typeName: string
|
|
13
13
|
typeSchemas: OperationSchemas
|
|
14
14
|
operation: Operation
|
|
15
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
15
16
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
16
17
|
transformer: Transformer | undefined
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
20
22
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
21
23
|
typeSchemas: OperationSchemas
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
|
|
26
|
+
function getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {
|
|
25
27
|
return FunctionParams.factory({
|
|
26
28
|
pathParams: {
|
|
27
29
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
28
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
30
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
29
31
|
},
|
|
30
32
|
data: typeSchemas.request?.name
|
|
31
33
|
? {
|
|
@@ -42,8 +44,8 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
|
|
|
42
44
|
})
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
46
|
-
const path = new URLPath(operation.path)
|
|
47
|
+
const getTransformer: Transformer = ({ operation, schemas, casing }) => {
|
|
48
|
+
const path = new URLPath(operation.path, { casing })
|
|
47
49
|
const keys = [
|
|
48
50
|
path.toObject({
|
|
49
51
|
type: 'path',
|
|
@@ -56,11 +58,12 @@ const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
|
56
58
|
return keys
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
60
|
-
const params = getParams({ pathParamsType, typeSchemas })
|
|
61
|
+
export function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
62
|
+
const params = getParams({ pathParamsType, paramsCasing, typeSchemas })
|
|
61
63
|
const keys = transformer({
|
|
62
64
|
operation,
|
|
63
65
|
schemas: typeSchemas,
|
|
66
|
+
casing: paramsCasing,
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
return (
|
|
@@ -12,23 +12,25 @@ type Props = {
|
|
|
12
12
|
name: string
|
|
13
13
|
clientName: string
|
|
14
14
|
typeSchemas: OperationSchemas
|
|
15
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
15
16
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
16
17
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type GetParamsProps = {
|
|
20
21
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
22
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
21
23
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
22
24
|
typeSchemas: OperationSchemas
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
27
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
26
28
|
if (paramsType === 'object') {
|
|
27
29
|
return FunctionParams.factory({
|
|
28
30
|
data: {
|
|
29
31
|
mode: 'object',
|
|
30
32
|
children: {
|
|
31
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
33
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
32
34
|
data: typeSchemas.request?.name
|
|
33
35
|
? {
|
|
34
36
|
type: typeSchemas.request?.name,
|
|
@@ -60,7 +62,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
60
62
|
pathParams: typeSchemas.pathParams?.name
|
|
61
63
|
? {
|
|
62
64
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
63
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
65
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
64
66
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
65
67
|
}
|
|
66
68
|
: undefined,
|
|
@@ -89,9 +91,10 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
89
91
|
})
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType }: Props): ReactNode {
|
|
93
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
94
|
+
export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props): ReactNode {
|
|
95
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
94
96
|
const clientParams = Client.getParams({
|
|
97
|
+
paramsCasing,
|
|
95
98
|
paramsType,
|
|
96
99
|
typeSchemas,
|
|
97
100
|
pathParamsType,
|
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import useSWR from
|
|
3
|
-
import type { RequestConfig, ResponseConfig } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import useSWR from 'swr'
|
|
3
|
+
import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
10
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
async function findPetsByTags({ params }: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
|
|
18
|
-
return res;
|
|
14
|
+
async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
|
|
15
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
16
|
+
return res
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
};
|
|
19
|
+
export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
|
|
20
|
+
return {
|
|
21
|
+
fetcher: async () => {
|
|
22
|
+
return findPetsByTags({ params }, config)
|
|
23
|
+
},
|
|
24
|
+
}
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
/**
|
|
32
28
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
33
29
|
* @summary Finds Pets by tags
|
|
34
30
|
* {@link /pet/findByTags}
|
|
35
31
|
*/
|
|
36
|
-
export function useFindPetsByTags(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
|
|
40
|
-
client?: Partial<RequestConfig
|
|
41
|
-
shouldFetch?: boolean
|
|
42
|
-
} = {}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
export function useFindPetsByTags(
|
|
33
|
+
{ params }: { params?: FindPetsByTagsQueryParams },
|
|
34
|
+
options: {
|
|
35
|
+
query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
|
|
36
|
+
client?: Partial<RequestConfig>
|
|
37
|
+
shouldFetch?: boolean
|
|
38
|
+
} = {},
|
|
39
|
+
) {
|
|
40
|
+
const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
|
|
41
|
+
|
|
42
|
+
const queryKey = findPetsByTagsQueryKey(params)
|
|
43
|
+
|
|
44
|
+
return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
|
|
45
|
+
...findPetsByTagsQueryOptions({ params }, config),
|
|
46
|
+
...queryOptions,
|
|
47
|
+
})
|
|
49
48
|
}
|