|
1 | 1 | "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 | | -}; |
13 | 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
14 | 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
15 | 4 | return new (P || (P = Promise))(function (resolve, reject) { |
@@ -63,14 +52,26 @@ var DgraphClientStub = (function () { |
63 | 52 | } |
64 | 53 | DgraphClientStub.prototype.detectApiVersion = function () { |
65 | 54 | return __awaiter(this, void 0, void 0, function () { |
66 | | - var health; |
| 55 | + var response, err_1; |
67 | 56 | return __generator(this, function (_a) { |
68 | 57 | switch (_a.label) { |
69 | | - case 0: return [4, this.health()]; |
| 58 | + case 0: |
| 59 | + _a.trys.push([0, 2, , 3]); |
| 60 | + return [4, this.getHealth()]; |
70 | 61 | case 1: |
71 | | - health = _a.sent(); |
72 | | - this.legacyApi = health.version.startsWith("1.0."); |
73 | | - return [2, health.version]; |
| 62 | + response = _a.sent(); |
| 63 | + if (response.data === "OK") { |
| 64 | + this.legacyApi = true; |
| 65 | + return [2, "1.0.x"]; |
| 66 | + } |
| 67 | + else { |
| 68 | + return [2, response.data["version"]]; |
| 69 | + } |
| 70 | + return [3, 3]; |
| 71 | + case 2: |
| 72 | + err_1 = _a.sent(); |
| 73 | + throw new Error("Invalid status code"); |
| 74 | + case 3: return [2]; |
74 | 75 | } |
75 | 76 | }); |
76 | 77 | }); |
@@ -249,33 +250,6 @@ var DgraphClientStub = (function () { |
249 | 250 | : "/abort/" + ctx.start_ts; |
250 | 251 | return this.callAPI(url, { method: "POST" }); |
251 | 252 | }; |
252 | | - DgraphClientStub.prototype.health = function () { |
253 | | - return __awaiter(this, void 0, void 0, function () { |
254 | | - var response, text; |
255 | | - return __generator(this, function (_a) { |
256 | | - switch (_a.label) { |
257 | | - case 0: return [4, fetch(this.getURL("health"), { |
258 | | - method: "GET", |
259 | | - })]; |
260 | | - case 1: |
261 | | - response = _a.sent(); |
262 | | - if (response.status >= 300 || response.status < 200) { |
263 | | - throw new Error("Invalid status code = " + response.status); |
264 | | - } |
265 | | - return [4, response.text()]; |
266 | | - case 2: |
267 | | - text = _a.sent(); |
268 | | - if (text === "OK") { |
269 | | - return [2, { |
270 | | - health: text, |
271 | | - version: "1.0.x", |
272 | | - }]; |
273 | | - } |
274 | | - return [2, __assign(__assign({}, JSON.parse(text)), { health: "OK" })]; |
275 | | - } |
276 | | - }); |
277 | | - }); |
278 | | - }; |
279 | 253 | DgraphClientStub.prototype.login = function (userid, password, refreshToken) { |
280 | 254 | return __awaiter(this, void 0, void 0, function () { |
281 | 255 | var body, res; |
|
0 commit comments