@@ -3,7 +3,6 @@ import type ts from 'typescript';
3
3
import { compiler } from '../../../compiler' ;
4
4
import type { ObjectValue } from '../../../compiler/types' ;
5
5
import { clientApi , clientModulePath } from '../../../generate/client' ;
6
- import type { TypeScriptFile } from '../../../generate/files' ;
7
6
import {
8
7
hasOperationDataRequired ,
9
8
statusCodeToGroup ,
@@ -21,13 +20,13 @@ import {
21
20
transformersId ,
22
21
} from '../transformers/plugin' ;
23
22
import {
24
- importIdentifierData ,
25
23
importIdentifierError ,
26
24
importIdentifierResponse ,
27
25
} from '../typescript/ref' ;
28
26
import { nuxtTypeComposable , nuxtTypeDefault } from './constants' ;
27
+ import { createParameters } from './params' ;
29
28
import { serviceFunctionIdentifier } from './plugin-legacy' ;
30
- import { createTypeOptions } from './typeOptions' ;
29
+ import { createTypeOmitNever , createTypeOptions } from './typeOptions' ;
31
30
import type { Config } from './types' ;
32
31
33
32
// copy-pasted from @hey-api/client-core
@@ -48,40 +47,6 @@ export interface Auth {
48
47
type : 'apiKey' | 'http' ;
49
48
}
50
49
51
- export const operationOptionsType = ( {
52
- context,
53
- file,
54
- operation,
55
- throwOnError,
56
- } : {
57
- context : IR . Context ;
58
- file : TypeScriptFile ;
59
- operation : IR . OperationObject ;
60
- throwOnError ?: string ;
61
- } ) => {
62
- const identifierData = importIdentifierData ( { context, file, operation } ) ;
63
- const identifierResponse = importIdentifierResponse ( {
64
- context,
65
- file,
66
- operation,
67
- } ) ;
68
-
69
- const optionsName = clientApi . Options . name ;
70
-
71
- const client = getClientPlugin ( context . config ) ;
72
- if ( client . name === '@hey-api/client-nuxt' ) {
73
- return `${ optionsName } <${ nuxtTypeComposable } , ${ identifierData . name || 'unknown' } , ${ identifierResponse . name || 'unknown' } , ${ nuxtTypeDefault } >` ;
74
- }
75
-
76
- // TODO: refactor this to be more generic, works for now
77
- if ( throwOnError ) {
78
- return `${ optionsName } <${ identifierData . name || 'unknown' } , ${ throwOnError } >` ;
79
- }
80
- return identifierData . name
81
- ? `${ optionsName } <${ identifierData . name } >`
82
- : optionsName ;
83
- } ;
84
-
85
50
export const sdkId = 'sdk' ;
86
51
87
52
/**
@@ -552,18 +517,12 @@ const generateClassSdk = ({
552
517
id : operation . id ,
553
518
operation,
554
519
} ) ,
555
- parameters : [
556
- {
557
- isRequired : isRequiredOptions ,
558
- name : 'options' ,
559
- type : operationOptionsType ( {
560
- context,
561
- file,
562
- operation,
563
- throwOnError : isNuxtClient ? undefined : 'ThrowOnError' ,
564
- } ) ,
565
- } ,
566
- ] ,
520
+ parameters : createParameters ( {
521
+ context,
522
+ file,
523
+ operation,
524
+ plugin,
525
+ } ) ,
567
526
returnType : undefined ,
568
527
statements : operationStatements ( {
569
528
context,
@@ -658,18 +617,12 @@ const generateFlatSdk = ({
658
617
] ,
659
618
exportConst : true ,
660
619
expression : compiler . arrowFunction ( {
661
- parameters : [
662
- {
663
- isRequired : isRequiredOptions ,
664
- name : 'options' ,
665
- type : operationOptionsType ( {
666
- context,
667
- file,
668
- operation,
669
- throwOnError : isNuxtClient ? undefined : 'ThrowOnError' ,
670
- } ) ,
671
- } ,
672
- ] ,
620
+ parameters : createParameters ( {
621
+ context,
622
+ file,
623
+ operation,
624
+ plugin,
625
+ } ) ,
673
626
returnType : undefined ,
674
627
statements : operationStatements ( {
675
628
context,
@@ -752,6 +705,9 @@ export const handler: Plugin.Handler<Config> = ({ context, plugin }) => {
752
705
context,
753
706
plugin,
754
707
} ) ;
708
+ createTypeOmitNever ( {
709
+ context,
710
+ } ) ;
755
711
756
712
if ( plugin . asClass ) {
757
713
generateClassSdk ( { context, plugin } ) ;
0 commit comments