1818 */
1919import entityOptions from '../../../jhipster/entity-options.ts' ;
2020
21+ import type { UnaryOptionType } from './unary-options.ts' ;
22+
2123const { MapperTypes, PaginationTypes, SearchTypes, ServiceTypes } = entityOptions ;
2224const { MAPSTRUCT } = MapperTypes ;
2325const NO_MAPPER = MapperTypes . NO ;
@@ -52,13 +54,17 @@ const Values = {
5254 search : searchValues ,
5355} as const ;
5456
57+ export type BinaryOptionType = ( typeof Options ) [ keyof typeof Options ] ;
58+
59+ export type JDLOptionName = BinaryOptionType | UnaryOptionType | 'paginate' ;
60+
5561const DefaultValues = {
5662 [ Options . DTO ] : Values [ Options . DTO ] . NO ,
5763 [ Options . SERVICE ] : Values [ Options . SERVICE ] . NO ,
5864 [ Options . PAGINATION ] : Values [ Options . PAGINATION ] . NO ,
5965} ;
6066
61- function getOptionName ( optionValue : string ) : string | undefined {
67+ function getOptionName ( optionValue : string ) : JDLOptionName | undefined {
6268 return optionNames . find ( optionName => ( Values as Record < string , Record < string , string > > ) [ optionName ] ?. [ optionValue ] ) ;
6369}
6470
@@ -72,14 +78,14 @@ const OptionValues = {
7278 couchbase : 'COUCHBASE' ,
7379} as const ;
7480
75- function forEach ( passedFunction : ( optionName : string ) => void ) : void {
81+ function forEach ( passedFunction : ( optionName : BinaryOptionType ) => void ) : void {
7682 if ( ! passedFunction ) {
7783 throw new Error ( 'A function has to be passed to loop over the binary options.' ) ;
7884 }
79- optionNames . forEach ( passedFunction ) ;
85+ optionNames . forEach ( optionName => passedFunction ( optionName as BinaryOptionType ) ) ;
8086}
8187
82- function exists ( passedOption : string | keyof typeof Values | 'microservice' | 'angularSuffix' | 'clientRootFolder' , passedValue ?: any ) {
88+ function exists ( passedOption : JDLOptionName , passedValue ?: any ) {
8389 return (
8490 ! ( optionNames as string [ ] ) . includes ( passedOption ) ||
8591 optionNames . some (
0 commit comments