@kubb/plugin-solid-query 0.0.0-canary-20241205221000 → 0.0.0-canary-20241213202051
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-MJ5KIMWZ.cjs → chunk-DVSYWSJI.cjs} +11 -7
- package/dist/chunk-DVSYWSJI.cjs.map +1 -0
- package/dist/{chunk-EUTZZKJ3.cjs → chunk-JJUVLRTD.cjs} +31 -23
- package/dist/chunk-JJUVLRTD.cjs.map +1 -0
- package/dist/{chunk-FDSKHS3A.js → chunk-Y4R4BN3G.js} +31 -23
- package/dist/chunk-Y4R4BN3G.js.map +1 -0
- package/dist/{chunk-46JQ7CUT.js → chunk-ZROTVRZS.js} +7 -3
- package/dist/chunk-ZROTVRZS.js.map +1 -0
- package/dist/components.cjs +4 -4
- package/dist/components.d.cts +13 -7
- package/dist/components.d.ts +13 -7
- package/dist/components.js +1 -1
- package/dist/generators.cjs +3 -3
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +9 -7
- 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 +7 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-Udob4Cmd.d.cts → types-CkeKuWIN.d.cts} +29 -2
- package/dist/{types-Udob4Cmd.d.ts → types-CkeKuWIN.d.ts} +29 -2
- package/package.json +12 -12
- package/src/components/Query.tsx +9 -3
- package/src/components/QueryKey.tsx +9 -6
- package/src/components/QueryOptions.tsx +9 -5
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -2
- package/src/generators/__snapshots__/findByTags.ts +2 -2
- package/src/generators/__snapshots__/findByTagsObject.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/queryGenerator.tsx +4 -0
- package/src/plugin.ts +3 -1
- package/src/types.ts +7 -0
- package/dist/chunk-46JQ7CUT.js.map +0 -1
- package/dist/chunk-EUTZZKJ3.cjs.map +0 -1
- package/dist/chunk-FDSKHS3A.js.map +0 -1
- package/dist/chunk-MJ5KIMWZ.cjs.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
|
/**
|
|
@@ -289,6 +310,11 @@ type Options = {
|
|
|
289
310
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
290
311
|
*/
|
|
291
312
|
override?: Array<Override<ResolvedOptions>>;
|
|
313
|
+
/**
|
|
314
|
+
* How to style your params, by default no casing is applied
|
|
315
|
+
* - 'camelcase' will use camelcase for the params names
|
|
316
|
+
*/
|
|
317
|
+
paramsCasing?: 'camelcase';
|
|
292
318
|
/**
|
|
293
319
|
* How to pass your params
|
|
294
320
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -331,6 +357,7 @@ type ResolvedOptions = {
|
|
|
331
357
|
baseURL?: string;
|
|
332
358
|
};
|
|
333
359
|
parser: Required<NonNullable<Options['parser']>>;
|
|
360
|
+
paramsCasing: Options['paramsCasing'];
|
|
334
361
|
paramsType: NonNullable<Options['paramsType']>;
|
|
335
362
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
336
363
|
queryKey: QueryKey | undefined;
|
|
@@ -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
|
/**
|
|
@@ -289,6 +310,11 @@ type Options = {
|
|
|
289
310
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
290
311
|
*/
|
|
291
312
|
override?: Array<Override<ResolvedOptions>>;
|
|
313
|
+
/**
|
|
314
|
+
* How to style your params, by default no casing is applied
|
|
315
|
+
* - 'camelcase' will use camelcase for the params names
|
|
316
|
+
*/
|
|
317
|
+
paramsCasing?: 'camelcase';
|
|
292
318
|
/**
|
|
293
319
|
* How to pass your params
|
|
294
320
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -331,6 +357,7 @@ type ResolvedOptions = {
|
|
|
331
357
|
baseURL?: string;
|
|
332
358
|
};
|
|
333
359
|
parser: Required<NonNullable<Options['parser']>>;
|
|
360
|
+
paramsCasing: Options['paramsCasing'];
|
|
334
361
|
paramsType: NonNullable<Options['paramsType']>;
|
|
335
362
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
336
363
|
queryKey: QueryKey | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-solid-query",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20241213202051",
|
|
4
4
|
"description": "Generator solid-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -63,24 +63,24 @@
|
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"remeda": "^2.17.4",
|
|
66
|
-
"@kubb/core": "0.0.0-canary-
|
|
67
|
-
"@kubb/
|
|
68
|
-
"@kubb/
|
|
69
|
-
"@kubb/plugin-oas": "0.0.0-canary-
|
|
70
|
-
"@kubb/plugin-ts": "0.0.0-canary-
|
|
71
|
-
"@kubb/plugin-zod": "0.0.0-canary-
|
|
72
|
-
"@kubb/react": "0.0.0-canary-
|
|
66
|
+
"@kubb/core": "0.0.0-canary-20241213202051",
|
|
67
|
+
"@kubb/fs": "0.0.0-canary-20241213202051",
|
|
68
|
+
"@kubb/oas": "0.0.0-canary-20241213202051",
|
|
69
|
+
"@kubb/plugin-oas": "0.0.0-canary-20241213202051",
|
|
70
|
+
"@kubb/plugin-ts": "0.0.0-canary-20241213202051",
|
|
71
|
+
"@kubb/plugin-zod": "0.0.0-canary-20241213202051",
|
|
72
|
+
"@kubb/react": "0.0.0-canary-20241213202051"
|
|
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": "0.0.0-canary-
|
|
80
|
-
"@kubb/config-tsup": "0.0.0-canary-
|
|
79
|
+
"@kubb/config-ts": "0.0.0-canary-20241213202051",
|
|
80
|
+
"@kubb/config-tsup": "0.0.0-canary-20241213202051"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@kubb/react": "0.0.0-canary-
|
|
83
|
+
"@kubb/react": "0.0.0-canary-20241213202051"
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": ">=20"
|
package/src/components/Query.tsx
CHANGED
|
@@ -18,19 +18,21 @@ type Props = {
|
|
|
18
18
|
queryKeyTypeName: string
|
|
19
19
|
typeSchemas: OperationSchemas
|
|
20
20
|
operation: Operation
|
|
21
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
type GetParamsProps = {
|
|
28
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
27
29
|
paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
|
|
28
30
|
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginSolidQuery['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') {
|
|
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
38
40
|
data: {
|
|
39
41
|
mode: 'object',
|
|
40
42
|
children: {
|
|
41
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
43
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
42
44
|
data: typeSchemas.request?.name
|
|
43
45
|
? {
|
|
44
46
|
type: typeSchemas.request?.name,
|
|
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
|
|
|
75
77
|
pathParams: typeSchemas.pathParams?.name
|
|
76
78
|
? {
|
|
77
79
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
78
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
80
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
79
81
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
80
82
|
}
|
|
81
83
|
: undefined,
|
|
@@ -114,6 +116,7 @@ export function Query({
|
|
|
114
116
|
queryKeyTypeName,
|
|
115
117
|
queryOptionsName,
|
|
116
118
|
queryKeyName,
|
|
119
|
+
paramsCasing,
|
|
117
120
|
paramsType,
|
|
118
121
|
pathParamsType,
|
|
119
122
|
dataReturnType,
|
|
@@ -127,13 +130,16 @@ export function Query({
|
|
|
127
130
|
const queryKeyParams = QueryKey.getParams({
|
|
128
131
|
pathParamsType,
|
|
129
132
|
typeSchemas,
|
|
133
|
+
paramsCasing,
|
|
130
134
|
})
|
|
131
135
|
const queryOptionsParams = QueryOptions.getParams({
|
|
132
136
|
paramsType,
|
|
137
|
+
paramsCasing,
|
|
133
138
|
pathParamsType,
|
|
134
139
|
typeSchemas,
|
|
135
140
|
})
|
|
136
141
|
const params = getParams({
|
|
142
|
+
paramsCasing,
|
|
137
143
|
paramsType,
|
|
138
144
|
pathParamsType,
|
|
139
145
|
dataReturnType,
|
|
@@ -12,20 +12,22 @@ type Props = {
|
|
|
12
12
|
typeName: string
|
|
13
13
|
typeSchemas: OperationSchemas
|
|
14
14
|
operation: Operation
|
|
15
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
15
16
|
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
16
17
|
transformer: Transformer | undefined
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
20
22
|
pathParamsType: PluginSolidQuery['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 (
|
|
@@ -14,23 +14,25 @@ type Props = {
|
|
|
14
14
|
clientName: string
|
|
15
15
|
queryKeyName: string
|
|
16
16
|
typeSchemas: OperationSchemas
|
|
17
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
17
18
|
paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
|
|
18
19
|
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
type GetParamsProps = {
|
|
23
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
22
24
|
paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
|
|
23
25
|
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
24
26
|
typeSchemas: OperationSchemas
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
29
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
28
30
|
if (paramsType === 'object') {
|
|
29
31
|
return FunctionParams.factory({
|
|
30
32
|
data: {
|
|
31
33
|
mode: 'object',
|
|
32
34
|
children: {
|
|
33
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
35
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
34
36
|
data: typeSchemas.request?.name
|
|
35
37
|
? {
|
|
36
38
|
type: typeSchemas.request?.name,
|
|
@@ -62,7 +64,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
62
64
|
pathParams: typeSchemas.pathParams?.name
|
|
63
65
|
? {
|
|
64
66
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
65
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
67
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
66
68
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
67
69
|
}
|
|
68
70
|
: undefined,
|
|
@@ -91,15 +93,17 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
91
93
|
})
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
|
|
95
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
96
|
+
export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
|
|
97
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
96
98
|
const clientParams = Client.getParams({
|
|
99
|
+
paramsCasing,
|
|
97
100
|
typeSchemas,
|
|
98
101
|
paramsType,
|
|
99
102
|
pathParamsType,
|
|
100
103
|
})
|
|
101
104
|
const queryKeyParams = QueryKey.getParams({
|
|
102
105
|
pathParamsType,
|
|
106
|
+
paramsCasing,
|
|
103
107
|
typeSchemas,
|
|
104
108
|
})
|
|
105
109
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/react-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/react-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
4
|
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import client from "@kubb/plugin-client/
|
|
2
|
-
import type { RequestConfig } from "@kubb/plugin-client/
|
|
1
|
+
import client from "@kubb/plugin-client/clients/axios";
|
|
2
|
+
import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "custom-query";
|
|
4
4
|
import { queryOptions, createQuery } from "custom-query";
|
|
5
5
|
|
|
@@ -80,6 +80,7 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
|
|
|
80
80
|
name={queryKey.name}
|
|
81
81
|
typeName={queryKey.typeName}
|
|
82
82
|
operation={operation}
|
|
83
|
+
paramsCasing={options.paramsCasing}
|
|
83
84
|
pathParamsType={options.pathParamsType}
|
|
84
85
|
typeSchemas={type.schemas}
|
|
85
86
|
transformer={options.queryKey}
|
|
@@ -93,6 +94,7 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
|
|
|
93
94
|
typeSchemas={type.schemas}
|
|
94
95
|
zodSchemas={zod.schemas}
|
|
95
96
|
dataReturnType={options.client.dataReturnType}
|
|
97
|
+
paramsCasing={options.paramsCasing}
|
|
96
98
|
paramsType={options.paramsType}
|
|
97
99
|
pathParamsType={options.pathParamsType}
|
|
98
100
|
parser={options.parser}
|
|
@@ -103,6 +105,7 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
|
|
|
103
105
|
clientName={client.name}
|
|
104
106
|
queryKeyName={queryKey.name}
|
|
105
107
|
typeSchemas={type.schemas}
|
|
108
|
+
paramsCasing={options.paramsCasing}
|
|
106
109
|
paramsType={options.paramsType}
|
|
107
110
|
pathParamsType={options.pathParamsType}
|
|
108
111
|
/>
|
|
@@ -117,6 +120,7 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
|
|
|
117
120
|
paramsType={options.paramsType}
|
|
118
121
|
pathParamsType={options.pathParamsType}
|
|
119
122
|
operation={operation}
|
|
123
|
+
paramsCasing={options.paramsCasing}
|
|
120
124
|
dataReturnType={options.client.dataReturnType}
|
|
121
125
|
queryKeyName={queryKey.name}
|
|
122
126
|
queryKeyTypeName={queryKey.typeName}
|
package/src/plugin.ts
CHANGED
|
@@ -29,6 +29,7 @@ export const pluginSolidQuery = createPlugin<PluginSolidQuery>((options) => {
|
|
|
29
29
|
queryKey = QueryKey.getTransformer,
|
|
30
30
|
generators = [queryGenerator].filter(Boolean),
|
|
31
31
|
query = {},
|
|
32
|
+
paramsCasing,
|
|
32
33
|
} = options
|
|
33
34
|
|
|
34
35
|
return {
|
|
@@ -36,7 +37,7 @@ export const pluginSolidQuery = createPlugin<PluginSolidQuery>((options) => {
|
|
|
36
37
|
options: {
|
|
37
38
|
output,
|
|
38
39
|
client: {
|
|
39
|
-
importPath: '@kubb/plugin-client/
|
|
40
|
+
importPath: '@kubb/plugin-client/clients/axios',
|
|
40
41
|
dataReturnType: 'data',
|
|
41
42
|
pathParamsType: 'inline',
|
|
42
43
|
...options.client,
|
|
@@ -54,6 +55,7 @@ export const pluginSolidQuery = createPlugin<PluginSolidQuery>((options) => {
|
|
|
54
55
|
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,
|
|
55
56
|
parser,
|
|
56
57
|
group,
|
|
58
|
+
paramsCasing,
|
|
57
59
|
},
|
|
58
60
|
pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),
|
|
59
61
|
resolvePath(baseName, pathMode, options) {
|
package/src/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { PluginReactQuery } from '@kubb/plugin-react-query'
|
|
|
8
8
|
type TransformerProps = {
|
|
9
9
|
operation: Operation
|
|
10
10
|
schemas: OperationSchemas
|
|
11
|
+
casing: 'camelcase' | undefined
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export type Transformer = (props: TransformerProps) => unknown[]
|
|
@@ -57,6 +58,11 @@ export type Options = {
|
|
|
57
58
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
58
59
|
*/
|
|
59
60
|
override?: Array<Override<ResolvedOptions>>
|
|
61
|
+
/**
|
|
62
|
+
* How to style your params, by default no casing is applied
|
|
63
|
+
* - 'camelcase' will use camelcase for the params names
|
|
64
|
+
*/
|
|
65
|
+
paramsCasing?: 'camelcase'
|
|
60
66
|
/**
|
|
61
67
|
* How to pass your params
|
|
62
68
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -98,6 +104,7 @@ type ResolvedOptions = {
|
|
|
98
104
|
group: Options['group']
|
|
99
105
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & { baseURL?: string }
|
|
100
106
|
parser: Required<NonNullable<Options['parser']>>
|
|
107
|
+
paramsCasing: Options['paramsCasing']
|
|
101
108
|
paramsType: NonNullable<Options['paramsType']>
|
|
102
109
|
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
103
110
|
queryKey: QueryKey | undefined
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generators/query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AAA,CAAK,QAAL,EAAY,IAAA,EAAM,CAAC,aAAa,CAAA,EAAG,MAAM,UAAY,EAAA,CAAA;AAAA,wBACrD,GAAA,CAAA,IAAA,CAAK,MAAL,EAAA,EAAY,IAAM,EAAA,CAAC,UAAY,EAAA,wBAAA,EAA0B,mBAAmB,CAAA,EAAG,IAAM,EAAA,UAAA,EAAY,YAAU,IAAC,EAAA,CAAA;AAAA,wBAC7G,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,MAAM,KAAM,CAAA,IAAA;AAAA,YACZ,kBAAkB,YAAa,CAAA,IAAA;AAAA,YAC/B,aAAa,IAAK,CAAA,OAAA;AAAA,YAClB,YAAY,OAAQ,CAAA,UAAA;AAAA,YACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,YACxB,SAAA;AAAA,YACA,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,YAC/B,cAAc,QAAS,CAAA,IAAA;AAAA,YACvB,kBAAkB,QAAS,CAAA;AAAA;AAAA;AAC7B,OACF,EAAA;AAAA,KAEJ,EAAA,CAAA;AAAA;AAGN,CAAC","file":"chunk-46JQ7CUT.js","sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSolidQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSolidQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSolidQuery>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(['post', 'put', 'delete', 'patch'], options.query ? options.query.methods : []).some((method) => operation.method === method)\n const importPath = options.query ? options.query.importPath : '@tanstack/solid-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const client = {\n name: getName(operation, { type: 'function' }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"]}
|