Skip to content

Commit 897243d

Browse files
authored
Merge pull request #36 from dgraph-io/micheldiz/revertCompilerOptions
Revert ts compile configs and bump some libs
2 parents 1b41935 + 46e1ba1 commit 897243d

File tree

12 files changed

+13855
-1658
lines changed

12 files changed

+13855
-1658
lines changed

lib/client.js

Lines changed: 101 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
23
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,74 +8,123 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
78
step((generator = generator.apply(thisArg, _arguments || [])).next());
89
});
910
};
10-
import { ERR_NO_CLIENTS } from "./errors";
11-
import { Txn } from "./txn";
12-
import { stringifyMessage } from "./util";
13-
export class DgraphClient {
14-
constructor(...clients) {
11+
var __generator = (this && this.__generator) || function (thisArg, body) {
12+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14+
function verb(n) { return function (v) { return step([n, v]); }; }
15+
function step(op) {
16+
if (f) throw new TypeError("Generator is already executing.");
17+
while (_) try {
18+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19+
if (y = 0, t) op = [op[0] & 2, t.value];
20+
switch (op[0]) {
21+
case 0: case 1: t = op; break;
22+
case 4: _.label++; return { value: op[1], done: false };
23+
case 5: _.label++; y = op[1]; op = [0]; continue;
24+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
25+
default:
26+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30+
if (t[2]) _.ops.pop();
31+
_.trys.pop(); continue;
32+
}
33+
op = body.call(thisArg, _);
34+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36+
}
37+
};
38+
Object.defineProperty(exports, "__esModule", { value: true });
39+
exports.DgraphClient = void 0;
40+
var errors_1 = require("./errors");
41+
var txn_1 = require("./txn");
42+
var util_1 = require("./util");
43+
var DgraphClient = (function () {
44+
function DgraphClient() {
45+
var clients = [];
46+
for (var _i = 0; _i < arguments.length; _i++) {
47+
clients[_i] = arguments[_i];
48+
}
1549
this.debugMode = false;
1650
this.queryTimeout = 600;
1751
if (clients.length === 0) {
18-
throw ERR_NO_CLIENTS;
52+
throw errors_1.ERR_NO_CLIENTS;
1953
}
2054
this.clients = clients;
2155
}
22-
setQueryTimeout(timeout) {
56+
DgraphClient.prototype.setQueryTimeout = function (timeout) {
2357
this.queryTimeout = timeout;
2458
return this;
25-
}
26-
getQueryTimeout() {
59+
};
60+
DgraphClient.prototype.getQueryTimeout = function () {
2761
return this.queryTimeout;
28-
}
29-
alter(op) {
30-
return __awaiter(this, void 0, void 0, function* () {
31-
this.debug(`Alter request:\n${stringifyMessage(op)}`);
32-
const c = this.anyClient();
33-
return c.alter(op);
62+
};
63+
DgraphClient.prototype.alter = function (op) {
64+
return __awaiter(this, void 0, void 0, function () {
65+
var c;
66+
return __generator(this, function (_a) {
67+
this.debug("Alter request:\n" + util_1.stringifyMessage(op));
68+
c = this.anyClient();
69+
return [2, c.alter(op)];
70+
});
3471
});
35-
}
36-
setAlphaAuthToken(authToken) {
37-
this.clients.forEach((c) => c.setAlphaAuthToken(authToken));
38-
}
39-
setSlashApiKey(apiKey) {
40-
this.clients.forEach((c) => c.setSlashApiKey(apiKey));
41-
}
42-
login(userid, password) {
43-
return __awaiter(this, void 0, void 0, function* () {
44-
this.debug(`Login request:\nuserid: ${userid}`);
45-
const c = this.anyClient();
46-
return c.login(userid, password);
72+
};
73+
DgraphClient.prototype.setAlphaAuthToken = function (authToken) {
74+
this.clients.forEach(function (c) {
75+
return c.setAlphaAuthToken(authToken);
4776
});
48-
}
49-
logout() {
77+
};
78+
DgraphClient.prototype.setSlashApiKey = function (apiKey) {
79+
this.clients.forEach(function (c) { return c.setSlashApiKey(apiKey); });
80+
};
81+
DgraphClient.prototype.login = function (userid, password) {
82+
return __awaiter(this, void 0, void 0, function () {
83+
var c;
84+
return __generator(this, function (_a) {
85+
this.debug("Login request:\nuserid: " + userid);
86+
c = this.anyClient();
87+
return [2, c.login(userid, password)];
88+
});
89+
});
90+
};
91+
DgraphClient.prototype.logout = function () {
5092
this.debug("Logout");
51-
this.clients.forEach((c) => c.logout());
52-
}
53-
newTxn(options) {
54-
return new Txn(this, options);
55-
}
56-
setDebugMode(mode = true) {
93+
this.clients.forEach(function (c) { return c.logout(); });
94+
};
95+
DgraphClient.prototype.newTxn = function (options) {
96+
return new txn_1.Txn(this, options);
97+
};
98+
DgraphClient.prototype.setDebugMode = function (mode) {
99+
if (mode === void 0) { mode = true; }
57100
this.debugMode = mode;
58-
}
59-
fetchUiKeywords() {
101+
};
102+
DgraphClient.prototype.fetchUiKeywords = function () {
60103
return this.anyClient().fetchUiKeywords();
61-
}
62-
getHealth(all = true) {
63-
return __awaiter(this, void 0, void 0, function* () {
64-
return this.anyClient().getHealth(all);
104+
};
105+
DgraphClient.prototype.getHealth = function (all) {
106+
if (all === void 0) { all = true; }
107+
return __awaiter(this, void 0, void 0, function () {
108+
return __generator(this, function (_a) {
109+
return [2, this.anyClient().getHealth(all)];
110+
});
65111
});
66-
}
67-
getState() {
68-
return __awaiter(this, void 0, void 0, function* () {
69-
return this.anyClient().getState();
112+
};
113+
DgraphClient.prototype.getState = function () {
114+
return __awaiter(this, void 0, void 0, function () {
115+
return __generator(this, function (_a) {
116+
return [2, this.anyClient().getState()];
117+
});
70118
});
71-
}
72-
debug(msg) {
119+
};
120+
DgraphClient.prototype.debug = function (msg) {
73121
if (this.debugMode) {
74122
console.log(msg);
75123
}
76-
}
77-
anyClient() {
124+
};
125+
DgraphClient.prototype.anyClient = function () {
78126
return this.clients[Math.floor(Math.random() * this.clients.length)];
79-
}
80-
}
127+
};
128+
return DgraphClient;
129+
}());
130+
exports.DgraphClient = DgraphClient;

0 commit comments

Comments
 (0)