Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index d94d3b8..4e9577b 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 _0x18bb=['error','stack','name','index','rawAttributes','model','map','filters','intersection','query','attributes','fields','length','hasOwnProperty','order','sort','filter','where','merge','VIRTUAL','SugarcrmConfiguration','include','findAll','rows','catch','show','params','keys','includeAll','options','find','create','body','getFields','findOne','SugarcrmField','nolimit','getSubjects','pick','getDescriptions','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','reject','save','then','destroy'];(function(_0x3d9c7e,_0x2f192c){var _0x5d6c3c=function(_0x677147){while(--_0x677147){_0x3d9c7e['push'](_0x3d9c7e['shift']());}};_0x5d6c3c(++_0x2f192c);}(_0x18bb,0x10f));var _0xb18b=function(_0x47e549,_0x2e53d6){_0x47e549=_0x47e549-0x0;var _0x251374=_0x18bb[_0x47e549];return _0x251374;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb18b('0x0'));var zipdir=require(_0xb18b('0x1'));var jsonpatch=require(_0xb18b('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb18b('0x3'));var Mustache=require('mustache');var util=require(_0xb18b('0x4'));var path=require(_0xb18b('0x5'));var sox=require(_0xb18b('0x6'));var csv=require('to-csv');var ejs=require(_0xb18b('0x7'));var fs=require('fs');var fs_extra=require(_0xb18b('0x8'));var _=require('lodash');var squel=require(_0xb18b('0x9'));var crypto=require(_0xb18b('0xa'));var jsforce=require(_0xb18b('0xb'));var deskjs=require(_0xb18b('0xc'));var toCsv=require(_0xb18b('0xd'));var querystring=require(_0xb18b('0xe'));var Papa=require(_0xb18b('0xf'));var Redis=require('ioredis');var authService=require(_0xb18b('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xb18b('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb18b('0x12'))(_0xb18b('0x13'));var utils=require(_0xb18b('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xb18b('0x15'));var db=require(_0xb18b('0x16'))['db'];function respondWithStatusCode(_0x33cf28,_0x18d74){_0x18d74=_0x18d74||0xcc;return function(_0x2557ef){if(_0x2557ef){return _0x33cf28[_0xb18b('0x17')](_0x18d74);}return _0x33cf28[_0xb18b('0x18')](_0x18d74)[_0xb18b('0x19')]();};}function respondWithResult(_0x1ec3d9,_0x2839f5){_0x2839f5=_0x2839f5||0xc8;return function(_0x3c031b){if(_0x3c031b){return _0x1ec3d9[_0xb18b('0x18')](_0x2839f5)['json'](_0x3c031b);}};}function respondWithFilteredResult(_0xf0b4b8,_0x423bf4){return function(_0x3284f4){if(_0x3284f4){var _0x244cf5=typeof _0x423bf4[_0xb18b('0x1a')]===_0xb18b('0x1b')&&typeof _0x423bf4[_0xb18b('0x1c')]==='undefined';var _0x47acaa=_0x3284f4[_0xb18b('0x1d')];var _0x22e55f=_0x244cf5?0x0:_0x423bf4[_0xb18b('0x1a')];var _0x3b9aa2=_0x244cf5?_0x3284f4[_0xb18b('0x1d')]:_0x423bf4['offset']+_0x423bf4['limit'];var _0xab9040;if(_0x3b9aa2>=_0x47acaa){_0x3b9aa2=_0x47acaa;_0xab9040=0xc8;}else{_0xab9040=0xce;}_0xf0b4b8[_0xb18b('0x18')](_0xab9040);return _0xf0b4b8[_0xb18b('0x1e')](_0xb18b('0x1f'),_0x22e55f+'-'+_0x3b9aa2+'/'+_0x47acaa)[_0xb18b('0x20')](_0x3284f4);}return null;};}function patchUpdates(_0x17005d){return function(_0x4495ac){try{jsonpatch['apply'](_0x4495ac,_0x17005d,!![]);}catch(_0x2b1b0a){return BPromise[_0xb18b('0x21')](_0x2b1b0a);}return _0x4495ac[_0xb18b('0x22')]();};}function saveUpdates(_0x1819ca,_0x17ae75){return function(_0x1a66a3){if(_0x1a66a3){return _0x1a66a3['update'](_0x1819ca)[_0xb18b('0x23')](function(_0x423b93){return _0x423b93;});}return null;};}function removeEntity(_0x4796f9,_0x104c74){return function(_0x5140ac){if(_0x5140ac){return _0x5140ac[_0xb18b('0x24')]()[_0xb18b('0x23')](function(){_0x4796f9[_0xb18b('0x18')](0xcc)[_0xb18b('0x19')]();});}};}function handleEntityNotFound(_0x1c3e72,_0x322094){return function(_0x1f3dbd){if(!_0x1f3dbd){_0x1c3e72['sendStatus'](0x194);}return _0x1f3dbd;};}function handleError(_0x199eab,_0x3ddace){_0x3ddace=_0x3ddace||0x1f4;return function(_0x362e07){logger[_0xb18b('0x25')](_0x362e07[_0xb18b('0x26')]);if(_0x362e07[_0xb18b('0x27')]){delete _0x362e07['name'];}_0x199eab[_0xb18b('0x18')](_0x3ddace)['send'](_0x362e07);};}exports[_0xb18b('0x28')]=function(_0x29ff95,_0x110665){var _0x8a0b5d={},_0x1ef6d7={},_0xc62dfe={'count':0x0,'rows':[]};var _0x25b542=_['map'](db['SugarcrmConfiguration'][_0xb18b('0x29')],function(_0x148390){return{'name':_0x148390['fieldName'],'type':_0x148390['type']['key']};});_0x1ef6d7[_0xb18b('0x2a')]=_[_0xb18b('0x2b')](_0x25b542,'name');_0x1ef6d7['query']=_['keys'](_0x29ff95['query']);_0x1ef6d7[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x1ef6d7[_0xb18b('0x2a')],_0x1ef6d7[_0xb18b('0x2e')]);_0x8a0b5d[_0xb18b('0x2f')]=_[_0xb18b('0x2d')](_0x1ef6d7[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x29ff95[_0xb18b('0x2e')]['fields']));_0x8a0b5d[_0xb18b('0x2f')]=_0x8a0b5d['attributes'][_0xb18b('0x31')]?_0x8a0b5d[_0xb18b('0x2f')]:_0x1ef6d7['model'];if(!_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x32')]('nolimit')){_0x8a0b5d[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x1c')]);_0x8a0b5d[_0xb18b('0x1a')]=qs['offset'](_0x29ff95['query'][_0xb18b('0x1a')]);}_0x8a0b5d[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x8a0b5d['where']=qs['filters'](_['pick'](_0x29ff95[_0xb18b('0x2e')],_0x1ef6d7[_0xb18b('0x2c')]),_0x25b542);if(_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x8a0b5d[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x8a0b5d[_0xb18b('0x36')],{'$or':_['map'](_0x25b542,function(_0x21123a){if(_0x21123a['type']!==_0xb18b('0x38')){var _0x3a1378={};_0x3a1378[_0x21123a[_0xb18b('0x27')]]={'$like':'%'+_0x29ff95[_0xb18b('0x2e')]['filter']+'%'};return _0x3a1378;}})});}_0x8a0b5d=_['merge']({},_0x8a0b5d,_0x29ff95['options']);var _0x4485e1={'where':_0x8a0b5d['where']};return db[_0xb18b('0x39')][_0xb18b('0x1d')](_0x4485e1)[_0xb18b('0x23')](function(_0x1e677e){_0xc62dfe[_0xb18b('0x1d')]=_0x1e677e;if(_0x29ff95[_0xb18b('0x2e')]['includeAll']){_0x8a0b5d[_0xb18b('0x3a')]=[{'all':!![]}];}return db['SugarcrmConfiguration'][_0xb18b('0x3b')](_0x8a0b5d);})[_0xb18b('0x23')](function(_0x31d515){_0xc62dfe[_0xb18b('0x3c')]=_0x31d515;return _0xc62dfe;})[_0xb18b('0x23')](respondWithFilteredResult(_0x110665,_0x8a0b5d))[_0xb18b('0x3d')](handleError(_0x110665,null));};exports[_0xb18b('0x3e')]=function(_0x320b3a,_0x3493bc){var _0xa24a87={'raw':![],'where':{'id':_0x320b3a[_0xb18b('0x3f')]['id']}},_0x3294b3={};_0x3294b3[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db['SugarcrmConfiguration'][_0xb18b('0x29')]);_0x3294b3['query']=_['keys'](_0x320b3a[_0xb18b('0x2e')]);_0x3294b3[_0xb18b('0x2c')]=_['intersection'](_0x3294b3[_0xb18b('0x2a')],_0x3294b3['query']);_0xa24a87['attributes']=_[_0xb18b('0x2d')](_0x3294b3[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x320b3a[_0xb18b('0x2e')]['fields']));_0xa24a87[_0xb18b('0x2f')]=_0xa24a87[_0xb18b('0x2f')][_0xb18b('0x31')]?_0xa24a87[_0xb18b('0x2f')]:_0x3294b3[_0xb18b('0x2a')];if(_0x320b3a[_0xb18b('0x2e')][_0xb18b('0x41')]){_0xa24a87[_0xb18b('0x3a')]=[{'all':!![]}];}_0xa24a87=_[_0xb18b('0x37')]({},_0xa24a87,_0x320b3a[_0xb18b('0x42')]);return db[_0xb18b('0x39')][_0xb18b('0x43')](_0xa24a87)[_0xb18b('0x23')](handleEntityNotFound(_0x3493bc,null))['then'](respondWithResult(_0x3493bc,null))[_0xb18b('0x3d')](handleError(_0x3493bc,null));};exports[_0xb18b('0x44')]=function(_0xddbf3f,_0x10da4f){return db[_0xb18b('0x39')][_0xb18b('0x44')](_0xddbf3f[_0xb18b('0x45')],{})['then'](respondWithResult(_0x10da4f,0xc9))[_0xb18b('0x3d')](handleError(_0x10da4f,null));};exports['update']=function(_0xf497c2,_0x470482){if(_0xf497c2[_0xb18b('0x45')]['id']){delete _0xf497c2[_0xb18b('0x45')]['id'];}return db[_0xb18b('0x39')]['find']({'where':{'id':_0xf497c2[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x470482,null))['then'](saveUpdates(_0xf497c2[_0xb18b('0x45')],null))[_0xb18b('0x23')](respondWithResult(_0x470482,null))['catch'](handleError(_0x470482,null));};exports['destroy']=function(_0x2af86d,_0x856ff8){return db['SugarcrmConfiguration'][_0xb18b('0x43')]({'where':{'id':_0x2af86d[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x856ff8,null))[_0xb18b('0x23')](removeEntity(_0x856ff8,null))[_0xb18b('0x3d')](handleError(_0x856ff8,null));};exports[_0xb18b('0x46')]=function(_0x2e5a40,_0x337361,_0x3c0cec){var _0x4f0d0b={};var _0x3a2920={};var _0x2da5da;var _0x407999;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x2e5a40[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x337361,null))[_0xb18b('0x23')](function(_0x429d0c){if(_0x429d0c){_0x2da5da=_0x429d0c;_0x3a2920[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')][_0xb18b('0x29')]);_0x3a2920[_0xb18b('0x2e')]=_[_0xb18b('0x40')](_0x2e5a40[_0xb18b('0x2e')]);_0x3a2920[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x3a2920['model'],_0x3a2920['query']);_0x4f0d0b[_0xb18b('0x2f')]=_[_0xb18b('0x2d')](_0x3a2920[_0xb18b('0x2a')],qs['fields'](_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x30')]));_0x4f0d0b[_0xb18b('0x2f')]=_0x4f0d0b[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x4f0d0b['attributes']:_0x3a2920[_0xb18b('0x2a')];_0x4f0d0b[_0xb18b('0x33')]=qs['sort'](_0x2e5a40['query']['sort']);_0x4f0d0b[_0xb18b('0x36')]=qs[_0xb18b('0x2c')](_['pick'](_0x2e5a40['query'],_0x3a2920['filters']));if(_0x2e5a40['query'][_0xb18b('0x35')]){_0x4f0d0b[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x4f0d0b[_0xb18b('0x36')],{'$or':_[_0xb18b('0x2b')](_0x4f0d0b[_0xb18b('0x2f')],function(_0x4c4750){var _0x366828={};_0x366828[_0x4c4750]={'$like':'%'+_0x2e5a40['query'][_0xb18b('0x35')]+'%'};return _0x366828;})});}_0x4f0d0b=_['merge']({},_0x4f0d0b,_0x2e5a40['options']);return _0x2da5da['getFields'](_0x4f0d0b);}})[_0xb18b('0x23')](function(_0x464c9e){if(_0x464c9e){_0x407999=_0x464c9e['length'];if(!_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x32')](_0xb18b('0x49'))){_0x4f0d0b[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x2e5a40[_0xb18b('0x2e')]['limit']);_0x4f0d0b[_0xb18b('0x1a')]=qs[_0xb18b('0x1a')](_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x1a')]);}return _0x2da5da['getFields'](_0x4f0d0b);}})['then'](function(_0x1cdaf1){if(_0x1cdaf1){return _0x1cdaf1?{'count':_0x407999,'rows':_0x1cdaf1}:null;}})[_0xb18b('0x23')](respondWithResult(_0x337361,null))[_0xb18b('0x3d')](handleError(_0x337361,null));};exports[_0xb18b('0x4a')]=function(_0x2f10da,_0x4f4783,_0x2d09c9){var _0x3171da={};var _0x470b38={};var _0x12783a;var _0x4fcac1;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x2f10da[_0xb18b('0x3f')]['id']}})['then'](handleEntityNotFound(_0x4f4783,null))[_0xb18b('0x23')](function(_0x159de6){if(_0x159de6){_0x12783a=_0x159de6;_0x470b38[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')]['rawAttributes']);_0x470b38['query']=_[_0xb18b('0x40')](_0x2f10da['query']);_0x470b38[_0xb18b('0x2c')]=_['intersection'](_0x470b38[_0xb18b('0x2a')],_0x470b38[_0xb18b('0x2e')]);_0x3171da[_0xb18b('0x2f')]=_['intersection'](_0x470b38[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x30')]));_0x3171da['attributes']=_0x3171da[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x3171da[_0xb18b('0x2f')]:_0x470b38[_0xb18b('0x2a')];_0x3171da[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x3171da[_0xb18b('0x36')]=qs['filters'](_[_0xb18b('0x4b')](_0x2f10da[_0xb18b('0x2e')],_0x470b38[_0xb18b('0x2c')]));if(_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x3171da['where']=_[_0xb18b('0x37')](_0x3171da[_0xb18b('0x36')],{'$or':_[_0xb18b('0x2b')](_0x3171da['attributes'],function(_0x4dc266){var _0x2476eb={};_0x2476eb[_0x4dc266]={'$like':'%'+_0x2f10da['query']['filter']+'%'};return _0x2476eb;})});}_0x3171da=_[_0xb18b('0x37')]({},_0x3171da,_0x2f10da['options']);return _0x12783a[_0xb18b('0x4a')](_0x3171da);}})[_0xb18b('0x23')](function(_0x296953){if(_0x296953){_0x4fcac1=_0x296953['length'];if(!_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x32')]('nolimit')){_0x3171da[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x2f10da[_0xb18b('0x2e')]['limit']);_0x3171da['offset']=qs[_0xb18b('0x1a')](_0x2f10da[_0xb18b('0x2e')]['offset']);}return _0x12783a[_0xb18b('0x4a')](_0x3171da);}})[_0xb18b('0x23')](function(_0x2f8b9b){if(_0x2f8b9b){return _0x2f8b9b?{'count':_0x4fcac1,'rows':_0x2f8b9b}:null;}})[_0xb18b('0x23')](respondWithResult(_0x4f4783,null))[_0xb18b('0x3d')](handleError(_0x4f4783,null));};exports[_0xb18b('0x4c')]=function(_0x21e88c,_0x5f3ec4,_0x4a1e16){var _0x2b3ef3={};var _0x4ee020={};var _0x3b77ce;var _0xe00288;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x21e88c['params']['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x5f3ec4,null))[_0xb18b('0x23')](function(_0xc4cdf3){if(_0xc4cdf3){_0x3b77ce=_0xc4cdf3;_0x4ee020[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')]['rawAttributes']);_0x4ee020[_0xb18b('0x2e')]=_[_0xb18b('0x40')](_0x21e88c['query']);_0x4ee020[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x4ee020[_0xb18b('0x2a')],_0x4ee020[_0xb18b('0x2e')]);_0x2b3ef3['attributes']=_[_0xb18b('0x2d')](_0x4ee020[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x21e88c['query'][_0xb18b('0x30')]));_0x2b3ef3[_0xb18b('0x2f')]=_0x2b3ef3[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x2b3ef3[_0xb18b('0x2f')]:_0x4ee020[_0xb18b('0x2a')];_0x2b3ef3[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x2b3ef3[_0xb18b('0x36')]=qs[_0xb18b('0x2c')](_[_0xb18b('0x4b')](_0x21e88c['query'],_0x4ee020[_0xb18b('0x2c')]));if(_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x2b3ef3[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x2b3ef3['where'],{'$or':_[_0xb18b('0x2b')](_0x2b3ef3[_0xb18b('0x2f')],function(_0x216151){var _0x118f74={};_0x118f74[_0x216151]={'$like':'%'+_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x35')]+'%'};return _0x118f74;})});}_0x2b3ef3=_[_0xb18b('0x37')]({},_0x2b3ef3,_0x21e88c[_0xb18b('0x42')]);return _0x3b77ce[_0xb18b('0x4c')](_0x2b3ef3);}})[_0xb18b('0x23')](function(_0x5118e5){if(_0x5118e5){_0xe00288=_0x5118e5[_0xb18b('0x31')];if(!_0x21e88c['query'][_0xb18b('0x32')](_0xb18b('0x49'))){_0x2b3ef3['limit']=qs[_0xb18b('0x1c')](_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x1c')]);_0x2b3ef3[_0xb18b('0x1a')]=qs[_0xb18b('0x1a')](_0x21e88c['query']['offset']);}return _0x3b77ce[_0xb18b('0x4c')](_0x2b3ef3);}})[_0xb18b('0x23')](function(_0x155270){if(_0x155270){return _0x155270?{'count':_0xe00288,'rows':_0x155270}:null;}})[_0xb18b('0x23')](respondWithResult(_0x5f3ec4,null))['catch'](handleError(_0x5f3ec4,null));};
\ No newline at end of file