@kubb/plugin-react-query 3.0.14 → 3.2.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-YGWYQQ6H.js → chunk-5NA5VRXZ.js} +78 -47
- package/dist/chunk-5NA5VRXZ.js.map +1 -0
- package/dist/{chunk-GMONUHPD.js → chunk-A24GQ5ZN.js} +18 -3
- package/dist/chunk-A24GQ5ZN.js.map +1 -0
- package/dist/{chunk-WOYQTGDC.cjs → chunk-EZXV6KB3.cjs} +78 -47
- package/dist/chunk-EZXV6KB3.cjs.map +1 -0
- package/dist/{chunk-PBJIUPCN.cjs → chunk-VWLT4KLD.cjs} +33 -18
- package/dist/chunk-VWLT4KLD.cjs.map +1 -0
- package/dist/components.cjs +9 -9
- package/dist/components.d.cts +29 -15
- package/dist/components.d.ts +29 -15
- package/dist/components.js +1 -1
- package/dist/generators.cjs +6 -6
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +18 -10
- 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 +16 -8
- package/dist/index.js.map +1 -1
- package/dist/{types-IuxCCG1K.d.cts → types-ClmUaz7P.d.cts} +14 -0
- package/dist/{types-IuxCCG1K.d.ts → types-ClmUaz7P.d.ts} +14 -0
- package/package.json +11 -11
- package/src/components/InfiniteQuery.tsx +9 -3
- package/src/components/InfiniteQueryOptions.tsx +9 -4
- package/src/components/Mutation.tsx +18 -4
- 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 +9 -5
- package/src/components/SuspenseQuery.tsx +9 -3
- package/src/generators/__snapshots__/clientPostImportPath.ts +4 -4
- package/src/generators/__snapshots__/getPetIdCamelCase.ts +52 -0
- package/src/generators/__snapshots__/postAsQuery.ts +4 -4
- package/src/generators/__snapshots__/updatePetById.ts +4 -4
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +4 -4
- package/src/generators/infiniteQueryGenerator.tsx +4 -0
- package/src/generators/mutationGenerator.tsx +3 -0
- package/src/generators/queryGenerator.tsx +4 -0
- package/src/generators/suspenseQueryGenerator.tsx +4 -0
- package/src/plugin.ts +16 -6
- package/src/types.ts +8 -0
- package/dist/chunk-GMONUHPD.js.map +0 -1
- package/dist/chunk-PBJIUPCN.cjs.map +0 -1
- package/dist/chunk-WOYQTGDC.cjs.map +0 -1
- package/dist/chunk-YGWYQQ6H.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAgBO,IAAM,oBAAuB,GAAA;AAEvB,IAAA,gBAAA,GAAmB,YAA+B,CAAA,CAAC,OAAY,KAAA;AAC1E,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,WAAW,EAAC;AAAA,IACZ,QAAW,GAAA,KAAA;AAAA,IACX,eAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,UAAA,GAAa,CAAC,cAAgB,EAAA,sBAAA,EAAwB,wBAAwB,iBAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/G,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QAAS,CAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAgBO,IAAM,oBAAuB,G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,EAAA,MAAA,CAAO,IAAI,CAAC,CAAA;AAChE,MAAA,MAAM,OAAU,GAAA,MAAM,aAAc,CAAA,OAAA,CAAQ,UAAW,EAAA;AAEvD,MAAA,IAAI,OAAS,EAAA;AACX,QAAK,IAAA,CAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,CAAO,OAAU,GAAA,OAAA;AAAA;AAGvC,MAAA,MAAM,kBAAqB,GAAA,IAAI,kBAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,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 } from '@kubb/plugin-oas'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n paramsCasing,\n } = options\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n parser,\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 if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\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"]}
|
|
@@ -47,6 +47,11 @@ type Options$1 = {
|
|
|
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.
|
|
@@ -87,12 +92,14 @@ type ResolvedOptions$1 = {
|
|
|
87
92
|
dataReturnType: NonNullable<Options$1['dataReturnType']>;
|
|
88
93
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
89
94
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
95
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
90
96
|
};
|
|
91
97
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
92
98
|
|
|
93
99
|
type TransformerProps = {
|
|
94
100
|
operation: Operation;
|
|
95
101
|
schemas: OperationSchemas;
|
|
102
|
+
casing: 'camelcase' | undefined;
|
|
96
103
|
};
|
|
97
104
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
98
105
|
type Suspense = object;
|
|
@@ -173,6 +180,11 @@ type Options = {
|
|
|
173
180
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
181
|
*/
|
|
175
182
|
override?: Array<Override<ResolvedOptions>>;
|
|
183
|
+
/**
|
|
184
|
+
* How to style your params, by default no casing is applied
|
|
185
|
+
* - 'camelcase' will use camelcase for the params names
|
|
186
|
+
*/
|
|
187
|
+
paramsCasing?: 'camelcase';
|
|
176
188
|
/**
|
|
177
189
|
* How to pass your params
|
|
178
190
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -223,11 +235,13 @@ type Options = {
|
|
|
223
235
|
};
|
|
224
236
|
type ResolvedOptions = {
|
|
225
237
|
output: Output;
|
|
238
|
+
group: Options['group'];
|
|
226
239
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
227
240
|
baseURL?: string;
|
|
228
241
|
};
|
|
229
242
|
parser: Required<NonNullable<Options['parser']>>;
|
|
230
243
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
244
|
+
paramsCasing: Options['paramsCasing'];
|
|
231
245
|
paramsType: NonNullable<Options['paramsType']>;
|
|
232
246
|
/**
|
|
233
247
|
* Only used of infinite
|
|
@@ -47,6 +47,11 @@ type Options$1 = {
|
|
|
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.
|
|
@@ -87,12 +92,14 @@ type ResolvedOptions$1 = {
|
|
|
87
92
|
dataReturnType: NonNullable<Options$1['dataReturnType']>;
|
|
88
93
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
89
94
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
95
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
90
96
|
};
|
|
91
97
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
92
98
|
|
|
93
99
|
type TransformerProps = {
|
|
94
100
|
operation: Operation;
|
|
95
101
|
schemas: OperationSchemas;
|
|
102
|
+
casing: 'camelcase' | undefined;
|
|
96
103
|
};
|
|
97
104
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
98
105
|
type Suspense = object;
|
|
@@ -173,6 +180,11 @@ type Options = {
|
|
|
173
180
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
181
|
*/
|
|
175
182
|
override?: Array<Override<ResolvedOptions>>;
|
|
183
|
+
/**
|
|
184
|
+
* How to style your params, by default no casing is applied
|
|
185
|
+
* - 'camelcase' will use camelcase for the params names
|
|
186
|
+
*/
|
|
187
|
+
paramsCasing?: 'camelcase';
|
|
176
188
|
/**
|
|
177
189
|
* How to pass your params
|
|
178
190
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -223,11 +235,13 @@ type Options = {
|
|
|
223
235
|
};
|
|
224
236
|
type ResolvedOptions = {
|
|
225
237
|
output: Output;
|
|
238
|
+
group: Options['group'];
|
|
226
239
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
227
240
|
baseURL?: string;
|
|
228
241
|
};
|
|
229
242
|
parser: Required<NonNullable<Options['parser']>>;
|
|
230
243
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
244
|
+
paramsCasing: Options['paramsCasing'];
|
|
231
245
|
paramsType: NonNullable<Options['paramsType']>;
|
|
232
246
|
/**
|
|
233
247
|
* Only used of infinite
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-react-query",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Generator react-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.0
|
|
67
|
-
"@kubb/
|
|
68
|
-
"@kubb/
|
|
69
|
-
"@kubb/plugin-oas": "3.0
|
|
70
|
-
"@kubb/plugin-ts": "3.0
|
|
71
|
-
"@kubb/
|
|
72
|
-
"@kubb/
|
|
66
|
+
"@kubb/core": "3.2.0",
|
|
67
|
+
"@kubb/oas": "3.2.0",
|
|
68
|
+
"@kubb/fs": "3.2.0",
|
|
69
|
+
"@kubb/plugin-oas": "3.2.0",
|
|
70
|
+
"@kubb/plugin-ts": "3.2.0",
|
|
71
|
+
"@kubb/react": "3.2.0",
|
|
72
|
+
"@kubb/plugin-zod": "3.2.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-
|
|
80
|
-
"@kubb/config-
|
|
79
|
+
"@kubb/config-tsup": "3.2.0",
|
|
80
|
+
"@kubb/config-ts": "3.2.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@kubb/react": "^3.0.0"
|
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
queryKeyTypeName: string
|
|
19
19
|
typeSchemas: OperationSchemas
|
|
20
20
|
operation: Operation
|
|
21
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -25,12 +26,13 @@ type Props = {
|
|
|
25
26
|
|
|
26
27
|
type GetParamsProps = {
|
|
27
28
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
29
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
28
30
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginReactQuery['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,
|
|
@@ -115,6 +117,7 @@ export function InfiniteQuery({
|
|
|
115
117
|
queryOptionsName,
|
|
116
118
|
queryKeyName,
|
|
117
119
|
paramsType,
|
|
120
|
+
paramsCasing,
|
|
118
121
|
pathParamsType,
|
|
119
122
|
dataReturnType,
|
|
120
123
|
typeSchemas,
|
|
@@ -127,13 +130,16 @@ export function InfiniteQuery({
|
|
|
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,
|
|
133
137
|
pathParamsType,
|
|
134
138
|
typeSchemas,
|
|
139
|
+
paramsCasing,
|
|
135
140
|
})
|
|
136
141
|
const params = getParams({
|
|
142
|
+
paramsCasing,
|
|
137
143
|
paramsType,
|
|
138
144
|
pathParamsType,
|
|
139
145
|
dataReturnType,
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
clientName: string
|
|
15
15
|
queryKeyName: string
|
|
16
16
|
typeSchemas: OperationSchemas
|
|
17
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
17
18
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
18
19
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
19
20
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -23,18 +24,19 @@ type Props = {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
type GetParamsProps = {
|
|
27
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
26
28
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
27
29
|
pathParamsType: PluginReactQuery['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: {
|
|
35
37
|
mode: 'object',
|
|
36
38
|
children: {
|
|
37
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
39
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
38
40
|
data: typeSchemas.request?.name
|
|
39
41
|
? {
|
|
40
42
|
type: typeSchemas.request?.name,
|
|
@@ -66,7 +68,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
66
68
|
pathParams: typeSchemas.pathParams?.name
|
|
67
69
|
? {
|
|
68
70
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
69
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
71
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
70
72
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
71
73
|
}
|
|
72
74
|
: undefined,
|
|
@@ -101,14 +103,16 @@ export function InfiniteQueryOptions({
|
|
|
101
103
|
initialPageParam,
|
|
102
104
|
cursorParam,
|
|
103
105
|
typeSchemas,
|
|
106
|
+
paramsCasing,
|
|
104
107
|
paramsType,
|
|
105
108
|
dataReturnType,
|
|
106
109
|
pathParamsType,
|
|
107
110
|
queryParam,
|
|
108
111
|
queryKeyName,
|
|
109
112
|
}: Props): ReactNode {
|
|
110
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
113
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
111
114
|
const clientParams = Client.getParams({
|
|
115
|
+
paramsCasing,
|
|
112
116
|
typeSchemas,
|
|
113
117
|
paramsType,
|
|
114
118
|
pathParamsType,
|
|
@@ -116,6 +120,7 @@ export function InfiniteQueryOptions({
|
|
|
116
120
|
const queryKeyParams = QueryKey.getParams({
|
|
117
121
|
pathParamsType,
|
|
118
122
|
typeSchemas,
|
|
123
|
+
paramsCasing,
|
|
119
124
|
})
|
|
120
125
|
|
|
121
126
|
const queryOptions = [
|
|
@@ -20,20 +20,22 @@ type Props = {
|
|
|
20
20
|
typeSchemas: OperationSchemas
|
|
21
21
|
operation: Operation
|
|
22
22
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
23
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
23
24
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
24
25
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
type GetParamsProps = {
|
|
29
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
28
30
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginReactQuery['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
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
38
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
37
39
|
data: typeSchemas.request?.name
|
|
38
40
|
? {
|
|
39
41
|
type: typeSchemas.request?.name,
|
|
@@ -71,26 +73,38 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
71
73
|
})
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
export function Mutation({
|
|
76
|
+
export function Mutation({
|
|
77
|
+
name,
|
|
78
|
+
clientName,
|
|
79
|
+
paramsCasing,
|
|
80
|
+
paramsType,
|
|
81
|
+
pathParamsType,
|
|
82
|
+
dataReturnType,
|
|
83
|
+
typeSchemas,
|
|
84
|
+
operation,
|
|
85
|
+
mutationKeyName,
|
|
86
|
+
}: Props): ReactNode {
|
|
75
87
|
const mutationKeyParams = MutationKey.getParams({
|
|
76
88
|
pathParamsType,
|
|
77
89
|
typeSchemas,
|
|
78
90
|
})
|
|
79
91
|
|
|
80
92
|
const params = getParams({
|
|
93
|
+
paramsCasing,
|
|
81
94
|
pathParamsType,
|
|
82
95
|
dataReturnType,
|
|
83
96
|
typeSchemas,
|
|
84
97
|
})
|
|
85
98
|
|
|
86
99
|
const clientParams = Client.getParams({
|
|
100
|
+
paramsCasing,
|
|
87
101
|
paramsType,
|
|
88
102
|
typeSchemas,
|
|
89
103
|
pathParamsType,
|
|
90
104
|
})
|
|
91
105
|
|
|
92
106
|
const mutationParams = FunctionParams.factory({
|
|
93
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
107
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
94
108
|
data: typeSchemas.request?.name
|
|
95
109
|
? {
|
|
96
110
|
type: typeSchemas.request?.name,
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
typeName: string
|
|
12
12
|
typeSchemas: OperationSchemas
|
|
13
13
|
operation: Operation
|
|
14
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
14
15
|
pathParamsType: PluginReactQuery['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, pathParamsType, paramsCasing, 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,19 +18,21 @@ type Props = {
|
|
|
18
18
|
queryKeyTypeName: string
|
|
19
19
|
typeSchemas: OperationSchemas
|
|
20
20
|
operation: Operation
|
|
21
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
type GetParamsProps = {
|
|
28
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
27
29
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
28
30
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginReactQuery['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,
|
|
@@ -115,6 +117,7 @@ export function Query({
|
|
|
115
117
|
queryOptionsName,
|
|
116
118
|
queryKeyName,
|
|
117
119
|
paramsType,
|
|
120
|
+
paramsCasing,
|
|
118
121
|
pathParamsType,
|
|
119
122
|
dataReturnType,
|
|
120
123
|
typeSchemas,
|
|
@@ -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,
|
|
133
137
|
pathParamsType,
|
|
134
138
|
typeSchemas,
|
|
139
|
+
paramsCasing,
|
|
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: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
15
16
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
16
17
|
transformer: Transformer | undefined
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
20
22
|
pathParamsType: PluginReactQuery['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, typeSchemas, paramsCasing })
|
|
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: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
17
18
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
18
19
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
type GetParamsProps = {
|
|
23
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
22
24
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
23
25
|
pathParamsType: PluginReactQuery['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,16 +93,18 @@ 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({
|
|
97
99
|
typeSchemas,
|
|
100
|
+
paramsCasing,
|
|
98
101
|
paramsType,
|
|
99
102
|
pathParamsType,
|
|
100
103
|
})
|
|
101
104
|
const queryKeyParams = QueryKey.getParams({
|
|
102
105
|
pathParamsType,
|
|
103
106
|
typeSchemas,
|
|
107
|
+
paramsCasing,
|
|
104
108
|
})
|
|
105
109
|
|
|
106
110
|
const enabled = Object.entries(queryKeyParams.flatParams)
|
|
@@ -18,19 +18,21 @@ type Props = {
|
|
|
18
18
|
queryKeyTypeName: string
|
|
19
19
|
typeSchemas: OperationSchemas
|
|
20
20
|
operation: Operation
|
|
21
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
21
22
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
22
23
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
23
24
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
type GetParamsProps = {
|
|
28
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
27
29
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
28
30
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
29
31
|
dataReturnType: PluginReactQuery['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,
|
|
@@ -115,6 +117,7 @@ export function SuspenseQuery({
|
|
|
115
117
|
queryOptionsName,
|
|
116
118
|
queryKeyName,
|
|
117
119
|
paramsType,
|
|
120
|
+
paramsCasing,
|
|
118
121
|
pathParamsType,
|
|
119
122
|
dataReturnType,
|
|
120
123
|
typeSchemas,
|
|
@@ -127,13 +130,16 @@ export function SuspenseQuery({
|
|
|
127
130
|
const queryKeyParams = QueryKey.getParams({
|
|
128
131
|
pathParamsType,
|
|
129
132
|
typeSchemas,
|
|
133
|
+
paramsCasing,
|
|
130
134
|
})
|
|
131
135
|
const queryOptionsParams = QueryOptions.getParams({
|
|
136
|
+
paramsCasing,
|
|
132
137
|
paramsType,
|
|
133
138
|
pathParamsType,
|
|
134
139
|
typeSchemas,
|
|
135
140
|
})
|
|
136
141
|
const params = getParams({
|
|
142
|
+
paramsCasing,
|
|
137
143
|
paramsType,
|
|
138
144
|
pathParamsType,
|
|
139
145
|
dataReturnType,
|