@toktokhan-dev/cli-plugin-gen-api-react-query 0.0.8 → 0.0.10
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/index.d.ts +1 -1
- package/dist/index.doc.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/custom-axios/api.eta +3 -3
- package/templates/custom-axios/procedure-call.eta +2 -2
- package/templates/custom-fetch/api.eta +3 -3
- package/templates/custom-fetch/procedure-call.eta +2 -2
- package/templates/my/react-query-hook.eta +7 -7
- package/templates/my/react-query-key.eta +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.doc.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ const genApi = defineCommand({
|
|
|
158
158
|
includeReactInfiniteQuery: true,
|
|
159
159
|
httpClientType: 'axios',
|
|
160
160
|
instancePath: GENERATE_SWAGGER_DATA.AXIOS_DEFAULT_INSTANCE_PATH,
|
|
161
|
-
|
|
161
|
+
paginationSets: [
|
|
162
162
|
{
|
|
163
163
|
keywords: ['cursor'],
|
|
164
164
|
nextKey: 'cursor',
|
package/package.json
CHANGED
|
@@ -84,11 +84,11 @@ const getConfigByRoute = (route) => {
|
|
|
84
84
|
const isMutation = hookVariant === "Mutation";
|
|
85
85
|
const hasPagination = !!pagination;
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const isOptionalVariables = _
|
|
88
88
|
// Find optional value
|
|
89
89
|
.filter(rawWrapperArgs, o => o.optional).length === rawWrapperArgs.length;
|
|
90
90
|
|
|
91
|
-
const conditionalVriablesText =
|
|
91
|
+
const conditionalVriablesText = isOptionalVariables? "variables?" : "variables";
|
|
92
92
|
const repalceTarget = "${" + conditionalVriablesText + ".";
|
|
93
93
|
|
|
94
94
|
|
|
@@ -97,7 +97,7 @@ const getConfigByRoute = (route) => {
|
|
|
97
97
|
hasPagination,
|
|
98
98
|
isQuery,
|
|
99
99
|
isMutation,
|
|
100
|
-
|
|
100
|
+
isOptionalVariables,
|
|
101
101
|
},
|
|
102
102
|
data: {
|
|
103
103
|
rawWrapperArgs,
|
|
@@ -48,11 +48,11 @@ const wrapperArgs = _
|
|
|
48
48
|
.map(argToTmpl)
|
|
49
49
|
.join('; ');
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const isOptionalVariables = _
|
|
52
52
|
// Find optional value
|
|
53
53
|
.filter(rawWrapperArgs, o => o.optional).length === rawWrapperArgs.length;
|
|
54
54
|
|
|
55
|
-
const conditionalVriablesText =
|
|
55
|
+
const conditionalVriablesText = isOptionalVariables? "variables?" : "variables";
|
|
56
56
|
const repalceTarget = "${" + conditionalVriablesText + ".";
|
|
57
57
|
const pathWithVariables = path.replace(/\$\{/g, repalceTarget);
|
|
58
58
|
|
|
@@ -80,11 +80,11 @@ const getConfigByRoute = (route) => {
|
|
|
80
80
|
const isMutation = hookVariant === "Mutation";
|
|
81
81
|
const hasPagination = !!pagination;
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const isOptionalVariables = _
|
|
84
84
|
// Find optional value
|
|
85
85
|
.filter(rawWrapperArgs, o => o.optional).length === rawWrapperArgs.length;
|
|
86
86
|
|
|
87
|
-
const conditionalVriablesText =
|
|
87
|
+
const conditionalVriablesText = isOptionalVariables ? "variables?" : "variables";
|
|
88
88
|
const repalceTarget = "${" + conditionalVriablesText + ".";
|
|
89
89
|
|
|
90
90
|
return {
|
|
@@ -92,7 +92,7 @@ const getConfigByRoute = (route) => {
|
|
|
92
92
|
hasPagination,
|
|
93
93
|
isQuery,
|
|
94
94
|
isMutation,
|
|
95
|
-
|
|
95
|
+
isOptionalVariables,
|
|
96
96
|
},
|
|
97
97
|
data: {
|
|
98
98
|
rawWrapperArgs,
|
|
@@ -47,11 +47,11 @@ const wrapperArgs = _
|
|
|
47
47
|
.map(argToTmpl)
|
|
48
48
|
.join('; ');
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const isOptionalVariables = _
|
|
51
51
|
// Find optional value
|
|
52
52
|
.filter(rawWrapperArgs, o => o.optional).length === rawWrapperArgs.length;
|
|
53
53
|
|
|
54
|
-
const conditionalVriablesText =
|
|
54
|
+
const conditionalVriablesText = isOptionalVariables? "variables?" : "variables";
|
|
55
55
|
const repalceTarget = "${" + conditionalVriablesText + ".";
|
|
56
56
|
const pathWithVariables = path.replace(/\$\{/g, repalceTarget);
|
|
57
57
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
hasPagination,
|
|
11
11
|
isQuery,
|
|
12
12
|
isMutation,
|
|
13
|
-
|
|
13
|
+
isOptionalVariables,
|
|
14
14
|
},
|
|
15
15
|
data: {
|
|
16
16
|
rawWrapperArgs,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
const { _, classNameCase } = utils;
|
|
35
35
|
|
|
36
|
-
const conditionalParamsText =
|
|
36
|
+
const conditionalParamsText = isOptionalVariables ? "params?" : "params"
|
|
37
37
|
const conditionCallWithVariabels = isQuery ? `(${conditionalParamsText}.variables)` : "";
|
|
38
38
|
const conditionParamQueryKey = isQuery ? `,${conditionalParamsText}.variables` : "";
|
|
39
39
|
const conditionWrapFunc = isQuery ? "() =>" : "";
|
|
@@ -75,10 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
<% if (isQuery) { %>
|
|
77
77
|
export const use<%~ classNameCase(functionName) %>Query = <
|
|
78
|
-
|
|
79
|
-
RequestFnReturn<typeof <%= apiInstanceName %>.<%~ functionName %>>,
|
|
80
|
-
Parameter<typeof <%= apiInstanceName %>.<%~ functionName %>>
|
|
81
|
-
>,
|
|
78
|
+
TData = RequestFnReturn<typeof <%= apiInstanceName %>.<%~ functionName %>>,
|
|
82
79
|
>(
|
|
83
80
|
<%~ conditionalParamsText %>: QueryHookParams<typeof <%= apiInstanceName %>.<%~ functionName %>,
|
|
84
81
|
<% if (isAxiosInstance) { %>
|
|
@@ -126,7 +123,10 @@
|
|
|
126
123
|
|
|
127
124
|
*/
|
|
128
125
|
export const use<%~ classNameCase(functionName) %>InfiniteQuery = <
|
|
129
|
-
|
|
126
|
+
TData = InfiniteData<
|
|
127
|
+
RequestFnReturn<typeof <%= apiInstanceName %>.<%~ functionName %>>,
|
|
128
|
+
Parameter<typeof <%= apiInstanceName %>.<%~ functionName %>>
|
|
129
|
+
>,
|
|
130
130
|
>(
|
|
131
131
|
<%~ conditionalParamsText %>: InfiniteQueryHookParams<typeof <%= apiInstanceName %>.<%~ functionName %>,
|
|
132
132
|
<% if (isAxiosInstance) { %>
|