Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / components / parsers / advancedSearch.js
index 223a27d..4e07d94 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x184e=['field','\x20AS\x20','$ne','$notIn','\x20IS\x20NULL)','$in','NOT\x20IN\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','<\x20?','>\x20?','<=\x20?','>=\x20?','BETWEEN\x20?\x20AND\x20?','start','DATE','utcOffset','hours','minutes','seconds','lodash','moment','sqlOperator','startsWith','[$or]','replace','[$and]','length','split','slice','shift','match','filter','indexOf','map','conditions','buildExpression','operator','$eq','$between','value','$gt','$lte','add','days','format','YYYY-MM-DD','castTo','text','CAST('];(function(_0x2e3e82,_0x171e55){var _0x2dd7dd=function(_0x29fe25){while(--_0x29fe25){_0x2e3e82['push'](_0x2e3e82['shift']());}};_0x2dd7dd(++_0x171e55);}(_0x184e,0xeb));var _0xe184=function(_0xa2b098,_0x461a08){_0xa2b098=_0xa2b098-0x0;var _0x29502e=_0x184e[_0xa2b098];return _0x29502e;};'use strict';var _=require(_0xe184('0x0'));var moment=require(_0xe184('0x1'));exports['parseSearch']=function(_0xa59006){var _0x1ef081={'conditions':[]};_0x1ef081[_0xe184('0x2')]=_[_0xe184('0x3')](_0xa59006,_0xe184('0x4'))?'or':'and';var _0x1a05f0=_0xa59006[_0xe184('0x5')](_0xe184('0x6'),'')['replace'](_0xe184('0x4'),'')['split']('||');for(var _0x6b7c36=0x0;_0x6b7c36<_0x1a05f0[_0xe184('0x7')];_0x6b7c36++){var _0x34473d=_0x1a05f0[_0x6b7c36][_0xe184('0x8')](':=');var _0x3cd9c8=_0x34473d[0x0];var _0x54205b=_0x34473d[_0xe184('0x9')](0x1);_0x54205b['forEach'](function(_0x563d0a){var _0x4be1e0=_0x563d0a['split']('[')[_0xe184('0xa')]();var _0x349eae=_0x563d0a[_0xe184('0xb')](/\[(.*?)\]/g);_0x349eae['forEach'](function(_0x4d5c19){var _0x1711d4=_0x4d5c19['split']('[')[_0xe184('0xc')](function(_0xb12887){return _0xb12887[_0xe184('0xd')](']')>-0x1;})[_0xe184('0xe')](function(_0x3f3e0f){return _0x3f3e0f[_0xe184('0x8')](']')[0x0];})[0x0];_0x1ef081[_0xe184('0xf')]['push']({'field':_0x3cd9c8,'operator':_0x4be1e0,'value':_0x1711d4});});});}return _0x1ef081;};exports[_0xe184('0x10')]=function(_0x28dac4,_0x348827,_0xe4b5eb){var _0x11b13f={};if(_0x348827==='DATE'){if(_0xe4b5eb[_0xe184('0x11')]===_0xe184('0x12')){_0xe4b5eb[_0xe184('0x11')]=_0xe184('0x13');_0xe4b5eb[_0xe184('0x14')]+=','+_0xe4b5eb[_0xe184('0x14')];}else if(_['includes']([_0xe184('0x15'),_0xe184('0x16')],_0xe4b5eb[_0xe184('0x11')])){_0xe4b5eb[_0xe184('0x14')]=moment(_0xe4b5eb[_0xe184('0x14')])[_0xe184('0x17')](0x1,_0xe184('0x18'))[_0xe184('0x19')](_0xe184('0x1a'));}}if(_0xe4b5eb[_0xe184('0x1b')]){_0x348827=_0xe4b5eb[_0xe184('0x1b')];_0x11b13f[_0xe184('0x1c')]=_0xe184('0x1d')+_0x28dac4+'.'+_0xe4b5eb[_0xe184('0x1e')]+_0xe184('0x1f')+_0xe4b5eb[_0xe184('0x1b')]+')\x20'+parseOperator(_0xe4b5eb[_0xe184('0x11')]);}else{_0x11b13f['text']=_0x28dac4+'.'+_0xe4b5eb[_0xe184('0x1e')]+'\x20'+parseOperator(_0xe4b5eb[_0xe184('0x11')]);}if(_['includes']([_0xe184('0x20'),_0xe184('0x21')],_0xe4b5eb[_0xe184('0x11')]))_0x11b13f['text']='('+_0x11b13f[_0xe184('0x1c')]+'\x20OR\x20'+_0x28dac4+'.'+_0xe4b5eb[_0xe184('0x1e')]+_0xe184('0x22');_0x11b13f['value']=parseValue(_0x348827,_0xe4b5eb[_0xe184('0x11')],_0xe4b5eb[_0xe184('0x14')]);return _0x11b13f;};function parseOperator(_0x1fa50e){var _0x436cd2;switch(_0x1fa50e){case _0xe184('0x23'):_0x436cd2='IN\x20?';break;case _0xe184('0x21'):_0x436cd2=_0xe184('0x24');break;case'$eq':_0x436cd2='=\x20?';break;case _0xe184('0x20'):_0x436cd2='<>\x20?';break;case _0xe184('0x25'):case _0xe184('0x26'):case _0xe184('0x27'):_0x436cd2=_0xe184('0x28');break;case _0xe184('0x29'):_0x436cd2=_0xe184('0x2a');break;case'$gt':_0x436cd2=_0xe184('0x2b');break;case _0xe184('0x16'):_0x436cd2=_0xe184('0x2c');break;case'$gte':_0x436cd2=_0xe184('0x2d');break;case _0xe184('0x13'):_0x436cd2=_0xe184('0x2e');break;}return _0x436cd2;}function parseValue(_0x4d82b6,_0x1b8521,_0x3d415a){var _0x5285d0={'start':undefined,'end':undefined};switch(_0x1b8521){case _0xe184('0x23'):case _0xe184('0x21'):_0x5285d0[_0xe184('0x2f')]=_0x3d415a[_0xe184('0x8')](',');break;case _0xe184('0x25'):_0x5285d0['start']='%'+_0x3d415a+'%';break;case _0xe184('0x26'):_0x5285d0[_0xe184('0x2f')]=_0x3d415a+'%';break;case _0xe184('0x27'):_0x5285d0['start']='%'+_0x3d415a;break;case _0xe184('0x13'):var _0x5094f3=_0x3d415a['split'](',');var _0x3d415a=_0x5094f3[_0xe184('0xa')]();var _0x3b6579=_0x5094f3['pop']();if(_0x4d82b6===_0xe184('0x30')){_0x3d415a=moment(_0x3d415a)[_0xe184('0x31')](0x0,!![])[_0xe184('0x19')]();_0x3b6579=moment(_0x3b6579)[_0xe184('0x31')](0x0,!![])[_0xe184('0x17')](0x17,_0xe184('0x32'))[_0xe184('0x17')](0x3b,_0xe184('0x33'))[_0xe184('0x17')](0x3b,_0xe184('0x34'))[_0xe184('0x19')]();}_0x5285d0={'start':_0x3d415a,'end':_0x3b6579};break;default:_0x5285d0[_0xe184('0x2f')]=_0x3d415a;break;}return _0x5285d0;}
\ No newline at end of file
+var _0x7248=['includes','$lte','add','days','format','YYYY-MM-DD','castTo','CAST(','field','\x20AS\x20','$ne','$notIn','text','\x20IS\x20NULL)','$in','NOT\x20IN\x20?','<>\x20?','$startsWith','$endsWith','LIKE\x20?','<\x20?','$gt','>\x20?','$gte','>=\x20?','BETWEEN\x20?\x20AND\x20?','$substring','start','utcOffset','hours','minutes','seconds','lodash','moment','parseSearch','sqlOperator','[$or]','replace','split','length','slice','shift','match','filter','indexOf','map','push','DATE','$eq','operator','$between','value'];(function(_0x304c47,_0x4e0e20){var _0x2dbd2c=function(_0x4f7049){while(--_0x4f7049){_0x304c47['push'](_0x304c47['shift']());}};_0x2dbd2c(++_0x4e0e20);}(_0x7248,0x88));var _0x8724=function(_0x5e944a,_0x2847b4){_0x5e944a=_0x5e944a-0x0;var _0x38f07b=_0x7248[_0x5e944a];return _0x38f07b;};'use strict';var _=require(_0x8724('0x0'));var moment=require(_0x8724('0x1'));exports[_0x8724('0x2')]=function(_0x21e872){var _0x198e89={'conditions':[]};_0x198e89[_0x8724('0x3')]=_['startsWith'](_0x21e872,_0x8724('0x4'))?'or':'and';var _0x336ade=_0x21e872[_0x8724('0x5')]('[$and]','')[_0x8724('0x5')](_0x8724('0x4'),'')[_0x8724('0x6')]('||');for(var _0x2d05d0=0x0;_0x2d05d0<_0x336ade[_0x8724('0x7')];_0x2d05d0++){var _0x1563e5=_0x336ade[_0x2d05d0][_0x8724('0x6')](':=');var _0x17a1cc=_0x1563e5[0x0];var _0x501555=_0x1563e5[_0x8724('0x8')](0x1);_0x501555['forEach'](function(_0x475dd6){var _0x421ede=_0x475dd6[_0x8724('0x6')]('[')[_0x8724('0x9')]();var _0x2dfc1e=_0x475dd6[_0x8724('0xa')](/\[(.*?)\]/g);_0x2dfc1e['forEach'](function(_0x150521){var _0x444ccf=_0x150521['split']('[')[_0x8724('0xb')](function(_0x4e4645){return _0x4e4645[_0x8724('0xc')](']')>-0x1;})[_0x8724('0xd')](function(_0x5694a1){return _0x5694a1[_0x8724('0x6')](']')[0x0];})[0x0];_0x198e89['conditions'][_0x8724('0xe')]({'field':_0x17a1cc,'operator':_0x421ede,'value':_0x444ccf});});});}return _0x198e89;};exports['buildExpression']=function(_0x2a68be,_0x4e7100,_0x4e40cc){var _0x82a07c={};if(_0x4e7100===_0x8724('0xf')){if(_0x4e40cc['operator']===_0x8724('0x10')){_0x4e40cc[_0x8724('0x11')]=_0x8724('0x12');_0x4e40cc[_0x8724('0x13')]+=','+_0x4e40cc['value'];}else if(_[_0x8724('0x14')](['$gt',_0x8724('0x15')],_0x4e40cc['operator'])){_0x4e40cc['value']=moment(_0x4e40cc[_0x8724('0x13')])[_0x8724('0x16')](0x1,_0x8724('0x17'))[_0x8724('0x18')](_0x8724('0x19'));}}if(_0x4e40cc[_0x8724('0x1a')]){_0x4e7100=_0x4e40cc[_0x8724('0x1a')];_0x82a07c['text']=_0x8724('0x1b')+_0x2a68be+'.'+_0x4e40cc[_0x8724('0x1c')]+_0x8724('0x1d')+_0x4e40cc[_0x8724('0x1a')]+')\x20'+parseOperator(_0x4e40cc[_0x8724('0x11')]);}else{_0x82a07c['text']=_0x2a68be+'.'+_0x4e40cc[_0x8724('0x1c')]+'\x20'+parseOperator(_0x4e40cc[_0x8724('0x11')]);}if(_[_0x8724('0x14')]([_0x8724('0x1e'),_0x8724('0x1f')],_0x4e40cc[_0x8724('0x11')]))_0x82a07c[_0x8724('0x20')]='('+_0x82a07c[_0x8724('0x20')]+'\x20OR\x20'+_0x2a68be+'.'+_0x4e40cc[_0x8724('0x1c')]+_0x8724('0x21');_0x82a07c[_0x8724('0x13')]=parseValue(_0x4e7100,_0x4e40cc[_0x8724('0x11')],_0x4e40cc[_0x8724('0x13')]);return _0x82a07c;};function parseOperator(_0x44fef9){var _0x2b2b6b;switch(_0x44fef9){case _0x8724('0x22'):_0x2b2b6b='IN\x20?';break;case _0x8724('0x1f'):_0x2b2b6b=_0x8724('0x23');break;case _0x8724('0x10'):_0x2b2b6b='=\x20?';break;case _0x8724('0x1e'):_0x2b2b6b=_0x8724('0x24');break;case'$substring':case _0x8724('0x25'):case _0x8724('0x26'):_0x2b2b6b=_0x8724('0x27');break;case'$lt':_0x2b2b6b=_0x8724('0x28');break;case _0x8724('0x29'):_0x2b2b6b=_0x8724('0x2a');break;case'$lte':_0x2b2b6b='<=\x20?';break;case _0x8724('0x2b'):_0x2b2b6b=_0x8724('0x2c');break;case _0x8724('0x12'):_0x2b2b6b=_0x8724('0x2d');break;}return _0x2b2b6b;}function parseValue(_0x48071c,_0x11376c,_0x21b54d){var _0x4ae033={'start':undefined,'end':undefined};switch(_0x11376c){case'$in':case _0x8724('0x1f'):_0x4ae033['start']=_0x21b54d[_0x8724('0x6')](',');break;case _0x8724('0x2e'):_0x4ae033['start']='%'+_0x21b54d+'%';break;case _0x8724('0x25'):_0x4ae033[_0x8724('0x2f')]=_0x21b54d+'%';break;case'$endsWith':_0x4ae033['start']='%'+_0x21b54d;break;case _0x8724('0x12'):var _0x424483=_0x21b54d[_0x8724('0x6')](',');var _0x21b54d=_0x424483[_0x8724('0x9')]();var _0x142041=_0x424483['pop']();if(_0x48071c===_0x8724('0xf')){_0x21b54d=moment(_0x21b54d)[_0x8724('0x30')](0x0,!![])[_0x8724('0x18')]();_0x142041=moment(_0x142041)[_0x8724('0x30')](0x0,!![])[_0x8724('0x16')](0x17,_0x8724('0x31'))[_0x8724('0x16')](0x3b,_0x8724('0x32'))[_0x8724('0x16')](0x3b,_0x8724('0x33'))['format']();}_0x4ae033={'start':_0x21b54d,'end':_0x142041};break;default:_0x4ae033[_0x8724('0x2f')]=_0x21b54d;break;}return _0x4ae033;}
\ No newline at end of file