61448756436efaa766d7ab57ac88ae9c4bb9bc60
[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 _0x0f37=['edges','addEdge','push','size','getVertex','no\x20vertex\x20found','info','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','vswitch','target','default','agicommand','invalid','traverseBFS','condition\x20not\x20found','exports','agi','menu','getdigits','getsecretdigits','vertices','numberOfEdges','prototype','addVertex'];(function(_0x521d82,_0x7a6e68){var _0xd24f2c=function(_0x19db8a){while(--_0x19db8a){_0x521d82['push'](_0x521d82['shift']());}};_0xd24f2c(++_0x7a6e68);}(_0x0f37,0xbc));var _0x70f3=function(_0xdd83e4,_0x356cca){_0xdd83e4=_0xdd83e4-0x0;var _0x5c9bfc=_0x0f37[_0xdd83e4];return _0x5c9bfc;};'use strict';var _=require('lodash');var logger=require('../../../config/logger')(_0x70f3('0x0'));var verticesWithRetry=[_0x70f3('0x1'),_0x70f3('0x2'),_0x70f3('0x3')];var Graph=function(){this[_0x70f3('0x4')]={};this['edges']={};this[_0x70f3('0x5')]=0x0;};Graph[_0x70f3('0x6')][_0x70f3('0x7')]=function(_0x277555){this[_0x70f3('0x4')][_0x277555['id']]=_0x277555;this[_0x70f3('0x8')][_0x277555['id']]=[];};Graph['prototype'][_0x70f3('0x9')]=function(_0x41db87,_0xc9cc3,_0x4b22eb){this[_0x70f3('0x8')][_0x41db87][_0x70f3('0xa')]({'target':_0xc9cc3,'condition':_0x4b22eb});this[_0x70f3('0x5')]+=0x1;};Graph[_0x70f3('0x6')][_0x70f3('0xb')]=function(){return _['size'](this[_0x70f3('0x4')]);};Graph[_0x70f3('0x6')]['relations']=function(){return this[_0x70f3('0x5')];};Graph[_0x70f3('0x6')][_0x70f3('0xc')]=function(_0x5692c7){return this[_0x70f3('0x4')][_0x5692c7];};Graph['prototype']['traverseBFS']=function(_0x12da5c,_0x539d47){if(!this[_0x70f3('0x4')][_0x12da5c]){return logger['info'](_0x70f3('0xd'));}var _0x13baa6=_0x539d47(this[_0x70f3('0x4')][_0x12da5c]);if(!_0x13baa6){return logger[_0x70f3('0xe')](_0x70f3('0xf'));}if(this[_0x70f3('0x8')][_0x12da5c][_0x70f3('0x10')]===0x0){return logger[_0x70f3('0xe')](_0x70f3('0x11'));}for(var _0x2c47e4=0x0,_0x51b283=[],_0x4c6afb=![];_0x2c47e4<this[_0x70f3('0x8')][_0x12da5c]['length'];_0x2c47e4+=0x1){if(this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x12')]){_0x51b283=this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x12')][_0x70f3('0x13')](',');for(var _0x5df413=0x0;_0x5df413<_0x51b283[_0x70f3('0x10')];_0x5df413+=0x1){if(this[_0x70f3('0x4')][_0x12da5c]['agicommand']===_0x70f3('0x14')&&_0x51b283[_0x5df413]==='-'){_0x4c6afb=this['edges'][_0x12da5c][_0x2c47e4][_0x70f3('0x15')];logger[_0x70f3('0xe')](_0x70f3('0x16'),_0x51b283[_0x5df413],this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x15')]);}else if(this[_0x70f3('0x4')][_0x12da5c][_0x70f3('0x17')]===_0x70f3('0x1')&&_0x51b283[_0x5df413]==='i'){_0x4c6afb=this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x15')];logger[_0x70f3('0xe')](_0x70f3('0x18'),_0x51b283[_0x5df413],this['edges'][_0x12da5c][_0x2c47e4][_0x70f3('0x15')]);}if(_0x51b283[_0x5df413]===_0x13baa6){return this[_0x70f3('0x19')](this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x15')],_0x539d47);}}}else{return this[_0x70f3('0x19')](this[_0x70f3('0x8')][_0x12da5c][_0x2c47e4][_0x70f3('0x15')],_0x539d47);}}if(_0x51b283[_0x70f3('0x10')]){if(this['vertices'][_0x12da5c]['agicommand']===_0x70f3('0x14')){if(_0x4c6afb){return this[_0x70f3('0x19')](_0x4c6afb,_0x539d47);}return logger['info']('default\x20on\x20switch\x20not\x20found');}else if(_['includes'](verticesWithRetry,this[_0x70f3('0x4')][_0x12da5c][_0x70f3('0x17')])){if(_0x13baa6==='-'){return logger['info']('max\x20retry\x20reach');}if(_0x4c6afb&&_0x13baa6!=='t'){return this[_0x70f3('0x19')](_0x4c6afb,_0x539d47);}return this[_0x70f3('0x19')](_0x12da5c,_0x539d47);}return logger[_0x70f3('0xe')](_0x70f3('0x1a'));}};module[_0x70f3('0x1b')]=Graph;