@kubb/plugin-vue-query 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-HWT3VLRR.js → chunk-FPSHQREX.js} +69 -32
- package/dist/chunk-FPSHQREX.js.map +1 -0
- package/dist/{chunk-YWUOBXLY.js → chunk-GNUJZEZD.js} +14 -3
- package/dist/chunk-GNUJZEZD.js.map +1 -0
- package/dist/{chunk-63EIV54R.cjs → chunk-M7ME77VI.cjs} +25 -14
- package/dist/chunk-M7ME77VI.cjs.map +1 -0
- package/dist/{chunk-JYBDVID2.cjs → chunk-X3AYO2AG.cjs} +69 -32
- package/dist/chunk-X3AYO2AG.cjs.map +1 -0
- package/dist/components.cjs +8 -8
- package/dist/components.d.cts +25 -13
- package/dist/components.d.ts +25 -13
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- 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 +5 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-DAqaLrlX.d.cts → types-B6HlLDzG.d.cts} +30 -3
- package/dist/{types-DAqaLrlX.d.ts → types-B6HlLDzG.d.ts} +30 -3
- package/package.json +11 -11
- package/src/components/InfiniteQuery.tsx +9 -1
- package/src/components/InfiniteQueryOptions.tsx +9 -2
- package/src/components/Mutation.tsx +18 -3
- package/src/components/MutationKey.tsx +5 -4
- package/src/components/Query.tsx +9 -1
- package/src/components/QueryKey.tsx +9 -5
- package/src/components/QueryOptions.tsx +9 -3
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +55 -36
- package/src/generators/__snapshots__/clientGetImportPath.ts +55 -36
- package/src/generators/__snapshots__/clientPostImportPath.ts +51 -33
- package/src/generators/__snapshots__/findByTags.ts +55 -36
- package/src/generators/__snapshots__/findByTagsObject.ts +57 -46
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +55 -36
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +56 -36
- package/src/generators/__snapshots__/findByTagsWithZod.ts +55 -36
- package/src/generators/__snapshots__/findInfiniteByTags.ts +62 -41
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +62 -41
- package/src/generators/__snapshots__/postAsQuery.ts +68 -38
- package/src/generators/__snapshots__/updatePetById.ts +51 -33
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +51 -35
- package/src/generators/infiniteQueryGenerator.tsx +4 -0
- 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-63EIV54R.cjs.map +0 -1
- package/dist/chunk-HWT3VLRR.js.map +0 -1
- package/dist/chunk-JYBDVID2.cjs.map +0 -1
- package/dist/chunk-YWUOBXLY.js.map +0 -1
|
@@ -33,7 +33,7 @@ type Options$2 = {
|
|
|
33
33
|
* Path to the client import path that will be used to do the API calls.
|
|
34
34
|
* It will be used as `import client from '${client.importPath}'`.
|
|
35
35
|
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
36
|
-
* @default '@kubb/plugin-client/
|
|
36
|
+
* @default '@kubb/plugin-client/clients/axios'
|
|
37
37
|
*/
|
|
38
38
|
importPath?: string;
|
|
39
39
|
/**
|
|
@@ -47,6 +47,11 @@ type Options$2 = {
|
|
|
47
47
|
* @default 'data'
|
|
48
48
|
*/
|
|
49
49
|
dataReturnType?: 'data' | 'full';
|
|
50
|
+
/**
|
|
51
|
+
* How to style your params, by default no casing is applied
|
|
52
|
+
* - 'camelcase' will use camelcase for the params names
|
|
53
|
+
*/
|
|
54
|
+
paramsCasing?: 'camelcase';
|
|
50
55
|
/**
|
|
51
56
|
* How to pass your params
|
|
52
57
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -63,10 +68,17 @@ type Options$2 = {
|
|
|
63
68
|
pathParamsType?: 'object' | 'inline';
|
|
64
69
|
/**
|
|
65
70
|
* Which parser can be used before returning the data
|
|
66
|
-
* - 'zod'
|
|
71
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
67
72
|
* @default 'client'
|
|
68
73
|
*/
|
|
69
74
|
parser?: 'client' | 'zod';
|
|
75
|
+
/**
|
|
76
|
+
* Which client should be used to do the HTTP calls
|
|
77
|
+
* - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
|
|
78
|
+
* - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
|
|
79
|
+
* @default 'axios'
|
|
80
|
+
*/
|
|
81
|
+
client?: 'axios' | 'fetch';
|
|
70
82
|
transformers?: {
|
|
71
83
|
/**
|
|
72
84
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -87,12 +99,14 @@ type ResolvedOptions$2 = {
|
|
|
87
99
|
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
100
|
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
101
|
paramsType: NonNullable<Options$2['paramsType']>;
|
|
102
|
+
paramsCasing: Options$2['paramsCasing'];
|
|
90
103
|
};
|
|
91
104
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
105
|
|
|
93
106
|
type TransformerProps$1 = {
|
|
94
107
|
operation: Operation;
|
|
95
108
|
schemas: OperationSchemas;
|
|
109
|
+
casing: 'camelcase' | undefined;
|
|
96
110
|
};
|
|
97
111
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
98
112
|
type Suspense = object;
|
|
@@ -173,6 +187,11 @@ type Options$1 = {
|
|
|
173
187
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
188
|
*/
|
|
175
189
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
190
|
+
/**
|
|
191
|
+
* How to style your params, by default no casing is applied
|
|
192
|
+
* - 'camelcase' will use camelcase for the params names
|
|
193
|
+
*/
|
|
194
|
+
paramsCasing?: 'camelcase';
|
|
176
195
|
/**
|
|
177
196
|
* How to pass your params
|
|
178
197
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -229,6 +248,7 @@ type ResolvedOptions$1 = {
|
|
|
229
248
|
};
|
|
230
249
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
231
250
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
251
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
232
252
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
233
253
|
/**
|
|
234
254
|
* Only used of infinite
|
|
@@ -245,6 +265,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
245
265
|
type TransformerProps = {
|
|
246
266
|
operation: Operation;
|
|
247
267
|
schemas: OperationSchemas;
|
|
268
|
+
casing: 'camelcase' | undefined;
|
|
248
269
|
};
|
|
249
270
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
250
271
|
/**
|
|
@@ -324,6 +345,11 @@ type Options = {
|
|
|
324
345
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
325
346
|
*/
|
|
326
347
|
override?: Array<Override<ResolvedOptions>>;
|
|
348
|
+
/**
|
|
349
|
+
* How to style your params, by default no casing is applied
|
|
350
|
+
* - 'camelcase' will use camelcase for the params names
|
|
351
|
+
*/
|
|
352
|
+
paramsCasing?: 'camelcase';
|
|
327
353
|
/**
|
|
328
354
|
* How to pass your params
|
|
329
355
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -375,6 +401,7 @@ type ResolvedOptions = {
|
|
|
375
401
|
baseURL?: string;
|
|
376
402
|
};
|
|
377
403
|
parser: Required<NonNullable<Options['parser']>>;
|
|
404
|
+
paramsCasing: Options['paramsCasing'];
|
|
378
405
|
paramsType: NonNullable<Options['paramsType']>;
|
|
379
406
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
380
407
|
/**
|
|
@@ -388,4 +415,4 @@ type ResolvedOptions = {
|
|
|
388
415
|
};
|
|
389
416
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
390
417
|
|
|
391
|
-
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
|
|
418
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T, PluginReactQuery as a };
|
|
@@ -33,7 +33,7 @@ type Options$2 = {
|
|
|
33
33
|
* Path to the client import path that will be used to do the API calls.
|
|
34
34
|
* It will be used as `import client from '${client.importPath}'`.
|
|
35
35
|
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
36
|
-
* @default '@kubb/plugin-client/
|
|
36
|
+
* @default '@kubb/plugin-client/clients/axios'
|
|
37
37
|
*/
|
|
38
38
|
importPath?: string;
|
|
39
39
|
/**
|
|
@@ -47,6 +47,11 @@ type Options$2 = {
|
|
|
47
47
|
* @default 'data'
|
|
48
48
|
*/
|
|
49
49
|
dataReturnType?: 'data' | 'full';
|
|
50
|
+
/**
|
|
51
|
+
* How to style your params, by default no casing is applied
|
|
52
|
+
* - 'camelcase' will use camelcase for the params names
|
|
53
|
+
*/
|
|
54
|
+
paramsCasing?: 'camelcase';
|
|
50
55
|
/**
|
|
51
56
|
* How to pass your params
|
|
52
57
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -63,10 +68,17 @@ type Options$2 = {
|
|
|
63
68
|
pathParamsType?: 'object' | 'inline';
|
|
64
69
|
/**
|
|
65
70
|
* Which parser can be used before returning the data
|
|
66
|
-
* - 'zod'
|
|
71
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
67
72
|
* @default 'client'
|
|
68
73
|
*/
|
|
69
74
|
parser?: 'client' | 'zod';
|
|
75
|
+
/**
|
|
76
|
+
* Which client should be used to do the HTTP calls
|
|
77
|
+
* - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
|
|
78
|
+
* - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
|
|
79
|
+
* @default 'axios'
|
|
80
|
+
*/
|
|
81
|
+
client?: 'axios' | 'fetch';
|
|
70
82
|
transformers?: {
|
|
71
83
|
/**
|
|
72
84
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -87,12 +99,14 @@ type ResolvedOptions$2 = {
|
|
|
87
99
|
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
100
|
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
101
|
paramsType: NonNullable<Options$2['paramsType']>;
|
|
102
|
+
paramsCasing: Options$2['paramsCasing'];
|
|
90
103
|
};
|
|
91
104
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
105
|
|
|
93
106
|
type TransformerProps$1 = {
|
|
94
107
|
operation: Operation;
|
|
95
108
|
schemas: OperationSchemas;
|
|
109
|
+
casing: 'camelcase' | undefined;
|
|
96
110
|
};
|
|
97
111
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
98
112
|
type Suspense = object;
|
|
@@ -173,6 +187,11 @@ type Options$1 = {
|
|
|
173
187
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
188
|
*/
|
|
175
189
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
190
|
+
/**
|
|
191
|
+
* How to style your params, by default no casing is applied
|
|
192
|
+
* - 'camelcase' will use camelcase for the params names
|
|
193
|
+
*/
|
|
194
|
+
paramsCasing?: 'camelcase';
|
|
176
195
|
/**
|
|
177
196
|
* How to pass your params
|
|
178
197
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -229,6 +248,7 @@ type ResolvedOptions$1 = {
|
|
|
229
248
|
};
|
|
230
249
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
231
250
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
251
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
232
252
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
233
253
|
/**
|
|
234
254
|
* Only used of infinite
|
|
@@ -245,6 +265,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
245
265
|
type TransformerProps = {
|
|
246
266
|
operation: Operation;
|
|
247
267
|
schemas: OperationSchemas;
|
|
268
|
+
casing: 'camelcase' | undefined;
|
|
248
269
|
};
|
|
249
270
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
250
271
|
/**
|
|
@@ -324,6 +345,11 @@ type Options = {
|
|
|
324
345
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
325
346
|
*/
|
|
326
347
|
override?: Array<Override<ResolvedOptions>>;
|
|
348
|
+
/**
|
|
349
|
+
* How to style your params, by default no casing is applied
|
|
350
|
+
* - 'camelcase' will use camelcase for the params names
|
|
351
|
+
*/
|
|
352
|
+
paramsCasing?: 'camelcase';
|
|
327
353
|
/**
|
|
328
354
|
* How to pass your params
|
|
329
355
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -375,6 +401,7 @@ type ResolvedOptions = {
|
|
|
375
401
|
baseURL?: string;
|
|
376
402
|
};
|
|
377
403
|
parser: Required<NonNullable<Options['parser']>>;
|
|
404
|
+
paramsCasing: Options['paramsCasing'];
|
|
378
405
|
paramsType: NonNullable<Options['paramsType']>;
|
|
379
406
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
380
407
|
/**
|
|
@@ -388,4 +415,4 @@ type ResolvedOptions = {
|
|
|
388
415
|
};
|
|
389
416
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
390
417
|
|
|
391
|
-
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
|
|
418
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T, PluginReactQuery as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Generator vue-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -63,21 +63,21 @@
|
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"remeda": "^2.17.4",
|
|
66
|
-
"@kubb/core": "3.
|
|
67
|
-
"@kubb/fs": "3.
|
|
68
|
-
"@kubb/oas": "3.
|
|
69
|
-
"@kubb/plugin-oas": "3.
|
|
70
|
-
"@kubb/plugin-ts": "3.
|
|
71
|
-
"@kubb/plugin-zod": "3.
|
|
72
|
-
"@kubb/react": "3.
|
|
66
|
+
"@kubb/core": "3.3.0",
|
|
67
|
+
"@kubb/fs": "3.3.0",
|
|
68
|
+
"@kubb/oas": "3.3.0",
|
|
69
|
+
"@kubb/plugin-oas": "3.3.0",
|
|
70
|
+
"@kubb/plugin-ts": "3.3.0",
|
|
71
|
+
"@kubb/plugin-zod": "3.3.0",
|
|
72
|
+
"@kubb/react": "3.3.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@types/react": "^18.3.
|
|
75
|
+
"@types/react": "^18.3.16",
|
|
76
76
|
"react": "^18.3.1",
|
|
77
77
|
"tsup": "^8.3.5",
|
|
78
78
|
"typescript": "^5.7.2",
|
|
79
|
-
"@kubb/config-ts": "3.
|
|
80
|
-
"@kubb/config-tsup": "3.
|
|
79
|
+
"@kubb/config-ts": "3.3.0",
|
|
80
|
+
"@kubb/config-tsup": "3.3.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@kubb/react": "^3.0.0"
|
|
@@ -18,19 +18,21 @@ type Props = {
|
|
|
18
18
|
queryKeyTypeName: string
|
|
19
19
|
typeSchemas: OperationSchemas
|
|
20
20
|
operation: Operation
|
|
21
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
type GetParamsProps = {
|
|
28
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
27
29
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
28
30
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
30
32
|
typeSchemas: OperationSchemas
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
35
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
34
36
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
35
37
|
|
|
36
38
|
if (paramsType === 'object') {
|
|
@@ -40,6 +42,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
40
42
|
children: {
|
|
41
43
|
...getPathParams(typeSchemas.pathParams, {
|
|
42
44
|
typed: true,
|
|
45
|
+
casing: paramsCasing,
|
|
43
46
|
override(item) {
|
|
44
47
|
return {
|
|
45
48
|
...item,
|
|
@@ -85,6 +88,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
85
88
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
86
89
|
children: getPathParams(typeSchemas.pathParams, {
|
|
87
90
|
typed: true,
|
|
91
|
+
casing: paramsCasing,
|
|
88
92
|
override(item) {
|
|
89
93
|
return {
|
|
90
94
|
...item,
|
|
@@ -130,6 +134,7 @@ export function InfiniteQuery({
|
|
|
130
134
|
queryKeyName,
|
|
131
135
|
paramsType,
|
|
132
136
|
pathParamsType,
|
|
137
|
+
paramsCasing,
|
|
133
138
|
dataReturnType,
|
|
134
139
|
typeSchemas,
|
|
135
140
|
operation,
|
|
@@ -141,13 +146,16 @@ export function InfiniteQuery({
|
|
|
141
146
|
const queryKeyParams = QueryKey.getParams({
|
|
142
147
|
pathParamsType,
|
|
143
148
|
typeSchemas,
|
|
149
|
+
paramsCasing,
|
|
144
150
|
})
|
|
145
151
|
const queryOptionsParams = QueryOptions.getParams({
|
|
146
152
|
paramsType,
|
|
147
153
|
pathParamsType,
|
|
148
154
|
typeSchemas,
|
|
155
|
+
paramsCasing,
|
|
149
156
|
})
|
|
150
157
|
const params = getParams({
|
|
158
|
+
paramsCasing,
|
|
151
159
|
paramsType,
|
|
152
160
|
pathParamsType,
|
|
153
161
|
dataReturnType,
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
clientName: string
|
|
15
15
|
queryKeyName: string
|
|
16
16
|
typeSchemas: OperationSchemas
|
|
17
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
17
18
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
18
19
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
19
20
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -23,12 +24,13 @@ type Props = {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
type GetParamsProps = {
|
|
27
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
26
28
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
27
29
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
28
30
|
typeSchemas: OperationSchemas
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
33
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
32
34
|
if (paramsType === 'object') {
|
|
33
35
|
return FunctionParams.factory({
|
|
34
36
|
data: {
|
|
@@ -36,6 +38,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
36
38
|
children: {
|
|
37
39
|
...getPathParams(typeSchemas.pathParams, {
|
|
38
40
|
typed: true,
|
|
41
|
+
casing: paramsCasing,
|
|
39
42
|
override(item) {
|
|
40
43
|
return {
|
|
41
44
|
...item,
|
|
@@ -76,6 +79,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
76
79
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
77
80
|
children: getPathParams(typeSchemas.pathParams, {
|
|
78
81
|
typed: true,
|
|
82
|
+
casing: paramsCasing,
|
|
79
83
|
override(item) {
|
|
80
84
|
return {
|
|
81
85
|
...item,
|
|
@@ -116,18 +120,21 @@ export function InfiniteQueryOptions({
|
|
|
116
120
|
cursorParam,
|
|
117
121
|
typeSchemas,
|
|
118
122
|
paramsType,
|
|
123
|
+
paramsCasing,
|
|
119
124
|
dataReturnType,
|
|
120
125
|
pathParamsType,
|
|
121
126
|
queryParam,
|
|
122
127
|
queryKeyName,
|
|
123
128
|
}: Props): ReactNode {
|
|
124
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
129
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
125
130
|
const clientParams = Client.getParams({
|
|
126
131
|
paramsType,
|
|
132
|
+
paramsCasing,
|
|
127
133
|
typeSchemas,
|
|
128
134
|
pathParamsType,
|
|
129
135
|
})
|
|
130
136
|
const queryKeyParams = QueryKey.getParams({
|
|
137
|
+
paramsCasing,
|
|
131
138
|
pathParamsType,
|
|
132
139
|
typeSchemas,
|
|
133
140
|
})
|
|
@@ -19,22 +19,25 @@ type Props = {
|
|
|
19
19
|
mutationKeyName: string
|
|
20
20
|
typeSchemas: OperationSchemas
|
|
21
21
|
operation: Operation
|
|
22
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
22
23
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
23
24
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
type GetParamsProps = {
|
|
29
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
28
30
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
30
32
|
typeSchemas: OperationSchemas
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
35
|
+
function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
34
36
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
35
37
|
const mutationParams = FunctionParams.factory({
|
|
36
38
|
...getPathParams(typeSchemas.pathParams, {
|
|
37
39
|
typed: true,
|
|
40
|
+
casing: paramsCasing,
|
|
38
41
|
override(item) {
|
|
39
42
|
return {
|
|
40
43
|
...item,
|
|
@@ -76,26 +79,38 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
76
79
|
})
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
export function Mutation({
|
|
82
|
+
export function Mutation({
|
|
83
|
+
name,
|
|
84
|
+
clientName,
|
|
85
|
+
paramsCasing,
|
|
86
|
+
paramsType,
|
|
87
|
+
pathParamsType,
|
|
88
|
+
dataReturnType,
|
|
89
|
+
typeSchemas,
|
|
90
|
+
operation,
|
|
91
|
+
mutationKeyName,
|
|
92
|
+
}: Props): ReactNode {
|
|
80
93
|
const mutationKeyParams = MutationKey.getParams({
|
|
81
94
|
pathParamsType,
|
|
82
95
|
typeSchemas,
|
|
83
96
|
})
|
|
84
97
|
|
|
85
98
|
const params = getParams({
|
|
99
|
+
paramsCasing,
|
|
86
100
|
pathParamsType,
|
|
87
101
|
dataReturnType,
|
|
88
102
|
typeSchemas,
|
|
89
103
|
})
|
|
90
104
|
|
|
91
105
|
const clientParams = Client.getParams({
|
|
106
|
+
paramsCasing,
|
|
92
107
|
paramsType,
|
|
93
108
|
typeSchemas,
|
|
94
109
|
pathParamsType,
|
|
95
110
|
})
|
|
96
111
|
|
|
97
112
|
const mutationParams = FunctionParams.factory({
|
|
98
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
113
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
99
114
|
data: typeSchemas.request?.name
|
|
100
115
|
? {
|
|
101
116
|
type: typeSchemas.request?.name,
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
typeName: string
|
|
12
12
|
typeSchemas: OperationSchemas
|
|
13
13
|
operation: Operation
|
|
14
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
14
15
|
pathParamsType: PluginVueQuery['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
|
@@ -19,19 +19,21 @@ type Props = {
|
|
|
19
19
|
queryKeyTypeName: string
|
|
20
20
|
typeSchemas: OperationSchemas
|
|
21
21
|
operation: Operation
|
|
22
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
22
23
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
23
24
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
24
25
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
type GetParamsProps = {
|
|
29
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
28
30
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
29
31
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
30
32
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
31
33
|
typeSchemas: OperationSchemas
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
36
|
+
function getParams({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
35
37
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
36
38
|
|
|
37
39
|
if (paramsType === 'object') {
|
|
@@ -41,6 +43,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
41
43
|
children: {
|
|
42
44
|
...getPathParams(typeSchemas.pathParams, {
|
|
43
45
|
typed: true,
|
|
46
|
+
casing: paramsCasing,
|
|
44
47
|
override(item) {
|
|
45
48
|
return {
|
|
46
49
|
...item,
|
|
@@ -86,6 +89,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
86
89
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
87
90
|
children: getPathParams(typeSchemas.pathParams, {
|
|
88
91
|
typed: true,
|
|
92
|
+
casing: paramsCasing,
|
|
89
93
|
override(item) {
|
|
90
94
|
return {
|
|
91
95
|
...item,
|
|
@@ -130,6 +134,7 @@ export function Query({
|
|
|
130
134
|
queryOptionsName,
|
|
131
135
|
queryKeyName,
|
|
132
136
|
paramsType,
|
|
137
|
+
paramsCasing,
|
|
133
138
|
pathParamsType,
|
|
134
139
|
dataReturnType,
|
|
135
140
|
typeSchemas,
|
|
@@ -142,13 +147,16 @@ export function Query({
|
|
|
142
147
|
const queryKeyParams = QueryKey.getParams({
|
|
143
148
|
pathParamsType,
|
|
144
149
|
typeSchemas,
|
|
150
|
+
paramsCasing,
|
|
145
151
|
})
|
|
146
152
|
const queryOptionsParams = QueryOptions.getParams({
|
|
147
153
|
paramsType,
|
|
148
154
|
pathParamsType,
|
|
149
155
|
typeSchemas,
|
|
156
|
+
paramsCasing,
|
|
150
157
|
})
|
|
151
158
|
const params = getParams({
|
|
159
|
+
paramsCasing,
|
|
152
160
|
paramsType,
|
|
153
161
|
pathParamsType,
|
|
154
162
|
dataReturnType,
|
|
@@ -12,21 +12,24 @@ type Props = {
|
|
|
12
12
|
typeName: string
|
|
13
13
|
typeSchemas: OperationSchemas
|
|
14
14
|
operation: Operation
|
|
15
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
15
16
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
16
17
|
transformer: Transformer | undefined
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
20
22
|
pathParamsType: PluginVueQuery['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
30
|
children: getPathParams(typeSchemas.pathParams, {
|
|
29
31
|
typed: true,
|
|
32
|
+
casing: paramsCasing,
|
|
30
33
|
override(item) {
|
|
31
34
|
return {
|
|
32
35
|
...item,
|
|
@@ -50,8 +53,8 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
|
|
|
50
53
|
})
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
54
|
-
const path = new URLPath(operation.path)
|
|
56
|
+
const getTransformer: Transformer = ({ operation, schemas, casing }) => {
|
|
57
|
+
const path = new URLPath(operation.path, { casing })
|
|
55
58
|
const keys = [
|
|
56
59
|
path.toObject({
|
|
57
60
|
type: 'path',
|
|
@@ -64,11 +67,12 @@ const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
|
64
67
|
return keys
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
68
|
-
const params = getParams({ pathParamsType, typeSchemas })
|
|
70
|
+
export function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
71
|
+
const params = getParams({ pathParamsType, typeSchemas, paramsCasing })
|
|
69
72
|
const keys = transformer({
|
|
70
73
|
operation,
|
|
71
74
|
schemas: typeSchemas,
|
|
75
|
+
casing: paramsCasing,
|
|
72
76
|
})
|
|
73
77
|
|
|
74
78
|
return (
|
|
@@ -15,17 +15,19 @@ type Props = {
|
|
|
15
15
|
clientName: string
|
|
16
16
|
queryKeyName: string
|
|
17
17
|
typeSchemas: OperationSchemas
|
|
18
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
18
19
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
19
20
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
type GetParamsProps = {
|
|
24
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
23
25
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
24
26
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
25
27
|
typeSchemas: OperationSchemas
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
30
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
29
31
|
if (paramsType === 'object') {
|
|
30
32
|
return FunctionParams.factory({
|
|
31
33
|
data: {
|
|
@@ -33,6 +35,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
33
35
|
children: {
|
|
34
36
|
...getPathParams(typeSchemas.pathParams, {
|
|
35
37
|
typed: true,
|
|
38
|
+
casing: paramsCasing,
|
|
36
39
|
override(item) {
|
|
37
40
|
return {
|
|
38
41
|
...item,
|
|
@@ -73,6 +76,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
73
76
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
74
77
|
children: getPathParams(typeSchemas.pathParams, {
|
|
75
78
|
typed: true,
|
|
79
|
+
casing: paramsCasing,
|
|
76
80
|
override(item) {
|
|
77
81
|
return {
|
|
78
82
|
...item,
|
|
@@ -106,16 +110,18 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
106
110
|
})
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
|
|
110
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
113
|
+
export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
|
|
114
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
111
115
|
const clientParams = Client.getParams({
|
|
112
116
|
paramsType,
|
|
117
|
+
paramsCasing,
|
|
113
118
|
typeSchemas,
|
|
114
119
|
pathParamsType,
|
|
115
120
|
})
|
|
116
121
|
const queryKeyParams = QueryKey.getParams({
|
|
117
122
|
pathParamsType,
|
|
118
123
|
typeSchemas,
|
|
124
|
+
paramsCasing,
|
|
119
125
|
})
|
|
120
126
|
|
|
121
127
|
const enabled = Object.entries(queryKeyParams.flatParams)
|