@@ -308,7 +308,7 @@ export const createHook = ({
308
308
309
309
if ( ! requestBodyComponent && ! paramsInPath . length && ! queryParam && ! headerParam ) {
310
310
output += `
311
- const ${ fetchName } = async () => {
311
+ export const ${ fetchName } = async () => {
312
312
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`);
313
313
return result.data;
314
314
}
@@ -318,12 +318,12 @@ export const createHook = ({
318
318
if ( ! requestBodyComponent && paramsInPath . length && queryParam && ! headerParam ) {
319
319
const config = isUpdateRequest ? 'undefined,{params}' : '{params}' ;
320
320
output += `
321
- type ${ componentName } Params = {
321
+ export type ${ componentName } Params = {
322
322
${ paramsTypes }
323
323
${ queryParamsType } ;
324
324
}
325
325
326
- const ${ fetchName } = async (props:${ componentName } Params) => {
326
+ export const ${ fetchName } = async (props:${ componentName } Params) => {
327
327
const {${ paramsInPath . join ( ', ' ) } , ...params} = props
328
328
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, ${ config } )
329
329
return result.data;
@@ -332,11 +332,11 @@ export const createHook = ({
332
332
333
333
if ( ! requestBodyComponent && paramsInPath . length && ! queryParam && ! headerParam ) {
334
334
output += `
335
- type ${ componentName } Params = {
335
+ export type ${ componentName } Params = {
336
336
${ paramsTypes }
337
337
}
338
338
339
- const ${ fetchName } = async (props: ${ componentName } Params ) => {
339
+ export const ${ fetchName } = async (props: ${ componentName } Params ) => {
340
340
const result = await api.${ verb } <${ responseTypes } >(\`${ route . replace ( / \{ / g, '{props.' ) } \`);
341
341
return result.data;
342
342
}
@@ -346,11 +346,11 @@ export const createHook = ({
346
346
if ( ! requestBodyComponent && ! paramsInPath . length && queryParam && ! headerParam ) {
347
347
const config = isUpdateRequest ? 'null,{params}' : '{params}' ;
348
348
output += `
349
- type ${ componentName } Params = {
349
+ export type ${ componentName } Params = {
350
350
${ queryParamsType }
351
351
}
352
352
353
- const ${ fetchName } = async (params: ${ componentName } Params) => {
353
+ export const ${ fetchName } = async (params: ${ componentName } Params) => {
354
354
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, ${ config } )
355
355
return result.data;
356
356
}
@@ -359,11 +359,11 @@ export const createHook = ({
359
359
if ( ! requestBodyComponent && ! paramsInPath . length && queryParam && headerParam ) {
360
360
const config = isUpdateRequest ? 'null,{headers, params: queryParams}' : '{headers, params: queryParams}' ;
361
361
output += `
362
- type ${ componentName } Params = {
362
+ export type ${ componentName } Params = {
363
363
${ headerParam }
364
364
${ queryParamsType }
365
365
}
366
- const ${ fetchName } = async (props: ${ componentName } Params) => {
366
+ export const ${ fetchName } = async (props: ${ componentName } Params) => {
367
367
const headers = {${ generateProps ( header ) } }
368
368
const queryParams = {${ generateProps ( queryParams ) } }
369
369
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, ${ config } )
@@ -373,11 +373,11 @@ export const createHook = ({
373
373
if ( ! requestBodyComponent && ! paramsInPath . length && ! queryParam && headerParam ) {
374
374
const config = isUpdateRequest ? 'null,{headers}' : '{headers}' ;
375
375
output += `
376
- type ${ componentName } Params = {
376
+ export type ${ componentName } Params = {
377
377
${ headerParam }
378
378
};
379
379
380
- const ${ fetchName } = async (headers: ${ componentName } Params) => {
380
+ export const ${ fetchName } = async (headers: ${ componentName } Params) => {
381
381
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, ${ config } );
382
382
return result.data;
383
383
}
@@ -386,9 +386,9 @@ export const createHook = ({
386
386
387
387
if ( requestBodyComponent && ! paramsInPath . length && ! queryParam && ! headerParam ) {
388
388
output += `
389
- type ${ componentName } Params = ${ requestBodyComponent }
389
+ export type ${ componentName } Params = ${ requestBodyComponent }
390
390
391
- const ${ fetchName } = async (body: ${ componentName } Params) => {
391
+ export const ${ fetchName } = async (body: ${ componentName } Params) => {
392
392
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, body)
393
393
return result.data
394
394
}
@@ -397,11 +397,11 @@ export const createHook = ({
397
397
398
398
if ( requestBodyComponent && ! paramsInPath . length && queryParam && ! headerParam ) {
399
399
output += `
400
- type ${ componentName } Params = ${ body } & {
400
+ export type ${ componentName } Params = ${ body } & {
401
401
${ queryParamsType }
402
402
}
403
403
404
- const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
404
+ export const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
405
405
${ generateBodyProps ( ) }
406
406
const params = {${ generateProps ( queryParams ) } }
407
407
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, body, {params})
@@ -412,11 +412,11 @@ export const createHook = ({
412
412
413
413
if ( requestBodyComponent && ! paramsInPath . length && ! queryParam && headerParam ) {
414
414
output += `
415
- type ${ componentName } Params = ${ body } & {
415
+ export type ${ componentName } Params = ${ body } & {
416
416
${ headerParam }
417
417
};
418
418
419
- const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
419
+ export const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
420
420
${ generateBodyProps ( ) }
421
421
const headers = {${ generateProps ( header ) } }
422
422
const result = await api.${ verb } <${ responseTypes } >(\`${ route } \`, body, {headers})
@@ -427,11 +427,11 @@ export const createHook = ({
427
427
428
428
if ( requestBodyComponent && ! paramsInPath . length && queryParam && headerParam ) {
429
429
output += `
430
- type ${ componentName } Params = ${ body } & {
430
+ export type ${ componentName } Params = ${ body } & {
431
431
${ headerParam }
432
432
${ paramsTypes }
433
433
};
434
- const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
434
+ export const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
435
435
${ generateBodyProps ( ) }
436
436
const headers = {${ generateProps ( header ) } }
437
437
const params = {${ generateProps ( queryParams ) } }
@@ -443,12 +443,12 @@ export const createHook = ({
443
443
444
444
if ( requestBodyComponent && paramsInPath . length && ! queryParam && ! headerParam ) {
445
445
output += `
446
- type ${ componentName } Params = ${ body } & {
446
+ export type ${ componentName } Params = ${ body } & {
447
447
${ headerParam }
448
448
${ paramsTypes }
449
449
};
450
450
// TEST1
451
- const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
451
+ export const ${ fetchName } = async (${ bodyProps } : ${ componentName } Params) => {
452
452
${ generateBodyProps ( ) }
453
453
const result = await api.${ verb } <${ responseTypes } >(\`${ route . replace ( / \{ / g, '{props.' ) } \`, body)
454
454
return result.data
@@ -467,12 +467,12 @@ export const createHook = ({
467
467
if ( ! requestBodyComponent && paramsInPath . length && ! queryParam && headerParam ) {
468
468
const config = isUpdateRequest ? 'null,{headers}' : '{headers}' ;
469
469
output += `
470
- type ${ componentName } Params = {
470
+ export type ${ componentName } Params = {
471
471
${ headerParam }
472
472
${ paramsTypes }
473
473
};
474
474
475
- const ${ fetchName } = async (props: ${ componentName } Params) => {
475
+ export const ${ fetchName } = async (props: ${ componentName } Params) => {
476
476
const headers = {${ generateProps ( header ) } }
477
477
const result = await api.${ verb } <${ responseTypes } >(\`${ route . replace ( / \{ / g, '{props.' ) } \`, ${ config } )
478
478
return result.data
0 commit comments