Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / agi / graph / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeaa2=['no\x20edge/s\x20available','split','agicommand','target','default','invalid','traverseBFS','vswitch','default\x20on\x20switch\x20not\x20found','includes','condition\x20not\x20found','../../../config/logger','agi','menu','getdigits','numberOfEdges','prototype','addVertex','vertices','edges','push','relations','getVertex','info','stop\x20traverse','length'];(function(_0x35ef6b,_0x202c42){var _0x3ad145=function(_0x3092de){while(--_0x3092de){_0x35ef6b['push'](_0x35ef6b['shift']());}};_0x3ad145(++_0x202c42);}(_0xeaa2,0x129));var _0x2eaa=function(_0x2de0a7,_0x38d3e7){_0x2de0a7=_0x2de0a7-0x0;var _0x429437=_0xeaa2[_0x2de0a7];return _0x429437;};'use strict';var _=require('lodash');var logger=require(_0x2eaa('0x0'))(_0x2eaa('0x1'));var verticesWithRetry=[_0x2eaa('0x2'),_0x2eaa('0x3'),'getsecretdigits'];var Graph=function(){this['vertices']={};this['edges']={};this[_0x2eaa('0x4')]=0x0;};Graph[_0x2eaa('0x5')][_0x2eaa('0x6')]=function(_0x31fa55){this[_0x2eaa('0x7')][_0x31fa55['id']]=_0x31fa55;this[_0x2eaa('0x8')][_0x31fa55['id']]=[];};Graph[_0x2eaa('0x5')]['addEdge']=function(_0x2f481f,_0x3e9729,_0x45a558){this[_0x2eaa('0x8')][_0x2f481f][_0x2eaa('0x9')]({'target':_0x3e9729,'condition':_0x45a558});this[_0x2eaa('0x4')]+=0x1;};Graph[_0x2eaa('0x5')]['size']=function(){return _['size'](this[_0x2eaa('0x7')]);};Graph[_0x2eaa('0x5')][_0x2eaa('0xa')]=function(){return this[_0x2eaa('0x4')];};Graph[_0x2eaa('0x5')][_0x2eaa('0xb')]=function(_0x57ca87){return this[_0x2eaa('0x7')][_0x57ca87];};Graph['prototype']['traverseBFS']=function(_0x44f2c9,_0x329170){if(!this['vertices'][_0x44f2c9]){return logger[_0x2eaa('0xc')]('no\x20vertex\x20found');}var _0x232379=_0x329170(this[_0x2eaa('0x7')][_0x44f2c9]);if(!_0x232379){return logger[_0x2eaa('0xc')](_0x2eaa('0xd'));}if(this[_0x2eaa('0x8')][_0x44f2c9][_0x2eaa('0xe')]===0x0){return logger[_0x2eaa('0xc')](_0x2eaa('0xf'));}for(var _0x142b1e=0x0,_0x4b17aa=[],_0x3cbf65=![];_0x142b1e<this[_0x2eaa('0x8')][_0x44f2c9][_0x2eaa('0xe')];_0x142b1e+=0x1){if(this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e]['condition']){_0x4b17aa=this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e]['condition'][_0x2eaa('0x10')](',');for(var _0x4f452e=0x0;_0x4f452e<_0x4b17aa[_0x2eaa('0xe')];_0x4f452e+=0x1){if(this[_0x2eaa('0x7')][_0x44f2c9][_0x2eaa('0x11')]==='vswitch'&&_0x4b17aa[_0x4f452e]==='-'){_0x3cbf65=this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e][_0x2eaa('0x12')];logger[_0x2eaa('0xc')](_0x2eaa('0x13'),_0x4b17aa[_0x4f452e],this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e]['target']);}else if(this['vertices'][_0x44f2c9]['agicommand']===_0x2eaa('0x2')&&_0x4b17aa[_0x4f452e]==='i'){_0x3cbf65=this['edges'][_0x44f2c9][_0x142b1e]['target'];logger['info'](_0x2eaa('0x14'),_0x4b17aa[_0x4f452e],this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e][_0x2eaa('0x12')]);}if(_0x4b17aa[_0x4f452e]===_0x232379){return this['traverseBFS'](this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e][_0x2eaa('0x12')],_0x329170);}}}else{return this[_0x2eaa('0x15')](this[_0x2eaa('0x8')][_0x44f2c9][_0x142b1e][_0x2eaa('0x12')],_0x329170);}}if(_0x4b17aa[_0x2eaa('0xe')]){if(this[_0x2eaa('0x7')][_0x44f2c9][_0x2eaa('0x11')]===_0x2eaa('0x16')){if(_0x3cbf65){return this['traverseBFS'](_0x3cbf65,_0x329170);}return logger['info'](_0x2eaa('0x17'));}else if(_[_0x2eaa('0x18')](verticesWithRetry,this['vertices'][_0x44f2c9][_0x2eaa('0x11')])){if(_0x232379==='-'){return logger[_0x2eaa('0xc')]('max\x20retry\x20reach');}if(_0x3cbf65&&_0x232379!=='t'){return this[_0x2eaa('0x15')](_0x3cbf65,_0x329170);}return this[_0x2eaa('0x15')](_0x44f2c9,_0x329170);}return logger['info'](_0x2eaa('0x19'));}};module['exports']=Graph;