@@ -607,7 +607,7 @@ export function hoistRequestAnnotations (
607
607
'maintenance' , 'manage' , 'manage_follow_index' , 'manage_ilm' , 'manage_leader_index' , 'monitor' ,
608
608
'read' , 'read_cross_cluster' , 'view_index_metadata' , 'write'
609
609
]
610
- const values = value . split ( ',' ) . map ( v => v . trim ( ) )
610
+ const values = parseCommaSeparated ( value )
611
611
for ( const v of values ) {
612
612
assert ( jsDocs , privileges . includes ( v ) , `The index privilege '${ v } ' does not exists.` )
613
613
}
@@ -622,7 +622,7 @@ export function hoistRequestAnnotations (
622
622
'manage_watcher' , 'monitor' , 'monitor_ml' , 'monitor_rollup' , 'monitor_snapshot' , 'monitor_text_structure' ,
623
623
'monitor_transform' , 'monitor_watcher' , 'read_ccr' , 'read_ilm' , 'read_pipeline' , 'read_slm' , 'transport_client'
624
624
]
625
- const values = value . split ( ',' ) . map ( v => v . trim ( ) )
625
+ const values = parseCommaSeparated ( value )
626
626
for ( const v of values ) {
627
627
assert ( jsDocs , privileges . includes ( v ) , `The cluster privilege '${ v } ' does not exists.` )
628
628
}
@@ -675,7 +675,7 @@ export function hoistTypeAnnotations (type: model.TypeDefinition, jsDocs: JSDoc[
675
675
assert ( jsDocs , docUrl != null , `The @doc_id '${ value . trim ( ) } ' is not present in _doc_ids/table.csv` )
676
676
type . docUrl = docUrl [ 1 ]
677
677
} else if ( tag === 'codegen_names' ) {
678
- type . codegenNames = value . split ( ',' ) . map ( v => v . trim ( ) )
678
+ type . codegenNames = parseCommaSeparated ( value )
679
679
assert ( jsDocs ,
680
680
type . kind === 'type_alias' && type . type . kind === 'union_of' && type . type . items . length === type . codegenNames . length ,
681
681
'@codegen_names must have the number of items as the union definition'
@@ -711,7 +711,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
711
711
setTags ( jsDocs , property , tags , validTags , ( tags , tag , value ) => {
712
712
if ( tag . endsWith ( '_serializer' ) ) {
713
713
} else if ( tag === 'aliases' ) {
714
- property . aliases = value . split ( ',' ) . map ( v => v . trim ( ) )
714
+ property . aliases = parseCommaSeparated ( value )
715
715
} else if ( tag === 'codegen_name' ) {
716
716
property . codegenName = value
717
717
} else if ( tag === 'doc_url' ) {
@@ -808,7 +808,7 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
808
808
if ( tag === 'codegen_name' ) {
809
809
member . codegenName = value
810
810
} else if ( tag === 'aliases' ) {
811
- member . aliases = value . split ( ',' ) . map ( v => v . trim ( ) )
811
+ member . aliases = parseCommaSeparated ( value )
812
812
} else if ( tag === 'since' ) {
813
813
assert ( jsDocs , semver . valid ( value ) , `${ member . name } 's @since is not valid semver: ${ value } ` )
814
814
member . since = value
@@ -992,6 +992,14 @@ export function parseVariantNameTag (jsDoc: JSDoc[]): string | undefined {
992
992
return name . replace ( / ' / g, '' )
993
993
}
994
994
995
+ /**
996
+ * Parses a list of comma-separated values as an array. Values can optionally be enclosed with single
997
+ * or double quotes.
998
+ */
999
+ export function parseCommaSeparated ( value : string ) : string [ ] {
1000
+ return value . split ( ',' ) . map ( v => v . trim ( ) . replace ( / [ " ' ] / g, '' ) )
1001
+ }
1002
+
995
1003
/**
996
1004
* Given a declaration, returns true if the declaration
997
1005
* if defined but never used, false otherwise.
0 commit comments