@@ -595,7 +595,7 @@ export function hoistRequestAnnotations (
595
595
'maintenance' , 'manage' , 'manage_follow_index' , 'manage_ilm' , 'manage_leader_index' , 'monitor' ,
596
596
'read' , 'read_cross_cluster' , 'view_index_metadata' , 'write'
597
597
]
598
- const values = value . split ( ',' ) . map ( v => v . trim ( ) )
598
+ const values = parseCommaSeparated ( value )
599
599
for ( const v of values ) {
600
600
assert ( jsDocs , privileges . includes ( v ) , `The index privilege '${ v } ' does not exists.` )
601
601
}
@@ -610,7 +610,7 @@ export function hoistRequestAnnotations (
610
610
'manage_watcher' , 'monitor' , 'monitor_ml' , 'monitor_rollup' , 'monitor_snapshot' , 'monitor_text_structure' ,
611
611
'monitor_transform' , 'monitor_watcher' , 'read_ccr' , 'read_ilm' , 'read_pipeline' , 'read_slm' , 'transport_client'
612
612
]
613
- const values = value . split ( ',' ) . map ( v => v . trim ( ) )
613
+ const values = parseCommaSeparated ( value )
614
614
for ( const v of values ) {
615
615
assert ( jsDocs , privileges . includes ( v ) , `The cluster privilege '${ v } ' does not exists.` )
616
616
}
@@ -657,7 +657,7 @@ export function hoistTypeAnnotations (type: model.TypeDefinition, jsDocs: JSDoc[
657
657
assert ( jsDocs , value . trim ( ) !== '' , `Type ${ type . name . namespace } .${ type . name . name } 's @doc_id cannot be empty` )
658
658
type . docId = value . trim ( )
659
659
} else if ( tag === 'codegen_names' ) {
660
- type . codegenNames = value . split ( ',' ) . map ( v => v . trim ( ) )
660
+ type . codegenNames = parseCommaSeparated ( value )
661
661
assert ( jsDocs ,
662
662
type . kind === 'type_alias' && type . type . kind === 'union_of' && type . type . items . length === type . codegenNames . length ,
663
663
'@codegen_names must have the number of items as the union definition'
@@ -685,7 +685,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
685
685
setTags ( jsDocs , property , tags , validTags , ( tags , tag , value ) => {
686
686
if ( tag . endsWith ( '_serializer' ) ) {
687
687
} else if ( tag === 'aliases' ) {
688
- property . aliases = value . split ( ',' ) . map ( v => v . trim ( ) )
688
+ property . aliases = parseCommaSeparated ( value )
689
689
} else if ( tag === 'codegen_name' ) {
690
690
property . codegenName = value
691
691
} else if ( tag === 'doc_url' ) {
@@ -778,7 +778,7 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
778
778
if ( tag === 'codegen_name' ) {
779
779
member . codegenName = value
780
780
} else if ( tag === 'aliases' ) {
781
- member . aliases = value . split ( ',' ) . map ( v => v . trim ( ) )
781
+ member . aliases = parseCommaSeparated ( value )
782
782
} else if ( tag === 'since' ) {
783
783
assert ( jsDocs , semver . valid ( value ) , `${ member . name } 's @since is not valid semver: ${ value } ` )
784
784
member . since = value
@@ -962,6 +962,14 @@ export function parseVariantNameTag (jsDoc: JSDoc[]): string | undefined {
962
962
return name . replace ( / ' / g, '' )
963
963
}
964
964
965
+ /**
966
+ * Parses a list of comma-separated values as an array. Values can optionally be enclosed with single
967
+ * or double quotes.
968
+ */
969
+ export function parseCommaSeparated ( value : string ) : string [ ] {
970
+ return value . split ( ',' ) . map ( v => v . trim ( ) . replace ( / [ " ' ] / g, '' ) )
971
+ }
972
+
965
973
/**
966
974
* Given a declaration, returns true if the declaration
967
975
* if defined but never used, false otherwise.
0 commit comments