react-query-lightbase-codegen 1.1.1 → 1.1.4
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/convertSwaggerFile.d.ts +5 -0
- package/{lib/esm → dist}/convertSwaggerFile.js +1 -0
- package/dist/convertSwaggerFile.js.map +1 -0
- package/dist/generateHooks.d.ts +25 -0
- package/dist/generateHooks.js +395 -0
- package/dist/generateHooks.js.map +1 -0
- package/dist/generateImports.d.ts +7 -0
- package/dist/generateImports.js +28 -0
- package/dist/generateImports.js.map +1 -0
- package/dist/generateSchemas.d.ts +7 -0
- package/{lib/esm → dist}/generateSchemas.js +7 -7
- package/dist/generateSchemas.js.map +1 -0
- package/dist/importSpecs.d.ts +15 -0
- package/dist/importSpecs.js +90 -0
- package/dist/importSpecs.js.map +1 -0
- package/{lib/esm/index.js → dist/index.d.ts} +0 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +24 -0
- package/{lib/esm → dist}/utils.js +22 -18
- package/dist/utils.js.map +1 -0
- package/package.json +3 -3
- package/src/generateHooks.ts +5 -2
- package/lib/cjs/convertSwaggerFile.js +0 -32
- package/lib/cjs/generateHooks.js +0 -368
- package/lib/cjs/generateImports.js +0 -26
- package/lib/cjs/generateSchemas.js +0 -104
- package/lib/cjs/importSpecs.js +0 -46
- package/lib/cjs/index.js +0 -7
- package/lib/cjs/utils.js +0 -165
- package/lib/esm/generateHooks.js +0 -360
- package/lib/esm/generateImports.js +0 -22
- package/lib/esm/importSpecs.js +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertSwaggerFile.js","sourceRoot":"","sources":["../src/convertSwaggerFile.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,SAA0B,EAA0B,EAAE;IACrG,MAAM,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACvD,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE;gBAC3D,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,aAAa;oBACb,YAAY,CAAC,OAAO,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBAC/D,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;iBAC/B;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentsObject, OperationObject, ParameterObject, ReferenceObject } from 'openapi3-ts';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a react-query component from openapi operation specs
|
|
4
|
+
*/
|
|
5
|
+
export declare const createHook: ({ operation, verb, route, operationIds, parameters, schemasComponents, headerFilters, overrides, }: {
|
|
6
|
+
operation: OperationObject;
|
|
7
|
+
verb: string;
|
|
8
|
+
route: string;
|
|
9
|
+
operationIds: string[];
|
|
10
|
+
parameters: (ReferenceObject | ParameterObject)[] | undefined;
|
|
11
|
+
schemasComponents?: ComponentsObject | undefined;
|
|
12
|
+
headerFilters?: string[] | undefined;
|
|
13
|
+
overrides?: Record<string, {
|
|
14
|
+
type: 'query';
|
|
15
|
+
} | {
|
|
16
|
+
type: 'mutation';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'infiniteQuery';
|
|
19
|
+
infiniteQueryParm: string;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
}) => {
|
|
22
|
+
implementation: string;
|
|
23
|
+
imports: string[];
|
|
24
|
+
queryImports: ("query" | "mutation" | "infiniteQuery")[];
|
|
25
|
+
};
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import lodash from 'lodash';
|
|
2
|
+
const { get, groupBy } = lodash;
|
|
3
|
+
import { formatDescription, getResReqTypes, isReference, resolveValue } from './utils.js';
|
|
4
|
+
import pasCase from 'case';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const { pascal, camel } = pasCase;
|
|
7
|
+
const IdentifierRegexp = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
8
|
+
/**
|
|
9
|
+
* Return every params in a path
|
|
10
|
+
*/
|
|
11
|
+
const getParamsInPath = (path) => {
|
|
12
|
+
let n;
|
|
13
|
+
const output = [];
|
|
14
|
+
const templatePathRegex = /\{(\w+)}/g;
|
|
15
|
+
while ((n = templatePathRegex.exec(path)) !== null) {
|
|
16
|
+
output.push(n[1]);
|
|
17
|
+
}
|
|
18
|
+
return output;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Generate a react-query component from openapi operation specs
|
|
22
|
+
*/
|
|
23
|
+
export const createHook = ({ operation, verb, route, operationIds, parameters, schemasComponents, headerFilters, overrides, }) => {
|
|
24
|
+
const { operationId = route.replace('/', '') } = operation;
|
|
25
|
+
if (operationId === '*') {
|
|
26
|
+
throw new Error(`Invalid operationId/Route set for ${verb} ${route}`);
|
|
27
|
+
}
|
|
28
|
+
if (operationIds.includes(operationId)) {
|
|
29
|
+
return { implementation: '', imports: [], queryImports: [] };
|
|
30
|
+
}
|
|
31
|
+
operationIds.push(operationId);
|
|
32
|
+
route = route.replace(/\{/g, '${').replace('//', '/'); // `/pet/{id}` => `/pet/${id}`
|
|
33
|
+
// Remove the last param of the route if we are in the DELETE case
|
|
34
|
+
let lastParamInTheRoute = null;
|
|
35
|
+
const componentName = pascal(operationId);
|
|
36
|
+
const isOk = ([statusCode]) => statusCode.toString().startsWith('2');
|
|
37
|
+
const responseTypes = getResReqTypes(Object.entries(operation.responses).filter(isOk)) || 'void';
|
|
38
|
+
const requestBodyTypes = getResReqTypes([['body', operation.requestBody]]);
|
|
39
|
+
let imports = [responseTypes];
|
|
40
|
+
let queryImports = [];
|
|
41
|
+
const paramsInPath = getParamsInPath(route).filter((param) => !(verb === 'delete' && param === lastParamInTheRoute));
|
|
42
|
+
const { query: queryParams = [], path: pathParams = [], header = [], } = groupBy([...(parameters || []), ...(operation.parameters || [])].map((p) => {
|
|
43
|
+
if (isReference(p)) {
|
|
44
|
+
return get(schemasComponents, p.$ref.replace('#/components/', '').replace('/', '.'));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return p;
|
|
48
|
+
}
|
|
49
|
+
}), 'in');
|
|
50
|
+
const headerParams = header.filter((p) => !headerFilters?.includes(p.name));
|
|
51
|
+
let enabled = [];
|
|
52
|
+
// TODO: extract all requestBody or remove useQuery variants
|
|
53
|
+
let enabledParam = '!!params';
|
|
54
|
+
[...queryParams, ...pathParams, ...headerParams].forEach((item) => {
|
|
55
|
+
if (item.required) {
|
|
56
|
+
enabled.push(`["${item.name}"]`);
|
|
57
|
+
if (enabledParam && enabledParam !== '!!params') {
|
|
58
|
+
enabledParam += `&& params['${item.name}'] != null`;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
enabledParam = `params['${item.name}'] != null`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// `!props${enabled.join('== null && !props')}`;
|
|
66
|
+
const paramsTypes = paramsInPath
|
|
67
|
+
.map((p) => {
|
|
68
|
+
try {
|
|
69
|
+
const { name, required, schema } = pathParams.find((i) => i.name === p);
|
|
70
|
+
return `${name}${required ? '' : '?'}: ${resolveValue(schema)}`;
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
throw new Error(`The path params ${p} can't be found in parameters (${operationId})`);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.join('; ');
|
|
77
|
+
const queryParamsType = queryParams
|
|
78
|
+
.map((p) => {
|
|
79
|
+
const processedName = IdentifierRegexp.test(p.name) ? p.name : `"${p.name}"`;
|
|
80
|
+
return `${formatDescription(p.description)}
|
|
81
|
+
${processedName}${p.required ? '' : '?'}: ${resolveValue(p.schema)}`;
|
|
82
|
+
})
|
|
83
|
+
.join(';\n ');
|
|
84
|
+
const headerType = headerParams
|
|
85
|
+
.map((p) => {
|
|
86
|
+
try {
|
|
87
|
+
const { name, required, schema } = headerParams.find((i) => i.name === p.name);
|
|
88
|
+
return `"${name}"${required ? '' : '?'}: ${resolveValue(schema)}`;
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw new Error(`The path params ${p} can't be found in parameters (${operationId})`);
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
.join('; ');
|
|
95
|
+
// Retrieve the type of the param for delete verb
|
|
96
|
+
const lastParamInTheRouteDefinition = operation.parameters && lastParamInTheRoute
|
|
97
|
+
? operation.parameters.find((p) => {
|
|
98
|
+
if (isReference(p)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return p.name === lastParamInTheRoute;
|
|
102
|
+
}) // Reference is not possible
|
|
103
|
+
: { schema: { type: 'string' } };
|
|
104
|
+
if (!lastParamInTheRouteDefinition) {
|
|
105
|
+
throw new Error(`The path params ${lastParamInTheRoute} can't be found in parameters (${operationId})`);
|
|
106
|
+
}
|
|
107
|
+
const defaultDescription = `type: ${verb}\noperationId: ${operationId}\nurl: ${route}`;
|
|
108
|
+
const description = formatDescription(operation.summary && operation.description
|
|
109
|
+
? `${defaultDescription}\n\n${operation.summary}\n\n${operation.description}`
|
|
110
|
+
: `${defaultDescription}`);
|
|
111
|
+
let output = `\n\n${description}`;
|
|
112
|
+
const headerParam = headerType && headerType !== 'void' ? `${headerType};` : '';
|
|
113
|
+
const queryParam = queryParamsType && queryParamsType !== 'void' ? `${queryParamsType}` : '';
|
|
114
|
+
const requestBodyComponent = requestBodyTypes && requestBodyTypes !== 'void' ? `${requestBodyTypes}` : '';
|
|
115
|
+
if (requestBodyComponent) {
|
|
116
|
+
imports.push(requestBodyComponent);
|
|
117
|
+
}
|
|
118
|
+
const isUpdateRequest = ['post', 'patch', 'put'].includes(verb);
|
|
119
|
+
const fetchName = camel(componentName);
|
|
120
|
+
const createQueryHooks = (emptyParams) => {
|
|
121
|
+
const params = emptyParams ? '' : `params: ${componentName}Params,`;
|
|
122
|
+
const key = emptyParams ? '' : `params`;
|
|
123
|
+
const mutationParams = emptyParams ? 'void' : `${componentName}Params`;
|
|
124
|
+
const queryParamType = emptyParams ? '' : `${componentName}Params &`;
|
|
125
|
+
const filterParams = emptyParams
|
|
126
|
+
? '{ filters }: { filters?: QueryFilters }'
|
|
127
|
+
: `{ params, filters }: { params: ${componentName}Params, filters?: QueryFilters }`;
|
|
128
|
+
const cacheParams = emptyParams
|
|
129
|
+
? `{updater, options}: {updater: Updater<${responseTypes} | undefined, ${responseTypes} | undefined>, options?: SetDataOptions | undefined}`
|
|
130
|
+
: `{params, updater, options}: {params: ${componentName}Params, updater: Updater<${responseTypes} | undefined, ${responseTypes} | undefined>, options?: SetDataOptions | undefined}`;
|
|
131
|
+
const queryKey = emptyParams
|
|
132
|
+
? `use${componentName}Query.baseKey()`
|
|
133
|
+
: `[...use${componentName}Query.baseKey(), params]`;
|
|
134
|
+
const props = emptyParams ? `props?` : `{ options = {}, ...params }`;
|
|
135
|
+
const options = emptyParams ? `...props?.options:` : `...options`;
|
|
136
|
+
const createQuery = () => `
|
|
137
|
+
type ${componentName}QueryProps<T = ${responseTypes}> = ${queryParamType} {
|
|
138
|
+
options?: UseQueryOptions<${responseTypes}, AxiosError, T, any>
|
|
139
|
+
}
|
|
140
|
+
export function use${componentName}Query<T = ${responseTypes}>(${props}: ${componentName}QueryProps<T>) {
|
|
141
|
+
return useQuery(use${componentName}Query.queryKey(${key}), async () => ${fetchName}(${key}), { enabled: ${enabledParam}, ${options} });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
use${componentName}Query.baseKey = (): QueryKey => ["${componentName.toLowerCase()}"];
|
|
145
|
+
|
|
146
|
+
use${componentName}Query.queryKey = (${params}): QueryKey => ${queryKey};
|
|
147
|
+
|
|
148
|
+
use${componentName}Query.updateCache = (${cacheParams}) => queryClient.setQueryData<${responseTypes}>(use${componentName}Query.queryKey(${key}), updater, options);
|
|
149
|
+
|
|
150
|
+
use${componentName}Query.getQueryState = (${filterParams})=> queryClient.getQueryState<${responseTypes}>(use${componentName}Query.queryKey(${key}), filters);
|
|
151
|
+
|
|
152
|
+
use${componentName}Query.getQueryData = (${filterParams})=> queryClient.getQueryData<${responseTypes}>(use${componentName}Query.queryKey(${key}), filters);
|
|
153
|
+
|
|
154
|
+
use${componentName}Query.prefetch = (${params}) => queryClient.prefetchQuery<${responseTypes}>(use${componentName}Query.queryKey(${key}), ()=> ${fetchName}(${key}));
|
|
155
|
+
|
|
156
|
+
use${componentName}Query.cancelQueries = (${params}) => queryClient.cancelQueries(use${componentName}Query.queryKey(${key}))
|
|
157
|
+
|
|
158
|
+
use${componentName}Query.invalidate = (${params}) => queryClient.invalidateQueries<${responseTypes}>(use${componentName}Query.queryKey(${key}));
|
|
159
|
+
|
|
160
|
+
use${componentName}Query.refetchStale = (${params}) => queryClient.refetchQueries<${responseTypes}>(use${componentName}Query.queryKey(${key}), { stale: true });
|
|
161
|
+
`;
|
|
162
|
+
const getInfiniteQuery = ({ pageParam }) => `
|
|
163
|
+
type ${componentName}QueryProps<T = ${responseTypes}> = ${queryParamType} {
|
|
164
|
+
options: UseInfiniteQueryOptions<${responseTypes}, AxiosError, T, any>
|
|
165
|
+
}
|
|
166
|
+
export function use${componentName}Query<T = ${responseTypes}>({ options = {}, ...params }: ${componentName}QueryProps<T>) {
|
|
167
|
+
return useInfiniteQuery(use${componentName}Query.queryKey(${key}), async ({ pageParam = 0 }) => ${fetchName}({${pageParam}: pageParam, ...params}), { enabled: ${enabledParam}, ...options });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
use${componentName}Query.baseKey = (): QueryKey => ["${componentName.toLowerCase()}"];
|
|
171
|
+
|
|
172
|
+
use${componentName}Query.queryKey = (${params}): QueryKey => ${queryKey};
|
|
173
|
+
|
|
174
|
+
`;
|
|
175
|
+
const createMutation = () => `
|
|
176
|
+
type ${componentName}MutationProps<T> = {
|
|
177
|
+
options?: UseMutationOptions<${responseTypes}, AxiosError, ${mutationParams}, T>
|
|
178
|
+
}
|
|
179
|
+
export function use${componentName}Mutation<T = ${responseTypes}>(props?: ${componentName}MutationProps<T>) {
|
|
180
|
+
return useMutation(async (${key}) => ${fetchName}(${key}), props?.options)
|
|
181
|
+
};
|
|
182
|
+
`;
|
|
183
|
+
const override = overrides?.[operationId];
|
|
184
|
+
if (override?.type === 'query') {
|
|
185
|
+
console.log(chalk.blue(`⚙️ [${operationId}] has been changed to a useQuery hook`));
|
|
186
|
+
queryImports.push('query');
|
|
187
|
+
return createQuery();
|
|
188
|
+
}
|
|
189
|
+
if (override?.type === 'mutation') {
|
|
190
|
+
queryImports.push('mutation');
|
|
191
|
+
console.log(chalk.blue(`⚙️ [${operationId}] has been changed to a useMutation hook`));
|
|
192
|
+
return createMutation();
|
|
193
|
+
}
|
|
194
|
+
if (override?.type === 'infiniteQuery') {
|
|
195
|
+
console.log(chalk.blue(`⚙️ [${operationId}] has been changed to a useInfiniteQuery hook`));
|
|
196
|
+
queryImports.push('infiniteQuery');
|
|
197
|
+
return getInfiniteQuery({ pageParam: override.infiniteQueryParm });
|
|
198
|
+
}
|
|
199
|
+
if (verb === 'get') {
|
|
200
|
+
queryImports.push('query');
|
|
201
|
+
return createQuery();
|
|
202
|
+
}
|
|
203
|
+
queryImports.push('mutation');
|
|
204
|
+
return createMutation();
|
|
205
|
+
};
|
|
206
|
+
output += createQueryHooks(!requestBodyComponent && !paramsInPath.length && !queryParam && !headerParam);
|
|
207
|
+
const hasRequestBodyArrray = requestBodyComponent && requestBodyComponent.includes('[]');
|
|
208
|
+
const body = hasRequestBodyArrray ? `{body: ${requestBodyComponent}}` : `${requestBodyComponent}`;
|
|
209
|
+
const bodyProps = hasRequestBodyArrray ? `{body, ...props}` : '{props}';
|
|
210
|
+
const generateProps = (props) => {
|
|
211
|
+
return props.map((item) => `["${item.name}"]: props["${item.name}"]`).join(',');
|
|
212
|
+
};
|
|
213
|
+
const generateBodyProps = () => {
|
|
214
|
+
const definitionKey = Object.keys(schemasComponents?.schemas || {}).find((key) => pascal(key) === requestBodyComponent);
|
|
215
|
+
if (definitionKey && !hasRequestBodyArrray) {
|
|
216
|
+
const scheme = schemasComponents?.schemas?.[definitionKey];
|
|
217
|
+
const generatedBodyProps = Object.keys(scheme.properties)
|
|
218
|
+
.map((item) => `["${item}"]: props["${item}"]`)
|
|
219
|
+
.join(',');
|
|
220
|
+
return `const body = {${generatedBodyProps}}`;
|
|
221
|
+
}
|
|
222
|
+
return '';
|
|
223
|
+
};
|
|
224
|
+
if (!requestBodyComponent && !paramsInPath.length && !queryParam && !headerParam) {
|
|
225
|
+
output += `
|
|
226
|
+
const ${fetchName} = async () => {
|
|
227
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`);
|
|
228
|
+
return result.data;
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
231
|
+
}
|
|
232
|
+
if (!requestBodyComponent && paramsInPath.length && queryParam && !headerParam) {
|
|
233
|
+
const config = isUpdateRequest ? 'body,{params}' : '{params}';
|
|
234
|
+
output += `
|
|
235
|
+
type ${componentName}Params = {
|
|
236
|
+
${paramsTypes}
|
|
237
|
+
${queryParamsType};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const ${fetchName} = async (props:${componentName}Params) => {
|
|
241
|
+
const {${paramsInPath.join(', ')}, ...params} = props
|
|
242
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, ${config})
|
|
243
|
+
return result.data;
|
|
244
|
+
}`;
|
|
245
|
+
}
|
|
246
|
+
if (!requestBodyComponent && paramsInPath.length && !queryParam && !headerParam) {
|
|
247
|
+
output += `
|
|
248
|
+
type ${componentName}Params = {
|
|
249
|
+
${paramsTypes}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const ${fetchName} = async (props: ${componentName}Params ) => {
|
|
253
|
+
const result = await api.${verb}<${responseTypes}>(\`${route.replace(/\{/g, '{props.')}\`);
|
|
254
|
+
return result.data;
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
258
|
+
if (!requestBodyComponent && !paramsInPath.length && queryParam && !headerParam) {
|
|
259
|
+
const config = isUpdateRequest ? 'null,{params}' : '{params}';
|
|
260
|
+
output += `
|
|
261
|
+
type ${componentName}Params = {
|
|
262
|
+
${queryParamsType}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const ${fetchName} = async (params: ${componentName}Params) => {
|
|
266
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, ${config})
|
|
267
|
+
return result.data;
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
}
|
|
271
|
+
if (!requestBodyComponent && !paramsInPath.length && queryParam && headerParam) {
|
|
272
|
+
const config = isUpdateRequest ? 'null,{headers, params: queryParams}' : '{headers, params: queryParams}';
|
|
273
|
+
output += `
|
|
274
|
+
type ${componentName}Params = {
|
|
275
|
+
${headerParam}
|
|
276
|
+
${queryParamsType}
|
|
277
|
+
}
|
|
278
|
+
const ${fetchName} = async (props: ${componentName}Params) => {
|
|
279
|
+
const headers = {${generateProps(header)}}
|
|
280
|
+
const queryParams = {${generateProps(queryParams)}}
|
|
281
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, ${config})
|
|
282
|
+
return result.data
|
|
283
|
+
}`;
|
|
284
|
+
}
|
|
285
|
+
if (!requestBodyComponent && !paramsInPath.length && !queryParam && headerParam) {
|
|
286
|
+
const config = isUpdateRequest ? 'null,{headers}' : '{headers}';
|
|
287
|
+
output += `
|
|
288
|
+
type ${componentName}Params = {
|
|
289
|
+
${headerParam}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const ${fetchName} = async (headers: ${componentName}Params) => {
|
|
293
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, ${config});
|
|
294
|
+
return result.data;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
if (requestBodyComponent && !paramsInPath.length && !queryParam && !headerParam) {
|
|
299
|
+
output += `
|
|
300
|
+
type ${componentName}Params = ${requestBodyComponent}
|
|
301
|
+
|
|
302
|
+
const ${fetchName} = async (body: ${componentName}Params) => {
|
|
303
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, body)
|
|
304
|
+
return result.data
|
|
305
|
+
}
|
|
306
|
+
`;
|
|
307
|
+
}
|
|
308
|
+
if (requestBodyComponent && !paramsInPath.length && queryParam && !headerParam) {
|
|
309
|
+
output += `
|
|
310
|
+
type ${componentName}Params = ${body} & {
|
|
311
|
+
${queryParamsType}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
|
|
315
|
+
${generateBodyProps()}
|
|
316
|
+
const params = {${generateProps(queryParams)}}
|
|
317
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, body, {params})
|
|
318
|
+
return result.data
|
|
319
|
+
}
|
|
320
|
+
`;
|
|
321
|
+
}
|
|
322
|
+
if (requestBodyComponent && !paramsInPath.length && !queryParam && headerParam) {
|
|
323
|
+
output += `
|
|
324
|
+
type ${componentName}Params = ${body} & {
|
|
325
|
+
${headerParam}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
|
|
329
|
+
${generateBodyProps()}
|
|
330
|
+
const headers = {${generateProps(header)}}
|
|
331
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, body, {headers})
|
|
332
|
+
return result.data
|
|
333
|
+
}
|
|
334
|
+
`;
|
|
335
|
+
}
|
|
336
|
+
if (requestBodyComponent && !paramsInPath.length && queryParam && headerParam) {
|
|
337
|
+
output += `
|
|
338
|
+
type ${componentName}Params = ${body} & {
|
|
339
|
+
${headerParam}
|
|
340
|
+
${paramsTypes}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
|
|
344
|
+
${generateBodyProps()}
|
|
345
|
+
const headers = {${generateProps(header)}}
|
|
346
|
+
const params = {${generateProps(queryParams)}}
|
|
347
|
+
const result = await api.${verb}<${responseTypes}>(\`${route}\`, body, {headers, params})
|
|
348
|
+
return result.data
|
|
349
|
+
}
|
|
350
|
+
`;
|
|
351
|
+
}
|
|
352
|
+
if (requestBodyComponent && paramsInPath.length && !queryParam && !headerParam) {
|
|
353
|
+
output += `
|
|
354
|
+
type ${componentName}Params = ${body} & {
|
|
355
|
+
${headerParam}
|
|
356
|
+
${paramsTypes}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
|
|
360
|
+
${generateBodyProps()}
|
|
361
|
+
const result = await api.${verb}<${responseTypes}>(\`${route.replace(/\{/g, '{props.')}\`, body)
|
|
362
|
+
return result.data
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
if (requestBodyComponent && paramsInPath.length && queryParam && !headerParam) {
|
|
367
|
+
output += `// TODO: NOT SUPPORTED requestBodyComponent && paramsInPath && queryParam)`;
|
|
368
|
+
}
|
|
369
|
+
if (requestBodyComponent && paramsInPath.length && queryParam && headerParam) {
|
|
370
|
+
output += `// TODO: NOT SUPPORTED requestBodyComponent && paramsInPath && queryParam && headerParam)`;
|
|
371
|
+
}
|
|
372
|
+
if (!requestBodyComponent && paramsInPath.length && !queryParam && headerParam) {
|
|
373
|
+
const config = isUpdateRequest ? 'null,{headers}' : '{headers}';
|
|
374
|
+
output += `
|
|
375
|
+
type ${componentName}Params = {
|
|
376
|
+
${headerParam}
|
|
377
|
+
${paramsTypes}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const ${fetchName} = async (props: ${componentName}Params) => {
|
|
381
|
+
const headers = {${generateProps(header)}}
|
|
382
|
+
const result = await api.${verb}<${responseTypes}>(\`${route.replace(/\{/g, '{props.')}\`, ${config})
|
|
383
|
+
return result.data
|
|
384
|
+
}
|
|
385
|
+
`;
|
|
386
|
+
}
|
|
387
|
+
if (!requestBodyComponent && paramsInPath.length && queryParam && headerParam) {
|
|
388
|
+
output += `// TODO: NOT SUPPORTED (paramsInPath && queryParam && headerParam)`;
|
|
389
|
+
}
|
|
390
|
+
if (requestBodyComponent && paramsInPath.length && !queryParam && headerParam) {
|
|
391
|
+
output += `// TODO: NOT SUPPORTED (requestBodyComponent && paramsInPath && headerParam)`;
|
|
392
|
+
}
|
|
393
|
+
return { implementation: output, imports, queryImports };
|
|
394
|
+
};
|
|
395
|
+
//# sourceMappingURL=generateHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateHooks.js","sourceRoot":"","sources":["../src/generateHooks.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAShC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,OAAO,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;AAElC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAEtD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AAU,IAAI,WAAW,EAAE;QAC7E,MAAM,IAAI,8EAA8E,CAAC;KAC1F;IAED,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const generateImports: ({ schemaName, apiDirectory, queryClientDir, schemaImports, queryImports, }: {
|
|
2
|
+
apiDirectory: string;
|
|
3
|
+
queryClientDir: string;
|
|
4
|
+
schemaName: string;
|
|
5
|
+
schemaImports: string[];
|
|
6
|
+
queryImports: ('query' | 'mutation' | 'infiniteQuery')[];
|
|
7
|
+
}) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const generateImports = ({ schemaName, apiDirectory, queryClientDir, schemaImports, queryImports, }) => {
|
|
2
|
+
const importTypes = schemaImports.join(',');
|
|
3
|
+
let imports = [];
|
|
4
|
+
if (queryImports.includes('query')) {
|
|
5
|
+
imports = [...imports, 'useQuery', 'UseQueryOptions', 'QueryKey', 'SetDataOptions', 'QueryFilters'];
|
|
6
|
+
}
|
|
7
|
+
if (queryImports.includes('infiniteQuery')) {
|
|
8
|
+
imports = [...imports, 'useInfiniteQuery', 'UseInfiniteQueryOptions', 'QueryKey'];
|
|
9
|
+
}
|
|
10
|
+
if (queryImports.includes('mutation')) {
|
|
11
|
+
imports = [...imports, 'UseMutationOptions', 'useMutation'];
|
|
12
|
+
}
|
|
13
|
+
const importString = [...new Set(imports)].join(',');
|
|
14
|
+
return `
|
|
15
|
+
import {
|
|
16
|
+
${importString}
|
|
17
|
+
} from '@tanstack/react-query';
|
|
18
|
+
|
|
19
|
+
import { AxiosError } from 'axios';
|
|
20
|
+
import { api } from '${apiDirectory}';
|
|
21
|
+
import { queryClient } from '${queryClientDir}';
|
|
22
|
+
|
|
23
|
+
import {${importTypes}} from './${schemaName}'
|
|
24
|
+
|
|
25
|
+
type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
|
|
26
|
+
`;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=generateImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateImports.js","sourceRoot":"","sources":["../src/generateImports.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,UAAU,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,GAOb,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,OAAO,GAAG,EAAc,CAAC;IAC7B,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAClC,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;KACrG;IACD,IAAI,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;QAC1C,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,UAAU,CAAC,CAAC;KACnF;IACD,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACrC,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,oBAAoB,EAAE,aAAa,CAAC,CAAC;KAC7D;IAED,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAErD,OAAO;;MAEH,YAAY;;;;yBAIO,YAAY;iCACJ,cAAc;;YAEnC,WAAW,aAAa,UAAU;;;GAG3C,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -9,8 +9,7 @@ import { getDocs, getResReqTypes } from './utils.js';
|
|
|
9
9
|
*/
|
|
10
10
|
const generateInterface = (name, schema) => {
|
|
11
11
|
const scalar = getScalar(schema);
|
|
12
|
-
return
|
|
13
|
-
${formatDescription(schema.description)}
|
|
12
|
+
return `${formatDescription(schema.description)}
|
|
14
13
|
export type ${pascal(name)} = ${scalar}
|
|
15
14
|
`;
|
|
16
15
|
};
|
|
@@ -48,13 +47,13 @@ const generateRequestBodiesDefinition = (requestBodies = {}) => {
|
|
|
48
47
|
const type = getResReqTypes([['', requestBody]]);
|
|
49
48
|
const isEmptyInterface = type === '{}';
|
|
50
49
|
if (isEmptyInterface) {
|
|
51
|
-
return `${doc}
|
|
50
|
+
return `${doc}\nexport type ${pascal(name)}RequestBody = ${type}`;
|
|
52
51
|
}
|
|
53
52
|
else if (type.includes('{') && !type.includes('|') && !type.includes('&')) {
|
|
54
|
-
return `${doc}
|
|
53
|
+
return `${doc}\nexport type ${pascal(name)}RequestBody = ${type}`;
|
|
55
54
|
}
|
|
56
55
|
else {
|
|
57
|
-
return `${doc}
|
|
56
|
+
return `${doc}\nexport type ${pascal(name)}RequestBody = ${type};`;
|
|
58
57
|
}
|
|
59
58
|
})
|
|
60
59
|
.join('\n\n') +
|
|
@@ -90,8 +89,9 @@ const generateResponsesDefinition = (responses = {}) => {
|
|
|
90
89
|
* Extract all types from #/components/schemas
|
|
91
90
|
*/
|
|
92
91
|
export const generateSchemas = ({ spec }) => {
|
|
93
|
-
const schemaOutput =
|
|
92
|
+
const schemaOutput = generateRequestBodiesDefinition(spec.components?.requestBodies) +
|
|
94
93
|
generateResponsesDefinition(spec.components?.responses) +
|
|
95
|
-
|
|
94
|
+
generateSchemasDefinition(spec.components?.schemas);
|
|
96
95
|
return schemaOutput;
|
|
97
96
|
};
|
|
97
|
+
//# sourceMappingURL=generateSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSchemas.js","sourceRoot":"","sources":["../src/generateSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,MAAM,CAAC;AAC3B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;A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 sourceDirectory, exportDirectory, apiDirectory, queryClientDir, headerFilters, overrides, }: {
|
|
2
|
+
sourceDirectory: string;
|
|
3
|
+
exportDirectory: string;
|
|
4
|
+
apiDirectory: string;
|
|
5
|
+
queryClientDir: string;
|
|
6
|
+
headerFilters?: string[];
|
|
7
|
+
overrides?: Record<string, {
|
|
8
|
+
type: 'query';
|
|
9
|
+
} | {
|
|
10
|
+
type: 'mutation';
|
|
11
|
+
} | {
|
|
12
|
+
type: 'infiniteQuery';
|
|
13
|
+
infiniteQueryParm: string;
|
|
14
|
+
}>;
|
|
15
|
+
}): void;
|