Built motion from commit 0c5f406c.|2.6.29
[motion2.git] / server / components / parsers / qs.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 _0x1c45=['DATE','YYYY-MM-DD','utc','format','$lte','subtract','isArray','limit','sort','map','indexOf','priority','cast','col','unsigned','substr','DESC','ASC','omit','isEmpty','length','isObject','isString','unset','hasOwnProperty','isNumeric','match','^[+]?[0-9]*$','isEmail','\x22{EXPR}\x22','{EXPR}','forEach','replace','join','getOptions','query','$id','name','intersection','attributes','nolimit','offset','order','where','pick','filter','object','columns','value','merge','VIRTUAL','lower','options','include','includeAll','push','lodash','sequelize','moment','../../mysqldb','keys','includes','parse','model','fields','raw','split','filters','forOwn','find','type'];(function(_0xd5e247,_0x1310e8){var _0x5c4136=function(_0x591860){while(--_0x591860){_0xd5e247['push'](_0xd5e247['shift']());}};_0x5c4136(++_0x1310e8);}(_0x1c45,0x7f));var _0x51c4=function(_0x4565bf,_0x5ad9d6){_0x4565bf=_0x4565bf-0x0;var _0x5610ba=_0x1c45[_0x4565bf];return _0x5610ba;};'use strict';var _=require(_0x51c4('0x0'));var sequelize=require(_0x51c4('0x1'));var moment=require(_0x51c4('0x2'));var db=require(_0x51c4('0x3'))['db'];var LIMIT_VALUE=0xfa;function hasSequelizeOperator(_0x4dc25e){var _0x4b7552=['ne'];try{var _0x4ac259=JSON['parse'](_0x4dc25e);var _0x4c1fc6=Object[_0x51c4('0x4')](_0x4ac259)[0x0];return _0x4b7552[_0x51c4('0x5')](_0x4c1fc6);}catch(_0x4db08f){return![];}}function getOperatorValue(_0x43fc53){var _0xf6b361=JSON[_0x51c4('0x6')](_0x43fc53);var _0x4ef66d=Object['keys'](_0xf6b361)[0x0];var _0x58e2a2=_0xf6b361[_0x4ef66d];return{['$'+_0x4ef66d]:_0x58e2a2};}function parseIncludeModel(_0x188d9b){var _0x2986cb=JSON[_0x51c4('0x6')](_0x188d9b);return{'model':db[_0x2986cb[_0x51c4('0x7')]],'as':_0x2986cb['alias'],'attributes':_0x2986cb[_0x51c4('0x8')],'raw':_0x2986cb[_0x51c4('0x9')]};}exports[_0x51c4('0x8')]=function(_0x1c9cce){var _0x2597b0=null;if(_0x1c9cce){_0x2597b0=_0x1c9cce[_0x51c4('0xa')](',');}return _0x2597b0;};exports[_0x51c4('0xb')]=function(_0x43e364,_0x3e5635){var _0x1bc161={};if(!_['isEmpty'](_0x43e364)){_[_0x51c4('0xc')](_0x43e364,function(_0x1de156,_0x3ca9d7){try{if(_0x3e5635){var _0x33693e=_[_0x51c4('0xd')](_0x3e5635,{'name':_0x3ca9d7})||{};if(hasSequelizeOperator(_0x1de156)){_0x1bc161[_0x3ca9d7]=getOperatorValue(_0x1de156);}else if(_0x33693e[_0x51c4('0xe')]===_0x51c4('0xf')&&_['isPlainObject'](_0x1de156)){var _0xf61be8=JSON[_0x51c4('0x6')](_0x1de156);var _0x2f7c46={'$gte':moment(moment(_0xf61be8['$gte'])['format'](_0x51c4('0x10')))[_0x51c4('0x11')]()[_0x51c4('0x12')](),'$lte':moment(moment(_0xf61be8[_0x51c4('0x13')])[_0x51c4('0x12')](_0x51c4('0x10')))['utc']()[_0x51c4('0x14')](0x1,'s')[_0x51c4('0x12')]()};_0x1bc161[_0x3ca9d7]=_0x2f7c46;}else if(_0x33693e['name']==='uniqueid'){_0x1bc161[_0x3ca9d7]=_0x1de156;}else{_0x1bc161[_0x3ca9d7]=_['isArray'](_0x1de156)?_0x1de156:JSON[_0x51c4('0x6')](_0x1de156);}}else{_0x1bc161[_0x3ca9d7]=_[_0x51c4('0x15')](_0x1de156)?_0x1de156:JSON['parse'](_0x1de156);}}catch(_0x352b44){_0x1bc161[_0x3ca9d7]=_0x1de156[_0x51c4('0xa')](',');}});}return _0x1bc161;};exports[_0x51c4('0x16')]=function(_0x558e14){_0x558e14=parseInt(_0x558e14,0xa);if(!_0x558e14||_0x558e14<0x0){_0x558e14=LIMIT_VALUE;}return _0x558e14;};exports['offset']=function(_0x21b7fc){_0x21b7fc=parseInt(_0x21b7fc,0xa);if(!_0x21b7fc||_0x21b7fc<0x0){_0x21b7fc=0x0;}return _0x21b7fc;};exports[_0x51c4('0x17')]=function(_0x59ff23){var _0x579dae,_0x1e8d13=null;if(_0x59ff23){_0x579dae=_0x59ff23[_0x51c4('0xa')](',');_0x1e8d13=_[_0x51c4('0x18')](_0x579dae,function(_0x5bdd64){if(_0x5bdd64[_0x51c4('0x19')]('-')===0x0){return[_0x5bdd64===_0x51c4('0x1a')?sequelize[_0x51c4('0x1b')](sequelize[_0x51c4('0x1c')]('priority'),_0x51c4('0x1d')):_0x5bdd64[_0x51c4('0x1e')](0x1),_0x51c4('0x1f')];}else{return[_0x5bdd64===_0x51c4('0x1a')?sequelize[_0x51c4('0x1b')](sequelize['col'](_0x51c4('0x1a')),_0x51c4('0x1d')):_0x5bdd64,_0x51c4('0x20')];}});}return _0x1e8d13;};exports[_0x51c4('0x21')]=function(_0x1bf5ef,_0x5ab8a9){if(_[_0x51c4('0x22')](_0x1bf5ef)){return _0x1bf5ef;}if(_[_0x51c4('0x15')](_0x1bf5ef)){for(var _0x574652=0x0;_0x574652<_0x1bf5ef[_0x51c4('0x23')];_0x574652+=0x1){_0x1bf5ef[_0x574652]=this[_0x51c4('0x21')](_0x1bf5ef[_0x574652],_0x5ab8a9);}return _0x1bf5ef;}if(!_[_0x51c4('0x24')](_0x1bf5ef)){return _0x1bf5ef;}if(_[_0x51c4('0x25')](_0x5ab8a9)){_0x5ab8a9=[_0x5ab8a9];}if(!_[_0x51c4('0x15')](_0x5ab8a9)){return _0x1bf5ef;}for(var _0x1d5053=0x0;_0x1d5053<_0x5ab8a9[_0x51c4('0x23')];_0x1d5053+=0x1){_[_0x51c4('0x26')](_0x1bf5ef,_0x5ab8a9[_0x1d5053]);}for(var _0x289216 in _0x1bf5ef){if(_0x1bf5ef[_0x51c4('0x27')](_0x289216)){_0x1bf5ef[_0x289216]=this[_0x51c4('0x21')](_0x1bf5ef[_0x289216],_0x5ab8a9);}}return _0x1bf5ef;};exports[_0x51c4('0x28')]=function(_0x153ff2){return _0x153ff2[_0x51c4('0x29')](RegExp(_0x51c4('0x2a')))?!![]:![];};exports[_0x51c4('0x2b')]=function(_0x110ac4){return _0x110ac4['match'](/^\S+@\S+$/)?!![]:![];};exports['getFullTextValue']=function(_0x6d55f1,_0x106886){var _0x3e40a2=[];var _0x499d8d=/[ `!@#$%^&*()_\-?~]/;var _0x1768cf=_0x106886?_0x51c4('0x2c'):_0x51c4('0x2d');_0x6d55f1[_0x51c4('0xa')](/[ ,]+/)[_0x51c4('0x2e')](function(_0x110443){_0x110443=_0x110443[_0x51c4('0x2f')](/([^:]")"+/g,'$1');_0x110443='+'+_0x110443+'*';var _0x32f498=_0x110443['match'](_0x499d8d);if(_0x32f498){_0x110443='\x22'+_0x110443+'\x22';}_0x3e40a2['push'](_0x110443);});_0x1768cf=_0x1768cf[_0x51c4('0x2f')]('{EXPR}',_0x3e40a2[_0x51c4('0x30')]('\x20'));return _0x1768cf;};exports[_0x51c4('0x31')]=function(_0x12c6c3,_0x16b18a,_0x1cab14){var _0xa6afb9={},_0x2c1953={};if(_0x16b18a[_0x51c4('0x32')][_0x51c4('0x33')]){_0x16b18a['query']['id']=_0x16b18a[_0x51c4('0x32')][_0x51c4('0x33')];delete _0x16b18a[_0x51c4('0x32')][_0x51c4('0x33')];}_0xa6afb9[_0x51c4('0x7')]=_[_0x51c4('0x18')](_0x12c6c3,_0x51c4('0x34'));_0xa6afb9[_0x51c4('0x32')]=_[_0x51c4('0x4')](_0x16b18a['query']);_0xa6afb9[_0x51c4('0xb')]=_[_0x51c4('0x35')](_0xa6afb9['model'],_0xa6afb9[_0x51c4('0x32')]);_0x2c1953[_0x51c4('0x36')]=_[_0x51c4('0x35')](_0xa6afb9[_0x51c4('0x7')],this[_0x51c4('0x8')](_0x16b18a[_0x51c4('0x32')][_0x51c4('0x8')]));_0x2c1953['attributes']=_0x2c1953[_0x51c4('0x36')][_0x51c4('0x23')]?_0x2c1953['attributes']:_0xa6afb9[_0x51c4('0x7')];if(!_0x16b18a['query'][_0x51c4('0x27')](_0x51c4('0x37'))){_0x2c1953['limit']=this[_0x51c4('0x16')](_0x16b18a[_0x51c4('0x32')][_0x51c4('0x16')]);_0x2c1953[_0x51c4('0x38')]=this[_0x51c4('0x38')](_0x16b18a[_0x51c4('0x32')]['offset']);}_0x2c1953[_0x51c4('0x39')]=this['sort'](_0x16b18a[_0x51c4('0x32')][_0x51c4('0x17')]);_0x2c1953[_0x51c4('0x3a')]=this[_0x51c4('0xb')](_[_0x51c4('0x3b')](_0x16b18a[_0x51c4('0x32')],_0xa6afb9[_0x51c4('0xb')]),_0x12c6c3);if(_0x16b18a[_0x51c4('0x32')]['filter']){var _0xd77fff=_0x12c6c3;var _0x271ec2=_0x16b18a[_0x51c4('0x32')][_0x51c4('0x3c')];if(typeof _0x271ec2===_0x51c4('0x3d')){_0xd77fff=_['filter'](_0x12c6c3,function(_0x4c889b){return _['includes'](_0x271ec2[_0x51c4('0x3e')],_0x4c889b[_0x51c4('0x34')]);});_0x271ec2=_0x271ec2[_0x51c4('0x3f')];}_0x2c1953[_0x51c4('0x3a')]=_[_0x51c4('0x40')](_0x2c1953['where'],{'$or':_[_0x51c4('0x18')](_0xd77fff,function(_0x2c51f4){if(_0x2c51f4[_0x51c4('0xe')]!==_0x51c4('0x41')){if(_0x1cab14){return sequelize[_0x51c4('0x3a')](sequelize['fn'](_0x51c4('0x42'),sequelize[_0x51c4('0x1c')](_0x2c51f4[_0x51c4('0x34')])),{'$like':sequelize['fn'](_0x51c4('0x42'),'%'+_0x16b18a[_0x51c4('0x32')][_0x51c4('0x3c')]+'%')});}else{var _0x2a0046={};_0x2a0046[_0x2c51f4[_0x51c4('0x34')]]={'$like':'%'+_0x16b18a[_0x51c4('0x32')][_0x51c4('0x3c')]+'%'};return _0x2a0046;}}})});}_0x2c1953=_[_0x51c4('0x40')]({},_0x2c1953,_0x16b18a[_0x51c4('0x43')]);return _0x2c1953;};exports[_0x51c4('0x44')]=function(_0x206d99){var _0x32f398=[];if(_0x206d99[_0x51c4('0x45')]){_0x32f398['push']({'all':!![]});}else if(_0x206d99['include']){if(Array[_0x51c4('0x15')](_0x206d99[_0x51c4('0x44')])){_0x32f398=Object['keys'](_0x206d99[_0x51c4('0x44')])[_0x51c4('0x18')](function(_0x3e545d){return parseIncludeModel(_0x206d99['include'][_0x3e545d]);});}else{var _0x328f6e=parseIncludeModel(_0x206d99[_0x51c4('0x44')]);_0x32f398[_0x51c4('0x46')](_0x328f6e);}}return _0x32f398;};