@@ -327,6 +327,34 @@ var DgraphClientStub = (function () {
327327 } ) ;
328328 } ) ;
329329 } ;
330+ DgraphClientStub . prototype . getHealth = function ( all ) {
331+ if ( all === void 0 ) { all = false ; }
332+ return __awaiter ( this , void 0 , void 0 , function ( ) {
333+ var url ;
334+ return __generator ( this , function ( _a ) {
335+ switch ( _a . label ) {
336+ case 0 :
337+ url = "health" + ( all ? "?all" : "" ) ;
338+ return [ 4 , this . callAPI ( url , {
339+ method : "GET" ,
340+ } ) ] ;
341+ case 1 : return [ 2 , _a . sent ( ) ] ;
342+ }
343+ } ) ;
344+ } ) ;
345+ } ;
346+ DgraphClientStub . prototype . getState = function ( ) {
347+ return __awaiter ( this , void 0 , void 0 , function ( ) {
348+ return __generator ( this , function ( _a ) {
349+ switch ( _a . label ) {
350+ case 0 : return [ 4 , this . callAPI ( "state" , {
351+ method : "GET" ,
352+ } ) ] ;
353+ case 1 : return [ 2 , _a . sent ( ) ] ;
354+ }
355+ } ) ;
356+ } ) ;
357+ } ;
330358 DgraphClientStub . prototype . setAutoRefresh = function ( val ) {
331359 if ( ! val ) {
332360 this . cancelRefreshTimer ( ) ;
@@ -352,27 +380,30 @@ var DgraphClientStub = (function () {
352380 } ;
353381 DgraphClientStub . prototype . callAPI = function ( path , config ) {
354382 return __awaiter ( this , void 0 , void 0 , function ( ) {
355- var url ;
383+ var url , response , json , errors ;
356384 return __generator ( this , function ( _a ) {
357- url = this . getURL ( path ) ;
358- if ( this . accessToken !== undefined && path !== "login" ) {
359- config . headers = config . headers !== undefined ? config . headers : { } ;
360- config . headers [ "X-Dgraph-AccessToken" ] = this . accessToken ;
361- }
362- return [ 2 , fetch ( url , config )
363- . then ( function ( response ) {
385+ switch ( _a . label ) {
386+ case 0 :
387+ url = this . getURL ( path ) ;
388+ if ( this . accessToken !== undefined && path !== "login" ) {
389+ config . headers = config . headers !== undefined ? config . headers : { } ;
390+ config . headers [ "X-Dgraph-AccessToken" ] = this . accessToken ;
391+ }
392+ return [ 4 , fetch ( url , config ) ] ;
393+ case 1 :
394+ response = _a . sent ( ) ;
364395 if ( response . status >= 300 || response . status < 200 ) {
365396 throw new Error ( "Invalid status code = " + response . status ) ;
366397 }
367- return response . json ( ) ;
368- } )
369- . then ( function ( json ) {
370- var errors = json . errors ;
398+ return [ 4 , response . json ( ) ] ;
399+ case 2 :
400+ json = _a . sent ( ) ;
401+ errors = json . errors ;
371402 if ( errors !== undefined ) {
372403 throw new errors_1 . APIError ( url , errors ) ;
373404 }
374- return json ;
375- } ) ] ;
405+ return [ 2 , json ] ;
406+ }
376407 } ) ;
377408 } ) ;
378409 } ;
0 commit comments