@@ -65,6 +65,7 @@ export function generateClient({
65
65
name,
66
66
exportModels,
67
67
exportServices,
68
+ exportErrorClass,
68
69
errorClassName,
69
70
generateJsDoc,
70
71
...filenameConfig
@@ -111,13 +112,17 @@ export function generateClient({
111
112
) ;
112
113
113
114
const errorTypeName = errorClassName ?? `${ name } Error` ;
114
- const errorTypeExport = exportNamedDeclaration (
115
- classDeclaration (
116
- identifier ( errorTypeName ) ,
117
- memberExpression ( identifier ( commonHttpClientImportName ) , identifier ( commonHttpClientErrorClassName ) ) ,
118
- classBody ( [ classProperty ( identifier ( 'name' ) , stringLiteral ( errorTypeName ) ) ] )
119
- )
115
+ const additionalTypeStatements : Statement [ ] = [ ] ;
116
+ const errorClassDeclaration = classDeclaration (
117
+ identifier ( errorTypeName ) ,
118
+ memberExpression ( identifier ( commonHttpClientImportName ) , identifier ( commonHttpClientErrorClassName ) ) ,
119
+ classBody ( [ classProperty ( identifier ( 'name' ) , stringLiteral ( errorTypeName ) ) ] )
120
120
) ;
121
+ if ( exportErrorClass !== false ) {
122
+ additionalTypeStatements . push ( exportNamedDeclaration ( errorClassDeclaration ) ) ;
123
+ } else {
124
+ additionalTypeStatements . push ( errorClassDeclaration ) ;
125
+ }
121
126
122
127
const clientClassBody = classBody ( [
123
128
classProperty (
@@ -281,8 +286,14 @@ export function generateClient({
281
286
const exportTypes : ExportNamedDeclaration = exportNamedDeclaration ( null , [ ] ) ;
282
287
exportTypes . exportKind = 'type' ;
283
288
284
- if ( exportModels ) {
289
+ if ( exportModels && exportModels !== 'none' ) {
290
+ const modelsToExport = new Set (
291
+ exportModels === 'all' ? modelImportInfos . map ( ( { modelName} ) => modelName ) : exportModels . models
292
+ ) ;
285
293
for ( const { modelName, importPath} of modelImportInfos ) {
294
+ if ( ! modelsToExport . has ( modelName ) ) {
295
+ continue ;
296
+ }
286
297
addDependencyImport ( dependencyImports , getRelativeImportPath ( clientImportPath , importPath ) , modelName , {
287
298
kind : 'type' ,
288
299
entity : { name : modelName }
@@ -293,8 +304,14 @@ export function generateClient({
293
304
294
305
const exports : ExportNamedDeclaration = exportNamedDeclaration ( null , [ ] ) ;
295
306
296
- if ( exportServices ) {
307
+ if ( exportServices && exportServices !== 'none' ) {
308
+ const servicesToExport = new Set (
309
+ exportServices === 'all' ? generatedServiceImports . map ( ( { name} ) => name ) : exportServices . services
310
+ ) ;
297
311
for ( const { name, importPath} of generatedServiceImports ) {
312
+ if ( ! servicesToExport . has ( name ) ) {
313
+ continue ;
314
+ }
298
315
addDependencyImport ( dependencyImports , getRelativeImportPath ( clientImportPath , importPath ) , name , {
299
316
kind : 'value' ,
300
317
entity : { name}
@@ -333,7 +350,7 @@ export function generateClient({
333
350
) ,
334
351
...generateTsImports ( dependencyImports ) ,
335
352
optionsTypeExport ,
336
- errorTypeExport ,
353
+ ... additionalTypeStatements ,
337
354
clientClass ,
338
355
...otherStatements ,
339
356
...( exportTypes . specifiers . length > 0 ? [ exportTypes ] : [ ] ) ,
0 commit comments