UNPKG

@ultipa-graph/ultipa-driver

Version:

NodeJS SDK for ultipa-server 5.1

78 lines 2.76 kB
"use strict"; 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.printEdge = exports.getEdgesPrintInfo = void 0; const chalk_1 = __importDefault(require("chalk")); const ULTIPA = __importStar(require("../types/types")); const alias_1 = require("./alias"); function getEdgesPrintInfo(edges, option) { let schemaMap = {}; let rows = []; edges?.forEach((n, i) => { let schema = n?.schema; if (!n) { schema = "printers_null_edges"; } if (!schemaMap[schema]) { schemaMap[schema] = []; } let row = !n ? { null_index: i } : { "@schema": schema, _uuid: n.uuid, _from: n.from, _to: n.to, ...n.values, }; if (option?.onlyRows) { rows.push(row); } else { schemaMap[schema].push(row); } }); if (option?.onlyRows) { return rows; } return schemaMap; } exports.getEdgesPrintInfo = getEdgesPrintInfo; function printEdge(dataItem) { if (dataItem?.type == ULTIPA.ResultType.RESULT_TYPE_EDGE) { let edges = dataItem.asEdges(); (0, alias_1.printAlias)(dataItem); let schemaMap = getEdgesPrintInfo(edges); for (const schema in schemaMap) { console.log(chalk_1.default.blue(` @${schema}`)); console.table(schemaMap[schema]); } } } exports.printEdge = printEdge; //# sourceMappingURL=edge.js.map