UNPKG

ngrx-vis

Version:

<p align="center"> <img src="https://github.com/co-IT/ngrx-vis/blob/master/assets/logo.png?raw=true"> </p>

69 lines (68 loc) 3.86 kB
"use strict"; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; Object.defineProperty(exports, "__esModule", { value: true }); var create_edge_1 = require("./create-edge"); var create_empty_data_set_1 = require("./create-empty-data-set"); var create_node_1 = require("./create-node"); function createNetwork(actionContexts) { return actionContexts.reduce(function (dataSet, actionContext) { var actionNode = create_node_1.createNode(actionContext.actionMeta.typeScope + "\\n" + actionContext.actionMeta.typeDescription, 0, 'action', actionContext.id); var dispatcherNodes = actionContext.dispatchers.map(function (actionDispatcher) { return create_node_1.createNode(actionDispatcher.caption || actionDispatcher.fileName, 1, actionDispatcher.category); }); var actionNodeToDispatcherNodesEdges = dispatcherNodes.map(function (dispatcherNode) { return create_edge_1.createEdge(actionNode, dispatcherNode, { dashes: true }); }); var dispatchNode = create_node_1.createNode('trigger', 2, 'dispatch'); var dispatcherNodesToDispatchNodeEdges = dispatcherNodes.map(function (dispatcherNode) { return create_edge_1.createEdge(dispatcherNode, dispatchNode); }); var followUpActionNodes = []; var actionHandlerToFollowUpActionEdges = []; var handlerNodes = actionContext.handlers.map(function (actionHandler) { var actionHandlerNode = create_node_1.createNode(actionHandler.caption || actionHandler.fileName, 3, actionHandler.category); if (actionHandler.followUpActions && actionHandler.followUpActions.length > 0) { var followUpDispatchNode_1 = create_node_1.createNode('dispatch', 4, 'dispatch'); actionHandlerToFollowUpActionEdges.push(create_edge_1.createEdge(actionHandlerNode, followUpDispatchNode_1)); var effectFollowUpActionNodes = actionHandler.followUpActions.map(function (followUpAction) { return create_node_1.createNode(followUpAction, 5, 'effect-action'); }); followUpActionNodes.push.apply(followUpActionNodes, __spread([followUpDispatchNode_1], effectFollowUpActionNodes)); actionHandlerToFollowUpActionEdges.push.apply(actionHandlerToFollowUpActionEdges, __spread(effectFollowUpActionNodes.map(function (effectFollowUpActionNode) { return create_edge_1.createEdge(followUpDispatchNode_1, effectFollowUpActionNode); }))); } return actionHandlerNode; }); var dispatchNodeToHandlerNodesEdges = handlerNodes.map(function (handlerNode) { return create_edge_1.createEdge(dispatchNode, handlerNode); }); return { nodes: __spread(dataSet.nodes, [ actionNode ], dispatcherNodes, [ dispatchNode ], handlerNodes, followUpActionNodes), edges: __spread(dataSet.edges, actionNodeToDispatcherNodesEdges, dispatcherNodesToDispatchNodeEdges, dispatchNodeToHandlerNodesEdges, actionHandlerToFollowUpActionEdges) }; }, create_empty_data_set_1.createEmptyDataSet()); } exports.createNetwork = createNetwork;