@ultipa-graph/ultipa-driver
Version:
NodeJS SDK for ultipa-server 5.1
68 lines • 2.82 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 ULTIPA = __importStar(require("../types/types"));
function printStatus(status, statistics) {
if (!status) {
return;
}
Object.assign(status, { "success?": status.code == ULTIPA.ErrorCode.SUCCESS ? "✅" : "❌" });
if (statistics) {
for (const key in statistics) {
if (statistics[key] != 0) {
status[`statistics.${key}`] = statistics[key];
}
}
}
console.table([status]);
if (status.code == ULTIPA.ErrorCode.SYNTAX_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