196192234abae0160385895b43fdd104c664b12b
[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 _0xf781=['length','isString','unset','hasOwnProperty','isNumeric','match','^[+]?[0-9]*$','isEmail','getFullTextValue','\x22{EXPR}\x22','{EXPR}','forEach','replace','push','join','getOptions','query','$id','model','name','attributes','nolimit','order','pick','filter','object','columns','value','where','merge','VIRTUAL','lower','options','lodash','sequelize','moment','parse','keys','includes','fields','split','filters','isEmpty','type','DATE','isPlainObject','$gte','format','YYYY-MM-DD','$lte','utc','subtract','uniqueid','isArray','limit','offset','sort','map','indexOf','priority','cast','col','DESC','unsigned','omit'];(function(_0x547add,_0x387042){var _0x2ed1f3=function(_0x3bbb4d){while(--_0x3bbb4d){_0x547add['push'](_0x547add['shift']());}};_0x2ed1f3(++_0x387042);}(_0xf781,0x125));var _0x1f78=function(_0x4bd8ce,_0x363ab3){_0x4bd8ce=_0x4bd8ce-0x0;var _0x2199a3=_0xf781[_0x4bd8ce];return _0x2199a3;};'use strict';var _=require(_0x1f78('0x0'));var sequelize=require(_0x1f78('0x1'));var moment=require(_0x1f78('0x2'));var LIMIT_VALUE=0xfa;function hasSequelizeOperator(_0x398ed5){var _0x1c9c9c=['ne'];try{var _0x524e42=JSON[_0x1f78('0x3')](_0x398ed5);var _0x592885=Object[_0x1f78('0x4')](_0x524e42)[0x0];return _0x1c9c9c[_0x1f78('0x5')](_0x592885);}catch(_0x1486cf){return![];}}function getOperatorValue(_0x41a44b){var _0x487bbf=JSON['parse'](_0x41a44b);var _0xe2e20d=Object[_0x1f78('0x4')](_0x487bbf)[0x0];var _0x479741=_0x487bbf[_0xe2e20d];return{['$'+_0xe2e20d]:_0x479741};}exports[_0x1f78('0x6')]=function(_0x276196){var _0x30fc1d=null;if(_0x276196){_0x30fc1d=_0x276196[_0x1f78('0x7')](',');}return _0x30fc1d;};exports[_0x1f78('0x8')]=function(_0x118d25,_0x3abd0e){var _0x459d32={};if(!_[_0x1f78('0x9')](_0x118d25)){_['forOwn'](_0x118d25,function(_0xc6ab4c,_0x48261e){try{if(_0x3abd0e){var _0x563d8b=_['find'](_0x3abd0e,{'name':_0x48261e})||{};if(hasSequelizeOperator(_0xc6ab4c)){_0x459d32[_0x48261e]=getOperatorValue(_0xc6ab4c);}else if(_0x563d8b[_0x1f78('0xa')]===_0x1f78('0xb')&&_[_0x1f78('0xc')](_0xc6ab4c)){var _0x34998f=JSON[_0x1f78('0x3')](_0xc6ab4c);var _0x2fc53f={'$gte':moment(moment(_0x34998f[_0x1f78('0xd')])[_0x1f78('0xe')](_0x1f78('0xf')))['utc']()[_0x1f78('0xe')](),'$lte':moment(moment(_0x34998f[_0x1f78('0x10')])[_0x1f78('0xe')](_0x1f78('0xf')))[_0x1f78('0x11')]()[_0x1f78('0x12')](0x1,'s')['format']()};_0x459d32[_0x48261e]=_0x2fc53f;}else if(_0x563d8b['name']===_0x1f78('0x13')){_0x459d32[_0x48261e]=_0xc6ab4c;}else{_0x459d32[_0x48261e]=_[_0x1f78('0x14')](_0xc6ab4c)?_0xc6ab4c:JSON[_0x1f78('0x3')](_0xc6ab4c);}}else{_0x459d32[_0x48261e]=_[_0x1f78('0x14')](_0xc6ab4c)?_0xc6ab4c:JSON['parse'](_0xc6ab4c);}}catch(_0x289aac){_0x459d32[_0x48261e]=_0xc6ab4c[_0x1f78('0x7')](',');}});}return _0x459d32;};exports[_0x1f78('0x15')]=function(_0x37e31c){_0x37e31c=parseInt(_0x37e31c,0xa);if(!_0x37e31c||_0x37e31c<0x0){_0x37e31c=LIMIT_VALUE;}return _0x37e31c;};exports[_0x1f78('0x16')]=function(_0x3c1073){_0x3c1073=parseInt(_0x3c1073,0xa);if(!_0x3c1073||_0x3c1073<0x0){_0x3c1073=0x0;}return _0x3c1073;};exports[_0x1f78('0x17')]=function(_0x5aa57a){var _0x31760b,_0x4a5761=null;if(_0x5aa57a){_0x31760b=_0x5aa57a[_0x1f78('0x7')](',');_0x4a5761=_[_0x1f78('0x18')](_0x31760b,function(_0x5aab9d){if(_0x5aab9d[_0x1f78('0x19')]('-')===0x0){return[_0x5aab9d===_0x1f78('0x1a')?sequelize[_0x1f78('0x1b')](sequelize[_0x1f78('0x1c')]('priority'),'unsigned'):_0x5aab9d['substr'](0x1),_0x1f78('0x1d')];}else{return[_0x5aab9d===_0x1f78('0x1a')?sequelize['cast'](sequelize['col']('priority'),_0x1f78('0x1e')):_0x5aab9d,'ASC'];}});}return _0x4a5761;};exports[_0x1f78('0x1f')]=function(_0x51abe1,_0x508749){if(_['isEmpty'](_0x51abe1)){return _0x51abe1;}if(_[_0x1f78('0x14')](_0x51abe1)){for(var _0x133790=0x0;_0x133790<_0x51abe1[_0x1f78('0x20')];_0x133790+=0x1){_0x51abe1[_0x133790]=this[_0x1f78('0x1f')](_0x51abe1[_0x133790],_0x508749);}return _0x51abe1;}if(!_['isObject'](_0x51abe1)){return _0x51abe1;}if(_[_0x1f78('0x21')](_0x508749)){_0x508749=[_0x508749];}if(!_[_0x1f78('0x14')](_0x508749)){return _0x51abe1;}for(var _0x4f08d3=0x0;_0x4f08d3<_0x508749[_0x1f78('0x20')];_0x4f08d3+=0x1){_[_0x1f78('0x22')](_0x51abe1,_0x508749[_0x4f08d3]);}for(var _0x24edc7 in _0x51abe1){if(_0x51abe1[_0x1f78('0x23')](_0x24edc7)){_0x51abe1[_0x24edc7]=this[_0x1f78('0x1f')](_0x51abe1[_0x24edc7],_0x508749);}}return _0x51abe1;};exports[_0x1f78('0x24')]=function(_0x2349b8){return _0x2349b8[_0x1f78('0x25')](RegExp(_0x1f78('0x26')))?!![]:![];};exports[_0x1f78('0x27')]=function(_0x303d3d){return _0x303d3d['match'](/^\S+@\S+$/)?!![]:![];};exports[_0x1f78('0x28')]=function(_0x38cccb,_0x3a5504){var _0x28eabc=[];var _0x526e2f=/[ `!@#$%^&*()_\-?~]/;var _0x3de753=_0x3a5504?_0x1f78('0x29'):_0x1f78('0x2a');_0x38cccb['split'](/[ ,]+/)[_0x1f78('0x2b')](function(_0x494f7d){_0x494f7d=_0x494f7d[_0x1f78('0x2c')](/([^:]")"+/g,'$1');_0x494f7d='+'+_0x494f7d+'*';var _0x30b7a4=_0x494f7d[_0x1f78('0x25')](_0x526e2f);if(_0x30b7a4){_0x494f7d='\x22'+_0x494f7d+'\x22';}_0x28eabc[_0x1f78('0x2d')](_0x494f7d);});_0x3de753=_0x3de753['replace'](_0x1f78('0x2a'),_0x28eabc[_0x1f78('0x2e')]('\x20'));return _0x3de753;};exports[_0x1f78('0x2f')]=function(_0x84d4f6,_0x232ef1,_0x56a85f){var _0x42fa6f={},_0x8dcdae={};if(_0x232ef1[_0x1f78('0x30')][_0x1f78('0x31')]){_0x232ef1[_0x1f78('0x30')]['id']=_0x232ef1[_0x1f78('0x30')][_0x1f78('0x31')];delete _0x232ef1['query'][_0x1f78('0x31')];}_0x42fa6f[_0x1f78('0x32')]=_[_0x1f78('0x18')](_0x84d4f6,_0x1f78('0x33'));_0x42fa6f['query']=_[_0x1f78('0x4')](_0x232ef1[_0x1f78('0x30')]);_0x42fa6f[_0x1f78('0x8')]=_['intersection'](_0x42fa6f[_0x1f78('0x32')],_0x42fa6f[_0x1f78('0x30')]);_0x8dcdae['attributes']=_['intersection'](_0x42fa6f[_0x1f78('0x32')],this[_0x1f78('0x6')](_0x232ef1[_0x1f78('0x30')]['fields']));_0x8dcdae[_0x1f78('0x34')]=_0x8dcdae[_0x1f78('0x34')]['length']?_0x8dcdae[_0x1f78('0x34')]:_0x42fa6f[_0x1f78('0x32')];if(!_0x232ef1[_0x1f78('0x30')][_0x1f78('0x23')](_0x1f78('0x35'))){_0x8dcdae['limit']=this['limit'](_0x232ef1[_0x1f78('0x30')]['limit']);_0x8dcdae[_0x1f78('0x16')]=this['offset'](_0x232ef1[_0x1f78('0x30')][_0x1f78('0x16')]);}_0x8dcdae[_0x1f78('0x36')]=this[_0x1f78('0x17')](_0x232ef1[_0x1f78('0x30')][_0x1f78('0x17')]);_0x8dcdae['where']=this[_0x1f78('0x8')](_[_0x1f78('0x37')](_0x232ef1[_0x1f78('0x30')],_0x42fa6f[_0x1f78('0x8')]),_0x84d4f6);if(_0x232ef1[_0x1f78('0x30')][_0x1f78('0x38')]){var _0x5dc865=_0x84d4f6;var _0x5e7fd6=_0x232ef1[_0x1f78('0x30')][_0x1f78('0x38')];if(typeof _0x5e7fd6===_0x1f78('0x39')){_0x5dc865=_[_0x1f78('0x38')](_0x84d4f6,function(_0x5d8a56){return _[_0x1f78('0x5')](_0x5e7fd6[_0x1f78('0x3a')],_0x5d8a56[_0x1f78('0x33')]);});_0x5e7fd6=_0x5e7fd6[_0x1f78('0x3b')];}_0x8dcdae[_0x1f78('0x3c')]=_[_0x1f78('0x3d')](_0x8dcdae['where'],{'$or':_[_0x1f78('0x18')](_0x5dc865,function(_0x5780fb){if(_0x5780fb[_0x1f78('0xa')]!==_0x1f78('0x3e')){if(_0x56a85f){return sequelize[_0x1f78('0x3c')](sequelize['fn'](_0x1f78('0x3f'),sequelize[_0x1f78('0x1c')](_0x5780fb[_0x1f78('0x33')])),{'$like':sequelize['fn']('lower','%'+_0x232ef1[_0x1f78('0x30')][_0x1f78('0x38')]+'%')});}else{var _0x2cd853={};_0x2cd853[_0x5780fb[_0x1f78('0x33')]]={'$like':'%'+_0x232ef1['query'][_0x1f78('0x38')]+'%'};return _0x2cd853;}}})});}_0x8dcdae=_[_0x1f78('0x3d')]({},_0x8dcdae,_0x232ef1[_0x1f78('0x40')]);return _0x8dcdae;};