Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit 1af2bd4

Browse files
committed
review changes
1 parent ca8cb14 commit 1af2bd4

File tree

15 files changed

+121
-116
lines changed

15 files changed

+121
-116
lines changed

lib/client.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DgraphClientStub } from "./clientStub";
22
import { Txn } from "./txn";
3-
import { Operation, Payload, UiKeywords, TxnOptions } from "./types";
3+
import { Operation, Payload, UiKeywords, TxnOptions, Response } from "./types";
44
export declare class DgraphClient {
55
private readonly clients;
66
private debugMode;
@@ -14,6 +14,8 @@ export declare class DgraphClient {
1414
newTxn(options?: TxnOptions): Txn;
1515
setDebugMode(mode?: boolean): void;
1616
fetchUiKeywords(): Promise<UiKeywords>;
17+
getHealth(all?: boolean): Promise<Response>;
18+
getState(): Promise<Response>;
1719
debug(msg: string): void;
1820
anyClient(): DgraphClientStub;
1921
}

lib/client.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ var DgraphClient = (function () {
9393
DgraphClient.prototype.fetchUiKeywords = function () {
9494
return this.anyClient().fetchUiKeywords();
9595
};
96+
DgraphClient.prototype.getHealth = function (all) {
97+
if (all === void 0) { all = true; }
98+
return __awaiter(this, void 0, void 0, function () {
99+
return __generator(this, function (_a) {
100+
switch (_a.label) {
101+
case 0: return [4, this.anyClient().getHealth(all)];
102+
case 1: return [2, _a.sent()];
103+
}
104+
});
105+
});
106+
};
107+
DgraphClient.prototype.getState = function () {
108+
return __awaiter(this, void 0, void 0, function () {
109+
return __generator(this, function (_a) {
110+
switch (_a.label) {
111+
case 0: return [4, this.anyClient().getState()];
112+
case 1: return [2, _a.sent()];
113+
}
114+
});
115+
});
116+
};
96117
DgraphClient.prototype.debug = function (msg) {
97118
if (this.debugMode) {
98119
console.log(msg);

lib/clientStub.d.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ export declare class DgraphClientStub {
2727
refreshToken?: string;
2828
};
2929
fetchUiKeywords(): Promise<UiKeywords>;
30+
getHealth(all?: boolean): Promise<Response>;
31+
getState(): Promise<Response>;
3032
setAutoRefresh(val: boolean): void;
3133
private cancelRefreshTimer;
3234
private maybeStartRefreshTimer;
33-
callAPI<T>(path: string, config: {
34-
method?: string;
35-
body?: string;
36-
headers?: {
37-
[k: string]: string;
38-
};
39-
}): Promise<T>;
35+
private callAPI;
4036
private getURL;
4137
}

lib/clientStub.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

lib/cluster.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/cluster.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ export * from "./clientStub";
33
export * from "./client";
44
export * from "./txn";
55
export * from "./errors";
6-
export * from './cluster';
7-
export * from './zero';
6+
export * from "./zero";

lib/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ __export(require("./clientStub"));
77
__export(require("./client"));
88
__export(require("./txn"));
99
__export(require("./errors"));
10-
__export(require("./cluster"));
1110
__export(require("./zero"));

lib/zero.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export declare class DgraphZero {
33
private readonly addr;
44
constructor(addr?: string);
55
getState(): Promise<Response>;
6-
getClusterHealth(): Promise<Response>;
6+
getHealth(all?: boolean): Promise<Response>;
77
private callAPI;
88
private getURL;
99
}

lib/zero.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,24 @@ var DgraphZero = (function () {
4747
}
4848
}
4949
DgraphZero.prototype.getState = function () {
50-
return this.callAPI("state", {});
50+
return __awaiter(this, void 0, void 0, function () {
51+
return __generator(this, function (_a) {
52+
switch (_a.label) {
53+
case 0: return [4, this.callAPI("state", {})];
54+
case 1: return [2, _a.sent()];
55+
}
56+
});
57+
});
5158
};
52-
DgraphZero.prototype.getClusterHealth = function () {
53-
return this.callAPI("health?all", {});
59+
DgraphZero.prototype.getHealth = function (all) {
60+
if (all === void 0) { all = false; }
61+
return __awaiter(this, void 0, void 0, function () {
62+
var url;
63+
return __generator(this, function (_a) {
64+
url = "health" + (all ? "?all" : "");
65+
return [2, this.callAPI(url, {})];
66+
});
67+
});
5468
};
5569
DgraphZero.prototype.callAPI = function (path, config) {
5670
return __awaiter(this, void 0, void 0, function () {

0 commit comments

Comments
 (0)