@@ -30,7 +30,7 @@ const DGRAPHCLOUD_API_KEY_HEADER = "X-Auth-Token";
3030export class DgraphClientStub {
3131 private readonly addr : string ;
3232 private readonly options : Options ;
33- // tslint: disable-next-line no-any
33+ /* eslint- disable-next-line @typescript-eslint/ no-explicit- any */
3434 private readonly jsonParser : ( text : string ) => any ;
3535 private legacyApi : boolean ;
3636 private accessToken : string ;
@@ -42,13 +42,12 @@ export class DgraphClientStub {
4242 addr ?: string ,
4343 stubConfig : {
4444 legacyApi ?: boolean ;
45- // tslint: disable-next-line no -any
45+ // eslint- disable-next-line @typescript-eslint/no-explicit -any
4646 jsonParser ?( text : string ) : any ;
4747 } = { } ,
4848 options : Options = { } ,
4949 ) {
5050 if ( addr === undefined ) {
51- // tslint:disable-next-line no-http-string
5251 this . addr = "http://localhost:8080" ;
5352 } else {
5453 this . addr = addr ;
@@ -60,13 +59,13 @@ export class DgraphClientStub {
6059 this . jsonParser =
6160 stubConfig . jsonParser !== undefined
6261 ? stubConfig . jsonParser
63- : // tslint: disable-next-line no-unsafe-any
64- JSON . parse . bind ( JSON ) ;
62+ : // eslint- disable-next-line @typescript-eslint/tslint/config
63+ JSON . parse . bind ( JSON ) ;
6564 }
6665
6766 public async detectApiVersion ( ) : Promise < string > {
6867 const health = await this . getHealth ( ) ;
69- // tslint: disable-next-line no-unsafe-any no-string-literal
68+ // eslint- disable-next-line @typescript-eslint/tslint/config, @typescript-eslint/dot-notation
7069 let version : string = health [ "version" ] || health [ 0 ] . version ;
7170 if ( version === undefined ) {
7271 version = "1.0.x" ;
@@ -205,19 +204,19 @@ export class DgraphClientStub {
205204 ) {
206205 body = `{
207206 ${
208- mu . setNquads === undefined
209- ? ""
210- : `set {
207+ mu . setNquads === undefined
208+ ? ""
209+ : `set {
211210 ${ mu . setNquads }
212211 }`
213- }
212+ }
214213 ${
215- mu . deleteNquads === undefined
216- ? ""
217- : `delete {
214+ mu . deleteNquads === undefined
215+ ? ""
216+ : `delete {
218217 ${ mu . deleteNquads }
219218 }`
220- }
219+ }
221220 }` ;
222221 } else if ( mu . mutation !== undefined ) {
223222 body = mu . mutation ;
@@ -250,7 +249,7 @@ export class DgraphClientStub {
250249 let nextDelim = "?" ;
251250 if ( mu . startTs > 0 ) {
252251 url +=
253- ( ! this . legacyApi ? ` ?startTs=` : `/` ) + mu . startTs . toString ( ) ;
252+ ( ! this . legacyApi ? " ?startTs=" : "/" ) + mu . startTs . toString ( ) ;
254253 nextDelim = "&" ;
255254 }
256255
@@ -428,15 +427,15 @@ export class DgraphClientStub {
428427 return this . callAPI ( "state" , this . options ) ;
429428 }
430429
431- public setAutoRefresh ( val : boolean ) {
430+ public setAutoRefresh ( val : boolean ) : void {
432431 if ( ! val ) {
433432 this . cancelRefreshTimer ( ) ;
434433 }
435434 this . autoRefresh = val ;
436435 this . maybeStartRefreshTimer ( this . accessToken ) ;
437436 }
438437
439- public setAlphaAuthToken ( authToken : string ) {
438+ public setAlphaAuthToken ( authToken : string ) : void {
440439 if ( this . options . headers === undefined ) {
441440 this . options . headers = { } ;
442441 }
@@ -445,51 +444,46 @@ export class DgraphClientStub {
445444
446445 /**
447446 * @deprecated since v21.3 and will be removed in v21.07 release.
448- * Please use {@link setCloudApiKey} instead.
447+ * Please use {@link setCloudApiKey} instead.
449448 */
450-
451- public setSlashApiKey ( apiKey : string ) {
449+ public setSlashApiKey ( apiKey : string ) : void {
452450 this . setCloudApiKey ( apiKey ) ;
453451 }
454452
455- public setCloudApiKey ( apiKey : string ) {
453+ public setCloudApiKey ( apiKey : string ) : void {
456454 if ( this . options . headers === undefined ) {
457455 this . options . headers = { } ;
458456 }
459457 this . options . headers [ DGRAPHCLOUD_API_KEY_HEADER ] = apiKey ;
460458 }
461459
462- private cancelRefreshTimer ( ) {
460+ private cancelRefreshTimer ( ) : void {
463461 if ( this . autoRefreshTimer !== undefined ) {
464- // tslint: disable-next-line
465- clearTimeout ( < any > this . autoRefreshTimer ) ;
462+ // eslint- disable-next-line @typescript-eslint/no-explicit-any
463+ clearTimeout ( ( this . autoRefreshTimer as any ) ) ;
466464 this . autoRefreshTimer = undefined ;
467465 }
468466 }
469467
470- private maybeStartRefreshTimer ( accessToken ?: string ) {
468+ private maybeStartRefreshTimer ( accessToken ?: string ) : void {
471469 if ( accessToken === undefined || ! this . autoRefresh ) {
472470 return ;
473471 }
474472 this . cancelRefreshTimer ( ) ;
475473
476474 const timeToWait = Math . max (
477475 2000 ,
478- // tslint: disable-next-line no-unsafe-any
479- ( < { exp : number } > jwt . decode ( accessToken ) ) . exp * 1000 -
476+ // eslint- disable-next-line @typescript-eslint/tslint/config
477+ ( jwt . decode ( accessToken ) as { exp : number } ) . exp * 1000 -
480478 Date . now ( ) -
481479 AUTO_REFRESH_PREFETCH_TIME ,
482480 ) ;
483481
484- // tslint:disable-next-line no-unsafe-any no-any
485- this . autoRefreshTimer = < number > (
486- ( < unknown > (
487- setTimeout (
488- ( ) => ( this . refreshToken !== undefined ? this . login ( ) : 0 ) ,
489- timeToWait ,
490- )
491- ) )
492- ) ;
482+ // eslint-disable-next-line @typescript-eslint/tslint/config
483+ this . autoRefreshTimer = ( setTimeout (
484+ ( ) => ( this . refreshToken !== undefined ? this . login ( ) : 0 ) ,
485+ timeToWait ,
486+ ) as unknown ) as number ;
493487 }
494488
495489 private async callAPI < T > ( path : string , config : Config ) : Promise < T > {
@@ -499,40 +493,38 @@ export class DgraphClientStub {
499493 config . headers [ ACL_TOKEN_HEADER ] = this . accessToken ;
500494 }
501495
502- // tslint: disable-next-line no-unsafe-any
496+ // eslint- disable-next-line @typescript-eslint/tslint/config
503497 const response = await fetch ( url , config ) ;
504498
505- // tslint: disable-next-line no-unsafe-any
499+ // eslint- disable-next-line @typescript-eslint/tslint/config
506500 if ( response . status >= 300 || response . status < 200 ) {
507- // tslint: disable-next-line no-unsafe-any
501+ // eslint- disable-next-line @typescript-eslint/tslint/config
508502 throw new HTTPError ( response ) ;
509503 }
510504
511505 let json ;
512- // tslint: disable-next-line no-unsafe-any
506+ // eslint- disable-next-line @typescript-eslint/tslint/config
513507 const responseText : string = await response . text ( ) ;
514508
515509 try {
516- // tslint: disable-next-line no-unsafe -any
510+ // eslint- disable-next-line @typescript-eslint/ no-explicit -any
517511 json = this . jsonParser ( responseText ) ;
518512 } catch ( e ) {
519513 if ( config . acceptRawText ) {
520- return < T > ( < unknown > responseText ) ;
514+ return ( responseText as unknown ) as T ;
521515 }
522- const err : ErrorNonJson = < ErrorNonJson > (
523- new Error ( "Response is not JSON" )
524- ) ;
516+ const err : ErrorNonJson = new Error ( "Response is not JSON" ) as ErrorNonJson ;
525517 err . responseText = responseText ;
526518 throw err ;
527519 }
528- // tslint: disable-next-line no-unsafe -any
529- const errors = ( < { errors : APIResultError [ ] } > json ) . errors ;
520+ // eslint- disable-next-line @typescript-eslint/ no-explicit -any
521+ const errors = ( json as { errors : APIResultError [ ] } ) . errors ;
530522
531523 if ( errors !== undefined ) {
532524 throw new APIError ( url , errors ) ;
533525 }
534526
535- return < T > json ;
527+ return json as T ;
536528 }
537529
538530 private getURL ( path : string ) : string {
0 commit comments