11"use strict" ;
2+ var __assign = ( this && this . __assign ) || function ( ) {
3+ __assign = Object . assign || function ( t ) {
4+ for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
5+ s = arguments [ i ] ;
6+ for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) )
7+ t [ p ] = s [ p ] ;
8+ }
9+ return t ;
10+ } ;
11+ return __assign . apply ( this , arguments ) ;
12+ } ;
213var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
314 function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
415 return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
@@ -41,13 +52,19 @@ var jwt = require("jsonwebtoken");
4152var errors_1 = require ( "./errors" ) ;
4253var AUTO_REFRESH_PREFETCH_TIME = 5000 ;
4354var DgraphClientStub = ( function ( ) {
44- function DgraphClientStub ( addr , legacyApi ) {
55+ function DgraphClientStub ( addr , legacyApi , options ) {
4556 if ( addr === undefined ) {
4657 this . addr = "http://localhost:8080" ;
4758 }
4859 else {
4960 this . addr = addr ;
5061 }
62+ if ( options === undefined ) {
63+ this . options = { } ;
64+ }
65+ else {
66+ this . options = options ;
67+ }
5168 this . legacyApi = ! ! legacyApi ;
5269 }
5370 DgraphClientStub . prototype . detectApiVersion = function ( ) {
@@ -82,10 +99,7 @@ var DgraphClientStub = (function () {
8299 else {
83100 return Promise . reject ( "Invalid op argument in alter" ) ;
84101 }
85- return this . callAPI ( "alter" , {
86- method : "POST" ,
87- body : body ,
88- } ) ;
102+ return this . callAPI ( "alter" , __assign ( __assign ( { } , this . options ) , { method : "POST" , body : body } ) ) ;
89103 } ;
90104 DgraphClientStub . prototype . query = function ( req ) {
91105 var headers = { } ;
@@ -155,11 +169,7 @@ var DgraphClientStub = (function () {
155169 . join ( "&" ) ;
156170 }
157171 }
158- return this . callAPI ( url , {
159- method : "POST" ,
160- body : req . query ,
161- headers : headers ,
162- } ) ;
172+ return this . callAPI ( url , __assign ( __assign ( { } , this . options ) , { method : "POST" , body : req . query , headers : headers } ) ) ;
163173 } ;
164174 DgraphClientStub . prototype . mutate = function ( mu ) {
165175 var body ;
@@ -222,11 +232,8 @@ var DgraphClientStub = (function () {
222232 headers [ "X-Dgraph-CommitNow" ] = "true" ;
223233 }
224234 }
225- return this . callAPI ( url , {
226- method : "POST" ,
227- body : body ,
228- headers : headers ,
229- } ) ;
235+ return this . callAPI ( url , __assign ( __assign ( { } , this . options ) , { method : "POST" , body : body ,
236+ headers : headers } ) ) ;
230237 } ;
231238 DgraphClientStub . prototype . commit = function ( ctx ) {
232239 var body ;
@@ -239,16 +246,13 @@ var DgraphClientStub = (function () {
239246 var url = ! this . legacyApi
240247 ? "commit?startTs=" + ctx . start_ts
241248 : "commit/" + ctx . start_ts ;
242- return this . callAPI ( url , {
243- method : "POST" ,
244- body : body ,
245- } ) ;
249+ return this . callAPI ( url , __assign ( __assign ( { } , this . options ) , { method : "POST" , body : body } ) ) ;
246250 } ;
247251 DgraphClientStub . prototype . abort = function ( ctx ) {
248252 var url = ! this . legacyApi
249253 ? "commit?startTs=" + ctx . start_ts + "&abort=true"
250254 : "/abort/" + ctx . start_ts ;
251- return this . callAPI ( url , { method : "POST" } ) ;
255+ return this . callAPI ( url , __assign ( __assign ( { } , this . options ) , { method : "POST" } ) ) ;
252256 } ;
253257 DgraphClientStub . prototype . login = function ( userid , password , refreshToken ) {
254258 return __awaiter ( this , void 0 , void 0 , function ( ) {
@@ -300,24 +304,22 @@ var DgraphClientStub = (function () {
300304 DgraphClientStub . prototype . fetchUiKeywords = function ( ) {
301305 return __awaiter ( this , void 0 , void 0 , function ( ) {
302306 return __generator ( this , function ( _a ) {
303- return [ 2 , this . callAPI ( "ui/keywords" , { } ) ] ;
307+ return [ 2 , this . callAPI ( "ui/keywords" , this . options ) ] ;
304308 } ) ;
305309 } ) ;
306310 } ;
307311 DgraphClientStub . prototype . getHealth = function ( all ) {
308312 if ( all === void 0 ) { all = false ; }
309313 return __awaiter ( this , void 0 , void 0 , function ( ) {
310314 return __generator ( this , function ( _a ) {
311- return [ 2 , this . callAPI ( "health" + ( all ? "?all" : "" ) , {
312- acceptRawText : true ,
313- } ) ] ;
315+ return [ 2 , this . callAPI ( "health" + ( all ? "?all" : "" ) , __assign ( __assign ( { } , this . options ) , { acceptRawText : true } ) ) ] ;
314316 } ) ;
315317 } ) ;
316318 } ;
317319 DgraphClientStub . prototype . getState = function ( ) {
318320 return __awaiter ( this , void 0 , void 0 , function ( ) {
319321 return __generator ( this , function ( _a ) {
320- return [ 2 , this . callAPI ( "state" , { } ) ] ;
322+ return [ 2 , this . callAPI ( "state" , this . options ) ] ;
321323 } ) ;
322324 } ) ;
323325 } ;
0 commit comments