rqlite-js 2.5.5 → 2.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,10 @@ var _contentTypes = require("./content-types");
14
14
 
15
15
 
16
16
  var _errors = require("./errors");
17
- var _retryable = require("./retryable");function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);enumerableOnly && (symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;})), keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = null != arguments[i] ? arguments[i] : {};i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {(0, _defineProperty2.default)(target, key, source[key]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}return target;}
18
-
19
-
20
-
17
+ var _retryable = require("./retryable");function ownKeys(e, r) {var t = Object.keys(e);if (Object.getOwnPropertySymbols) {var o = Object.getOwnPropertySymbols(e);r && (o = o.filter(function (r) {return Object.getOwnPropertyDescriptor(e, r).enumerable;})), t.push.apply(t, o);}return t;}function _objectSpread(e) {for (var r = 1; r < arguments.length; r++) {var t = null != arguments[r] ? arguments[r] : {};r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {(0, _defineProperty2.default)(e, r, t[r]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));});}return e;} /**
18
+ * Plain HTTP client to be used when creating RQLite specific API HTTP clients
19
+ * @module http-request
20
+ */
21
21
 
22
22
 
23
23
  /**
@@ -58,18 +58,18 @@ var _retryable = require("./retryable");function ownKeys(object, enumerableOnly)
58
58
  /**
59
59
  * The default timeout value
60
60
  */
61
- const DEAULT_TIMEOUT = 30000;
61
+ const DEAULT_TIMEOUT = exports.DEAULT_TIMEOUT = 30000;
62
62
 
63
63
  /**
64
64
  * The default to retry a request using the next host in the chain
65
- */exports.DEAULT_TIMEOUT = DEAULT_TIMEOUT;
66
- const DEAULT_RETRY_DELAY = 30000;
65
+ */
66
+ const DEAULT_RETRY_DELAY = exports.DEAULT_RETRY_DELAY = 30000;
67
67
 
68
68
  /**
69
69
  * Create default header for all HTTP requests
70
70
  * @param {Object} [headers={}] HTTP headers to send with the request
71
71
  * @returns {Object} The headers with defaults applied
72
- */exports.DEAULT_RETRY_DELAY = DEAULT_RETRY_DELAY;
72
+ */
73
73
  function createDefaultHeaders(headers = {}) {
74
74
  const _headers$Accept = headers.Accept,Accept = _headers$Accept === void 0 ? _contentTypes.CONTENT_TYPE_APPLICATION_JSON : _headers$Accept;
75
75
  return _objectSpread(_objectSpread({}, headers), {}, { Accept });
@@ -89,14 +89,14 @@ function cleanPath(path) {
89
89
  * backoff algorithm.
90
90
  * @param {Number} attempt The retry attempt
91
91
  * @param {Number} base The base of the exponential backoff
92
- * @param {Number} pow The exponential power
92
+ * @param {Number} exponent The exponential power
93
93
  * @returns {Number} The time to wait in milliseconds
94
94
  */
95
- function getWaitTimeExponential(attempt = 0, base = 100, pow = 2) {
95
+ function getWaitTimeExponential(attempt = 0, base = 100, exponent = 2) {
96
96
  if (attempt === 0) {
97
97
  return 0;
98
98
  }
99
- return Math.pow(pow, attempt) * base;
99
+ return Math.pow(exponent, attempt) * base;
100
100
  }
101
101
 
102
102
  /**
@@ -105,78 +105,83 @@ function getWaitTimeExponential(attempt = 0, base = 100, pow = 2) {
105
105
  * server
106
106
  */
107
107
  class HttpRequest {
108
- /**
109
- * The index of the host in this.hosts which will be tried
110
- * first before attempting other hosts
111
- * @type {Number}
112
- */
113
108
 
114
109
 
115
- /**
116
- * Whether or not the setNextActiveHostIndex() should
117
- * perform a round robin strategy
118
- */
119
110
 
120
111
 
121
- /**
122
- * The regex pattern to check if a uri is absolute or relative,
123
- * if it is absolute the host is not appended
124
- */
125
112
 
126
113
 
127
- /**
128
- * A list of hosts that are tried in round robin fashion
129
- * when certain HTTP responses are received
130
- * @type {String[]}
131
- */
132
114
 
133
115
 
134
- /**
135
- * @type {import('http').Agent} The http agent if it is set
136
- */
137
116
 
138
117
 
139
- /**
140
- * @type {import('https').Agent} The https agent if it is set
141
- */
142
118
 
143
119
 
144
- /**
145
- * The host list index of the leader node defaults
146
- * to the first host
147
- * @type {Number}
148
- */
149
120
 
150
121
 
151
- /**
152
- * Http error codes which are considered retryable
153
- * @type {Set}
154
- */
155
122
 
156
123
 
157
- /**
158
- * Http status codes which are considered retryable
159
- * @type {Set}
160
- */
161
124
 
162
125
 
163
- /**
164
- * Http methods which are considered retryable
165
- * @type {Set}
166
- */
167
126
 
168
127
 
169
- /**
170
- * The exponential backoff base for retries
171
- */
172
128
 
173
129
 
174
- /**
175
- * Authentication Map
176
- * @type {Map}
177
- * @property {String} username
178
- * @property {String} password
179
- */
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
180
185
 
181
186
 
182
187
  /**
@@ -199,58 +204,63 @@ class HttpRequest {
199
204
  * @param {Set|String[]} [options.retryableHttpMethods] The list of retryable http methods
200
205
  * @param {Number} [options.exponentailBackoffBase] The value for exponentail backoff base
201
206
  * for retry exponential backoff
202
- */
203
- constructor(hosts, options = {}) {(0, _defineProperty2.default)(this, "activeHostIndex", 0);(0, _defineProperty2.default)(this, "activeHostRoundRobin", true);(0, _defineProperty2.default)(this, "absoluteUriPattern", /^https?:\/\//);(0, _defineProperty2.default)(this, "hosts", []);(0, _defineProperty2.default)(this, "httpAgent", void 0);(0, _defineProperty2.default)(this, "httpsAgent", void 0);(0, _defineProperty2.default)(this, "leaderHostIndex", 0);(0, _defineProperty2.default)(this, "retryableErrorCodes", _retryable.RETRYABLE_ERROR_CODES);(0, _defineProperty2.default)(this, "retryableStatusCodes", _retryable.RETRYABLE_STATUS_CODES);(0, _defineProperty2.default)(this, "retryableHttpMethods", _retryable.RETRYABLE_HTTP_METHODS);(0, _defineProperty2.default)(this, "exponentailBackoffBase", 100);(0, _defineProperty2.default)(this, "authentication", new Map());
204
- this.setHosts(hosts);
205
- if (this.getTotalHosts() === 0) {
206
- throw new Error('At least one host must be provided');
207
- }
208
- const _options$activeHostRo =
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
- options.activeHostRoundRobin,activeHostRoundRobin = _options$activeHostRo === void 0 ? true : _options$activeHostRo,httpAgent = options.httpAgent,httpsAgent = options.httpsAgent,retryableErrorCodes = options.retryableErrorCodes,retryableStatusCodes = options.retryableStatusCodes,retryableHttpMethods = options.retryableHttpMethods,exponentailBackoffBase = options.exponentailBackoffBase,authentication = options.authentication;
218
- if (typeof authentication === 'object') {
219
- const username = authentication.username,password = authentication.password;
220
- if (username) {
221
- this.authentication.set('username', username);
222
- }
223
- if (password) {
224
- this.authentication.set('password', password);
225
- }
226
- }
227
- if (typeof activeHostRoundRobin !== 'undefined') {
228
- this.setActiveHostRoundRobin(activeHostRoundRobin);
229
- }
230
- if (typeof httpAgent !== 'undefined') {
231
- this.setHttpAgent(httpAgent);
232
- }
233
- if (typeof httpsAgent !== 'undefined') {
234
- this.setHttpsAgent(httpsAgent);
235
- }
236
- if (retryableErrorCodes instanceof Set || Array.isArray(retryableErrorCodes)) {
237
- this.setRetryableErrorCodes(
238
- Array.isArray(retryableErrorCodes) ? Set(retryableErrorCodes) : retryableErrorCodes);
239
-
240
- }
241
- if (retryableStatusCodes instanceof Set || Array.isArray(retryableStatusCodes)) {
242
- this.setRetryableStatusCodes(
243
- Array.isArray(retryableStatusCodes) ? Set(retryableStatusCodes) : retryableStatusCodes);
244
-
207
+ * @param {Number} [options.exponentailBackoffExponent] Exponent to increase backoff each try
208
+ */
209
+ constructor(hosts, options = {}) {/**
210
+ * The index of the host in this.hosts which will be tried
211
+ * first before attempting other hosts
212
+ * @type {Number}
213
+ */(0, _defineProperty2.default)(this, "activeHostIndex", 0); /**
214
+ * Whether or not the setNextActiveHostIndex() should
215
+ * perform a round robin strategy
216
+ */(0, _defineProperty2.default)(this, "activeHostRoundRobin", true); /**
217
+ * The regex pattern to check if a uri is absolute or relative,
218
+ * if it is absolute the host is not appended
219
+ */(0, _defineProperty2.default)(this, "absoluteUriPattern", /^https?:\/\//); /**
220
+ * A list of hosts that are tried in round robin fashion
221
+ * when certain HTTP responses are received
222
+ * @type {String[]}
223
+ */(0, _defineProperty2.default)(this, "hosts", []); /**
224
+ * @type {import('http').Agent} The http agent if it is set
225
+ */(0, _defineProperty2.default)(this, "httpAgent", void 0); /**
226
+ * @type {import('https').Agent} The https agent if it is set
227
+ */(0, _defineProperty2.default)(this, "httpsAgent", void 0); /**
228
+ * The host list index of the leader node defaults
229
+ * to the first host
230
+ * @type {Number}
231
+ */(0, _defineProperty2.default)(this, "leaderHostIndex", 0); /**
232
+ * Http error codes which are considered retryable
233
+ * @type {Set}
234
+ */(0, _defineProperty2.default)(this, "retryableErrorCodes", _retryable.RETRYABLE_ERROR_CODES); /**
235
+ * Http status codes which are considered retryable
236
+ * @type {Set}
237
+ */(0, _defineProperty2.default)(this, "retryableStatusCodes", _retryable.RETRYABLE_STATUS_CODES); /**
238
+ * Http methods which are considered retryable
239
+ * @type {Set}
240
+ */(0, _defineProperty2.default)(this, "retryableHttpMethods", _retryable.RETRYABLE_HTTP_METHODS); /**
241
+ * The exponential backoff base for retries
242
+ */(0, _defineProperty2.default)(this, "exponentailBackoffBase", 100); /**
243
+ * The exponent to increase backoff each try
244
+ */(0, _defineProperty2.default)(this, "exponentailBackoffExponent", 1.1); /**
245
+ * Authentication Map
246
+ * @type {Map}
247
+ * @property {String} username
248
+ * @property {String} password
249
+ */(0, _defineProperty2.default)(this, "authentication", new Map());this.setHosts(hosts);if (this.getTotalHosts() === 0) {throw new Error('At least one host must be provided');}const _options$activeHostRo = options.activeHostRoundRobin,activeHostRoundRobin = _options$activeHostRo === void 0 ? true : _options$activeHostRo,httpAgent = options.httpAgent,httpsAgent = options.httpsAgent,retryableErrorCodes = options.retryableErrorCodes,retryableStatusCodes = options.retryableStatusCodes,retryableHttpMethods = options.retryableHttpMethods,exponentailBackoffExponent = options.exponentailBackoffExponent,exponentailBackoffBase = options.exponentailBackoffBase,authentication = options.authentication;if (typeof authentication === 'object') {const username = authentication.username,password = authentication.password;if (username) {this.authentication.set('username', username);}if (password) {this.authentication.set('password', password);}}if (typeof activeHostRoundRobin !== 'undefined') {this.setActiveHostRoundRobin(activeHostRoundRobin);}if (typeof httpAgent !== 'undefined') {this.setHttpAgent(httpAgent);}if (typeof httpsAgent !== 'undefined') {this.setHttpsAgent(httpsAgent);}if (retryableErrorCodes instanceof Set || Array.isArray(retryableErrorCodes)) {this.setRetryableErrorCodes(Array.isArray(retryableErrorCodes) ? Set(retryableErrorCodes) : retryableErrorCodes);}if (retryableStatusCodes instanceof Set || Array.isArray(retryableStatusCodes)) {this.setRetryableStatusCodes(
250
+ Array.isArray(retryableStatusCodes) ? Set(retryableStatusCodes) : retryableStatusCodes
251
+ );
245
252
  }
246
253
  if (retryableHttpMethods instanceof Set || Array.isArray(retryableHttpMethods)) {
247
254
  this.setRetryableHttpMethods(
248
- Array.isArray(retryableHttpMethods) ? Set(retryableHttpMethods) : retryableHttpMethods);
249
-
255
+ Array.isArray(retryableHttpMethods) ? Set(retryableHttpMethods) : retryableHttpMethods
256
+ );
250
257
  }
251
258
  if (Number.isFinite(exponentailBackoffBase)) {
252
259
  this.setExponentailBackoffBase(exponentailBackoffBase);
253
260
  }
261
+ if (Number.isFinite(exponentailBackoffExponent)) {
262
+ this.setExponentailBackoffExponent(exponentailBackoffExponent);
263
+ }
254
264
  }
255
265
 
256
266
  /**
@@ -285,6 +295,22 @@ class HttpRequest {
285
295
  return this.exponentailBackoffBase;
286
296
  }
287
297
 
298
+ /**
299
+ * Set the exponentail backoff exponent
300
+ * @param {Number} exponentailBackoffExponent
301
+ */
302
+ setExponentailBackoffExponent(exponentailBackoffExponent) {
303
+ this.exponentailBackoffExponent = exponentailBackoffExponent;
304
+ }
305
+
306
+ /**
307
+ * Get the exponentail backoff exponent
308
+ * @return {Number} The exponentail backoff exponent
309
+ */
310
+ getExponentailBackoffExponent() {
311
+ return this.exponentailBackoffExponent;
312
+ }
313
+
288
314
  /**
289
315
  * Set the retryable error codes
290
316
  * @param {Set} retryableErrorCodes
@@ -552,10 +578,10 @@ class HttpRequest {
552
578
  */
553
579
  requestIsRetryable(options = {}) {
554
580
  const
555
- statusCode =
581
+ statusCode =
556
582
 
557
583
 
558
- options.statusCode,errorCode = options.errorCode,httpMethod = options.httpMethod;
584
+ options.statusCode,errorCode = options.errorCode,httpMethod = options.httpMethod;
559
585
  // Honor strictly the http method
560
586
  if (!this.getRetryableHttpMethods().has(httpMethod)) {
561
587
  return false;
@@ -578,7 +604,7 @@ class HttpRequest {
578
604
  */
579
605
  fetch(options = {}) {var _this = this;return (0, _asyncToGenerator2.default)(function* () {
580
606
  const
581
- body =
607
+ body =
582
608
 
583
609
 
584
610
 
@@ -594,7 +620,8 @@ class HttpRequest {
594
620
 
595
621
 
596
622
 
597
- options.body,_options$headers = options.headers,headers = _options$headers === void 0 ? {} : _options$headers,_options$httpMethod = options.httpMethod,httpMethod = _options$httpMethod === void 0 ? _httpMethods.HTTP_METHOD_GET : _options$httpMethod,query = options.query,_options$stream = options.stream,stream = _options$stream === void 0 ? false : _options$stream,_options$timeout = options.timeout,timeout = _options$timeout === void 0 ? DEAULT_TIMEOUT : _options$timeout,_options$useLeader = options.useLeader,useLeader = _options$useLeader === void 0 ? false : _options$useLeader,_options$retries = options.retries,retries = _options$retries === void 0 ? _this.getTotalHosts() * 3 : _options$retries,_options$maxRedirects = options.maxRedirects,maxRedirects = _options$maxRedirects === void 0 ? 10 : _options$maxRedirects,_options$attempt = options.attempt,attempt = _options$attempt === void 0 ? 0 : _options$attempt,_options$retryAttempt = options.retryAttempt,retryAttempt = _options$retryAttempt === void 0 ? 0 : _options$retryAttempt,_options$redirectAtte = options.redirectAttempt,redirectAttempt = _options$redirectAtte === void 0 ? 0 : _options$redirectAtte,attemptHostIndex = options.attemptHostIndex,_options$exponentailB = options.exponentailBackoffBase,exponentailBackoffBase = _options$exponentailB === void 0 ? _this.getExponentailBackoffBase() : _options$exponentailB,_options$httpAgent = options.httpAgent,httpAgent = _options$httpAgent === void 0 ? _this.getHttpAgent() : _options$httpAgent,_options$httpsAgent = options.httpsAgent,httpsAgent = _options$httpsAgent === void 0 ? _this.getHttpsAgent() : _options$httpsAgent;
623
+
624
+ options.body,_options$headers = options.headers,headers = _options$headers === void 0 ? {} : _options$headers,_options$httpMethod = options.httpMethod,httpMethod = _options$httpMethod === void 0 ? _httpMethods.HTTP_METHOD_GET : _options$httpMethod,query = options.query,_options$stream = options.stream,stream = _options$stream === void 0 ? false : _options$stream,_options$timeout = options.timeout,timeout = _options$timeout === void 0 ? DEAULT_TIMEOUT : _options$timeout,_options$useLeader = options.useLeader,useLeader = _options$useLeader === void 0 ? false : _options$useLeader,_options$retries = options.retries,retries = _options$retries === void 0 ? _this.getTotalHosts() * 3 : _options$retries,_options$maxRedirects = options.maxRedirects,maxRedirects = _options$maxRedirects === void 0 ? 10 : _options$maxRedirects,_options$attempt = options.attempt,attempt = _options$attempt === void 0 ? 0 : _options$attempt,_options$retryAttempt = options.retryAttempt,retryAttempt = _options$retryAttempt === void 0 ? 0 : _options$retryAttempt,_options$redirectAtte = options.redirectAttempt,redirectAttempt = _options$redirectAtte === void 0 ? 0 : _options$redirectAtte,attemptHostIndex = options.attemptHostIndex,_options$exponentailB = options.exponentailBackoffExponent,exponentailBackoffExponent = _options$exponentailB === void 0 ? _this.getExponentailBackoffExponent() : _options$exponentailB,_options$exponentailB2 = options.exponentailBackoffBase,exponentailBackoffBase = _options$exponentailB2 === void 0 ? _this.getExponentailBackoffBase() : _options$exponentailB2,_options$httpAgent = options.httpAgent,httpAgent = _options$httpAgent === void 0 ? _this.getHttpAgent() : _options$httpAgent,_options$httpsAgent = options.httpsAgent,httpsAgent = _options$httpsAgent === void 0 ? _this.getHttpsAgent() : _options$httpsAgent;
598
625
  // Honor the supplied attemptHostIndex or get the active host
599
626
  const activeHost = Number.isFinite(attemptHostIndex) ? _this.getHosts()[attemptHostIndex] :
600
627
  _this.getActiveHost(useLeader);
@@ -608,8 +635,8 @@ class HttpRequest {
608
635
  if (_this.authentication.size) {
609
636
  auth = {
610
637
  username: _this.authentication.get('username'),
611
- password: _this.authentication.get('password') };
612
-
638
+ password: _this.authentication.get('password')
639
+ };
613
640
  }
614
641
  const response = yield (0, _axios.default)({
615
642
  url: uri,
@@ -625,15 +652,15 @@ class HttpRequest {
625
652
  httpAgent,
626
653
  paramsSerializer(params) {
627
654
  return (0, _qs.stringify)(params, { arrayFormat: 'brackets' });
628
- } });
629
-
655
+ }
656
+ });
630
657
  if (stream) {
631
658
  return response.data;
632
659
  }
633
660
  return {
634
661
  body: response.data,
635
- status: response.status };
636
-
662
+ status: response.status
663
+ };
637
664
  } catch (e) {
638
665
  const _e$response = e.response,response = _e$response === void 0 ? {} : _e$response,errorCode = e.code;
639
666
  const responseStatus = response.status,_response$headers = response.headers,responseHeaders = _response$headers === void 0 ? {} : _response$headers;
@@ -641,8 +668,8 @@ class HttpRequest {
641
668
  const retryable = _this.requestIsRetryable({
642
669
  statusCode: responseStatus,
643
670
  errorCode,
644
- httpMethod });
645
-
671
+ httpMethod
672
+ });
646
673
  // Save the next active host index and pass it to retry manually
647
674
  let nextAttemptHostIndex = Number.isFinite(attemptHostIndex) ? attemptHostIndex :
648
675
  _this.getActiveHostIndex();
@@ -671,21 +698,26 @@ class HttpRequest {
671
698
  uri: location,
672
699
  attempt: attempt + 1,
673
700
  redirectAttempt: redirectAttempt + 1,
674
- attemptHostIndex: nextAttemptHostIndex }));
675
-
701
+ attemptHostIndex: nextAttemptHostIndex })
702
+ );
676
703
  }
677
704
  if (retryable && retryAttempt < retries) {
678
- const waitTime = getWaitTimeExponential(retryAttempt, exponentailBackoffBase);
679
- const delayPromise = new Promise((resolve) => {
680
- setTimeout(resolve, waitTime);
705
+ const waitTime = getWaitTimeExponential(
706
+ retryAttempt,
707
+ exponentailBackoffBase,
708
+ exponentailBackoffExponent
709
+ );
710
+ yield new Promise((resolve) => {
711
+ setTimeout(() => {
712
+ resolve(undefined);
713
+ }, waitTime);
681
714
  });
682
- yield delayPromise;
683
715
  return _this.fetch(_objectSpread(_objectSpread({},
684
716
  options), {}, {
685
717
  attempt: attempt + 1,
686
718
  retryAttempt: retryAttempt + 1,
687
- attemptHostIndex: nextAttemptHostIndex }));
688
-
719
+ attemptHostIndex: nextAttemptHostIndex })
720
+ );
689
721
  }
690
722
  throw e;
691
723
  }})();
@@ -707,5 +739,6 @@ class HttpRequest {
707
739
  */
708
740
  post(options = {}) {var _this3 = this;return (0, _asyncToGenerator2.default)(function* () {
709
741
  return _this3.fetch(_objectSpread(_objectSpread({}, options), {}, { httpMethod: _httpMethods.HTTP_METHOD_POST }));})();
710
- }}exports.default = HttpRequest;
742
+ }
743
+ }exports.default = HttpRequest;
711
744
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DEAULT_TIMEOUT","DEAULT_RETRY_DELAY","createDefaultHeaders","headers","Accept","CONTENT_TYPE_APPLICATION_JSON","cleanPath","path","String","replace","getWaitTimeExponential","attempt","base","pow","HttpRequest","constructor","hosts","options","RETRYABLE_ERROR_CODES","RETRYABLE_STATUS_CODES","RETRYABLE_HTTP_METHODS","Map","setHosts","getTotalHosts","Error","activeHostRoundRobin","httpAgent","httpsAgent","retryableErrorCodes","retryableStatusCodes","retryableHttpMethods","exponentailBackoffBase","authentication","username","password","set","setActiveHostRoundRobin","setHttpAgent","setHttpsAgent","Set","Array","isArray","setRetryableErrorCodes","setRetryableStatusCodes","setRetryableHttpMethods","Number","isFinite","setExponentailBackoffBase","setAuthentication","getExponentailBackoffBase","getRetryableErrorCodes","getRetryableStatusCodes","getRetryableHttpMethods","getHttpAgent","getHttpsAgent","split","reduce","acc","v","host","trim","concat","getHosts","findHostIndex","parsedHostToFind","findIndex","parsedHost","every","field","getActiveHost","useLeader","activeHostIndex","getLeaderHostIndex","getActiveHostIndex","setActiveHostIndex","totalHosts","leaderHostIndex","setLeaderHostIndex","getActiveHostRoundRobin","getNextActiveHostIndex","nextIndex","setNextActiveHostIndex","length","uriIsAbsolute","uri","absoluteUriPattern","test","requestIsRetryable","statusCode","errorCode","httpMethod","has","fetch","body","HTTP_METHOD_GET","query","stream","timeout","retries","maxRedirects","retryAttempt","redirectAttempt","attemptHostIndex","activeHost","auth","size","get","response","url","data","responseType","method","params","paramsSerializer","arrayFormat","status","e","code","responseStatus","responseHeaders","retryable","nextAttemptHostIndex","location","undefined","newLeaderHostIndex","waitTime","delayPromise","Promise","resolve","setTimeout","post","HTTP_METHOD_POST"],"sources":["../../es6/http-request/index.js"],"sourcesContent":["/**\n * Plain HTTP client to be used when creating RQLite specific API HTTP clients\n * @module http-request\n */\nimport axios from 'axios'\nimport { stringify as stringifyQuery } from 'qs'\nimport { parse as parseUrl } from 'url'\nimport {\n HTTP_METHOD_GET,\n HTTP_METHOD_POST,\n} from './http-methods'\nimport {\n CONTENT_TYPE_APPLICATION_JSON,\n // CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n} from './content-types'\nimport { ERROR_HTTP_REQUEST_MAX_REDIRECTS } from './errors'\nimport {\n RETRYABLE_ERROR_CODES,\n RETRYABLE_HTTP_METHODS,\n RETRYABLE_STATUS_CODES,\n} from './retryable'\n\n/**\n * RQliteJS HTTP Request options\n * @typedef HttpRequestOptions\n * @type {Object}\n * @property {Object} [auth] A object for user authentication\n * @property {String} [auth.username] The username for authentication\n * @property {String} [auth.password] The username for authentication\n * @property {Object} [body] The body of the HTTP request\n * @property {Object} [headers={}] HTTP headers to send with the request\n * @property {String} [httpMethod=HTTP_METHOD_GET] The HTTP method for the request\n * i.e. GET or POST\n * @property {Object} [query] An object with the query to send with the HTTP request\n * @property {Boolean} [stream=false] When true the returned value is a request object with\n * stream support instead of a request-promise result\n * @property {Number} [timeout=DEAULT_TIMEOUT] Optional timeout to override default\n * @property {String} uri The uri for the request which can be a relative path to use\n * the currently active host or a full i.e. http://localhost:4001/db/query which is used\n * literally\n * @property {Boolean} [useLeader=false] When true the request will use the master host, the\n * first host in this.hosts, this is ideal for write operations to skip the redirect\n * @property {Number} [retries] The number of retries, defaults to the number of\n * hosts times 3\n * @property {Number} [maxRedirects=10] The maximum number of HTTP redirects to follow before\n * throwing an error\n * @property {Number} [attempt=0] The current attempt count when retrying or redirecting\n * @property {Number} [retryAttempt=0] The current attempt based on retry logic\n * @property {Number} [redirectAttempt=0] The current attempt based on redirect logic\n * @property {Number} [attemptHostIndex] When in a retry state the host index of the last\n * attempt which is used to get the next host index\n * @property {import('http').Agent} [httpAgent] An option http agent, useful for\n * keepalive pools using plain HTTP\n * @property {import('https').Agent} [httpsAgent] An option http agent, useful\n * for keepalive pools using SSL\n */\n\n/**\n * The default timeout value\n */\nexport const DEAULT_TIMEOUT = 30000\n\n/**\n * The default to retry a request using the next host in the chain\n */\nexport const DEAULT_RETRY_DELAY = 30000\n\n/**\n * Create default header for all HTTP requests\n * @param {Object} [headers={}] HTTP headers to send with the request\n * @returns {Object} The headers with defaults applied\n */\nexport function createDefaultHeaders (headers = {}) {\n const { Accept = CONTENT_TYPE_APPLICATION_JSON } = headers\n return { ...headers, Accept }\n}\n\n/**\n * Clean the request path remove / from the beginning\n * @param {String} path The path to clean\n * @returns {String} The clean path\n */\nfunction cleanPath (path) {\n return String(path).replace(/^\\//, '')\n}\n\n/**\n * Returns the next wait interval, in milliseconds, using an exponential\n * backoff algorithm.\n * @param {Number} attempt The retry attempt\n * @param {Number} base The base of the exponential backoff\n * @param {Number} pow The exponential power\n * @returns {Number} The time to wait in milliseconds\n */\nexport function getWaitTimeExponential (attempt = 0, base = 100, pow = 2) {\n if (attempt === 0) {\n return 0\n }\n return (pow ** attempt) * base\n}\n\n/**\n * Generic HTTP Request class which all RQLiteJS client\n * should extend for consistent communitication with an RQLite\n * server\n */\nexport default class HttpRequest {\n /**\n * The index of the host in this.hosts which will be tried\n * first before attempting other hosts\n * @type {Number}\n */\n activeHostIndex = 0\n\n /**\n * Whether or not the setNextActiveHostIndex() should\n * perform a round robin strategy\n */\n activeHostRoundRobin = true\n\n /**\n * The regex pattern to check if a uri is absolute or relative,\n * if it is absolute the host is not appended\n */\n absoluteUriPattern = /^https?:\\/\\//\n\n /**\n * A list of hosts that are tried in round robin fashion\n * when certain HTTP responses are received\n * @type {String[]}\n */\n hosts = []\n\n /**\n * @type {import('http').Agent} The http agent if it is set\n */\n httpAgent\n\n /**\n * @type {import('https').Agent} The https agent if it is set\n */\n httpsAgent\n\n /**\n * The host list index of the leader node defaults\n * to the first host\n * @type {Number}\n */\n leaderHostIndex = 0\n\n /**\n * Http error codes which are considered retryable\n * @type {Set}\n */\n retryableErrorCodes = RETRYABLE_ERROR_CODES\n\n /**\n * Http status codes which are considered retryable\n * @type {Set}\n */\n retryableStatusCodes = RETRYABLE_STATUS_CODES\n\n /**\n * Http methods which are considered retryable\n * @type {Set}\n */\n retryableHttpMethods = RETRYABLE_HTTP_METHODS\n\n /**\n * The exponential backoff base for retries\n */\n exponentailBackoffBase = 100\n\n /**\n * Authentication Map\n * @type {Map}\n * @property {String} username\n * @property {String} password\n */\n authentication = new Map()\n\n /**\n * Construtor for HttpRequest\n * @param {String[]|String} hosts An array of RQLite hosts or a string\n * that will be split on \",\" to create an array of hosts, the first\n * host will be tried first when there are multiple hosts\n * @param {Object} [options={}] Additional options\n * @param {Object} [options.authentication] Authentication options\n * @param {String} [options.authentication.username] The host authentication username\n * @param {String} [options.authentication.password] The host authentication password\n * @param {Boolean} [options.activeHostRoundRobin=true] If true this.setNextActiveHostIndex()\n * will perform a round robin when called\n * @param {import('http').Agent} [options.httpAgent] An option http agent, useful for\n * keepalive pools using plain HTTP\n * @param {import('https').Agent} [options.httpsAgent] An option http agent, useful\n * for keepalive pools using SSL\n * @param {Set|String[]} [options.retryableErrorCodes] The list of retryable error codes\n * @param {Set|Number[]} [options.retryableStatusCodes] The list of retryable http status codes\n * @param {Set|String[]} [options.retryableHttpMethods] The list of retryable http methods\n * @param {Number} [options.exponentailBackoffBase] The value for exponentail backoff base\n * for retry exponential backoff\n */\n constructor (hosts, options = {}) {\n this.setHosts(hosts)\n if (this.getTotalHosts() === 0) {\n throw new Error('At least one host must be provided')\n }\n const {\n activeHostRoundRobin = true,\n httpAgent,\n httpsAgent,\n retryableErrorCodes,\n retryableStatusCodes,\n retryableHttpMethods,\n exponentailBackoffBase,\n authentication,\n } = options\n if (typeof authentication === 'object') {\n const { username, password } = authentication\n if (username) {\n this.authentication.set('username', username)\n }\n if (password) {\n this.authentication.set('password', password)\n }\n }\n if (typeof activeHostRoundRobin !== 'undefined') {\n this.setActiveHostRoundRobin(activeHostRoundRobin)\n }\n if (typeof httpAgent !== 'undefined') {\n this.setHttpAgent(httpAgent)\n }\n if (typeof httpsAgent !== 'undefined') {\n this.setHttpsAgent(httpsAgent)\n }\n if (retryableErrorCodes instanceof Set || Array.isArray(retryableErrorCodes)) {\n this.setRetryableErrorCodes(\n Array.isArray(retryableErrorCodes) ? Set(retryableErrorCodes) : retryableErrorCodes,\n )\n }\n if (retryableStatusCodes instanceof Set || Array.isArray(retryableStatusCodes)) {\n this.setRetryableStatusCodes(\n Array.isArray(retryableStatusCodes) ? Set(retryableStatusCodes) : retryableStatusCodes,\n )\n }\n if (retryableHttpMethods instanceof Set || Array.isArray(retryableHttpMethods)) {\n this.setRetryableHttpMethods(\n Array.isArray(retryableHttpMethods) ? Set(retryableHttpMethods) : retryableHttpMethods,\n )\n }\n if (Number.isFinite(exponentailBackoffBase)) {\n this.setExponentailBackoffBase(exponentailBackoffBase)\n }\n }\n\n /**\n * Set authentication information\n * @param {Object} [authentication] Authentication data\n * @param {String} [authentication.username] The host authentication username\n * @param {String} [authentication.password] The host authentication password\n */\n setAuthentication (authentication = {}) {\n const { username, password } = authentication\n if (username) {\n this.authentication.set('username', username)\n }\n if (password) {\n this.authentication.set('password', password)\n }\n }\n\n /**\n * Set the exponentail backoff base\n * @param {Number} exponentailBackoffBase\n */\n setExponentailBackoffBase (exponentailBackoffBase) {\n this.exponentailBackoffBase = exponentailBackoffBase\n }\n\n /**\n * Get the exponentail backoff base\n * @return {Number} The exponentail backoff base\n */\n getExponentailBackoffBase () {\n return this.exponentailBackoffBase\n }\n\n /**\n * Set the retryable error codes\n * @param {Set} retryableErrorCodes\n */\n setRetryableErrorCodes (retryableErrorCodes) {\n this.retryableErrorCodes = retryableErrorCodes\n }\n\n /**\n * Get the retryable error codes\n * @returns {Set}\n */\n getRetryableErrorCodes () {\n return this.retryableErrorCodes\n }\n\n /**\n * Set the retryable status codes\n * @param {Set} retryableStatusCodes\n */\n setRetryableStatusCodes (retryableStatusCodes) {\n this.retryableStatusCodes = retryableStatusCodes\n }\n\n /**\n * Get the retryable status codes\n * @returns {Set}\n */\n getRetryableStatusCodes () {\n return this.retryableStatusCodes\n }\n\n /**\n * Set the retryable http methods\n * @param {Set} retryableHttpMethods\n */\n setRetryableHttpMethods (retryableHttpMethods) {\n this.retryableHttpMethods = retryableHttpMethods\n }\n\n /**\n * Get the retryable http methods\n * @returns {Set}\n */\n getRetryableHttpMethods () {\n return this.retryableHttpMethods\n }\n\n /**\n * Set an http agent which is useful for http keepalive requests\n * @param {import('http').Agent} httpAgent An http agent\n */\n setHttpAgent (httpAgent) {\n this.httpAgent = httpAgent\n }\n\n /**\n * Get the set http agent\n * @returns {import('http').Agent|undefined} The https agent if it is set\n */\n getHttpAgent () {\n return this.httpAgent\n }\n\n /**\n * Set an https agent which is useful for https keepalive requests\n * @param {import('https').Agent} httpsAgent An https agent\n */\n setHttpsAgent (httpsAgent) {\n this.httpsAgent = httpsAgent\n }\n\n /**\n * Get the set https agent\n * @returns {import('https').Agent|undefined} The https agent if it is set\n */\n getHttpsAgent () {\n return this.httpsAgent\n }\n\n /**\n * Set the list of hosts\n * @param {String[]|String} hosts An array of RQLite hosts or a string\n * that will be split on \",\" to create an array of hosts, the first\n * host will be tried first when there are multiple hosts\n */\n setHosts (hosts) {\n this.hosts = !Array.isArray(hosts) ? String(hosts).split(',') : hosts\n this.hosts = this.hosts.reduce((acc, v) => {\n // Remove trailing slashed from hosts\n const host = String(v).trim().replace(/\\/$/, '')\n if (!host) {\n return acc\n }\n return acc.concat(host)\n }, [])\n }\n\n /**\n * Get the list of hosts\n * @returns {String[]} The list of hosts\n */\n getHosts () {\n return this.hosts\n }\n\n /**\n * Given a host string find the index of that host in the hosts\n * @param {String} host A host to find in hosts\n * @returns {Number} The found host index or -1 if not found\n */\n findHostIndex (host) {\n const parsedHostToFind = parseUrl(host)\n return this.getHosts().findIndex((v) => {\n const parsedHost = parseUrl(v)\n // Find a host where all the parsed fields match the requested host\n return ['hostname', 'protocol', 'port', 'path'].every((field) => parsedHostToFind[field] === parsedHost[field])\n })\n }\n\n /**\n * Get the current active host from the hosts array\n * @param {Boolean} useLeader If true use the first host which is always\n * the master, this is prefered for write operations\n * @returns {String} The active host\n */\n getActiveHost (useLeader) {\n // When useLeader is true we should just use the first host\n const activeHostIndex = useLeader ? this.getLeaderHostIndex() : this.getActiveHostIndex()\n return this.getHosts()[activeHostIndex]\n }\n\n /**\n * Set the active host index with check based on this.hosts\n * @param {Number} activeHostIndex The index\n * @returns {Number} The active host index\n */\n setActiveHostIndex (activeHostIndex) {\n if (!Number.isFinite(activeHostIndex)) {\n throw new Error('The activeHostIndex should be a finite number')\n }\n const totalHosts = this.getTotalHosts()\n if (activeHostIndex < 0) {\n // Don't allow an index less then zero\n this.activeHostIndex = 0\n } else if (activeHostIndex >= totalHosts) {\n // Don't allow an index greater then the length of the hosts\n this.activeHostIndex = totalHosts - 1\n } else {\n this.activeHostIndex = activeHostIndex\n }\n return this.activeHostIndex\n }\n\n /**\n * Get the host index for the leader node\n * @returns {Number} The host index for the leader node\n */\n getLeaderHostIndex () {\n return this.leaderHostIndex\n }\n\n /**\n * Set the index in the host array for the leader node\n * @param {Number} leaderHostIndex The index of the host that is the leader node\n * @returns {Number} The host index for the leader node\n */\n setLeaderHostIndex (leaderHostIndex) {\n if (!Number.isFinite(leaderHostIndex)) {\n throw new Error('The leaderHostIndex should be a finite number')\n }\n const totalHosts = this.getTotalHosts()\n if (leaderHostIndex < 0) {\n this.leaderHostIndex = 0\n } else if (leaderHostIndex > totalHosts) {\n this.leaderHostIndex = totalHosts - 1\n } else {\n this.leaderHostIndex = leaderHostIndex\n }\n return this.leaderHostIndex\n }\n\n /**\n * Get the active host index\n * @returns {Number} The active host index\n */\n getActiveHostIndex () {\n return this.activeHostIndex\n }\n\n /**\n * Set active host round robin value\n * @param {Boolean} activeHostRoundRobin If true setActiveHostIndex() will\n * perform a round robin\n */\n setActiveHostRoundRobin (activeHostRoundRobin) {\n if (typeof activeHostRoundRobin !== 'boolean') {\n throw new Error('The activeHostRoundRobin argument must be boolean')\n }\n this.activeHostRoundRobin = activeHostRoundRobin\n }\n\n /**\n * Get active host round robin value\n * @returns {Boolean} The value of activeHostRoundRobin\n */\n getActiveHostRoundRobin () {\n return this.activeHostRoundRobin\n }\n\n /**\n * Get the next active host index\n * @param {Number} [activeHostIndex] An optional paramater to provide the active host index\n * @returns {Number} The next active host index which will wrap around to zero\n */\n getNextActiveHostIndex (activeHostIndex = this.getActiveHostIndex()) {\n const totalHosts = this.getTotalHosts()\n const nextIndex = activeHostIndex + 1\n // If we are past the last index start back over at 1\n if (totalHosts === nextIndex) {\n return 0\n }\n return nextIndex\n }\n\n /**\n * Set the active host index to the next host using a\n * round robin strategy\n */\n setNextActiveHostIndex () {\n // Don't bother if we only have one host\n if (!this.getActiveHostRoundRobin()) {\n return\n }\n const totalHosts = this.getTotalHosts()\n if (this.getActiveHostRoundRobin() && totalHosts <= 1) {\n return\n }\n this.setActiveHostIndex(this.getNextActiveHostIndex())\n }\n\n /**\n * Get the total number of hosts\n * @returns {Number} The total number of hosts\n */\n getTotalHosts () {\n return this.getHosts().length\n }\n\n /**\n * Returns whether or not the uri passes a test for this.absoluteUriPattern\n * @returns {Boolean} True if the path is absolute\n */\n uriIsAbsolute (uri) {\n return this.absoluteUriPattern.test(uri)\n }\n\n /**\n * Returns true when the HTTP request is retryable\n * @param {Object} options The options\n * @param {Number} options.statusCode The HTTP status code\n * @param {String} options.errorCode The error code\n * @param {String} options.httpMethod The http method\n * @returns {Boolean} True if the request is retry able\n */\n requestIsRetryable (options = {}) {\n const {\n statusCode,\n errorCode,\n httpMethod,\n } = options\n // Honor strictly the http method\n if (!this.getRetryableHttpMethods().has(httpMethod)) {\n return false\n }\n if (statusCode && this.getRetryableStatusCodes().has(statusCode)) {\n return true\n }\n if (errorCode && this.getRetryableErrorCodes().has(errorCode)) {\n return true\n }\n return false\n }\n\n /**\n * Perform an HTTP request using the provided options\n * @param {HttpRequestOptions} [options={}] Options for the HTTP client\n * @returns {Promise<{status: Number, body: Object|String}>} An object with a status and body\n * property when stream is false and a stream when the stream option is true\n * @throws {ERROR_HTTP_REQUEST_MAX_REDIRECTS} When the maximum number of redirect has been reached\n */\n async fetch (options = {}) {\n const {\n body,\n headers = {},\n httpMethod = HTTP_METHOD_GET,\n query,\n stream = false,\n timeout = DEAULT_TIMEOUT,\n useLeader = false,\n retries = this.getTotalHosts() * 3,\n maxRedirects = 10,\n attempt = 0,\n retryAttempt = 0,\n redirectAttempt = 0,\n attemptHostIndex,\n exponentailBackoffBase = this.getExponentailBackoffBase(),\n httpAgent = this.getHttpAgent(),\n httpsAgent = this.getHttpsAgent(),\n } = options\n // Honor the supplied attemptHostIndex or get the active host\n const activeHost = Number.isFinite(attemptHostIndex) ? this.getHosts()[attemptHostIndex]\n : this.getActiveHost(useLeader)\n let { uri } = options\n if (!uri) {\n throw new Error('The uri option is required')\n }\n uri = this.uriIsAbsolute(uri) ? uri : `${activeHost}/${cleanPath(uri)}`\n try {\n let auth\n if (this.authentication.size) {\n auth = {\n username: this.authentication.get('username'),\n password: this.authentication.get('password'),\n }\n }\n const response = await axios({\n url: uri,\n auth,\n data: body,\n maxRedirects: 0, // Handle redirects manually to allow reposting data\n headers: createDefaultHeaders(headers),\n responseType: stream ? 'stream' : 'json',\n method: httpMethod,\n params: query,\n timeout,\n httpsAgent,\n httpAgent,\n paramsSerializer (params) {\n return stringifyQuery(params, { arrayFormat: 'brackets' })\n },\n })\n if (stream) {\n return response.data\n }\n return {\n body: response.data,\n status: response.status,\n }\n } catch (e) {\n const { response = {}, code: errorCode } = e\n const { status: responseStatus, headers: responseHeaders = {} } = response\n // Check if the error was a redirect\n const retryable = this.requestIsRetryable({\n statusCode: responseStatus,\n errorCode,\n httpMethod,\n })\n // Save the next active host index and pass it to retry manually\n let nextAttemptHostIndex = Number.isFinite(attemptHostIndex) ? attemptHostIndex\n : this.getActiveHostIndex()\n nextAttemptHostIndex += 1\n // We go past the last index start from zero\n if (nextAttemptHostIndex === this.getTotalHosts()) {\n nextAttemptHostIndex = 0\n }\n // First check if this is a redirect error\n if (responseStatus === 301 || responseStatus === 302) {\n // We maxed out on redirect attempts\n if (redirectAttempt >= maxRedirects) {\n throw ERROR_HTTP_REQUEST_MAX_REDIRECTS(`The maximum number of redirects ${maxRedirects} has been reached`)\n }\n const location = typeof responseHeaders === 'object' ? responseHeaders.location : undefined\n // If we were asked to use the leader, but got redirect the leader moved so remember it\n if (useLeader) {\n const newLeaderHostIndex = this.findHostIndex(location)\n // If the redirect exists in the hosts list remember it for next time\n if (newLeaderHostIndex > -1) {\n this.setLeaderHostIndex(newLeaderHostIndex)\n }\n }\n return this.fetch({\n ...options,\n uri: location,\n attempt: attempt + 1,\n redirectAttempt: redirectAttempt + 1,\n attemptHostIndex: nextAttemptHostIndex,\n })\n }\n if (retryable && retryAttempt < retries) {\n const waitTime = getWaitTimeExponential(retryAttempt, exponentailBackoffBase)\n const delayPromise = new Promise((resolve) => {\n setTimeout(resolve, waitTime)\n })\n await delayPromise\n return this.fetch({\n ...options,\n attempt: attempt + 1,\n retryAttempt: retryAttempt + 1,\n attemptHostIndex: nextAttemptHostIndex,\n })\n }\n throw e\n }\n }\n\n /**\n * Perform an HTTP GET request\n * @param {HttpRequestOptions} [options={}] The options\n * @see this.fetch() for options\n */\n async get (options = {}) {\n return this.fetch({ ...options, httpMethod: HTTP_METHOD_GET })\n }\n\n /**\n * Perform an HTTP POST request\n * @param {HttpRequestOptions} [options={}] The options\n * @see this.fetch() for options\n */\n async post (options = {}) {\n return this.fetch({ ...options, httpMethod: HTTP_METHOD_POST })\n }\n}\n"],"mappings":";;;;AAIA;AACA;AACA;AACA;;;;AAIA;;;;AAIA;AACA,wC;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,KAAvB;;AAEP;AACA;AACA,G;AACO,MAAMC,kBAAkB,GAAG,KAA3B;;AAEP;AACA;AACA;AACA;AACA,G;AACO,SAASC,oBAAT,CAA+BC,OAAO,GAAG,EAAzC,EAA6C;EAClD,wBAAmDA,OAAnD,CAAQC,MAAR,CAAQA,MAAR,gCAAiBC,2CAAjB;EACA,uCAAYF,OAAZ,SAAqBC,MAArB;AACD;;AAED;AACA;AACA;AACA;AACA;AACA,SAASE,SAAT,CAAoBC,IAApB,EAA0B;EACxB,OAAOC,MAAM,CAACD,IAAD,CAAN,CAAaE,OAAb,CAAqB,KAArB,E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gBAAgB,EAAEmB,oBAJb,IAAP;;QAMD;QACD,MAAML,CAAN;MACD,CAhHwB;EAiH1B;;EAED;AACF;AACA;AACA;AACA;EACQV,GAAG,CAAEzF,OAAO,GAAG,EAAZ,EAAgB;MACvB,OAAO,MAAI,CAAC2E,KAAL,iCAAgB3E,OAAhB,SAAyByE,UAAU,EAAEI,4BAArC,IAAP,CADuB;EAExB;;EAED;AACF;AACA;AACA;AACA;EACQoC,IAAI,CAAEjH,OAAO,GAAG,EAAZ,EAAgB;MACxB,OAAO,MAAI,CAAC2E,KAAL,iCAAgB3E,OAAhB,SAAyByE,UAAU,EAAEyC,6BAArC,IAAP,CADwB;EAEzB,CA3lB8B,C"}
1
+ {"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_qs","_url","_httpMethods","_contentTypes","_errors","_retryable","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DEAULT_TIMEOUT","exports","DEAULT_RETRY_DELAY","createDefaultHeaders","headers","_headers$Accept","Accept","CONTENT_TYPE_APPLICATION_JSON","cleanPath","path","String","replace","getWaitTimeExponential","attempt","base","exponent","Math","pow","HttpRequest","constructor","hosts","options","RETRYABLE_ERROR_CODES","RETRYABLE_STATUS_CODES","RETRYABLE_HTTP_METHODS","Map","setHosts","getTotalHosts","Error","_options$activeHostRo","activeHostRoundRobin","httpAgent","httpsAgent","retryableErrorCodes","retryableStatusCodes","retryableHttpMethods","exponentailBackoffExponent","exponentailBackoffBase","authentication","username","password","set","setActiveHostRoundRobin","setHttpAgent","setHttpsAgent","Set","Array","isArray","setRetryableErrorCodes","setRetryableStatusCodes","setRetryableHttpMethods","Number","isFinite","setExponentailBackoffBase","setExponentailBackoffExponent","setAuthentication","getExponentailBackoffBase","getExponentailBackoffExponent","getRetryableErrorCodes","getRetryableStatusCodes","getRetryableHttpMethods","getHttpAgent","getHttpsAgent","split","reduce","acc","v","host","trim","concat","getHosts","findHostIndex","parsedHostToFind","parseUrl","findIndex","parsedHost","every","field","getActiveHost","useLeader","activeHostIndex","getLeaderHostIndex","getActiveHostIndex","setActiveHostIndex","totalHosts","leaderHostIndex","setLeaderHostIndex","getActiveHostRoundRobin","getNextActiveHostIndex","nextIndex","setNextActiveHostIndex","uriIsAbsolute","uri","absoluteUriPattern","test","requestIsRetryable","statusCode","errorCode","httpMethod","has","fetch","_this","_asyncToGenerator2","body","_options$headers","_options$httpMethod","HTTP_METHOD_GET","query","_options$stream","stream","_options$timeout","timeout","_options$useLeader","_options$retries","retries","_options$maxRedirects","maxRedirects","_options$attempt","_options$retryAttempt","retryAttempt","_options$redirectAtte","redirectAttempt","attemptHostIndex","_options$exponentailB","_options$exponentailB2","_options$httpAgent","_options$httpsAgent","activeHost","auth","size","get","response","axios","url","data","responseType","method","params","paramsSerializer","stringifyQuery","arrayFormat","status","_e$response","code","responseStatus","_response$headers","responseHeaders","retryable","nextAttemptHostIndex","ERROR_HTTP_REQUEST_MAX_REDIRECTS","location","undefined","newLeaderHostIndex","waitTime","Promise","resolve","setTimeout","_this2","post","_this3","HTTP_METHOD_POST"],"sources":["../../es6/http-request/index.js"],"sourcesContent":["/**\n * Plain HTTP client to be used when creating RQLite specific API HTTP clients\n * @module http-request\n */\nimport axios from 'axios'\nimport { stringify as stringifyQuery } from 'qs'\nimport { parse as parseUrl } from 'url'\nimport {\n HTTP_METHOD_GET,\n HTTP_METHOD_POST,\n} from './http-methods'\nimport {\n CONTENT_TYPE_APPLICATION_JSON,\n // CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n} from './content-types'\nimport { ERROR_HTTP_REQUEST_MAX_REDIRECTS } from './errors'\nimport {\n RETRYABLE_ERROR_CODES,\n RETRYABLE_HTTP_METHODS,\n RETRYABLE_STATUS_CODES,\n} from './retryable'\n\n/**\n * RQliteJS HTTP Request options\n * @typedef HttpRequestOptions\n * @type {Object}\n * @property {Object} [auth] A object for user authentication\n * @property {String} [auth.username] The username for authentication\n * @property {String} [auth.password] The username for authentication\n * @property {Object} [body] The body of the HTTP request\n * @property {Object} [headers={}] HTTP headers to send with the request\n * @property {String} [httpMethod=HTTP_METHOD_GET] The HTTP method for the request\n * i.e. GET or POST\n * @property {Object} [query] An object with the query to send with the HTTP request\n * @property {Boolean} [stream=false] When true the returned value is a request object with\n * stream support instead of a request-promise result\n * @property {Number} [timeout=DEAULT_TIMEOUT] Optional timeout to override default\n * @property {String} uri The uri for the request which can be a relative path to use\n * the currently active host or a full i.e. http://localhost:4001/db/query which is used\n * literally\n * @property {Boolean} [useLeader=false] When true the request will use the master host, the\n * first host in this.hosts, this is ideal for write operations to skip the redirect\n * @property {Number} [retries] The number of retries, defaults to the number of\n * hosts times 3\n * @property {Number} [maxRedirects=10] The maximum number of HTTP redirects to follow before\n * throwing an error\n * @property {Number} [attempt=0] The current attempt count when retrying or redirecting\n * @property {Number} [retryAttempt=0] The current attempt based on retry logic\n * @property {Number} [redirectAttempt=0] The current attempt based on redirect logic\n * @property {Number} [attemptHostIndex] When in a retry state the host index of the last\n * attempt which is used to get the next host index\n * @property {import('http').Agent} [httpAgent] An option http agent, useful for\n * keepalive pools using plain HTTP\n * @property {import('https').Agent} [httpsAgent] An option http agent, useful\n * for keepalive pools using SSL\n */\n\n/**\n * The default timeout value\n */\nexport const DEAULT_TIMEOUT = 30000\n\n/**\n * The default to retry a request using the next host in the chain\n */\nexport const DEAULT_RETRY_DELAY = 30000\n\n/**\n * Create default header for all HTTP requests\n * @param {Object} [headers={}] HTTP headers to send with the request\n * @returns {Object} The headers with defaults applied\n */\nexport function createDefaultHeaders (headers = {}) {\n const { Accept = CONTENT_TYPE_APPLICATION_JSON } = headers\n return { ...headers, Accept }\n}\n\n/**\n * Clean the request path remove / from the beginning\n * @param {String} path The path to clean\n * @returns {String} The clean path\n */\nfunction cleanPath (path) {\n return String(path).replace(/^\\//, '')\n}\n\n/**\n * Returns the next wait interval, in milliseconds, using an exponential\n * backoff algorithm.\n * @param {Number} attempt The retry attempt\n * @param {Number} base The base of the exponential backoff\n * @param {Number} exponent The exponential power\n * @returns {Number} The time to wait in milliseconds\n */\nexport function getWaitTimeExponential (attempt = 0, base = 100, exponent = 2) {\n if (attempt === 0) {\n return 0\n }\n return (exponent ** attempt) * base\n}\n\n/**\n * Generic HTTP Request class which all RQLiteJS client\n * should extend for consistent communitication with an RQLite\n * server\n */\nexport default class HttpRequest {\n /**\n * The index of the host in this.hosts which will be tried\n * first before attempting other hosts\n * @type {Number}\n */\n activeHostIndex = 0\n\n /**\n * Whether or not the setNextActiveHostIndex() should\n * perform a round robin strategy\n */\n activeHostRoundRobin = true\n\n /**\n * The regex pattern to check if a uri is absolute or relative,\n * if it is absolute the host is not appended\n */\n absoluteUriPattern = /^https?:\\/\\//\n\n /**\n * A list of hosts that are tried in round robin fashion\n * when certain HTTP responses are received\n * @type {String[]}\n */\n hosts = []\n\n /**\n * @type {import('http').Agent} The http agent if it is set\n */\n httpAgent\n\n /**\n * @type {import('https').Agent} The https agent if it is set\n */\n httpsAgent\n\n /**\n * The host list index of the leader node defaults\n * to the first host\n * @type {Number}\n */\n leaderHostIndex = 0\n\n /**\n * Http error codes which are considered retryable\n * @type {Set}\n */\n retryableErrorCodes = RETRYABLE_ERROR_CODES\n\n /**\n * Http status codes which are considered retryable\n * @type {Set}\n */\n retryableStatusCodes = RETRYABLE_STATUS_CODES\n\n /**\n * Http methods which are considered retryable\n * @type {Set}\n */\n retryableHttpMethods = RETRYABLE_HTTP_METHODS\n\n /**\n * The exponential backoff base for retries\n */\n exponentailBackoffBase = 100\n\n /**\n * The exponent to increase backoff each try\n */\n exponentailBackoffExponent = 1.1\n\n /**\n * Authentication Map\n * @type {Map}\n * @property {String} username\n * @property {String} password\n */\n authentication = new Map()\n\n /**\n * Construtor for HttpRequest\n * @param {String[]|String} hosts An array of RQLite hosts or a string\n * that will be split on \",\" to create an array of hosts, the first\n * host will be tried first when there are multiple hosts\n * @param {Object} [options={}] Additional options\n * @param {Object} [options.authentication] Authentication options\n * @param {String} [options.authentication.username] The host authentication username\n * @param {String} [options.authentication.password] The host authentication password\n * @param {Boolean} [options.activeHostRoundRobin=true] If true this.setNextActiveHostIndex()\n * will perform a round robin when called\n * @param {import('http').Agent} [options.httpAgent] An option http agent, useful for\n * keepalive pools using plain HTTP\n * @param {import('https').Agent} [options.httpsAgent] An option http agent, useful\n * for keepalive pools using SSL\n * @param {Set|String[]} [options.retryableErrorCodes] The list of retryable error codes\n * @param {Set|Number[]} [options.retryableStatusCodes] The list of retryable http status codes\n * @param {Set|String[]} [options.retryableHttpMethods] The list of retryable http methods\n * @param {Number} [options.exponentailBackoffBase] The value for exponentail backoff base\n * for retry exponential backoff\n * @param {Number} [options.exponentailBackoffExponent] Exponent to increase backoff each try\n */\n constructor (hosts, options = {}) {\n this.setHosts(hosts)\n if (this.getTotalHosts() === 0) {\n throw new Error('At least one host must be provided')\n }\n const {\n activeHostRoundRobin = true,\n httpAgent,\n httpsAgent,\n retryableErrorCodes,\n retryableStatusCodes,\n retryableHttpMethods,\n exponentailBackoffExponent,\n exponentailBackoffBase,\n authentication,\n } = options\n if (typeof authentication === 'object') {\n const { username, password } = authentication\n if (username) {\n this.authentication.set('username', username)\n }\n if (password) {\n this.authentication.set('password', password)\n }\n }\n if (typeof activeHostRoundRobin !== 'undefined') {\n this.setActiveHostRoundRobin(activeHostRoundRobin)\n }\n if (typeof httpAgent !== 'undefined') {\n this.setHttpAgent(httpAgent)\n }\n if (typeof httpsAgent !== 'undefined') {\n this.setHttpsAgent(httpsAgent)\n }\n if (retryableErrorCodes instanceof Set || Array.isArray(retryableErrorCodes)) {\n this.setRetryableErrorCodes(\n Array.isArray(retryableErrorCodes) ? Set(retryableErrorCodes) : retryableErrorCodes,\n )\n }\n if (retryableStatusCodes instanceof Set || Array.isArray(retryableStatusCodes)) {\n this.setRetryableStatusCodes(\n Array.isArray(retryableStatusCodes) ? Set(retryableStatusCodes) : retryableStatusCodes,\n )\n }\n if (retryableHttpMethods instanceof Set || Array.isArray(retryableHttpMethods)) {\n this.setRetryableHttpMethods(\n Array.isArray(retryableHttpMethods) ? Set(retryableHttpMethods) : retryableHttpMethods,\n )\n }\n if (Number.isFinite(exponentailBackoffBase)) {\n this.setExponentailBackoffBase(exponentailBackoffBase)\n }\n if (Number.isFinite(exponentailBackoffExponent)) {\n this.setExponentailBackoffExponent(exponentailBackoffExponent)\n }\n }\n\n /**\n * Set authentication information\n * @param {Object} [authentication] Authentication data\n * @param {String} [authentication.username] The host authentication username\n * @param {String} [authentication.password] The host authentication password\n */\n setAuthentication (authentication = {}) {\n const { username, password } = authentication\n if (username) {\n this.authentication.set('username', username)\n }\n if (password) {\n this.authentication.set('password', password)\n }\n }\n\n /**\n * Set the exponentail backoff base\n * @param {Number} exponentailBackoffBase\n */\n setExponentailBackoffBase (exponentailBackoffBase) {\n this.exponentailBackoffBase = exponentailBackoffBase\n }\n\n /**\n * Get the exponentail backoff base\n * @return {Number} The exponentail backoff base\n */\n getExponentailBackoffBase () {\n return this.exponentailBackoffBase\n }\n\n /**\n * Set the exponentail backoff exponent\n * @param {Number} exponentailBackoffExponent\n */\n setExponentailBackoffExponent (exponentailBackoffExponent) {\n this.exponentailBackoffExponent = exponentailBackoffExponent\n }\n\n /**\n * Get the exponentail backoff exponent\n * @return {Number} The exponentail backoff exponent\n */\n getExponentailBackoffExponent () {\n return this.exponentailBackoffExponent\n }\n\n /**\n * Set the retryable error codes\n * @param {Set} retryableErrorCodes\n */\n setRetryableErrorCodes (retryableErrorCodes) {\n this.retryableErrorCodes = retryableErrorCodes\n }\n\n /**\n * Get the retryable error codes\n * @returns {Set}\n */\n getRetryableErrorCodes () {\n return this.retryableErrorCodes\n }\n\n /**\n * Set the retryable status codes\n * @param {Set} retryableStatusCodes\n */\n setRetryableStatusCodes (retryableStatusCodes) {\n this.retryableStatusCodes = retryableStatusCodes\n }\n\n /**\n * Get the retryable status codes\n * @returns {Set}\n */\n getRetryableStatusCodes () {\n return this.retryableStatusCodes\n }\n\n /**\n * Set the retryable http methods\n * @param {Set} retryableHttpMethods\n */\n setRetryableHttpMethods (retryableHttpMethods) {\n this.retryableHttpMethods = retryableHttpMethods\n }\n\n /**\n * Get the retryable http methods\n * @returns {Set}\n */\n getRetryableHttpMethods () {\n return this.retryableHttpMethods\n }\n\n /**\n * Set an http agent which is useful for http keepalive requests\n * @param {import('http').Agent} httpAgent An http agent\n */\n setHttpAgent (httpAgent) {\n this.httpAgent = httpAgent\n }\n\n /**\n * Get the set http agent\n * @returns {import('http').Agent|undefined} The https agent if it is set\n */\n getHttpAgent () {\n return this.httpAgent\n }\n\n /**\n * Set an https agent which is useful for https keepalive requests\n * @param {import('https').Agent} httpsAgent An https agent\n */\n setHttpsAgent (httpsAgent) {\n this.httpsAgent = httpsAgent\n }\n\n /**\n * Get the set https agent\n * @returns {import('https').Agent|undefined} The https agent if it is set\n */\n getHttpsAgent () {\n return this.httpsAgent\n }\n\n /**\n * Set the list of hosts\n * @param {String[]|String} hosts An array of RQLite hosts or a string\n * that will be split on \",\" to create an array of hosts, the first\n * host will be tried first when there are multiple hosts\n */\n setHosts (hosts) {\n this.hosts = !Array.isArray(hosts) ? String(hosts).split(',') : hosts\n this.hosts = this.hosts.reduce((acc, v) => {\n // Remove trailing slashed from hosts\n const host = String(v).trim().replace(/\\/$/, '')\n if (!host) {\n return acc\n }\n return acc.concat(host)\n }, [])\n }\n\n /**\n * Get the list of hosts\n * @returns {String[]} The list of hosts\n */\n getHosts () {\n return this.hosts\n }\n\n /**\n * Given a host string find the index of that host in the hosts\n * @param {String} host A host to find in hosts\n * @returns {Number} The found host index or -1 if not found\n */\n findHostIndex (host) {\n const parsedHostToFind = parseUrl(host)\n return this.getHosts().findIndex((v) => {\n const parsedHost = parseUrl(v)\n // Find a host where all the parsed fields match the requested host\n return ['hostname', 'protocol', 'port', 'path'].every((field) => parsedHostToFind[field] === parsedHost[field])\n })\n }\n\n /**\n * Get the current active host from the hosts array\n * @param {Boolean} useLeader If true use the first host which is always\n * the master, this is prefered for write operations\n * @returns {String} The active host\n */\n getActiveHost (useLeader) {\n // When useLeader is true we should just use the first host\n const activeHostIndex = useLeader ? this.getLeaderHostIndex() : this.getActiveHostIndex()\n return this.getHosts()[activeHostIndex]\n }\n\n /**\n * Set the active host index with check based on this.hosts\n * @param {Number} activeHostIndex The index\n * @returns {Number} The active host index\n */\n setActiveHostIndex (activeHostIndex) {\n if (!Number.isFinite(activeHostIndex)) {\n throw new Error('The activeHostIndex should be a finite number')\n }\n const totalHosts = this.getTotalHosts()\n if (activeHostIndex < 0) {\n // Don't allow an index less then zero\n this.activeHostIndex = 0\n } else if (activeHostIndex >= totalHosts) {\n // Don't allow an index greater then the length of the hosts\n this.activeHostIndex = totalHosts - 1\n } else {\n this.activeHostIndex = activeHostIndex\n }\n return this.activeHostIndex\n }\n\n /**\n * Get the host index for the leader node\n * @returns {Number} The host index for the leader node\n */\n getLeaderHostIndex () {\n return this.leaderHostIndex\n }\n\n /**\n * Set the index in the host array for the leader node\n * @param {Number} leaderHostIndex The index of the host that is the leader node\n * @returns {Number} The host index for the leader node\n */\n setLeaderHostIndex (leaderHostIndex) {\n if (!Number.isFinite(leaderHostIndex)) {\n throw new Error('The leaderHostIndex should be a finite number')\n }\n const totalHosts = this.getTotalHosts()\n if (leaderHostIndex < 0) {\n this.leaderHostIndex = 0\n } else if (leaderHostIndex > totalHosts) {\n this.leaderHostIndex = totalHosts - 1\n } else {\n this.leaderHostIndex = leaderHostIndex\n }\n return this.leaderHostIndex\n }\n\n /**\n * Get the active host index\n * @returns {Number} The active host index\n */\n getActiveHostIndex () {\n return this.activeHostIndex\n }\n\n /**\n * Set active host round robin value\n * @param {Boolean} activeHostRoundRobin If true setActiveHostIndex() will\n * perform a round robin\n */\n setActiveHostRoundRobin (activeHostRoundRobin) {\n if (typeof activeHostRoundRobin !== 'boolean') {\n throw new Error('The activeHostRoundRobin argument must be boolean')\n }\n this.activeHostRoundRobin = activeHostRoundRobin\n }\n\n /**\n * Get active host round robin value\n * @returns {Boolean} The value of activeHostRoundRobin\n */\n getActiveHostRoundRobin () {\n return this.activeHostRoundRobin\n }\n\n /**\n * Get the next active host index\n * @param {Number} [activeHostIndex] An optional paramater to provide the active host index\n * @returns {Number} The next active host index which will wrap around to zero\n */\n getNextActiveHostIndex (activeHostIndex = this.getActiveHostIndex()) {\n const totalHosts = this.getTotalHosts()\n const nextIndex = activeHostIndex + 1\n // If we are past the last index start back over at 1\n if (totalHosts === nextIndex) {\n return 0\n }\n return nextIndex\n }\n\n /**\n * Set the active host index to the next host using a\n * round robin strategy\n */\n setNextActiveHostIndex () {\n // Don't bother if we only have one host\n if (!this.getActiveHostRoundRobin()) {\n return\n }\n const totalHosts = this.getTotalHosts()\n if (this.getActiveHostRoundRobin() && totalHosts <= 1) {\n return\n }\n this.setActiveHostIndex(this.getNextActiveHostIndex())\n }\n\n /**\n * Get the total number of hosts\n * @returns {Number} The total number of hosts\n */\n getTotalHosts () {\n return this.getHosts().length\n }\n\n /**\n * Returns whether or not the uri passes a test for this.absoluteUriPattern\n * @returns {Boolean} True if the path is absolute\n */\n uriIsAbsolute (uri) {\n return this.absoluteUriPattern.test(uri)\n }\n\n /**\n * Returns true when the HTTP request is retryable\n * @param {Object} options The options\n * @param {Number} options.statusCode The HTTP status code\n * @param {String} options.errorCode The error code\n * @param {String} options.httpMethod The http method\n * @returns {Boolean} True if the request is retry able\n */\n requestIsRetryable (options = {}) {\n const {\n statusCode,\n errorCode,\n httpMethod,\n } = options\n // Honor strictly the http method\n if (!this.getRetryableHttpMethods().has(httpMethod)) {\n return false\n }\n if (statusCode && this.getRetryableStatusCodes().has(statusCode)) {\n return true\n }\n if (errorCode && this.getRetryableErrorCodes().has(errorCode)) {\n return true\n }\n return false\n }\n\n /**\n * Perform an HTTP request using the provided options\n * @param {HttpRequestOptions} [options={}] Options for the HTTP client\n * @returns {Promise<{status: Number, body: Object|String}>} An object with a status and body\n * property when stream is false and a stream when the stream option is true\n * @throws {ERROR_HTTP_REQUEST_MAX_REDIRECTS} When the maximum number of redirect has been reached\n */\n async fetch (options = {}) {\n const {\n body,\n headers = {},\n httpMethod = HTTP_METHOD_GET,\n query,\n stream = false,\n timeout = DEAULT_TIMEOUT,\n useLeader = false,\n retries = this.getTotalHosts() * 3,\n maxRedirects = 10,\n attempt = 0,\n retryAttempt = 0,\n redirectAttempt = 0,\n attemptHostIndex,\n exponentailBackoffExponent = this.getExponentailBackoffExponent(),\n exponentailBackoffBase = this.getExponentailBackoffBase(),\n httpAgent = this.getHttpAgent(),\n httpsAgent = this.getHttpsAgent(),\n } = options\n // Honor the supplied attemptHostIndex or get the active host\n const activeHost = Number.isFinite(attemptHostIndex) ? this.getHosts()[attemptHostIndex]\n : this.getActiveHost(useLeader)\n let { uri } = options\n if (!uri) {\n throw new Error('The uri option is required')\n }\n uri = this.uriIsAbsolute(uri) ? uri : `${activeHost}/${cleanPath(uri)}`\n try {\n let auth\n if (this.authentication.size) {\n auth = {\n username: this.authentication.get('username'),\n password: this.authentication.get('password'),\n }\n }\n const response = await axios({\n url: uri,\n auth,\n data: body,\n maxRedirects: 0, // Handle redirects manually to allow reposting data\n headers: createDefaultHeaders(headers),\n responseType: stream ? 'stream' : 'json',\n method: httpMethod,\n params: query,\n timeout,\n httpsAgent,\n httpAgent,\n paramsSerializer (params) {\n return stringifyQuery(params, { arrayFormat: 'brackets' })\n },\n })\n if (stream) {\n return response.data\n }\n return {\n body: response.data,\n status: response.status,\n }\n } catch (e) {\n const { response = {}, code: errorCode } = e\n const { status: responseStatus, headers: responseHeaders = {} } = response\n // Check if the error was a redirect\n const retryable = this.requestIsRetryable({\n statusCode: responseStatus,\n errorCode,\n httpMethod,\n })\n // Save the next active host index and pass it to retry manually\n let nextAttemptHostIndex = Number.isFinite(attemptHostIndex) ? attemptHostIndex\n : this.getActiveHostIndex()\n nextAttemptHostIndex += 1\n // We go past the last index start from zero\n if (nextAttemptHostIndex === this.getTotalHosts()) {\n nextAttemptHostIndex = 0\n }\n // First check if this is a redirect error\n if (responseStatus === 301 || responseStatus === 302) {\n // We maxed out on redirect attempts\n if (redirectAttempt >= maxRedirects) {\n throw ERROR_HTTP_REQUEST_MAX_REDIRECTS(`The maximum number of redirects ${maxRedirects} has been reached`)\n }\n const location = typeof responseHeaders === 'object' ? responseHeaders.location : undefined\n // If we were asked to use the leader, but got redirect the leader moved so remember it\n if (useLeader) {\n const newLeaderHostIndex = this.findHostIndex(location)\n // If the redirect exists in the hosts list remember it for next time\n if (newLeaderHostIndex > -1) {\n this.setLeaderHostIndex(newLeaderHostIndex)\n }\n }\n return this.fetch({\n ...options,\n uri: location,\n attempt: attempt + 1,\n redirectAttempt: redirectAttempt + 1,\n attemptHostIndex: nextAttemptHostIndex,\n })\n }\n if (retryable && retryAttempt < retries) {\n const waitTime = getWaitTimeExponential(\n retryAttempt,\n exponentailBackoffBase,\n exponentailBackoffExponent,\n )\n await new Promise((resolve) => {\n setTimeout(() => {\n resolve(undefined)\n }, waitTime)\n })\n return this.fetch({\n ...options,\n attempt: attempt + 1,\n retryAttempt: retryAttempt + 1,\n attemptHostIndex: nextAttemptHostIndex,\n })\n }\n throw e\n }\n }\n\n /**\n * Perform an HTTP GET request\n * @param {HttpRequestOptions} [options={}] The options\n * @see this.fetch() for options\n */\n async get (options = {}) {\n return this.fetch({ ...options, httpMethod: HTTP_METHOD_GET })\n }\n\n /**\n * Perform an HTTP POST request\n * @param {HttpRequestOptions} [options={}] The options\n * @see this.fetch() for options\n */\n async post (options = {}) {\n return this.fetch({ ...options, httpMethod: HTTP_METHOD_POST })\n }\n}\n"],"mappings":";;;;AAIA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;;;;AAIA,IAAAI,aAAA,GAAAJ,OAAA;;;;AAIA,IAAAK,OAAA,GA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