Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / components / parsers / advancedSearch.js
index f62cb3b..b84d46a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1ea9=['$in','IN\x20?','$notIn','NOT\x20IN\x20?','$substring','$startsWith','<=\x20?','$gte','>=\x20?','BETWEEN\x20?\x20AND\x20?','start','$endsWith','pop','utcOffset','add','hours','lodash','moment','sqlOperator','startsWith','[$or]','and','[$and]','replace','split','slice','forEach','shift','match','indexOf','map','conditions','push','buildExpression','DATE','$eq','$between','value','includes','$gt','$lte','operator','days','format','YYYY-MM-DD','castTo','text','CAST(','field','\x20AS\x20','$ne','\x20OR\x20','\x20IS\x20NULL)'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x1ea9,0x7a));var _0x91ea=function(_0x43a74f,_0x37376a){_0x43a74f=_0x43a74f-0x0;var _0xe84cb=_0x1ea9[_0x43a74f];return _0xe84cb;};'use strict';var _=require(_0x91ea('0x0'));var moment=require(_0x91ea('0x1'));exports['parseSearch']=function(_0x18a14d){var _0x5cd335={'conditions':[]};_0x5cd335[_0x91ea('0x2')]=_[_0x91ea('0x3')](_0x18a14d,_0x91ea('0x4'))?'or':_0x91ea('0x5');var _0x20a391=_0x18a14d['replace'](_0x91ea('0x6'),'')[_0x91ea('0x7')](_0x91ea('0x4'),'')[_0x91ea('0x8')]('||');for(var _0x34e194=0x0;_0x34e194<_0x20a391['length'];_0x34e194++){var _0x2c33e0=_0x20a391[_0x34e194][_0x91ea('0x8')](':=');var _0x2470c0=_0x2c33e0[0x0];var _0x1c16cc=_0x2c33e0[_0x91ea('0x9')](0x1);_0x1c16cc[_0x91ea('0xa')](function(_0x57b12f){var _0x18b3f6=_0x57b12f['split']('[')[_0x91ea('0xb')]();var _0x3363d8=_0x57b12f[_0x91ea('0xc')](/\[(.*?)\]/g);_0x3363d8[_0x91ea('0xa')](function(_0x46668e){var _0xff7b5=_0x46668e[_0x91ea('0x8')]('[')['filter'](function(_0x54a10e){return _0x54a10e[_0x91ea('0xd')](']')>-0x1;})[_0x91ea('0xe')](function(_0xc1e816){return _0xc1e816[_0x91ea('0x8')](']')[0x0];})[0x0];_0x5cd335[_0x91ea('0xf')][_0x91ea('0x10')]({'field':_0x2470c0,'operator':_0x18b3f6,'value':_0xff7b5});});});}return _0x5cd335;};exports[_0x91ea('0x11')]=function(_0xce2d43,_0x5c1146,_0x3e66ba){var _0x3bc18d={};if(_0x5c1146===_0x91ea('0x12')){if(_0x3e66ba['operator']===_0x91ea('0x13')){_0x3e66ba['operator']=_0x91ea('0x14');_0x3e66ba[_0x91ea('0x15')]+=','+_0x3e66ba[_0x91ea('0x15')];}else if(_[_0x91ea('0x16')]([_0x91ea('0x17'),_0x91ea('0x18')],_0x3e66ba[_0x91ea('0x19')])){_0x3e66ba[_0x91ea('0x15')]=moment(_0x3e66ba[_0x91ea('0x15')])['add'](0x1,_0x91ea('0x1a'))[_0x91ea('0x1b')](_0x91ea('0x1c'));}}if(_0x3e66ba[_0x91ea('0x1d')]){_0x5c1146=_0x3e66ba['castTo'];_0x3bc18d[_0x91ea('0x1e')]=_0x91ea('0x1f')+_0xce2d43+'.'+_0x3e66ba[_0x91ea('0x20')]+_0x91ea('0x21')+_0x3e66ba[_0x91ea('0x1d')]+')\x20'+parseOperator(_0x3e66ba[_0x91ea('0x19')]);}else{_0x3bc18d[_0x91ea('0x1e')]=_0xce2d43+'.'+_0x3e66ba[_0x91ea('0x20')]+'\x20'+parseOperator(_0x3e66ba['operator']);}if(_['includes']([_0x91ea('0x22'),'$notIn'],_0x3e66ba[_0x91ea('0x19')]))_0x3bc18d['text']='('+_0x3bc18d['text']+_0x91ea('0x23')+_0xce2d43+'.'+_0x3e66ba['field']+_0x91ea('0x24');_0x3bc18d[_0x91ea('0x15')]=parseValue(_0x5c1146,_0x3e66ba[_0x91ea('0x19')],_0x3e66ba[_0x91ea('0x15')]);return _0x3bc18d;};function parseOperator(_0x4603c8){var _0x2f304f;switch(_0x4603c8){case _0x91ea('0x25'):_0x2f304f=_0x91ea('0x26');break;case _0x91ea('0x27'):_0x2f304f=_0x91ea('0x28');break;case'$eq':_0x2f304f='=\x20?';break;case _0x91ea('0x22'):_0x2f304f='<>\x20?';break;case _0x91ea('0x29'):case _0x91ea('0x2a'):case'$endsWith':_0x2f304f='LIKE\x20?';break;case'$lt':_0x2f304f='<\x20?';break;case _0x91ea('0x17'):_0x2f304f='>\x20?';break;case _0x91ea('0x18'):_0x2f304f=_0x91ea('0x2b');break;case _0x91ea('0x2c'):_0x2f304f=_0x91ea('0x2d');break;case'$between':_0x2f304f=_0x91ea('0x2e');break;}return _0x2f304f;}function parseValue(_0x16a2c5,_0x5d914e,_0xac1b51){var _0x5ae92e={'start':undefined,'end':undefined};switch(_0x5d914e){case _0x91ea('0x25'):case _0x91ea('0x27'):_0x5ae92e[_0x91ea('0x2f')]=_0xac1b51['split'](',');break;case _0x91ea('0x29'):_0x5ae92e['start']='%'+_0xac1b51+'%';break;case _0x91ea('0x2a'):_0x5ae92e['start']=_0xac1b51+'%';break;case _0x91ea('0x30'):_0x5ae92e[_0x91ea('0x2f')]='%'+_0xac1b51;break;case'$between':var _0x16ecb8=_0xac1b51[_0x91ea('0x8')](',');var _0xac1b51=_0x16ecb8[_0x91ea('0xb')]();var _0x142386=_0x16ecb8[_0x91ea('0x31')]();if(_0x16a2c5===_0x91ea('0x12')){_0xac1b51=moment(_0xac1b51)[_0x91ea('0x32')](0x0,!![])[_0x91ea('0x1b')]();_0x142386=moment(_0x142386)[_0x91ea('0x32')](0x0,!![])[_0x91ea('0x33')](0x17,_0x91ea('0x34'))[_0x91ea('0x33')](0x3b,'minutes')['add'](0x3b,'seconds')[_0x91ea('0x1b')]();}_0x5ae92e={'start':_0xac1b51,'end':_0x142386};break;default:_0x5ae92e[_0x91ea('0x2f')]=_0xac1b51;break;}return _0x5ae92e;}
\ No newline at end of file
+var _0x1fd8=['hours','minutes','lodash','moment','parseSearch','sqlOperator','[$or]','split','length','slice','forEach','match','filter','buildExpression','DATE','operator','$eq','$between','value','includes','$gt','add','days','format','YYYY-MM-DD','castTo','text','CAST(','\x20AS\x20','$ne','$notIn','\x20OR\x20','field','\x20IS\x20NULL)','NOT\x20IN\x20?','=\x20?','<>\x20?','$substring','$endsWith','$lt','<\x20?','>\x20?','$lte','<=\x20?','$gte','BETWEEN\x20?\x20AND\x20?','$in','start','pop','utcOffset'];(function(_0x57a749,_0xbeb6a1){var _0x140804=function(_0x28aec0){while(--_0x28aec0){_0x57a749['push'](_0x57a749['shift']());}};_0x140804(++_0xbeb6a1);}(_0x1fd8,0x66));var _0x81fd=function(_0x2b2642,_0x368f21){_0x2b2642=_0x2b2642-0x0;var _0x3e8807=_0x1fd8[_0x2b2642];return _0x3e8807;};'use strict';var _=require(_0x81fd('0x0'));var moment=require(_0x81fd('0x1'));exports[_0x81fd('0x2')]=function(_0x1be25c){var _0x2d005e={'conditions':[]};_0x2d005e[_0x81fd('0x3')]=_['startsWith'](_0x1be25c,_0x81fd('0x4'))?'or':'and';var _0x139688=_0x1be25c['replace']('[$and]','')['replace']('[$or]','')[_0x81fd('0x5')]('||');for(var _0x30a71d=0x0;_0x30a71d<_0x139688[_0x81fd('0x6')];_0x30a71d++){var _0x61e583=_0x139688[_0x30a71d]['split'](':=');var _0x266e12=_0x61e583[0x0];var _0x5bd0f1=_0x61e583[_0x81fd('0x7')](0x1);_0x5bd0f1[_0x81fd('0x8')](function(_0x4d77bc){var _0x278803=_0x4d77bc[_0x81fd('0x5')]('[')['shift']();var _0x10e335=_0x4d77bc[_0x81fd('0x9')](/\[(.*?)\]/g);_0x10e335[_0x81fd('0x8')](function(_0x5c68d4){var _0x203d84=_0x5c68d4['split']('[')[_0x81fd('0xa')](function(_0x2c7759){return _0x2c7759['indexOf'](']')>-0x1;})['map'](function(_0x400fb6){return _0x400fb6[_0x81fd('0x5')](']')[0x0];})[0x0];_0x2d005e['conditions']['push']({'field':_0x266e12,'operator':_0x278803,'value':_0x203d84});});});}return _0x2d005e;};exports[_0x81fd('0xb')]=function(_0x364ba9,_0x4b16ef,_0x58b104){var _0x741766={};if(_0x4b16ef===_0x81fd('0xc')){if(_0x58b104[_0x81fd('0xd')]===_0x81fd('0xe')){_0x58b104[_0x81fd('0xd')]=_0x81fd('0xf');_0x58b104[_0x81fd('0x10')]+=','+_0x58b104[_0x81fd('0x10')];}else if(_[_0x81fd('0x11')]([_0x81fd('0x12'),'$lte'],_0x58b104[_0x81fd('0xd')])){_0x58b104['value']=moment(_0x58b104[_0x81fd('0x10')])[_0x81fd('0x13')](0x1,_0x81fd('0x14'))[_0x81fd('0x15')](_0x81fd('0x16'));}}if(_0x58b104[_0x81fd('0x17')]){_0x4b16ef=_0x58b104['castTo'];_0x741766[_0x81fd('0x18')]=_0x81fd('0x19')+_0x364ba9+'.'+_0x58b104['field']+_0x81fd('0x1a')+_0x58b104['castTo']+')\x20'+parseOperator(_0x58b104[_0x81fd('0xd')]);}else{_0x741766[_0x81fd('0x18')]=_0x364ba9+'.'+_0x58b104['field']+'\x20'+parseOperator(_0x58b104['operator']);}if(_[_0x81fd('0x11')]([_0x81fd('0x1b'),_0x81fd('0x1c')],_0x58b104['operator']))_0x741766[_0x81fd('0x18')]='('+_0x741766[_0x81fd('0x18')]+_0x81fd('0x1d')+_0x364ba9+'.'+_0x58b104[_0x81fd('0x1e')]+_0x81fd('0x1f');_0x741766[_0x81fd('0x10')]=parseValue(_0x4b16ef,_0x58b104[_0x81fd('0xd')],_0x58b104[_0x81fd('0x10')]);return _0x741766;};function parseOperator(_0x113d81){var _0x2d9fa6;switch(_0x113d81){case'$in':_0x2d9fa6='IN\x20?';break;case _0x81fd('0x1c'):_0x2d9fa6=_0x81fd('0x20');break;case _0x81fd('0xe'):_0x2d9fa6=_0x81fd('0x21');break;case'$ne':_0x2d9fa6=_0x81fd('0x22');break;case _0x81fd('0x23'):case'$startsWith':case _0x81fd('0x24'):_0x2d9fa6='LIKE\x20?';break;case _0x81fd('0x25'):_0x2d9fa6=_0x81fd('0x26');break;case'$gt':_0x2d9fa6=_0x81fd('0x27');break;case _0x81fd('0x28'):_0x2d9fa6=_0x81fd('0x29');break;case _0x81fd('0x2a'):_0x2d9fa6='>=\x20?';break;case _0x81fd('0xf'):_0x2d9fa6=_0x81fd('0x2b');break;}return _0x2d9fa6;}function parseValue(_0x2cdbfc,_0x374ff2,_0x3aa161){var _0x4fb40d={'start':undefined,'end':undefined};switch(_0x374ff2){case _0x81fd('0x2c'):case _0x81fd('0x1c'):_0x4fb40d[_0x81fd('0x2d')]=_0x3aa161[_0x81fd('0x5')](',');break;case _0x81fd('0x23'):_0x4fb40d[_0x81fd('0x2d')]='%'+_0x3aa161+'%';break;case'$startsWith':_0x4fb40d[_0x81fd('0x2d')]=_0x3aa161+'%';break;case'$endsWith':_0x4fb40d[_0x81fd('0x2d')]='%'+_0x3aa161;break;case _0x81fd('0xf'):var _0x219b25=_0x3aa161[_0x81fd('0x5')](',');var _0x3aa161=_0x219b25['shift']();var _0x440436=_0x219b25[_0x81fd('0x2e')]();if(_0x2cdbfc===_0x81fd('0xc')){_0x3aa161=moment(_0x3aa161)[_0x81fd('0x2f')](0x0,!![])[_0x81fd('0x15')]();_0x440436=moment(_0x440436)[_0x81fd('0x2f')](0x0,!![])[_0x81fd('0x13')](0x17,_0x81fd('0x30'))[_0x81fd('0x13')](0x3b,_0x81fd('0x31'))[_0x81fd('0x13')](0x3b,'seconds')[_0x81fd('0x15')]();}_0x4fb40d={'start':_0x3aa161,'end':_0x440436};break;default:_0x4fb40d[_0x81fd('0x2d')]=_0x3aa161;break;}return _0x4fb40d;}
\ No newline at end of file