Built motion from commit (unavailable).|2.5.10
[motion2.git] / server / components / parsers / advancedSearch.js
index df8f4c1..d7e969f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x294b=['$lt','>\x20?','$lte','>=\x20?','start','$endsWith','shift','pop','utcOffset','minutes','seconds','moment','startsWith','[$or]','and','[$and]','replace','split','length','forEach','match','map','conditions','push','buildExpression','DATE','operator','$eq','$between','includes','$gt','value','add','days','castTo','field','\x20AS\x20','text','$notIn','\x20OR\x20','\x20IS\x20NULL)','$in','IN\x20?','NOT\x20IN\x20?','=\x20?','$ne','<>\x20?','$substring','$startsWith','LIKE\x20?'];(function(_0x13962c,_0x18e542){var _0x24abef=function(_0x20fc83){while(--_0x20fc83){_0x13962c['push'](_0x13962c['shift']());}};_0x24abef(++_0x18e542);}(_0x294b,0x105));var _0xb294=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x294b[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var moment=require(_0xb294('0x0'));exports['parseSearch']=function(_0x150689){var _0x29d44e={'conditions':[]};_0x29d44e['sqlOperator']=_[_0xb294('0x1')](_0x150689,_0xb294('0x2'))?'or':_0xb294('0x3');var _0x4e77d0=_0x150689['replace'](_0xb294('0x4'),'')[_0xb294('0x5')]('[$or]','')[_0xb294('0x6')]('||');for(var _0x538606=0x0;_0x538606<_0x4e77d0[_0xb294('0x7')];_0x538606++){var _0x1c90aa=_0x4e77d0[_0x538606]['split'](':=');var _0x102c62=_0x1c90aa[0x0];var _0x19a567=_0x1c90aa['slice'](0x1);_0x19a567[_0xb294('0x8')](function(_0x3b12b2){var _0x11be0a=_0x3b12b2[_0xb294('0x6')]('[')['shift']();var _0x1cd2bd=_0x3b12b2[_0xb294('0x9')](/\[(.*?)\]/g);_0x1cd2bd['forEach'](function(_0x18df6c){var _0x113176=_0x18df6c[_0xb294('0x6')]('[')['filter'](function(_0x3a05cd){return _0x3a05cd['indexOf'](']')>-0x1;})[_0xb294('0xa')](function(_0x4f6ab3){return _0x4f6ab3['split'](']')[0x0];})[0x0];_0x29d44e[_0xb294('0xb')][_0xb294('0xc')]({'field':_0x102c62,'operator':_0x11be0a,'value':_0x113176});});});}return _0x29d44e;};exports[_0xb294('0xd')]=function(_0x53320e,_0x439b34,_0x58b847){var _0x1e1dfe={};if(_0x439b34===_0xb294('0xe')){if(_0x58b847[_0xb294('0xf')]===_0xb294('0x10')){_0x58b847[_0xb294('0xf')]=_0xb294('0x11');_0x58b847['value']+=','+_0x58b847['value'];}else if(_[_0xb294('0x12')]([_0xb294('0x13'),'$lte'],_0x58b847['operator'])){_0x58b847[_0xb294('0x14')]=moment(_0x58b847[_0xb294('0x14')])[_0xb294('0x15')](0x1,_0xb294('0x16'))['format']('YYYY-MM-DD');}}if(_0x58b847[_0xb294('0x17')]){_0x439b34=_0x58b847['castTo'];_0x1e1dfe['text']='CAST('+_0x53320e+'.'+_0x58b847[_0xb294('0x18')]+_0xb294('0x19')+_0x58b847[_0xb294('0x17')]+')\x20'+parseOperator(_0x58b847[_0xb294('0xf')]);}else{_0x1e1dfe[_0xb294('0x1a')]=_0x53320e+'.'+_0x58b847[_0xb294('0x18')]+'\x20'+parseOperator(_0x58b847[_0xb294('0xf')]);}if(_[_0xb294('0x12')](['$ne',_0xb294('0x1b')],_0x58b847['operator']))_0x1e1dfe['text']='('+_0x1e1dfe[_0xb294('0x1a')]+_0xb294('0x1c')+_0x53320e+'.'+_0x58b847[_0xb294('0x18')]+_0xb294('0x1d');_0x1e1dfe[_0xb294('0x14')]=parseValue(_0x439b34,_0x58b847[_0xb294('0xf')],_0x58b847[_0xb294('0x14')]);return _0x1e1dfe;};function parseOperator(_0x132d2d){var _0x197dbc;switch(_0x132d2d){case _0xb294('0x1e'):_0x197dbc=_0xb294('0x1f');break;case'$notIn':_0x197dbc=_0xb294('0x20');break;case _0xb294('0x10'):_0x197dbc=_0xb294('0x21');break;case _0xb294('0x22'):_0x197dbc=_0xb294('0x23');break;case _0xb294('0x24'):case _0xb294('0x25'):case'$endsWith':_0x197dbc=_0xb294('0x26');break;case _0xb294('0x27'):_0x197dbc='<\x20?';break;case'$gt':_0x197dbc=_0xb294('0x28');break;case _0xb294('0x29'):_0x197dbc='<=\x20?';break;case'$gte':_0x197dbc=_0xb294('0x2a');break;case _0xb294('0x11'):_0x197dbc='BETWEEN\x20?\x20AND\x20?';break;}return _0x197dbc;}function parseValue(_0x58be8b,_0x3f95f1,_0x5888da){var _0x241590={'start':undefined,'end':undefined};switch(_0x3f95f1){case'$in':case _0xb294('0x1b'):_0x241590[_0xb294('0x2b')]=_0x5888da[_0xb294('0x6')](',');break;case _0xb294('0x24'):_0x241590[_0xb294('0x2b')]='%'+_0x5888da+'%';break;case _0xb294('0x25'):_0x241590[_0xb294('0x2b')]=_0x5888da+'%';break;case _0xb294('0x2c'):_0x241590['start']='%'+_0x5888da;break;case _0xb294('0x11'):var _0x132b30=_0x5888da[_0xb294('0x6')](',');var _0x5888da=_0x132b30[_0xb294('0x2d')]();var _0x3f57cd=_0x132b30[_0xb294('0x2e')]();if(_0x58be8b===_0xb294('0xe')){_0x5888da=moment(_0x5888da)[_0xb294('0x2f')](0x0,!![])['format']();_0x3f57cd=moment(_0x3f57cd)['utcOffset'](0x0,!![])[_0xb294('0x15')](0x17,'hours')[_0xb294('0x15')](0x3b,_0xb294('0x30'))[_0xb294('0x15')](0x3b,_0xb294('0x31'))['format']();}_0x241590={'start':_0x5888da,'end':_0x3f57cd};break;default:_0x241590[_0xb294('0x2b')]=_0x5888da;break;}return _0x241590;}
\ No newline at end of file
+var _0xf506=['$in','IN\x20?','NOT\x20IN\x20?','<>\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','>\x20?','$lte','<=\x20?','>=\x20?','$between','start','pop','utcOffset','minutes','seconds','lodash','parseSearch','sqlOperator','startsWith','and','[$and]','replace','[$or]','split','slice','forEach','shift','match','filter','conditions','push','buildExpression','DATE','operator','$eq','value','includes','$gt','add','days','format','YYYY-MM-DD','castTo','text','CAST(','field','$ne','$notIn','\x20IS\x20NULL)'];(function(_0x5185cf,_0x18e620){var _0x53a6b5=function(_0x414d58){while(--_0x414d58){_0x5185cf['push'](_0x5185cf['shift']());}};_0x53a6b5(++_0x18e620);}(_0xf506,0x1f0));var _0x6f50=function(_0x414e76,_0x196f24){_0x414e76=_0x414e76-0x0;var _0x341320=_0xf506[_0x414e76];return _0x341320;};'use strict';var _=require(_0x6f50('0x0'));var moment=require('moment');exports[_0x6f50('0x1')]=function(_0x1a1a1e){var _0x2e93e7={'conditions':[]};_0x2e93e7[_0x6f50('0x2')]=_[_0x6f50('0x3')](_0x1a1a1e,'[$or]')?'or':_0x6f50('0x4');var _0x5bfb54=_0x1a1a1e['replace'](_0x6f50('0x5'),'')[_0x6f50('0x6')](_0x6f50('0x7'),'')['split']('||');for(var _0x34697d=0x0;_0x34697d<_0x5bfb54['length'];_0x34697d++){var _0x50616b=_0x5bfb54[_0x34697d][_0x6f50('0x8')](':=');var _0xc4858e=_0x50616b[0x0];var _0x59196f=_0x50616b[_0x6f50('0x9')](0x1);_0x59196f[_0x6f50('0xa')](function(_0x416181){var _0x13c1bd=_0x416181[_0x6f50('0x8')]('[')[_0x6f50('0xb')]();var _0x4c3629=_0x416181[_0x6f50('0xc')](/\[(.*?)\]/g);_0x4c3629[_0x6f50('0xa')](function(_0x2ecdfd){var _0x10871c=_0x2ecdfd[_0x6f50('0x8')]('[')[_0x6f50('0xd')](function(_0x272726){return _0x272726['indexOf'](']')>-0x1;})['map'](function(_0x40fbf2){return _0x40fbf2[_0x6f50('0x8')](']')[0x0];})[0x0];_0x2e93e7[_0x6f50('0xe')][_0x6f50('0xf')]({'field':_0xc4858e,'operator':_0x13c1bd,'value':_0x10871c});});});}return _0x2e93e7;};exports[_0x6f50('0x10')]=function(_0x11209a,_0x30fe06,_0x45ea98){var _0x528ab6={};if(_0x30fe06===_0x6f50('0x11')){if(_0x45ea98[_0x6f50('0x12')]===_0x6f50('0x13')){_0x45ea98['operator']='$between';_0x45ea98[_0x6f50('0x14')]+=','+_0x45ea98[_0x6f50('0x14')];}else if(_[_0x6f50('0x15')]([_0x6f50('0x16'),'$lte'],_0x45ea98[_0x6f50('0x12')])){_0x45ea98['value']=moment(_0x45ea98[_0x6f50('0x14')])[_0x6f50('0x17')](0x1,_0x6f50('0x18'))[_0x6f50('0x19')](_0x6f50('0x1a'));}}if(_0x45ea98['castTo']){_0x30fe06=_0x45ea98[_0x6f50('0x1b')];_0x528ab6[_0x6f50('0x1c')]=_0x6f50('0x1d')+_0x11209a+'.'+_0x45ea98[_0x6f50('0x1e')]+'\x20AS\x20'+_0x45ea98[_0x6f50('0x1b')]+')\x20'+parseOperator(_0x45ea98[_0x6f50('0x12')]);}else{_0x528ab6['text']=_0x11209a+'.'+_0x45ea98['field']+'\x20'+parseOperator(_0x45ea98['operator']);}if(_[_0x6f50('0x15')]([_0x6f50('0x1f'),_0x6f50('0x20')],_0x45ea98['operator']))_0x528ab6[_0x6f50('0x1c')]='('+_0x528ab6[_0x6f50('0x1c')]+'\x20OR\x20'+_0x11209a+'.'+_0x45ea98[_0x6f50('0x1e')]+_0x6f50('0x21');_0x528ab6[_0x6f50('0x14')]=parseValue(_0x30fe06,_0x45ea98['operator'],_0x45ea98['value']);return _0x528ab6;};function parseOperator(_0x3dfa60){var _0x13982e;switch(_0x3dfa60){case _0x6f50('0x22'):_0x13982e=_0x6f50('0x23');break;case _0x6f50('0x20'):_0x13982e=_0x6f50('0x24');break;case _0x6f50('0x13'):_0x13982e='=\x20?';break;case'$ne':_0x13982e=_0x6f50('0x25');break;case _0x6f50('0x26'):case _0x6f50('0x27'):case _0x6f50('0x28'):_0x13982e=_0x6f50('0x29');break;case _0x6f50('0x2a'):_0x13982e='<\x20?';break;case _0x6f50('0x16'):_0x13982e=_0x6f50('0x2b');break;case _0x6f50('0x2c'):_0x13982e=_0x6f50('0x2d');break;case'$gte':_0x13982e=_0x6f50('0x2e');break;case _0x6f50('0x2f'):_0x13982e='BETWEEN\x20?\x20AND\x20?';break;}return _0x13982e;}function parseValue(_0x10cba7,_0x548f9e,_0x119cfb){var _0x2beed8={'start':undefined,'end':undefined};switch(_0x548f9e){case _0x6f50('0x22'):case _0x6f50('0x20'):_0x2beed8[_0x6f50('0x30')]=_0x119cfb[_0x6f50('0x8')](',');break;case'$substring':_0x2beed8[_0x6f50('0x30')]='%'+_0x119cfb+'%';break;case _0x6f50('0x27'):_0x2beed8[_0x6f50('0x30')]=_0x119cfb+'%';break;case _0x6f50('0x28'):_0x2beed8[_0x6f50('0x30')]='%'+_0x119cfb;break;case _0x6f50('0x2f'):var _0x397b8b=_0x119cfb['split'](',');var _0x119cfb=_0x397b8b[_0x6f50('0xb')]();var _0x417d2f=_0x397b8b[_0x6f50('0x31')]();if(_0x10cba7===_0x6f50('0x11')){_0x119cfb=moment(_0x119cfb)[_0x6f50('0x32')](0x0,!![])[_0x6f50('0x19')]();_0x417d2f=moment(_0x417d2f)[_0x6f50('0x32')](0x0,!![])['add'](0x17,'hours')[_0x6f50('0x17')](0x3b,_0x6f50('0x33'))['add'](0x3b,_0x6f50('0x34'))['format']();}_0x2beed8={'start':_0x119cfb,'end':_0x417d2f};break;default:_0x2beed8['start']=_0x119cfb;break;}return _0x2beed8;}
\ No newline at end of file