@ultipa-graph/ultipa-node-sdk
Version:
NodeJS SDK for ultipa-server 4.0
45 lines • 1.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printStatistics = exports.printStatus = void 0;
const chalk_1 = __importDefault(require("chalk"));
const types_1 = require("../types");
function printStatus(status, statistics) {
if (!status) {
return;
}
Object.assign(status, { "success?": status.code == types_1.ULTIPA.Code.SUCCESS ? "✅" : "❌" });
if (statistics) {
for (const key in statistics) {
if (statistics[key] != 0) {
status[`statistics.${key}`] = statistics[key];
}
}
}
console.table([status]);
if (status.code == types_1.ULTIPA.Code.UQL_ERROR) {
// [1-5]abcd().nodes() as n return n{*} limit 5\nsyntax error, unexpected Identifier\n
let message = status.message;
let v = message.match(/\[([0-9]*)-([0-9]*)\]/);
if (v) {
let find = v[0];
let start = +v[1] - 1;
let end = +v[2] - 1;
message = message.substring(find.length);
let startStr = message.substring(0, start);
let colorStr = message.substring(start, end);
let endStr = message.substring(end);
console.log(`${chalk_1.default.yellow(startStr)}${chalk_1.default.red(colorStr)}${chalk_1.default.yellow(endStr)}`);
}
}
}
exports.printStatus = printStatus;
function printStatistics(statistics) {
if (statistics) {
console.table(statistics);
}
}
exports.printStatistics = printStatistics;
//# sourceMappingURL=status.js.map