@@ -12,7 +12,6 @@ import type {
1212 GraphQLFieldConfig ,
1313 GraphQLFieldConfigMap ,
1414 GraphQLFieldConfigArgumentMap ,
15- GraphQLFieldMap ,
1615 GraphQLInputType ,
1716} from "graphql/type/definition" ; // eslint-disable-line
1817
@@ -89,8 +88,7 @@ export default class ElasticApiParser {
8988 opts . elasticClient . transport . _config . apiVersion ) ||
9089 '_default' ;
9190 const apiFilePath = path . resolve (
92- opts . elasticApiFilePath ||
93- ElasticApiParser . findApiVersionFile ( this . apiVersion )
91+ opts . elasticApiFilePath || ElasticApiParser . findApiVersionFile ( this . apiVersion )
9492 ) ;
9593 const source = ElasticApiParser . loadApiFile ( apiFilePath ) ;
9694 this . parsedSource = ElasticApiParser . parseSource ( source ) ;
@@ -109,9 +107,7 @@ export default class ElasticApiParser {
109107 try {
110108 code = ElasticApiParser . loadFile ( absolutePath ) ;
111109 } catch ( e ) {
112- throw new Error (
113- `Cannot load Elastic API source file from ${ absolutePath } `
114- ) ;
110+ throw new Error ( `Cannot load Elastic API source file from ${ absolutePath } ` ) ;
115111 }
116112 return ElasticApiParser . cleanUpSource ( code ) ;
117113 }
@@ -121,9 +117,7 @@ export default class ElasticApiParser {
121117 try {
122118 code = ElasticApiParser . loadFile ( absolutePath ) ;
123119 } catch ( e ) {
124- throw new Error (
125- `Cannot load Elastic API file with avaliable versions from ${ absolutePath } `
126- ) ;
120+ throw new Error ( `Cannot load Elastic API file with avaliable versions from ${ absolutePath } ` ) ;
127121 }
128122 return code ;
129123 }
@@ -135,29 +129,21 @@ export default class ElasticApiParser {
135129
136130 // parsing elasticsearch module 13.x and above
137131 // get '5.3'() { return require('./5_3'); },
138- const re = new RegExp (
139- `\\'${ version } \\'\\(\\).*require\\(\\'(.+)\\'\\)` ,
140- 'gi'
141- ) ;
132+ const re = new RegExp ( `\\'${ version } \\'\\(\\).*require\\(\\'(.+)\\'\\)` , 'gi' ) ;
142133 const match = re . exec ( apiListCode ) ;
143134 if ( match && match [ 1 ] ) {
144135 return path . resolve ( apiFolder , `${ match [ 1 ] } .js` ) ;
145136 }
146137
147138 // parsing elasticsearch module 12.x and below
148139 // '5.0': require('./5_0'),
149- const re12 = new RegExp (
150- `\\'${ version } \\':\\srequire\\(\\'(.+)\\'\\)` ,
151- 'gi'
152- ) ;
140+ const re12 = new RegExp ( `\\'${ version } \\':\\srequire\\(\\'(.+)\\'\\)` , 'gi' ) ;
153141 const match12 = re12 . exec ( apiListCode ) ;
154142 if ( match12 && match12 [ 1 ] ) {
155143 return path . resolve ( apiFolder , `${ match12 [ 1 ] } .js` ) ;
156144 }
157145
158- throw new Error (
159- `Can not found Elastic version '${ version } ' in ${ apiListFile } `
160- ) ;
146+ throw new Error ( `Can not found Elastic version '${ version } ' in ${ apiListFile } ` ) ;
161147 }
162148
163149 static cleanUpSource ( code : string ) : string {
@@ -172,9 +158,7 @@ export default class ElasticApiParser {
172158 return codeCleaned ;
173159 }
174160
175- static parseParamsDescription (
176- doxItemAST : any
177- ) : { [ fieldName : string ] : string } {
161+ static parseParamsDescription ( doxItemAST : any ) : { [ fieldName : string ] : string } {
178162 const descriptions = { } ;
179163 if ( Array . isArray ( doxItemAST . tags ) ) {
180164 doxItemAST . tags . forEach ( tag => {
@@ -184,9 +168,7 @@ export default class ElasticApiParser {
184168 const name = ElasticApiParser . cleanupParamName ( tag . name ) ;
185169 if ( ! name ) return ;
186170
187- descriptions [ name ] = ElasticApiParser . cleanupDescription (
188- tag . description
189- ) ;
171+ descriptions [ name ] = ElasticApiParser . cleanupDescription ( tag . description ) ;
190172 } ) ;
191173 }
192174 return descriptions ;
@@ -258,9 +240,7 @@ export default class ElasticApiParser {
258240 // method description
259241 let description ;
260242 if ( item . description && item . description . full ) {
261- description = ElasticApiParser . cleanupDescription (
262- item . description . full
263- ) ;
243+ description = ElasticApiParser . cleanupDescription ( item . description . full ) ;
264244 }
265245
266246 const elasticMethod = ElasticApiParser . getMethodName ( item . ctx . string ) ;
@@ -310,12 +290,9 @@ export default class ElasticApiParser {
310290 throw new Error ( `Elastic search method '${ methodName } ' does not exists.` ) ;
311291 }
312292
313- const {
314- description,
315- argsSettings,
316- argsDescriptions,
317- elasticMethod,
318- } = this . parsedSource [ methodName ] ;
293+ const { description, argsSettings, argsDescriptions, elasticMethod } = this . parsedSource [
294+ methodName
295+ ] ;
319296
320297 const argMap = this . settingsToArgMap ( argsSettings , argsDescriptions ) ;
321298
@@ -366,10 +343,7 @@ export default class ElasticApiParser {
366343 return result ;
367344 }
368345
369- paramTypeToGraphQL (
370- paramCfg : ElasticParamConfigT ,
371- fieldName : string
372- ) : GraphQLInputType {
346+ paramTypeToGraphQL ( paramCfg : ElasticParamConfigT , fieldName : string ) : GraphQLInputType {
373347 switch ( paramCfg . type ) {
374348 case 'string' :
375349 return GraphQLString ;
@@ -458,11 +432,7 @@ export default class ElasticApiParser {
458432
459433 if ( params ) {
460434 Object . keys ( params ) . forEach ( k => {
461- const fieldConfig = this . paramToGraphQLArgConfig (
462- params [ k ] ,
463- k ,
464- descriptions [ k ]
465- ) ;
435+ const fieldConfig = this . paramToGraphQLArgConfig ( params [ k ] , k , descriptions [ k ] ) ;
466436 if ( fieldConfig ) {
467437 result [ k ] = fieldConfig ;
468438 }
@@ -475,11 +445,7 @@ export default class ElasticApiParser {
475445 urlList . forEach ( item => {
476446 if ( item . req ) {
477447 Object . keys ( item . req ) . forEach ( k => {
478- const fieldConfig = this . paramToGraphQLArgConfig (
479- item . req [ k ] ,
480- k ,
481- descriptions [ k ]
482- ) ;
448+ const fieldConfig = this . paramToGraphQLArgConfig ( item . req [ k ] , k , descriptions [ k ] ) ;
483449 if ( fieldConfig ) {
484450 result [ k ] = fieldConfig ;
485451 }
@@ -491,7 +457,7 @@ export default class ElasticApiParser {
491457 return result ;
492458 }
493459
494- reassembleNestedFields ( fields : GraphQLFieldMap < * , * > ) : GraphQLFieldMap < * , * > {
460+ reassembleNestedFields ( fields : GraphQLFieldConfigMap < * , * > ) : GraphQLFieldConfigMap < * , * > {
495461 const result = { } ;
496462 Object . keys ( fields ) . forEach ( k => {
497463 const names = k . split ( '.' ) ;
@@ -510,10 +476,7 @@ export default class ElasticApiParser {
510476 } ,
511477 } ;
512478 }
513- TypeComposer . create ( result [ names [ 0 ] ] . type ) . setField (
514- names [ 1 ] ,
515- fields [ k ]
516- ) ;
479+ TypeComposer . create ( result [ names [ 0 ] ] . type ) . setField ( names [ 1 ] , fields [ k ] ) ;
517480 }
518481 } ) ;
519482
0 commit comments