Built motion from commit f57cc866.|2.6.31
[motion2.git] / server / components / parsers / advancedSearch.js
index 2f213db..325d47e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb63f=['castTo','CAST(','\x20AS\x20','text','field','includes','$notIn','\x20OR\x20','\x20IS\x20NULL)','$in','IN\x20?','NOT\x20IN\x20?','=\x20?','$ne','<>\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','<\x20?','>\x20?','$lte','$gte','BETWEEN\x20?\x20AND\x20?','start','pop','DATE','utcOffset','hours','minutes','seconds','lodash','moment','parseSearch','sqlOperator','[$or]','and','replace','split','length','slice','shift','match','forEach','indexOf','conditions','push','buildExpression','operator','$eq','$between','value','$gt','add','days','format','YYYY-MM-DD'];(function(_0x3b76e9,_0x39efb2){var _0x43489c=function(_0x1040a9){while(--_0x1040a9){_0x3b76e9['push'](_0x3b76e9['shift']());}};_0x43489c(++_0x39efb2);}(_0xb63f,0x108));var _0xfb63=function(_0x307d86,_0x9264f2){_0x307d86=_0x307d86-0x0;var _0x361745=_0xb63f[_0x307d86];return _0x361745;};'use strict';var _=require(_0xfb63('0x0'));var moment=require(_0xfb63('0x1'));exports[_0xfb63('0x2')]=function(_0x5b0d67){var _0x3405e5={'conditions':[]};_0x3405e5[_0xfb63('0x3')]=_['startsWith'](_0x5b0d67,_0xfb63('0x4'))?'or':_0xfb63('0x5');var _0x4173eb=_0x5b0d67[_0xfb63('0x6')]('[$and]','')[_0xfb63('0x6')](_0xfb63('0x4'),'')[_0xfb63('0x7')]('||');for(var _0x3c030f=0x0;_0x3c030f<_0x4173eb[_0xfb63('0x8')];_0x3c030f++){var _0x46c68a=_0x4173eb[_0x3c030f][_0xfb63('0x7')](':=');var _0x3c87b8=_0x46c68a[0x0];var _0x163719=_0x46c68a[_0xfb63('0x9')](0x1);_0x163719['forEach'](function(_0xf27538){var _0x5a88c3=_0xf27538[_0xfb63('0x7')]('[')[_0xfb63('0xa')]();var _0x356415=_0xf27538[_0xfb63('0xb')](/\[(.*?)\]/g);_0x356415[_0xfb63('0xc')](function(_0xa1fb7){var _0x5770ea=_0xa1fb7['split']('[')['filter'](function(_0x39227b){return _0x39227b[_0xfb63('0xd')](']')>-0x1;})['map'](function(_0x3ecb99){return _0x3ecb99[_0xfb63('0x7')](']')[0x0];})[0x0];_0x3405e5[_0xfb63('0xe')][_0xfb63('0xf')]({'field':_0x3c87b8,'operator':_0x5a88c3,'value':_0x5770ea});});});}return _0x3405e5;};exports[_0xfb63('0x10')]=function(_0x5b734d,_0x168cd1,_0x395025){var _0x1ce115={};if(_0x168cd1==='DATE'){if(_0x395025[_0xfb63('0x11')]===_0xfb63('0x12')){_0x395025[_0xfb63('0x11')]=_0xfb63('0x13');_0x395025[_0xfb63('0x14')]+=','+_0x395025[_0xfb63('0x14')];}else if(_['includes']([_0xfb63('0x15'),'$lte'],_0x395025[_0xfb63('0x11')])){_0x395025[_0xfb63('0x14')]=moment(_0x395025[_0xfb63('0x14')])[_0xfb63('0x16')](0x1,_0xfb63('0x17'))[_0xfb63('0x18')](_0xfb63('0x19'));}}if(_0x395025[_0xfb63('0x1a')]){_0x168cd1=_0x395025[_0xfb63('0x1a')];_0x1ce115['text']=_0xfb63('0x1b')+_0x5b734d+'.'+_0x395025['field']+_0xfb63('0x1c')+_0x395025[_0xfb63('0x1a')]+')\x20'+parseOperator(_0x395025[_0xfb63('0x11')]);}else{_0x1ce115[_0xfb63('0x1d')]=_0x5b734d+'.'+_0x395025[_0xfb63('0x1e')]+'\x20'+parseOperator(_0x395025[_0xfb63('0x11')]);}if(_[_0xfb63('0x1f')](['$ne',_0xfb63('0x20')],_0x395025[_0xfb63('0x11')]))_0x1ce115['text']='('+_0x1ce115[_0xfb63('0x1d')]+_0xfb63('0x21')+_0x5b734d+'.'+_0x395025['field']+_0xfb63('0x22');_0x1ce115[_0xfb63('0x14')]=parseValue(_0x168cd1,_0x395025['operator'],_0x395025[_0xfb63('0x14')]);return _0x1ce115;};function parseOperator(_0x158195){var _0x19fbcc;switch(_0x158195){case _0xfb63('0x23'):_0x19fbcc=_0xfb63('0x24');break;case _0xfb63('0x20'):_0x19fbcc=_0xfb63('0x25');break;case _0xfb63('0x12'):_0x19fbcc=_0xfb63('0x26');break;case _0xfb63('0x27'):_0x19fbcc=_0xfb63('0x28');break;case _0xfb63('0x29'):case _0xfb63('0x2a'):case _0xfb63('0x2b'):_0x19fbcc=_0xfb63('0x2c');break;case _0xfb63('0x2d'):_0x19fbcc=_0xfb63('0x2e');break;case _0xfb63('0x15'):_0x19fbcc=_0xfb63('0x2f');break;case _0xfb63('0x30'):_0x19fbcc='<=\x20?';break;case _0xfb63('0x31'):_0x19fbcc='>=\x20?';break;case _0xfb63('0x13'):_0x19fbcc=_0xfb63('0x32');break;}return _0x19fbcc;}function parseValue(_0x25aa90,_0x3fcae1,_0x7d6078){var _0x5e6534={'start':undefined,'end':undefined};switch(_0x3fcae1){case'$in':case _0xfb63('0x20'):_0x5e6534[_0xfb63('0x33')]=_0x7d6078[_0xfb63('0x7')](',');break;case'$substring':_0x5e6534[_0xfb63('0x33')]='%'+_0x7d6078+'%';break;case'$startsWith':_0x5e6534['start']=_0x7d6078+'%';break;case'$endsWith':_0x5e6534[_0xfb63('0x33')]='%'+_0x7d6078;break;case _0xfb63('0x13'):var _0x2da103=_0x7d6078[_0xfb63('0x7')](',');var _0x7d6078=_0x2da103[_0xfb63('0xa')]();var _0x102238=_0x2da103[_0xfb63('0x34')]();if(_0x25aa90===_0xfb63('0x35')){_0x7d6078=moment(_0x7d6078)['utcOffset'](0x0,!![])['format']();_0x102238=moment(_0x102238)[_0xfb63('0x36')](0x0,!![])[_0xfb63('0x16')](0x17,_0xfb63('0x37'))[_0xfb63('0x16')](0x3b,_0xfb63('0x38'))[_0xfb63('0x16')](0x3b,_0xfb63('0x39'))[_0xfb63('0x18')]();}_0x5e6534={'start':_0x7d6078,'end':_0x102238};break;default:_0x5e6534['start']=_0x7d6078;break;}return _0x5e6534;}
\ No newline at end of file
+var _0x539f=['push','buildExpression','DATE','operator','$eq','$between','value','includes','$gt','add','days','castTo','text','CAST(','field','\x20AS\x20','$ne','$notIn','\x20OR\x20','\x20IS\x20NULL)','IN\x20?','=\x20?','<>\x20?','$substring','$startsWith','$endsWith','$lt','>\x20?','$lte','<=\x20?','$gte','>=\x20?','$in','start','shift','utcOffset','hours','minutes','seconds','format','lodash','moment','parseSearch','sqlOperator','[$or]','replace','[$and]','split','length','slice','forEach','filter','map','conditions'];(function(_0x179e11,_0xf65436){var _0x549f04=function(_0x610545){while(--_0x610545){_0x179e11['push'](_0x179e11['shift']());}};_0x549f04(++_0xf65436);}(_0x539f,0x94));var _0xf539=function(_0x59bc5b,_0xb4c0d3){_0x59bc5b=_0x59bc5b-0x0;var _0x2ac320=_0x539f[_0x59bc5b];return _0x2ac320;};'use strict';var _=require(_0xf539('0x0'));var moment=require(_0xf539('0x1'));exports[_0xf539('0x2')]=function(_0xc57a59){var _0x1b81a4={'conditions':[]};_0x1b81a4[_0xf539('0x3')]=_['startsWith'](_0xc57a59,_0xf539('0x4'))?'or':'and';var _0x276287=_0xc57a59[_0xf539('0x5')](_0xf539('0x6'),'')[_0xf539('0x5')]('[$or]','')[_0xf539('0x7')]('||');for(var _0x38e27f=0x0;_0x38e27f<_0x276287[_0xf539('0x8')];_0x38e27f++){var _0x6fc6f=_0x276287[_0x38e27f][_0xf539('0x7')](':=');var _0x373268=_0x6fc6f[0x0];var _0x2bef58=_0x6fc6f[_0xf539('0x9')](0x1);_0x2bef58[_0xf539('0xa')](function(_0x52f148){var _0x48a366=_0x52f148[_0xf539('0x7')]('[')['shift']();var _0x112061=_0x52f148['match'](/\[(.*?)\]/g);_0x112061[_0xf539('0xa')](function(_0x43fdc6){var _0x58c8f4=_0x43fdc6[_0xf539('0x7')]('[')[_0xf539('0xb')](function(_0x33a010){return _0x33a010['indexOf'](']')>-0x1;})[_0xf539('0xc')](function(_0x2f2c56){return _0x2f2c56[_0xf539('0x7')](']')[0x0];})[0x0];_0x1b81a4[_0xf539('0xd')][_0xf539('0xe')]({'field':_0x373268,'operator':_0x48a366,'value':_0x58c8f4});});});}return _0x1b81a4;};exports[_0xf539('0xf')]=function(_0x356c75,_0x362fe7,_0x1f0ea8){var _0xc8d9d9={};if(_0x362fe7===_0xf539('0x10')){if(_0x1f0ea8[_0xf539('0x11')]===_0xf539('0x12')){_0x1f0ea8[_0xf539('0x11')]=_0xf539('0x13');_0x1f0ea8[_0xf539('0x14')]+=','+_0x1f0ea8[_0xf539('0x14')];}else if(_[_0xf539('0x15')]([_0xf539('0x16'),'$lte'],_0x1f0ea8[_0xf539('0x11')])){_0x1f0ea8['value']=moment(_0x1f0ea8[_0xf539('0x14')])[_0xf539('0x17')](0x1,_0xf539('0x18'))['format']('YYYY-MM-DD');}}if(_0x1f0ea8[_0xf539('0x19')]){_0x362fe7=_0x1f0ea8[_0xf539('0x19')];_0xc8d9d9[_0xf539('0x1a')]=_0xf539('0x1b')+_0x356c75+'.'+_0x1f0ea8[_0xf539('0x1c')]+_0xf539('0x1d')+_0x1f0ea8['castTo']+')\x20'+parseOperator(_0x1f0ea8[_0xf539('0x11')]);}else{_0xc8d9d9[_0xf539('0x1a')]=_0x356c75+'.'+_0x1f0ea8['field']+'\x20'+parseOperator(_0x1f0ea8[_0xf539('0x11')]);}if(_[_0xf539('0x15')]([_0xf539('0x1e'),_0xf539('0x1f')],_0x1f0ea8[_0xf539('0x11')]))_0xc8d9d9[_0xf539('0x1a')]='('+_0xc8d9d9[_0xf539('0x1a')]+_0xf539('0x20')+_0x356c75+'.'+_0x1f0ea8[_0xf539('0x1c')]+_0xf539('0x21');_0xc8d9d9[_0xf539('0x14')]=parseValue(_0x362fe7,_0x1f0ea8[_0xf539('0x11')],_0x1f0ea8['value']);return _0xc8d9d9;};function parseOperator(_0x35e323){var _0x134195;switch(_0x35e323){case'$in':_0x134195=_0xf539('0x22');break;case _0xf539('0x1f'):_0x134195='NOT\x20IN\x20?';break;case _0xf539('0x12'):_0x134195=_0xf539('0x23');break;case _0xf539('0x1e'):_0x134195=_0xf539('0x24');break;case _0xf539('0x25'):case _0xf539('0x26'):case _0xf539('0x27'):_0x134195='LIKE\x20?';break;case _0xf539('0x28'):_0x134195='<\x20?';break;case _0xf539('0x16'):_0x134195=_0xf539('0x29');break;case _0xf539('0x2a'):_0x134195=_0xf539('0x2b');break;case _0xf539('0x2c'):_0x134195=_0xf539('0x2d');break;case _0xf539('0x13'):_0x134195='BETWEEN\x20?\x20AND\x20?';break;}return _0x134195;}function parseValue(_0x5f5406,_0x378258,_0x2327a9){var _0x435d42={'start':undefined,'end':undefined};switch(_0x378258){case _0xf539('0x2e'):case'$notIn':_0x435d42[_0xf539('0x2f')]=_0x2327a9[_0xf539('0x7')](',');break;case _0xf539('0x25'):_0x435d42[_0xf539('0x2f')]='%'+_0x2327a9+'%';break;case _0xf539('0x26'):_0x435d42[_0xf539('0x2f')]=_0x2327a9+'%';break;case _0xf539('0x27'):_0x435d42[_0xf539('0x2f')]='%'+_0x2327a9;break;case _0xf539('0x13'):var _0x206649=_0x2327a9['split'](',');var _0x2327a9=_0x206649[_0xf539('0x30')]();var _0xa29f1b=_0x206649['pop']();if(_0x5f5406===_0xf539('0x10')){_0x2327a9=moment(_0x2327a9)[_0xf539('0x31')](0x0,!![])['format']();_0xa29f1b=moment(_0xa29f1b)[_0xf539('0x31')](0x0,!![])[_0xf539('0x17')](0x17,_0xf539('0x32'))[_0xf539('0x17')](0x3b,_0xf539('0x33'))[_0xf539('0x17')](0x3b,_0xf539('0x34'))[_0xf539('0x35')]();}_0x435d42={'start':_0x2327a9,'end':_0xa29f1b};break;default:_0x435d42['start']=_0x2327a9;break;}return _0x435d42;}
\ No newline at end of file