Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index d94d3b8..326bcd3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc84f=['request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','SugarcrmConfiguration,\x20%s,\x20%s','message','result','catch','status','end','json','count','offset','limit','Content-Range','apply','reject','update','destroy','sendStatus','stack','name','send','map','SugarcrmConfiguration','fieldName','type','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','includeAll','include','findAll','rows','params','keys','rawAttributes','create','body','find','getFields','findOne','SugarcrmField','options','getSubjects','getDescriptions','html-pdf','eml-format','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','then','info'];(function(_0x10942c,_0x2969cb){var _0x5530b0=function(_0x34b22f){while(--_0x34b22f){_0x10942c['push'](_0x10942c['shift']());}};_0x5530b0(++_0x2969cb);}(_0xc84f,0x1a5));var _0xfc84=function(_0x50b10b,_0x21fb33){_0x50b10b=_0x50b10b-0x0;var _0x3e5581=_0xc84f[_0x50b10b];return _0x3e5581;};'use strict';var pdf=require(_0xfc84('0x0'));var emlformat=require(_0xfc84('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xfc84('0x2'));var rp=require('request-promise');var moment=require(_0xfc84('0x3'));var BPromise=require(_0xfc84('0x4'));var Mustache=require(_0xfc84('0x5'));var util=require('util');var path=require(_0xfc84('0x6'));var sox=require(_0xfc84('0x7'));var csv=require(_0xfc84('0x8'));var ejs=require(_0xfc84('0x9'));var fs=require('fs');var _=require(_0xfc84('0xa'));var squel=require('squel');var crypto=require(_0xfc84('0xb'));var jsforce=require(_0xfc84('0xc'));var deskjs=require(_0xfc84('0xd'));var toCsv=require(_0xfc84('0x8'));var querystring=require(_0xfc84('0xe'));var Papa=require('papaparse');var Redis=require(_0xfc84('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xfc84('0x10'));var as=require(_0xfc84('0x11'));var hardwareService=require(_0xfc84('0x12'));var logger=require(_0xfc84('0x13'))('api');var utils=require(_0xfc84('0x14'));var config=require('../../config/environment');var db=require(_0xfc84('0x15'))['db'];var jayson=require(_0xfc84('0x16'));var client=jayson[_0xfc84('0x17')]['http']({'port':0x232a});function checkPasswordPattern(_0x33197b,_0x373e0d,_0x1bccff){if(_0x1bccff){var _0x25e0ae=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x25e0ae['test'](_0x373e0d)){return _0x33197b;}else{throw new db[(_0xfc84('0x18'))][(_0xfc84('0x19'))](_0xfc84('0x1a'));}}else{return _0x33197b;}}function respondWithRpcPromise(_0x550c5d,_0x219a0b,_0x10969a,_0x33bbf6){return new BPromise(function(_0x4bf6ee,_0x410bda){var _0x3f79c7=_0x33bbf6||client;return _0x3f79c7['request'](_0x550c5d,_0x10969a)[_0xfc84('0x1b')](function(_0x55ae09){logger[_0xfc84('0x1c')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x219a0b,_0xfc84('0x1d'));logger[_0xfc84('0x1e')](_0xfc84('0x1f'),_0x219a0b,_0xfc84('0x1d'),JSON[_0xfc84('0x20')](_0x55ae09));if(_0x55ae09[_0xfc84('0x21')]){if(_0x55ae09[_0xfc84('0x21')][_0xfc84('0x22')]===0x1f4){logger['error'](_0xfc84('0x23'),_0x219a0b,_0x55ae09[_0xfc84('0x21')]['message']);return _0x410bda(_0x55ae09[_0xfc84('0x21')]['message']);}logger[_0xfc84('0x21')](_0xfc84('0x23'),_0x219a0b,_0x55ae09['error'][_0xfc84('0x24')]);return _0x4bf6ee(_0x55ae09[_0xfc84('0x21')][_0xfc84('0x24')]);}else{logger[_0xfc84('0x1c')](_0xfc84('0x23'),_0x219a0b,_0xfc84('0x1d'));_0x4bf6ee(_0x55ae09[_0xfc84('0x25')]['message']);}})[_0xfc84('0x26')](function(_0x59abb6){logger[_0xfc84('0x21')](_0xfc84('0x23'),_0x219a0b,_0x59abb6);_0x410bda(_0x59abb6);});});}function respondWithStatusCode(_0x391b4e,_0x2201df){_0x2201df=_0x2201df||0xcc;return function(_0x45b432){if(_0x45b432){return _0x391b4e['sendStatus'](_0x2201df);}return _0x391b4e[_0xfc84('0x27')](_0x2201df)[_0xfc84('0x28')]();};}function respondWithResult(_0x35b2fe,_0x1e0ce0){_0x1e0ce0=_0x1e0ce0||0xc8;return function(_0x2e7e29){if(_0x2e7e29){return _0x35b2fe['status'](_0x1e0ce0)[_0xfc84('0x29')](_0x2e7e29);}};}function respondWithFilteredResult(_0x4d9cdd,_0x2451f8){return function(_0x4d069e){if(_0x4d069e){var _0x3bc6e0=_0x4d069e[_0xfc84('0x2a')],_0x5a4b38=_0x2451f8[_0xfc84('0x2b')],_0x5a3c0d=_0x2451f8[_0xfc84('0x2b')]+_0x2451f8[_0xfc84('0x2c')],_0x4906fd;if(_0x5a3c0d>=_0x3bc6e0){_0x5a3c0d=_0x3bc6e0;_0x4906fd=0xc8;}else{_0x4906fd=0xce;}_0x4d9cdd[_0xfc84('0x27')](_0x4906fd);return _0x4d9cdd['set'](_0xfc84('0x2d'),_0x5a4b38+'-'+_0x5a3c0d+'/'+_0x3bc6e0)['json'](_0x4d069e);}return null;};}function patchUpdates(_0x180bd1){return function(_0x27030e){try{jsonpatch[_0xfc84('0x2e')](_0x27030e,_0x180bd1,!![]);}catch(_0x48adfe){return BPromise[_0xfc84('0x2f')](_0x48adfe);}return _0x27030e['save']();};}function saveUpdates(_0x113038,_0x350591){return function(_0x3c1b59){if(_0x3c1b59){return _0x3c1b59[_0xfc84('0x30')](_0x113038)['then'](function(_0x459cbd){return _0x459cbd;});}return null;};}function removeEntity(_0x314af9,_0x7daa3b){return function(_0x5c2bec){if(_0x5c2bec){return _0x5c2bec[_0xfc84('0x31')]()['then'](function(){_0x314af9[_0xfc84('0x27')](0xcc)[_0xfc84('0x28')]();});}};}function handleEntityNotFound(_0x22dc11,_0x58bc74){return function(_0x32e62){if(!_0x32e62){_0x22dc11[_0xfc84('0x32')](0x194);}return _0x32e62;};}function handleError(_0x112225,_0x4f7d38){_0x4f7d38=_0x4f7d38||0x1f4;return function(_0x51881e){logger['error'](_0x51881e[_0xfc84('0x33')]);if(_0x51881e[_0xfc84('0x34')]){delete _0x51881e[_0xfc84('0x34')];}_0x112225[_0xfc84('0x27')](_0x4f7d38)[_0xfc84('0x35')](_0x51881e);};}exports['index']=function(_0x3f9c23,_0x83447b){var _0xba7d3a={},_0x374ab0={},_0x477e93={'count':0x0,'rows':[]};var _0x1c261e=_[_0xfc84('0x36')](db[_0xfc84('0x37')]['rawAttributes'],function(_0xffa7e7){return{'name':_0xffa7e7[_0xfc84('0x38')],'type':_0xffa7e7[_0xfc84('0x39')]['key']};});_0x374ab0[_0xfc84('0x3a')]=_[_0xfc84('0x36')](_0x1c261e,'name');_0x374ab0['query']=_['keys'](_0x3f9c23[_0xfc84('0x3b')]);_0x374ab0[_0xfc84('0x3c')]=_['intersection'](_0x374ab0[_0xfc84('0x3a')],_0x374ab0[_0xfc84('0x3b')]);_0xba7d3a[_0xfc84('0x3d')]=_[_0xfc84('0x3e')](_0x374ab0[_0xfc84('0x3a')],qs['fields'](_0x3f9c23[_0xfc84('0x3b')][_0xfc84('0x3f')]));_0xba7d3a[_0xfc84('0x3d')]=_0xba7d3a['attributes'][_0xfc84('0x40')]?_0xba7d3a['attributes']:_0x374ab0[_0xfc84('0x3a')];if(!_0x3f9c23['query'][_0xfc84('0x41')](_0xfc84('0x42'))){_0xba7d3a[_0xfc84('0x2c')]=qs[_0xfc84('0x2c')](_0x3f9c23[_0xfc84('0x3b')][_0xfc84('0x2c')]);_0xba7d3a[_0xfc84('0x2b')]=qs[_0xfc84('0x2b')](_0x3f9c23['query'][_0xfc84('0x2b')]);}_0xba7d3a[_0xfc84('0x43')]=qs[_0xfc84('0x44')](_0x3f9c23[_0xfc84('0x3b')][_0xfc84('0x44')]);_0xba7d3a['where']=qs[_0xfc84('0x3c')](_[_0xfc84('0x45')](_0x3f9c23[_0xfc84('0x3b')],_0x374ab0[_0xfc84('0x3c')]));if(_0x3f9c23['query'][_0xfc84('0x46')]){_0xba7d3a[_0xfc84('0x47')]=_[_0xfc84('0x48')](_0xba7d3a[_0xfc84('0x47')],{'$or':_[_0xfc84('0x36')](_0x1c261e,function(_0x5621d5){if(_0x5621d5['type']!==_0xfc84('0x49')){var _0xb790b0={};_0xb790b0[_0x5621d5[_0xfc84('0x34')]]={'$like':'%'+_0x3f9c23[_0xfc84('0x3b')][_0xfc84('0x46')]+'%'};return _0xb790b0;}})});}_0xba7d3a=_[_0xfc84('0x48')]({},_0xba7d3a,_0x3f9c23['options']);var _0x5b1cc8={'where':_0xba7d3a[_0xfc84('0x47')]};return db['SugarcrmConfiguration'][_0xfc84('0x2a')](_0x5b1cc8)[_0xfc84('0x1b')](function(_0x591977){_0x477e93['count']=_0x591977;if(_0x3f9c23[_0xfc84('0x3b')][_0xfc84('0x4a')]){_0xba7d3a[_0xfc84('0x4b')]=[{'all':!![]}];}return db['SugarcrmConfiguration'][_0xfc84('0x4c')](_0xba7d3a);})[_0xfc84('0x1b')](function(_0x2ff809){_0x477e93[_0xfc84('0x4d')]=_0x2ff809;return _0x477e93;})[_0xfc84('0x1b')](respondWithFilteredResult(_0x83447b,_0xba7d3a))[_0xfc84('0x26')](handleError(_0x83447b,null));};exports['show']=function(_0x595ea2,_0x3c762d){var _0x13c92={'raw':![],'where':{'id':_0x595ea2[_0xfc84('0x4e')]['id']}},_0x46699b={};_0x46699b[_0xfc84('0x3a')]=_[_0xfc84('0x4f')](db[_0xfc84('0x37')][_0xfc84('0x50')]);_0x46699b[_0xfc84('0x3b')]=_[_0xfc84('0x4f')](_0x595ea2['query']);_0x46699b[_0xfc84('0x3c')]=_[_0xfc84('0x3e')](_0x46699b[_0xfc84('0x3a')],_0x46699b['query']);_0x13c92[_0xfc84('0x3d')]=_[_0xfc84('0x3e')](_0x46699b[_0xfc84('0x3a')],qs[_0xfc84('0x3f')](_0x595ea2[_0xfc84('0x3b')][_0xfc84('0x3f')]));_0x13c92[_0xfc84('0x3d')]=_0x13c92['attributes'][_0xfc84('0x40')]?_0x13c92[_0xfc84('0x3d')]:_0x46699b[_0xfc84('0x3a')];if(_0x595ea2[_0xfc84('0x3b')][_0xfc84('0x4a')]){_0x13c92['include']=[{'all':!![]}];}_0x13c92=_['merge']({},_0x13c92,_0x595ea2['options']);return db[_0xfc84('0x37')]['find'](_0x13c92)[_0xfc84('0x1b')](handleEntityNotFound(_0x3c762d,null))[_0xfc84('0x1b')](respondWithResult(_0x3c762d,null))[_0xfc84('0x26')](handleError(_0x3c762d,null));};exports[_0xfc84('0x51')]=function(_0x2f8585,_0x308d61){return db[_0xfc84('0x37')]['create'](_0x2f8585[_0xfc84('0x52')],{})['then'](respondWithResult(_0x308d61,0xc9))[_0xfc84('0x26')](handleError(_0x308d61,null));};exports[_0xfc84('0x30')]=function(_0xf365ab,_0x44ff5d){if(_0xf365ab['body']['id']){delete _0xf365ab[_0xfc84('0x52')]['id'];}return db['SugarcrmConfiguration'][_0xfc84('0x53')]({'where':{'id':_0xf365ab[_0xfc84('0x4e')]['id']}})['then'](handleEntityNotFound(_0x44ff5d,null))[_0xfc84('0x1b')](saveUpdates(_0xf365ab['body'],null))['then'](respondWithResult(_0x44ff5d,null))[_0xfc84('0x26')](handleError(_0x44ff5d,null));};exports[_0xfc84('0x31')]=function(_0x43ee0f,_0x299b73){return db[_0xfc84('0x37')][_0xfc84('0x53')]({'where':{'id':_0x43ee0f['params']['id']}})[_0xfc84('0x1b')](handleEntityNotFound(_0x299b73,null))[_0xfc84('0x1b')](removeEntity(_0x299b73,null))[_0xfc84('0x26')](handleError(_0x299b73,null));};exports[_0xfc84('0x54')]=function(_0x1d4473,_0x79dc4,_0x4f05d3){var _0x1e1494={};var _0x5f3d12={};var _0x5b8b6f;var _0xe52ffb;return db[_0xfc84('0x37')][_0xfc84('0x55')]({'where':{'id':_0x1d4473[_0xfc84('0x4e')]['id']}})[_0xfc84('0x1b')](handleEntityNotFound(_0x79dc4,null))['then'](function(_0x505deb){if(_0x505deb){_0x5b8b6f=_0x505deb;_0x5f3d12['model']=_[_0xfc84('0x4f')](db[_0xfc84('0x56')]['rawAttributes']);_0x5f3d12[_0xfc84('0x3b')]=_[_0xfc84('0x4f')](_0x1d4473[_0xfc84('0x3b')]);_0x5f3d12[_0xfc84('0x3c')]=_[_0xfc84('0x3e')](_0x5f3d12[_0xfc84('0x3a')],_0x5f3d12[_0xfc84('0x3b')]);_0x1e1494[_0xfc84('0x3d')]=_[_0xfc84('0x3e')](_0x5f3d12[_0xfc84('0x3a')],qs[_0xfc84('0x3f')](_0x1d4473[_0xfc84('0x3b')][_0xfc84('0x3f')]));_0x1e1494[_0xfc84('0x3d')]=_0x1e1494[_0xfc84('0x3d')]['length']?_0x1e1494[_0xfc84('0x3d')]:_0x5f3d12['model'];_0x1e1494[_0xfc84('0x43')]=qs[_0xfc84('0x44')](_0x1d4473['query']['sort']);_0x1e1494['where']=qs[_0xfc84('0x3c')](_[_0xfc84('0x45')](_0x1d4473['query'],_0x5f3d12[_0xfc84('0x3c')]));if(_0x1d4473[_0xfc84('0x3b')][_0xfc84('0x46')]){_0x1e1494['where']=_[_0xfc84('0x48')](_0x1e1494[_0xfc84('0x47')],{'$or':_[_0xfc84('0x36')](_0x1e1494[_0xfc84('0x3d')],function(_0x5540b0){var _0x42c62e={};_0x42c62e[_0x5540b0]={'$like':'%'+_0x1d4473['query']['filter']+'%'};return _0x42c62e;})});}_0x1e1494=_[_0xfc84('0x48')]({},_0x1e1494,_0x1d4473[_0xfc84('0x57')]);return _0x5b8b6f[_0xfc84('0x54')](_0x1e1494);}})[_0xfc84('0x1b')](function(_0x4820ca){if(_0x4820ca){_0xe52ffb=_0x4820ca['length'];if(!_0x1d4473['query']['hasOwnProperty'](_0xfc84('0x42'))){_0x1e1494[_0xfc84('0x2c')]=qs['limit'](_0x1d4473[_0xfc84('0x3b')][_0xfc84('0x2c')]);_0x1e1494[_0xfc84('0x2b')]=qs['offset'](_0x1d4473['query']['offset']);}return _0x5b8b6f[_0xfc84('0x54')](_0x1e1494);}})[_0xfc84('0x1b')](function(_0x23b1a5){if(_0x23b1a5){return _0x23b1a5?{'count':_0xe52ffb,'rows':_0x23b1a5}:null;}})[_0xfc84('0x1b')](respondWithResult(_0x79dc4,null))[_0xfc84('0x26')](handleError(_0x79dc4,null));};exports[_0xfc84('0x58')]=function(_0x525cea,_0x2e23dc,_0x49bc3a){var _0x345e12={};var _0x488913={};var _0x41ea23;var _0xd963b0;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x525cea[_0xfc84('0x4e')]['id']}})[_0xfc84('0x1b')](handleEntityNotFound(_0x2e23dc,null))[_0xfc84('0x1b')](function(_0x1cfd03){if(_0x1cfd03){_0x41ea23=_0x1cfd03;_0x488913['model']=_['keys'](db['SugarcrmField']['rawAttributes']);_0x488913[_0xfc84('0x3b')]=_[_0xfc84('0x4f')](_0x525cea['query']);_0x488913[_0xfc84('0x3c')]=_[_0xfc84('0x3e')](_0x488913[_0xfc84('0x3a')],_0x488913[_0xfc84('0x3b')]);_0x345e12[_0xfc84('0x3d')]=_[_0xfc84('0x3e')](_0x488913['model'],qs[_0xfc84('0x3f')](_0x525cea['query']['fields']));_0x345e12[_0xfc84('0x3d')]=_0x345e12[_0xfc84('0x3d')][_0xfc84('0x40')]?_0x345e12[_0xfc84('0x3d')]:_0x488913[_0xfc84('0x3a')];_0x345e12[_0xfc84('0x43')]=qs[_0xfc84('0x44')](_0x525cea[_0xfc84('0x3b')][_0xfc84('0x44')]);_0x345e12[_0xfc84('0x47')]=qs[_0xfc84('0x3c')](_['pick'](_0x525cea[_0xfc84('0x3b')],_0x488913['filters']));if(_0x525cea[_0xfc84('0x3b')][_0xfc84('0x46')]){_0x345e12[_0xfc84('0x47')]=_[_0xfc84('0x48')](_0x345e12['where'],{'$or':_[_0xfc84('0x36')](_0x345e12[_0xfc84('0x3d')],function(_0x1856d0){var _0x3ba069={};_0x3ba069[_0x1856d0]={'$like':'%'+_0x525cea['query']['filter']+'%'};return _0x3ba069;})});}_0x345e12=_[_0xfc84('0x48')]({},_0x345e12,_0x525cea[_0xfc84('0x57')]);return _0x41ea23['getSubjects'](_0x345e12);}})['then'](function(_0x42ce61){if(_0x42ce61){_0xd963b0=_0x42ce61[_0xfc84('0x40')];if(!_0x525cea[_0xfc84('0x3b')][_0xfc84('0x41')](_0xfc84('0x42'))){_0x345e12['limit']=qs['limit'](_0x525cea[_0xfc84('0x3b')][_0xfc84('0x2c')]);_0x345e12[_0xfc84('0x2b')]=qs[_0xfc84('0x2b')](_0x525cea[_0xfc84('0x3b')][_0xfc84('0x2b')]);}return _0x41ea23[_0xfc84('0x58')](_0x345e12);}})['then'](function(_0x36654a){if(_0x36654a){return _0x36654a?{'count':_0xd963b0,'rows':_0x36654a}:null;}})['then'](respondWithResult(_0x2e23dc,null))[_0xfc84('0x26')](handleError(_0x2e23dc,null));};exports[_0xfc84('0x59')]=function(_0x43c9c2,_0x5bc5e0,_0x179128){var _0x30766a={};var _0x1bae6b={};var _0x571a80;var _0x32aceb;return db[_0xfc84('0x37')]['findOne']({'where':{'id':_0x43c9c2[_0xfc84('0x4e')]['id']}})[_0xfc84('0x1b')](handleEntityNotFound(_0x5bc5e0,null))[_0xfc84('0x1b')](function(_0x440be5){if(_0x440be5){_0x571a80=_0x440be5;_0x1bae6b[_0xfc84('0x3a')]=_['keys'](db[_0xfc84('0x56')][_0xfc84('0x50')]);_0x1bae6b['query']=_[_0xfc84('0x4f')](_0x43c9c2[_0xfc84('0x3b')]);_0x1bae6b[_0xfc84('0x3c')]=_[_0xfc84('0x3e')](_0x1bae6b[_0xfc84('0x3a')],_0x1bae6b[_0xfc84('0x3b')]);_0x30766a[_0xfc84('0x3d')]=_['intersection'](_0x1bae6b[_0xfc84('0x3a')],qs[_0xfc84('0x3f')](_0x43c9c2[_0xfc84('0x3b')][_0xfc84('0x3f')]));_0x30766a[_0xfc84('0x3d')]=_0x30766a['attributes']['length']?_0x30766a[_0xfc84('0x3d')]:_0x1bae6b[_0xfc84('0x3a')];_0x30766a[_0xfc84('0x43')]=qs[_0xfc84('0x44')](_0x43c9c2[_0xfc84('0x3b')]['sort']);_0x30766a[_0xfc84('0x47')]=qs[_0xfc84('0x3c')](_[_0xfc84('0x45')](_0x43c9c2[_0xfc84('0x3b')],_0x1bae6b['filters']));if(_0x43c9c2[_0xfc84('0x3b')][_0xfc84('0x46')]){_0x30766a[_0xfc84('0x47')]=_[_0xfc84('0x48')](_0x30766a['where'],{'$or':_['map'](_0x30766a[_0xfc84('0x3d')],function(_0x15a2f3){var _0x1a76f0={};_0x1a76f0[_0x15a2f3]={'$like':'%'+_0x43c9c2[_0xfc84('0x3b')][_0xfc84('0x46')]+'%'};return _0x1a76f0;})});}_0x30766a=_[_0xfc84('0x48')]({},_0x30766a,_0x43c9c2[_0xfc84('0x57')]);return _0x571a80[_0xfc84('0x59')](_0x30766a);}})['then'](function(_0xb5a450){if(_0xb5a450){_0x32aceb=_0xb5a450['length'];if(!_0x43c9c2[_0xfc84('0x3b')]['hasOwnProperty'](_0xfc84('0x42'))){_0x30766a[_0xfc84('0x2c')]=qs[_0xfc84('0x2c')](_0x43c9c2['query'][_0xfc84('0x2c')]);_0x30766a[_0xfc84('0x2b')]=qs[_0xfc84('0x2b')](_0x43c9c2['query']['offset']);}return _0x571a80[_0xfc84('0x59')](_0x30766a);}})[_0xfc84('0x1b')](function(_0x16883f){if(_0x16883f){return _0x16883f?{'count':_0x32aceb,'rows':_0x16883f}:null;}})[_0xfc84('0x1b')](respondWithResult(_0x5bc5e0,null))[_0xfc84('0x26')](handleError(_0x5bc5e0,null));};
\ No newline at end of file
+var _0x6bb1=['getDescriptions','rimraf','zip-dir','fast-json-patch','mustache','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','json','undefined','offset','count','limit','status','set','Content-Range','apply','save','then','destroy','error','stack','name','send','index','map','SugarcrmConfiguration','rawAttributes','fieldName','type','model','keys','filters','intersection','query','attributes','length','hasOwnProperty','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','fields','find','create','body','params','getFields','findOne','SugarcrmField','pick','nolimit','getSubjects'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0x6bb1,0x1cf));var _0x16bb=function(_0x3bf80d,_0x2650df){_0x3bf80d=_0x3bf80d-0x0;var _0x505f21=_0x6bb1[_0x3bf80d];return _0x505f21;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x16bb('0x0'));var zipdir=require(_0x16bb('0x1'));var jsonpatch=require(_0x16bb('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x16bb('0x3'));var util=require('util');var path=require('path');var sox=require(_0x16bb('0x4'));var csv=require(_0x16bb('0x5'));var ejs=require(_0x16bb('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x16bb('0x7'));var jsforce=require(_0x16bb('0x8'));var deskjs=require(_0x16bb('0x9'));var toCsv=require(_0x16bb('0x5'));var querystring=require(_0x16bb('0xa'));var Papa=require(_0x16bb('0xb'));var Redis=require('ioredis');var authService=require(_0x16bb('0xc'));var qs=require(_0x16bb('0xd'));var as=require(_0x16bb('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x16bb('0xf'))('api');var utils=require(_0x16bb('0x10'));var config=require(_0x16bb('0x11'));var licenseUtil=require(_0x16bb('0x12'));var db=require(_0x16bb('0x13'))['db'];function respondWithStatusCode(_0x461c2e,_0x5c5763){_0x5c5763=_0x5c5763||0xcc;return function(_0x20fef8){if(_0x20fef8){return _0x461c2e[_0x16bb('0x14')](_0x5c5763);}return _0x461c2e['status'](_0x5c5763)[_0x16bb('0x15')]();};}function respondWithResult(_0x34d0a5,_0x1c3e6b){_0x1c3e6b=_0x1c3e6b||0xc8;return function(_0x231d61){if(_0x231d61){return _0x34d0a5['status'](_0x1c3e6b)[_0x16bb('0x16')](_0x231d61);}};}function respondWithFilteredResult(_0x2c2f45,_0x3160d2){return function(_0x16d8d8){if(_0x16d8d8){var _0xeba497=typeof _0x3160d2['offset']===_0x16bb('0x17')&&typeof _0x3160d2['limit']===_0x16bb('0x17');var _0x14bba5=_0x16d8d8['count'];var _0x34d25b=_0xeba497?0x0:_0x3160d2[_0x16bb('0x18')];var _0x4385c2=_0xeba497?_0x16d8d8[_0x16bb('0x19')]:_0x3160d2['offset']+_0x3160d2[_0x16bb('0x1a')];var _0x53bd98;if(_0x4385c2>=_0x14bba5){_0x4385c2=_0x14bba5;_0x53bd98=0xc8;}else{_0x53bd98=0xce;}_0x2c2f45[_0x16bb('0x1b')](_0x53bd98);return _0x2c2f45[_0x16bb('0x1c')](_0x16bb('0x1d'),_0x34d25b+'-'+_0x4385c2+'/'+_0x14bba5)[_0x16bb('0x16')](_0x16d8d8);}return null;};}function patchUpdates(_0x505ab2){return function(_0x3c4a07){try{jsonpatch[_0x16bb('0x1e')](_0x3c4a07,_0x505ab2,!![]);}catch(_0x3affe0){return BPromise['reject'](_0x3affe0);}return _0x3c4a07[_0x16bb('0x1f')]();};}function saveUpdates(_0x1c80a2,_0x39a881){return function(_0x4145a2){if(_0x4145a2){return _0x4145a2['update'](_0x1c80a2)[_0x16bb('0x20')](function(_0x2fb83c){return _0x2fb83c;});}return null;};}function removeEntity(_0x2c5ad6,_0x3717cc){return function(_0x46d7c8){if(_0x46d7c8){return _0x46d7c8[_0x16bb('0x21')]()[_0x16bb('0x20')](function(){_0x2c5ad6[_0x16bb('0x1b')](0xcc)[_0x16bb('0x15')]();});}};}function handleEntityNotFound(_0x14d6cb,_0x517a28){return function(_0x5b2b08){if(!_0x5b2b08){_0x14d6cb[_0x16bb('0x14')](0x194);}return _0x5b2b08;};}function handleError(_0x12f436,_0x534ac7){_0x534ac7=_0x534ac7||0x1f4;return function(_0x15dfc5){logger[_0x16bb('0x22')](_0x15dfc5[_0x16bb('0x23')]);if(_0x15dfc5[_0x16bb('0x24')]){delete _0x15dfc5[_0x16bb('0x24')];}_0x12f436[_0x16bb('0x1b')](_0x534ac7)[_0x16bb('0x25')](_0x15dfc5);};}exports[_0x16bb('0x26')]=function(_0x56a155,_0x21307b){var _0x10d324={},_0x25ca6f={},_0x554f7c={'count':0x0,'rows':[]};var _0x25a731=_[_0x16bb('0x27')](db[_0x16bb('0x28')][_0x16bb('0x29')],function(_0x1fe89f){return{'name':_0x1fe89f[_0x16bb('0x2a')],'type':_0x1fe89f[_0x16bb('0x2b')]['key']};});_0x25ca6f[_0x16bb('0x2c')]=_[_0x16bb('0x27')](_0x25a731,_0x16bb('0x24'));_0x25ca6f['query']=_[_0x16bb('0x2d')](_0x56a155['query']);_0x25ca6f[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x25ca6f[_0x16bb('0x2c')],_0x25ca6f[_0x16bb('0x30')]);_0x10d324[_0x16bb('0x31')]=_['intersection'](_0x25ca6f[_0x16bb('0x2c')],qs['fields'](_0x56a155['query']['fields']));_0x10d324[_0x16bb('0x31')]=_0x10d324[_0x16bb('0x31')][_0x16bb('0x32')]?_0x10d324[_0x16bb('0x31')]:_0x25ca6f[_0x16bb('0x2c')];if(!_0x56a155[_0x16bb('0x30')][_0x16bb('0x33')]('nolimit')){_0x10d324[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x56a155[_0x16bb('0x30')][_0x16bb('0x1a')]);_0x10d324['offset']=qs[_0x16bb('0x18')](_0x56a155['query'][_0x16bb('0x18')]);}_0x10d324[_0x16bb('0x34')]=qs[_0x16bb('0x35')](_0x56a155[_0x16bb('0x30')][_0x16bb('0x35')]);_0x10d324[_0x16bb('0x36')]=qs[_0x16bb('0x2e')](_['pick'](_0x56a155[_0x16bb('0x30')],_0x25ca6f[_0x16bb('0x2e')]),_0x25a731);if(_0x56a155[_0x16bb('0x30')][_0x16bb('0x37')]){_0x10d324[_0x16bb('0x36')]=_['merge'](_0x10d324['where'],{'$or':_[_0x16bb('0x27')](_0x25a731,function(_0x4c5ccb){if(_0x4c5ccb[_0x16bb('0x2b')]!==_0x16bb('0x38')){var _0x2c5d1a={};_0x2c5d1a[_0x4c5ccb[_0x16bb('0x24')]]={'$like':'%'+_0x56a155[_0x16bb('0x30')]['filter']+'%'};return _0x2c5d1a;}})});}_0x10d324=_[_0x16bb('0x39')]({},_0x10d324,_0x56a155[_0x16bb('0x3a')]);var _0x5a164c={'where':_0x10d324['where']};return db[_0x16bb('0x28')]['count'](_0x5a164c)[_0x16bb('0x20')](function(_0x62e3f0){_0x554f7c[_0x16bb('0x19')]=_0x62e3f0;if(_0x56a155['query'][_0x16bb('0x3b')]){_0x10d324[_0x16bb('0x3c')]=[{'all':!![]}];}return db[_0x16bb('0x28')][_0x16bb('0x3d')](_0x10d324);})[_0x16bb('0x20')](function(_0x28ef2f){_0x554f7c[_0x16bb('0x3e')]=_0x28ef2f;return _0x554f7c;})[_0x16bb('0x20')](respondWithFilteredResult(_0x21307b,_0x10d324))[_0x16bb('0x3f')](handleError(_0x21307b,null));};exports[_0x16bb('0x40')]=function(_0x4cd7d6,_0x30332c){var _0x517bed={'raw':![],'where':{'id':_0x4cd7d6['params']['id']}},_0x387a79={};_0x387a79[_0x16bb('0x2c')]=_[_0x16bb('0x2d')](db[_0x16bb('0x28')]['rawAttributes']);_0x387a79[_0x16bb('0x30')]=_[_0x16bb('0x2d')](_0x4cd7d6[_0x16bb('0x30')]);_0x387a79[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x387a79[_0x16bb('0x2c')],_0x387a79[_0x16bb('0x30')]);_0x517bed[_0x16bb('0x31')]=_['intersection'](_0x387a79[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0x4cd7d6[_0x16bb('0x30')][_0x16bb('0x41')]));_0x517bed[_0x16bb('0x31')]=_0x517bed[_0x16bb('0x31')][_0x16bb('0x32')]?_0x517bed['attributes']:_0x387a79[_0x16bb('0x2c')];if(_0x4cd7d6[_0x16bb('0x30')][_0x16bb('0x3b')]){_0x517bed[_0x16bb('0x3c')]=[{'all':!![]}];}_0x517bed=_[_0x16bb('0x39')]({},_0x517bed,_0x4cd7d6[_0x16bb('0x3a')]);return db['SugarcrmConfiguration'][_0x16bb('0x42')](_0x517bed)['then'](handleEntityNotFound(_0x30332c,null))[_0x16bb('0x20')](respondWithResult(_0x30332c,null))[_0x16bb('0x3f')](handleError(_0x30332c,null));};exports['create']=function(_0x10e66e,_0x7eb48e){return db[_0x16bb('0x28')][_0x16bb('0x43')](_0x10e66e[_0x16bb('0x44')],{})[_0x16bb('0x20')](respondWithResult(_0x7eb48e,0xc9))[_0x16bb('0x3f')](handleError(_0x7eb48e,null));};exports['update']=function(_0xd4985,_0x400933){if(_0xd4985[_0x16bb('0x44')]['id']){delete _0xd4985['body']['id'];}return db[_0x16bb('0x28')][_0x16bb('0x42')]({'where':{'id':_0xd4985[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x400933,null))['then'](saveUpdates(_0xd4985[_0x16bb('0x44')],null))[_0x16bb('0x20')](respondWithResult(_0x400933,null))[_0x16bb('0x3f')](handleError(_0x400933,null));};exports[_0x16bb('0x21')]=function(_0x4eb48f,_0x136de1){return db[_0x16bb('0x28')][_0x16bb('0x42')]({'where':{'id':_0x4eb48f['params']['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x136de1,null))[_0x16bb('0x20')](removeEntity(_0x136de1,null))[_0x16bb('0x3f')](handleError(_0x136de1,null));};exports[_0x16bb('0x46')]=function(_0x269ae3,_0x38b131,_0x37ead1){var _0x17ed8a={};var _0x224ef5={};var _0x4eede6;var _0x5abef4;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0x269ae3['params']['id']}})['then'](handleEntityNotFound(_0x38b131,null))['then'](function(_0x1ea100){if(_0x1ea100){_0x4eede6=_0x1ea100;_0x224ef5[_0x16bb('0x2c')]=_[_0x16bb('0x2d')](db[_0x16bb('0x48')][_0x16bb('0x29')]);_0x224ef5[_0x16bb('0x30')]=_[_0x16bb('0x2d')](_0x269ae3[_0x16bb('0x30')]);_0x224ef5[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x224ef5[_0x16bb('0x2c')],_0x224ef5[_0x16bb('0x30')]);_0x17ed8a['attributes']=_[_0x16bb('0x2f')](_0x224ef5[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x41')]));_0x17ed8a[_0x16bb('0x31')]=_0x17ed8a['attributes'][_0x16bb('0x32')]?_0x17ed8a[_0x16bb('0x31')]:_0x224ef5[_0x16bb('0x2c')];_0x17ed8a[_0x16bb('0x34')]=qs['sort'](_0x269ae3['query'][_0x16bb('0x35')]);_0x17ed8a[_0x16bb('0x36')]=qs[_0x16bb('0x2e')](_[_0x16bb('0x49')](_0x269ae3[_0x16bb('0x30')],_0x224ef5[_0x16bb('0x2e')]));if(_0x269ae3[_0x16bb('0x30')][_0x16bb('0x37')]){_0x17ed8a[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0x17ed8a[_0x16bb('0x36')],{'$or':_['map'](_0x17ed8a[_0x16bb('0x31')],function(_0x428868){var _0x591663={};_0x591663[_0x428868]={'$like':'%'+_0x269ae3[_0x16bb('0x30')]['filter']+'%'};return _0x591663;})});}_0x17ed8a=_[_0x16bb('0x39')]({},_0x17ed8a,_0x269ae3[_0x16bb('0x3a')]);return _0x4eede6['getFields'](_0x17ed8a);}})[_0x16bb('0x20')](function(_0x720210){if(_0x720210){_0x5abef4=_0x720210['length'];if(!_0x269ae3[_0x16bb('0x30')]['hasOwnProperty'](_0x16bb('0x4a'))){_0x17ed8a[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x1a')]);_0x17ed8a[_0x16bb('0x18')]=qs[_0x16bb('0x18')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x18')]);}return _0x4eede6[_0x16bb('0x46')](_0x17ed8a);}})[_0x16bb('0x20')](function(_0x1e1fb1){if(_0x1e1fb1){return _0x1e1fb1?{'count':_0x5abef4,'rows':_0x1e1fb1}:null;}})['then'](respondWithResult(_0x38b131,null))[_0x16bb('0x3f')](handleError(_0x38b131,null));};exports['getSubjects']=function(_0xcd21dc,_0x2b4062,_0x47387a){var _0x5a5fdd={};var _0x43cec={};var _0x27a378;var _0x466d37;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0xcd21dc[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x2b4062,null))[_0x16bb('0x20')](function(_0x573bf){if(_0x573bf){_0x27a378=_0x573bf;_0x43cec[_0x16bb('0x2c')]=_['keys'](db[_0x16bb('0x48')]['rawAttributes']);_0x43cec['query']=_['keys'](_0xcd21dc[_0x16bb('0x30')]);_0x43cec[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x43cec['model'],_0x43cec[_0x16bb('0x30')]);_0x5a5fdd[_0x16bb('0x31')]=_[_0x16bb('0x2f')](_0x43cec[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0xcd21dc['query'][_0x16bb('0x41')]));_0x5a5fdd[_0x16bb('0x31')]=_0x5a5fdd[_0x16bb('0x31')][_0x16bb('0x32')]?_0x5a5fdd[_0x16bb('0x31')]:_0x43cec[_0x16bb('0x2c')];_0x5a5fdd[_0x16bb('0x34')]=qs['sort'](_0xcd21dc['query'][_0x16bb('0x35')]);_0x5a5fdd['where']=qs[_0x16bb('0x2e')](_['pick'](_0xcd21dc['query'],_0x43cec['filters']));if(_0xcd21dc[_0x16bb('0x30')]['filter']){_0x5a5fdd[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0x5a5fdd[_0x16bb('0x36')],{'$or':_[_0x16bb('0x27')](_0x5a5fdd[_0x16bb('0x31')],function(_0x5d626){var _0x24e521={};_0x24e521[_0x5d626]={'$like':'%'+_0xcd21dc[_0x16bb('0x30')]['filter']+'%'};return _0x24e521;})});}_0x5a5fdd=_[_0x16bb('0x39')]({},_0x5a5fdd,_0xcd21dc['options']);return _0x27a378['getSubjects'](_0x5a5fdd);}})[_0x16bb('0x20')](function(_0x499a43){if(_0x499a43){_0x466d37=_0x499a43[_0x16bb('0x32')];if(!_0xcd21dc[_0x16bb('0x30')][_0x16bb('0x33')](_0x16bb('0x4a'))){_0x5a5fdd[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0xcd21dc['query']['limit']);_0x5a5fdd['offset']=qs['offset'](_0xcd21dc['query'][_0x16bb('0x18')]);}return _0x27a378[_0x16bb('0x4b')](_0x5a5fdd);}})['then'](function(_0x3702d7){if(_0x3702d7){return _0x3702d7?{'count':_0x466d37,'rows':_0x3702d7}:null;}})[_0x16bb('0x20')](respondWithResult(_0x2b4062,null))[_0x16bb('0x3f')](handleError(_0x2b4062,null));};exports[_0x16bb('0x4c')]=function(_0x3ee984,_0x1a7013,_0x5c401e){var _0xf80464={};var _0x1d6d06={};var _0xd77c89;var _0x3d38b9;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0x3ee984[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x1a7013,null))[_0x16bb('0x20')](function(_0xa8e26b){if(_0xa8e26b){_0xd77c89=_0xa8e26b;_0x1d6d06[_0x16bb('0x2c')]=_['keys'](db[_0x16bb('0x48')][_0x16bb('0x29')]);_0x1d6d06[_0x16bb('0x30')]=_['keys'](_0x3ee984[_0x16bb('0x30')]);_0x1d6d06[_0x16bb('0x2e')]=_['intersection'](_0x1d6d06['model'],_0x1d6d06[_0x16bb('0x30')]);_0xf80464[_0x16bb('0x31')]=_[_0x16bb('0x2f')](_0x1d6d06['model'],qs[_0x16bb('0x41')](_0x3ee984[_0x16bb('0x30')][_0x16bb('0x41')]));_0xf80464[_0x16bb('0x31')]=_0xf80464[_0x16bb('0x31')][_0x16bb('0x32')]?_0xf80464[_0x16bb('0x31')]:_0x1d6d06[_0x16bb('0x2c')];_0xf80464['order']=qs[_0x16bb('0x35')](_0x3ee984[_0x16bb('0x30')]['sort']);_0xf80464[_0x16bb('0x36')]=qs['filters'](_[_0x16bb('0x49')](_0x3ee984['query'],_0x1d6d06['filters']));if(_0x3ee984['query'][_0x16bb('0x37')]){_0xf80464[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0xf80464[_0x16bb('0x36')],{'$or':_[_0x16bb('0x27')](_0xf80464[_0x16bb('0x31')],function(_0x4ad651){var _0x527392={};_0x527392[_0x4ad651]={'$like':'%'+_0x3ee984[_0x16bb('0x30')][_0x16bb('0x37')]+'%'};return _0x527392;})});}_0xf80464=_[_0x16bb('0x39')]({},_0xf80464,_0x3ee984['options']);return _0xd77c89[_0x16bb('0x4c')](_0xf80464);}})['then'](function(_0x4a8674){if(_0x4a8674){_0x3d38b9=_0x4a8674[_0x16bb('0x32')];if(!_0x3ee984[_0x16bb('0x30')][_0x16bb('0x33')](_0x16bb('0x4a'))){_0xf80464[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x3ee984[_0x16bb('0x30')][_0x16bb('0x1a')]);_0xf80464[_0x16bb('0x18')]=qs[_0x16bb('0x18')](_0x3ee984[_0x16bb('0x30')]['offset']);}return _0xd77c89[_0x16bb('0x4c')](_0xf80464);}})[_0x16bb('0x20')](function(_0x1b7cdf){if(_0x1b7cdf){return _0x1b7cdf?{'count':_0x3d38b9,'rows':_0x1b7cdf}:null;}})['then'](respondWithResult(_0x1a7013,null))[_0x16bb('0x3f')](handleError(_0x1a7013,null));};
\ No newline at end of file