Built motion from commit 980b26c3.|2.6.29
[motion2.git] / server / components / parsers / advancedSearch.js
index 8a219ba..207e05c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbbf7=['DATE','utcOffset','format','hours','minutes','seconds','parseSearch','sqlOperator','startsWith','and','replace','[$and]','split','length','slice','forEach','shift','match','filter','indexOf','map','conditions','push','buildExpression','$eq','operator','$between','value','includes','$gt','add','days','YYYY-MM-DD','castTo','text','CAST(','field','\x20AS\x20','$ne','\x20OR\x20','\x20IS\x20NULL)','$in','IN\x20?','$notIn','NOT\x20IN\x20?','=\x20?','<>\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','<\x20?','>\x20?','$lte','<=\x20?','$gte','BETWEEN\x20?\x20AND\x20?','start','pop'];(function(_0x44bacc,_0x3b2ba4){var _0x531f13=function(_0xcd9bfb){while(--_0xcd9bfb){_0x44bacc['push'](_0x44bacc['shift']());}};_0x531f13(++_0x3b2ba4);}(_0xbbf7,0x1aa));var _0x7bbf=function(_0x17c2c9,_0x214e62){_0x17c2c9=_0x17c2c9-0x0;var _0x2b22a9=_0xbbf7[_0x17c2c9];return _0x2b22a9;};'use strict';var _=require('lodash');var moment=require('moment');exports[_0x7bbf('0x0')]=function(_0x13956b){var _0x43d6b3={'conditions':[]};_0x43d6b3[_0x7bbf('0x1')]=_[_0x7bbf('0x2')](_0x13956b,'[$or]')?'or':_0x7bbf('0x3');var _0x5a10c9=_0x13956b[_0x7bbf('0x4')](_0x7bbf('0x5'),'')[_0x7bbf('0x4')]('[$or]','')[_0x7bbf('0x6')]('||');for(var _0x253860=0x0;_0x253860<_0x5a10c9[_0x7bbf('0x7')];_0x253860++){var _0x3648f2=_0x5a10c9[_0x253860][_0x7bbf('0x6')](':=');var _0x26f809=_0x3648f2[0x0];var _0xe4e52d=_0x3648f2[_0x7bbf('0x8')](0x1);_0xe4e52d[_0x7bbf('0x9')](function(_0x5977cc){var _0x1b79a4=_0x5977cc[_0x7bbf('0x6')]('[')[_0x7bbf('0xa')]();var _0x4dcde7=_0x5977cc[_0x7bbf('0xb')](/\[(.*?)\]/g);_0x4dcde7[_0x7bbf('0x9')](function(_0x361b5c){var _0x5ed10a=_0x361b5c[_0x7bbf('0x6')]('[')[_0x7bbf('0xc')](function(_0x413455){return _0x413455[_0x7bbf('0xd')](']')>-0x1;})[_0x7bbf('0xe')](function(_0x427354){return _0x427354[_0x7bbf('0x6')](']')[0x0];})[0x0];_0x43d6b3[_0x7bbf('0xf')][_0x7bbf('0x10')]({'field':_0x26f809,'operator':_0x1b79a4,'value':_0x5ed10a});});});}return _0x43d6b3;};exports[_0x7bbf('0x11')]=function(_0xae469a,_0x16cfff,_0x3e7d06){var _0x5a708b={};if(_0x16cfff==='DATE'){if(_0x3e7d06['operator']===_0x7bbf('0x12')){_0x3e7d06[_0x7bbf('0x13')]=_0x7bbf('0x14');_0x3e7d06['value']+=','+_0x3e7d06[_0x7bbf('0x15')];}else if(_[_0x7bbf('0x16')]([_0x7bbf('0x17'),'$lte'],_0x3e7d06[_0x7bbf('0x13')])){_0x3e7d06[_0x7bbf('0x15')]=moment(_0x3e7d06[_0x7bbf('0x15')])[_0x7bbf('0x18')](0x1,_0x7bbf('0x19'))['format'](_0x7bbf('0x1a'));}}if(_0x3e7d06[_0x7bbf('0x1b')]){_0x16cfff=_0x3e7d06[_0x7bbf('0x1b')];_0x5a708b[_0x7bbf('0x1c')]=_0x7bbf('0x1d')+_0xae469a+'.'+_0x3e7d06[_0x7bbf('0x1e')]+_0x7bbf('0x1f')+_0x3e7d06[_0x7bbf('0x1b')]+')\x20'+parseOperator(_0x3e7d06[_0x7bbf('0x13')]);}else{_0x5a708b[_0x7bbf('0x1c')]=_0xae469a+'.'+_0x3e7d06['field']+'\x20'+parseOperator(_0x3e7d06[_0x7bbf('0x13')]);}if(_[_0x7bbf('0x16')]([_0x7bbf('0x20'),'$notIn'],_0x3e7d06['operator']))_0x5a708b['text']='('+_0x5a708b[_0x7bbf('0x1c')]+_0x7bbf('0x21')+_0xae469a+'.'+_0x3e7d06[_0x7bbf('0x1e')]+_0x7bbf('0x22');_0x5a708b[_0x7bbf('0x15')]=parseValue(_0x16cfff,_0x3e7d06[_0x7bbf('0x13')],_0x3e7d06[_0x7bbf('0x15')]);return _0x5a708b;};function parseOperator(_0x4082c8){var _0x4791f6;switch(_0x4082c8){case _0x7bbf('0x23'):_0x4791f6=_0x7bbf('0x24');break;case _0x7bbf('0x25'):_0x4791f6=_0x7bbf('0x26');break;case'$eq':_0x4791f6=_0x7bbf('0x27');break;case _0x7bbf('0x20'):_0x4791f6=_0x7bbf('0x28');break;case _0x7bbf('0x29'):case _0x7bbf('0x2a'):case _0x7bbf('0x2b'):_0x4791f6=_0x7bbf('0x2c');break;case _0x7bbf('0x2d'):_0x4791f6=_0x7bbf('0x2e');break;case'$gt':_0x4791f6=_0x7bbf('0x2f');break;case _0x7bbf('0x30'):_0x4791f6=_0x7bbf('0x31');break;case _0x7bbf('0x32'):_0x4791f6='>=\x20?';break;case _0x7bbf('0x14'):_0x4791f6=_0x7bbf('0x33');break;}return _0x4791f6;}function parseValue(_0x33e870,_0x4725cc,_0x4c8096){var _0x588487={'start':undefined,'end':undefined};switch(_0x4725cc){case _0x7bbf('0x23'):case _0x7bbf('0x25'):_0x588487[_0x7bbf('0x34')]=_0x4c8096[_0x7bbf('0x6')](',');break;case'$substring':_0x588487[_0x7bbf('0x34')]='%'+_0x4c8096+'%';break;case'$startsWith':_0x588487[_0x7bbf('0x34')]=_0x4c8096+'%';break;case'$endsWith':_0x588487[_0x7bbf('0x34')]='%'+_0x4c8096;break;case'$between':var _0x51304e=_0x4c8096[_0x7bbf('0x6')](',');var _0x4c8096=_0x51304e['shift']();var _0x27f995=_0x51304e[_0x7bbf('0x35')]();if(_0x33e870===_0x7bbf('0x36')){_0x4c8096=moment(_0x4c8096)[_0x7bbf('0x37')](0x0,!![])[_0x7bbf('0x38')]();_0x27f995=moment(_0x27f995)[_0x7bbf('0x37')](0x0,!![])[_0x7bbf('0x18')](0x17,_0x7bbf('0x39'))['add'](0x3b,_0x7bbf('0x3a'))['add'](0x3b,_0x7bbf('0x3b'))[_0x7bbf('0x38')]();}_0x588487={'start':_0x4c8096,'end':_0x27f995};break;default:_0x588487[_0x7bbf('0x34')]=_0x4c8096;break;}return _0x588487;}
\ No newline at end of file
+var _0x7e17=['$notIn','text','\x20OR\x20','\x20IS\x20NULL)','$in','IN\x20?','NOT\x20IN\x20?','=\x20?','$ne','<>\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','<\x20?','>\x20?','<=\x20?','>=\x20?','BETWEEN\x20?\x20AND\x20?','start','pop','DATE','utcOffset','add','minutes','lodash','moment','sqlOperator','[$or]','and','[$and]','replace','split','forEach','shift','match','filter','indexOf','buildExpression','operator','$eq','$between','includes','$gt','$lte','value','days','format','castTo','field','\x20AS\x20'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x7e17,0x1ba));var _0x77e1=function(_0x29d87d,_0x23dc31){_0x29d87d=_0x29d87d-0x0;var _0x1fd84b=_0x7e17[_0x29d87d];return _0x1fd84b;};'use strict';var _=require(_0x77e1('0x0'));var moment=require(_0x77e1('0x1'));exports['parseSearch']=function(_0x273deb){var _0x534a90={'conditions':[]};_0x534a90[_0x77e1('0x2')]=_['startsWith'](_0x273deb,_0x77e1('0x3'))?'or':_0x77e1('0x4');var _0x3eb954=_0x273deb['replace'](_0x77e1('0x5'),'')[_0x77e1('0x6')](_0x77e1('0x3'),'')[_0x77e1('0x7')]('||');for(var _0x103d04=0x0;_0x103d04<_0x3eb954['length'];_0x103d04++){var _0x296847=_0x3eb954[_0x103d04][_0x77e1('0x7')](':=');var _0x14899c=_0x296847[0x0];var _0x3ad425=_0x296847['slice'](0x1);_0x3ad425[_0x77e1('0x8')](function(_0x5e1dc3){var _0xe2ddbf=_0x5e1dc3[_0x77e1('0x7')]('[')[_0x77e1('0x9')]();var _0x4dd183=_0x5e1dc3[_0x77e1('0xa')](/\[(.*?)\]/g);_0x4dd183[_0x77e1('0x8')](function(_0x151da8){var _0x3b62c3=_0x151da8[_0x77e1('0x7')]('[')[_0x77e1('0xb')](function(_0x3dd5ba){return _0x3dd5ba[_0x77e1('0xc')](']')>-0x1;})['map'](function(_0x7f198e){return _0x7f198e['split'](']')[0x0];})[0x0];_0x534a90['conditions']['push']({'field':_0x14899c,'operator':_0xe2ddbf,'value':_0x3b62c3});});});}return _0x534a90;};exports[_0x77e1('0xd')]=function(_0x5dc086,_0x276eb8,_0x775919){var _0x5aac07={};if(_0x276eb8==='DATE'){if(_0x775919[_0x77e1('0xe')]===_0x77e1('0xf')){_0x775919[_0x77e1('0xe')]=_0x77e1('0x10');_0x775919['value']+=','+_0x775919['value'];}else if(_[_0x77e1('0x11')]([_0x77e1('0x12'),_0x77e1('0x13')],_0x775919[_0x77e1('0xe')])){_0x775919['value']=moment(_0x775919[_0x77e1('0x14')])['add'](0x1,_0x77e1('0x15'))[_0x77e1('0x16')]('YYYY-MM-DD');}}if(_0x775919[_0x77e1('0x17')]){_0x276eb8=_0x775919[_0x77e1('0x17')];_0x5aac07['text']='CAST('+_0x5dc086+'.'+_0x775919[_0x77e1('0x18')]+_0x77e1('0x19')+_0x775919[_0x77e1('0x17')]+')\x20'+parseOperator(_0x775919[_0x77e1('0xe')]);}else{_0x5aac07['text']=_0x5dc086+'.'+_0x775919[_0x77e1('0x18')]+'\x20'+parseOperator(_0x775919['operator']);}if(_['includes'](['$ne',_0x77e1('0x1a')],_0x775919[_0x77e1('0xe')]))_0x5aac07[_0x77e1('0x1b')]='('+_0x5aac07[_0x77e1('0x1b')]+_0x77e1('0x1c')+_0x5dc086+'.'+_0x775919[_0x77e1('0x18')]+_0x77e1('0x1d');_0x5aac07[_0x77e1('0x14')]=parseValue(_0x276eb8,_0x775919[_0x77e1('0xe')],_0x775919[_0x77e1('0x14')]);return _0x5aac07;};function parseOperator(_0x21b721){var _0x2c9415;switch(_0x21b721){case _0x77e1('0x1e'):_0x2c9415=_0x77e1('0x1f');break;case _0x77e1('0x1a'):_0x2c9415=_0x77e1('0x20');break;case _0x77e1('0xf'):_0x2c9415=_0x77e1('0x21');break;case _0x77e1('0x22'):_0x2c9415=_0x77e1('0x23');break;case _0x77e1('0x24'):case _0x77e1('0x25'):case _0x77e1('0x26'):_0x2c9415=_0x77e1('0x27');break;case _0x77e1('0x28'):_0x2c9415=_0x77e1('0x29');break;case _0x77e1('0x12'):_0x2c9415=_0x77e1('0x2a');break;case _0x77e1('0x13'):_0x2c9415=_0x77e1('0x2b');break;case'$gte':_0x2c9415=_0x77e1('0x2c');break;case'$between':_0x2c9415=_0x77e1('0x2d');break;}return _0x2c9415;}function parseValue(_0x507040,_0x3fcc45,_0x578477){var _0x600d5={'start':undefined,'end':undefined};switch(_0x3fcc45){case'$in':case _0x77e1('0x1a'):_0x600d5[_0x77e1('0x2e')]=_0x578477[_0x77e1('0x7')](',');break;case _0x77e1('0x24'):_0x600d5['start']='%'+_0x578477+'%';break;case _0x77e1('0x25'):_0x600d5[_0x77e1('0x2e')]=_0x578477+'%';break;case _0x77e1('0x26'):_0x600d5['start']='%'+_0x578477;break;case _0x77e1('0x10'):var _0x3eff7e=_0x578477['split'](',');var _0x578477=_0x3eff7e['shift']();var _0x386f7e=_0x3eff7e[_0x77e1('0x2f')]();if(_0x507040===_0x77e1('0x30')){_0x578477=moment(_0x578477)[_0x77e1('0x31')](0x0,!![])[_0x77e1('0x16')]();_0x386f7e=moment(_0x386f7e)[_0x77e1('0x31')](0x0,!![])['add'](0x17,'hours')[_0x77e1('0x32')](0x3b,_0x77e1('0x33'))[_0x77e1('0x32')](0x3b,'seconds')['format']();}_0x600d5={'start':_0x578477,'end':_0x386f7e};break;default:_0x600d5[_0x77e1('0x2e')]=_0x578477;break;}return _0x600d5;}
\ No newline at end of file