Built motion from commit (unavailable).|2.5.15
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index c766612..6b8c497 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdc06=['getSubjects','findOne','pick','getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','http','Sequelize','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','SugarcrmConfiguration,\x20%s,\x20%s','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','sendStatus','status','count','offset','limit','set','json','apply','reject','save','update','destroy','end','name','send','index','map','SugarcrmConfiguration','type','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','order','sort','filter','where','VIRTUAL','merge','options','rows','catch','params','rawAttributes','length','includeAll','create','body','find','getFields','SugarcrmField','nolimit'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xdc06,0x112));var _0x6dc0=function(_0x2cfd94,_0x27e2eb){_0x2cfd94=_0x2cfd94-0x0;var _0x5855ae=_0xdc06[_0x2cfd94];return _0x5855ae;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6dc0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x6dc0('0x1'));var jsonpatch=require(_0x6dc0('0x2'));var rp=require(_0x6dc0('0x3'));var moment=require(_0x6dc0('0x4'));var BPromise=require(_0x6dc0('0x5'));var Mustache=require(_0x6dc0('0x6'));var util=require('util');var path=require('path');var sox=require(_0x6dc0('0x7'));var csv=require(_0x6dc0('0x8'));var ejs=require(_0x6dc0('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6dc0('0xa'));var crypto=require(_0x6dc0('0xb'));var jsforce=require(_0x6dc0('0xc'));var deskjs=require(_0x6dc0('0xd'));var toCsv=require(_0x6dc0('0x8'));var querystring=require(_0x6dc0('0xe'));var Papa=require(_0x6dc0('0xf'));var Redis=require(_0x6dc0('0x10'));var authService=require(_0x6dc0('0x11'));var qs=require(_0x6dc0('0x12'));var as=require(_0x6dc0('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x6dc0('0x14'))('api');var utils=require(_0x6dc0('0x15'));var config=require('../../config/environment');var db=require(_0x6dc0('0x16'))['db'];var jayson=require(_0x6dc0('0x17'));var client=jayson[_0x6dc0('0x18')][_0x6dc0('0x19')]({'port':0x232a});function checkPasswordPattern(_0x5b3452,_0x35823e,_0x2b1f45){if(_0x2b1f45){var _0x54516e=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x54516e['test'](_0x35823e)){return _0x5b3452;}else{throw new db[(_0x6dc0('0x1a'))]['ValidationError'](_0x6dc0('0x1b'));}}else{return _0x5b3452;}}function respondWithRpcPromise(_0x2805ee,_0x31e6b0,_0x1887ff,_0x10716f){return new BPromise(function(_0x31a467,_0x388ac8){var _0x1b377e=_0x10716f||client;return _0x1b377e[_0x6dc0('0x1c')](_0x2805ee,_0x1887ff)[_0x6dc0('0x1d')](function(_0x2633e6){logger['info'](_0x6dc0('0x1e'),_0x31e6b0,'request\x20sent');logger[_0x6dc0('0x1f')](_0x6dc0('0x20'),_0x31e6b0,_0x6dc0('0x21'),JSON[_0x6dc0('0x22')](_0x2633e6));if(_0x2633e6[_0x6dc0('0x23')]){if(_0x2633e6['error'][_0x6dc0('0x24')]===0x1f4){logger[_0x6dc0('0x23')](_0x6dc0('0x1e'),_0x31e6b0,_0x2633e6[_0x6dc0('0x23')][_0x6dc0('0x25')]);return _0x388ac8(_0x2633e6['error'][_0x6dc0('0x25')]);}logger[_0x6dc0('0x23')](_0x6dc0('0x1e'),_0x31e6b0,_0x2633e6[_0x6dc0('0x23')][_0x6dc0('0x25')]);return _0x31a467(_0x2633e6[_0x6dc0('0x23')]['message']);}else{logger[_0x6dc0('0x26')](_0x6dc0('0x1e'),_0x31e6b0,_0x6dc0('0x21'));_0x31a467(_0x2633e6[_0x6dc0('0x27')]['message']);}})['catch'](function(_0x4cd3c0){logger[_0x6dc0('0x23')](_0x6dc0('0x1e'),_0x31e6b0,_0x4cd3c0);_0x388ac8(_0x4cd3c0);});});}function respondWithStatusCode(_0x390d50,_0x20978d){_0x20978d=_0x20978d||0xcc;return function(_0x162425){if(_0x162425){return _0x390d50[_0x6dc0('0x28')](_0x20978d);}return _0x390d50['status'](_0x20978d)['end']();};}function respondWithResult(_0x2ce26e,_0x718a19){_0x718a19=_0x718a19||0xc8;return function(_0x1276f3){if(_0x1276f3){return _0x2ce26e[_0x6dc0('0x29')](_0x718a19)['json'](_0x1276f3);}};}function respondWithFilteredResult(_0x2c631f,_0x56a059){return function(_0x49822e){if(_0x49822e){var _0x756777=_0x49822e[_0x6dc0('0x2a')],_0x4aa0e9=_0x56a059[_0x6dc0('0x2b')],_0x304c16=_0x56a059[_0x6dc0('0x2b')]+_0x56a059[_0x6dc0('0x2c')],_0x241a74;if(_0x304c16>=_0x756777){_0x304c16=_0x756777;_0x241a74=0xc8;}else{_0x241a74=0xce;}_0x2c631f[_0x6dc0('0x29')](_0x241a74);return _0x2c631f[_0x6dc0('0x2d')]('Content-Range',_0x4aa0e9+'-'+_0x304c16+'/'+_0x756777)[_0x6dc0('0x2e')](_0x49822e);}return null;};}function patchUpdates(_0x43529d){return function(_0x4e041a){try{jsonpatch[_0x6dc0('0x2f')](_0x4e041a,_0x43529d,!![]);}catch(_0x2c5941){return BPromise[_0x6dc0('0x30')](_0x2c5941);}return _0x4e041a[_0x6dc0('0x31')]();};}function saveUpdates(_0xda3bcb,_0xce2954){return function(_0x3df2c8){if(_0x3df2c8){return _0x3df2c8[_0x6dc0('0x32')](_0xda3bcb)['then'](function(_0x18558c){return _0x18558c;});}return null;};}function removeEntity(_0x4346a5,_0x282918){return function(_0x3d3add){if(_0x3d3add){return _0x3d3add[_0x6dc0('0x33')]()[_0x6dc0('0x1d')](function(){_0x4346a5[_0x6dc0('0x29')](0xcc)[_0x6dc0('0x34')]();});}};}function handleEntityNotFound(_0x4b485a,_0x5e87a7){return function(_0x47a89a){if(!_0x47a89a){_0x4b485a['sendStatus'](0x194);}return _0x47a89a;};}function handleError(_0x1a640d,_0x57ad5d){_0x57ad5d=_0x57ad5d||0x1f4;return function(_0x144129){logger[_0x6dc0('0x23')](_0x144129['stack']);if(_0x144129[_0x6dc0('0x35')]){delete _0x144129[_0x6dc0('0x35')];}_0x1a640d[_0x6dc0('0x29')](_0x57ad5d)[_0x6dc0('0x36')](_0x144129);};}exports[_0x6dc0('0x37')]=function(_0x3324fa,_0x2c8aa8){var _0x2845c0={},_0x2149a3={},_0x39d2c0={'count':0x0,'rows':[]};var _0x299a73=_[_0x6dc0('0x38')](db[_0x6dc0('0x39')]['rawAttributes'],function(_0x1597a0){return{'name':_0x1597a0['fieldName'],'type':_0x1597a0[_0x6dc0('0x3a')]['key']};});_0x2149a3[_0x6dc0('0x3b')]=_['map'](_0x299a73,_0x6dc0('0x35'));_0x2149a3[_0x6dc0('0x3c')]=_[_0x6dc0('0x3d')](_0x3324fa[_0x6dc0('0x3c')]);_0x2149a3[_0x6dc0('0x3e')]=_['intersection'](_0x2149a3['model'],_0x2149a3['query']);_0x2845c0[_0x6dc0('0x3f')]=_[_0x6dc0('0x40')](_0x2149a3[_0x6dc0('0x3b')],qs[_0x6dc0('0x41')](_0x3324fa[_0x6dc0('0x3c')][_0x6dc0('0x41')]));_0x2845c0['attributes']=_0x2845c0[_0x6dc0('0x3f')]['length']?_0x2845c0[_0x6dc0('0x3f')]:_0x2149a3[_0x6dc0('0x3b')];if(!_0x3324fa['query'][_0x6dc0('0x42')]('nolimit')){_0x2845c0[_0x6dc0('0x2c')]=qs[_0x6dc0('0x2c')](_0x3324fa[_0x6dc0('0x3c')]['limit']);_0x2845c0[_0x6dc0('0x2b')]=qs[_0x6dc0('0x2b')](_0x3324fa[_0x6dc0('0x3c')]['offset']);}_0x2845c0[_0x6dc0('0x43')]=qs['sort'](_0x3324fa['query'][_0x6dc0('0x44')]);_0x2845c0['where']=qs['filters'](_['pick'](_0x3324fa[_0x6dc0('0x3c')],_0x2149a3[_0x6dc0('0x3e')]));if(_0x3324fa['query'][_0x6dc0('0x45')]){_0x2845c0[_0x6dc0('0x46')]=_['merge'](_0x2845c0[_0x6dc0('0x46')],{'$or':_[_0x6dc0('0x38')](_0x299a73,function(_0x2bee01){if(_0x2bee01[_0x6dc0('0x3a')]!==_0x6dc0('0x47')){var _0x5b54aa={};_0x5b54aa[_0x2bee01['name']]={'$like':'%'+_0x3324fa['query'][_0x6dc0('0x45')]+'%'};return _0x5b54aa;}})});}_0x2845c0=_[_0x6dc0('0x48')]({},_0x2845c0,_0x3324fa[_0x6dc0('0x49')]);var _0x1b915e={'where':_0x2845c0[_0x6dc0('0x46')]};return db[_0x6dc0('0x39')][_0x6dc0('0x2a')](_0x1b915e)['then'](function(_0x45a4d4){_0x39d2c0[_0x6dc0('0x2a')]=_0x45a4d4;if(_0x3324fa['query']['includeAll']){_0x2845c0['include']=[{'all':!![]}];}return db[_0x6dc0('0x39')]['findAll'](_0x2845c0);})[_0x6dc0('0x1d')](function(_0x5c75e3){_0x39d2c0[_0x6dc0('0x4a')]=_0x5c75e3;return _0x39d2c0;})[_0x6dc0('0x1d')](respondWithFilteredResult(_0x2c8aa8,_0x2845c0))[_0x6dc0('0x4b')](handleError(_0x2c8aa8,null));};exports['show']=function(_0x441b4b,_0x1b318d){var _0x58c9b2={'raw':![],'where':{'id':_0x441b4b[_0x6dc0('0x4c')]['id']}},_0x5ea9f3={};_0x5ea9f3[_0x6dc0('0x3b')]=_[_0x6dc0('0x3d')](db['SugarcrmConfiguration'][_0x6dc0('0x4d')]);_0x5ea9f3[_0x6dc0('0x3c')]=_[_0x6dc0('0x3d')](_0x441b4b[_0x6dc0('0x3c')]);_0x5ea9f3['filters']=_['intersection'](_0x5ea9f3[_0x6dc0('0x3b')],_0x5ea9f3['query']);_0x58c9b2['attributes']=_[_0x6dc0('0x40')](_0x5ea9f3['model'],qs[_0x6dc0('0x41')](_0x441b4b[_0x6dc0('0x3c')]['fields']));_0x58c9b2[_0x6dc0('0x3f')]=_0x58c9b2[_0x6dc0('0x3f')][_0x6dc0('0x4e')]?_0x58c9b2[_0x6dc0('0x3f')]:_0x5ea9f3[_0x6dc0('0x3b')];if(_0x441b4b[_0x6dc0('0x3c')][_0x6dc0('0x4f')]){_0x58c9b2['include']=[{'all':!![]}];}_0x58c9b2=_['merge']({},_0x58c9b2,_0x441b4b[_0x6dc0('0x49')]);return db[_0x6dc0('0x39')]['find'](_0x58c9b2)['then'](handleEntityNotFound(_0x1b318d,null))[_0x6dc0('0x1d')](respondWithResult(_0x1b318d,null))[_0x6dc0('0x4b')](handleError(_0x1b318d,null));};exports[_0x6dc0('0x50')]=function(_0x1ab57a,_0x315443){return db[_0x6dc0('0x39')][_0x6dc0('0x50')](_0x1ab57a[_0x6dc0('0x51')],{})[_0x6dc0('0x1d')](respondWithResult(_0x315443,0xc9))['catch'](handleError(_0x315443,null));};exports['update']=function(_0x5d18b2,_0x489014){if(_0x5d18b2['body']['id']){delete _0x5d18b2[_0x6dc0('0x51')]['id'];}return db[_0x6dc0('0x39')][_0x6dc0('0x52')]({'where':{'id':_0x5d18b2[_0x6dc0('0x4c')]['id']}})[_0x6dc0('0x1d')](handleEntityNotFound(_0x489014,null))[_0x6dc0('0x1d')](saveUpdates(_0x5d18b2[_0x6dc0('0x51')],null))[_0x6dc0('0x1d')](respondWithResult(_0x489014,null))[_0x6dc0('0x4b')](handleError(_0x489014,null));};exports[_0x6dc0('0x33')]=function(_0x472650,_0x5b6945){return db['SugarcrmConfiguration'][_0x6dc0('0x52')]({'where':{'id':_0x472650[_0x6dc0('0x4c')]['id']}})[_0x6dc0('0x1d')](handleEntityNotFound(_0x5b6945,null))['then'](removeEntity(_0x5b6945,null))[_0x6dc0('0x4b')](handleError(_0x5b6945,null));};exports[_0x6dc0('0x53')]=function(_0x1ee8d4,_0x1a5912,_0x1bc069){var _0x122306={};var _0x30e134={};var _0x124616;var _0x885fae;return db[_0x6dc0('0x39')]['findOne']({'where':{'id':_0x1ee8d4[_0x6dc0('0x4c')]['id']}})[_0x6dc0('0x1d')](handleEntityNotFound(_0x1a5912,null))['then'](function(_0x3a9c15){if(_0x3a9c15){_0x124616=_0x3a9c15;_0x30e134[_0x6dc0('0x3b')]=_['keys'](db[_0x6dc0('0x54')]['rawAttributes']);_0x30e134[_0x6dc0('0x3c')]=_[_0x6dc0('0x3d')](_0x1ee8d4[_0x6dc0('0x3c')]);_0x30e134[_0x6dc0('0x3e')]=_[_0x6dc0('0x40')](_0x30e134[_0x6dc0('0x3b')],_0x30e134['query']);_0x122306[_0x6dc0('0x3f')]=_[_0x6dc0('0x40')](_0x30e134['model'],qs['fields'](_0x1ee8d4[_0x6dc0('0x3c')][_0x6dc0('0x41')]));_0x122306[_0x6dc0('0x3f')]=_0x122306[_0x6dc0('0x3f')][_0x6dc0('0x4e')]?_0x122306[_0x6dc0('0x3f')]:_0x30e134[_0x6dc0('0x3b')];_0x122306['order']=qs[_0x6dc0('0x44')](_0x1ee8d4[_0x6dc0('0x3c')][_0x6dc0('0x44')]);_0x122306[_0x6dc0('0x46')]=qs[_0x6dc0('0x3e')](_['pick'](_0x1ee8d4['query'],_0x30e134['filters']));if(_0x1ee8d4[_0x6dc0('0x3c')][_0x6dc0('0x45')]){_0x122306[_0x6dc0('0x46')]=_[_0x6dc0('0x48')](_0x122306[_0x6dc0('0x46')],{'$or':_['map'](_0x122306[_0x6dc0('0x3f')],function(_0xf88283){var _0xc418d5={};_0xc418d5[_0xf88283]={'$like':'%'+_0x1ee8d4[_0x6dc0('0x3c')][_0x6dc0('0x45')]+'%'};return _0xc418d5;})});}_0x122306=_['merge']({},_0x122306,_0x1ee8d4[_0x6dc0('0x49')]);return _0x124616[_0x6dc0('0x53')](_0x122306);}})[_0x6dc0('0x1d')](function(_0x57e72){if(_0x57e72){_0x885fae=_0x57e72[_0x6dc0('0x4e')];if(!_0x1ee8d4[_0x6dc0('0x3c')][_0x6dc0('0x42')](_0x6dc0('0x55'))){_0x122306['limit']=qs[_0x6dc0('0x2c')](_0x1ee8d4[_0x6dc0('0x3c')]['limit']);_0x122306['offset']=qs[_0x6dc0('0x2b')](_0x1ee8d4['query'][_0x6dc0('0x2b')]);}return _0x124616[_0x6dc0('0x53')](_0x122306);}})[_0x6dc0('0x1d')](function(_0x439445){if(_0x439445){return _0x439445?{'count':_0x885fae,'rows':_0x439445}:null;}})[_0x6dc0('0x1d')](respondWithResult(_0x1a5912,null))[_0x6dc0('0x4b')](handleError(_0x1a5912,null));};exports[_0x6dc0('0x56')]=function(_0x2a4c68,_0x99682,_0x19c977){var _0x4873db={};var _0x111870={};var _0xbb733a;var _0x3cb84f;return db[_0x6dc0('0x39')][_0x6dc0('0x57')]({'where':{'id':_0x2a4c68[_0x6dc0('0x4c')]['id']}})[_0x6dc0('0x1d')](handleEntityNotFound(_0x99682,null))[_0x6dc0('0x1d')](function(_0x17aedf){if(_0x17aedf){_0xbb733a=_0x17aedf;_0x111870['model']=_['keys'](db[_0x6dc0('0x54')][_0x6dc0('0x4d')]);_0x111870['query']=_['keys'](_0x2a4c68[_0x6dc0('0x3c')]);_0x111870['filters']=_[_0x6dc0('0x40')](_0x111870[_0x6dc0('0x3b')],_0x111870[_0x6dc0('0x3c')]);_0x4873db['attributes']=_[_0x6dc0('0x40')](_0x111870[_0x6dc0('0x3b')],qs[_0x6dc0('0x41')](_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x41')]));_0x4873db[_0x6dc0('0x3f')]=_0x4873db[_0x6dc0('0x3f')][_0x6dc0('0x4e')]?_0x4873db[_0x6dc0('0x3f')]:_0x111870[_0x6dc0('0x3b')];_0x4873db[_0x6dc0('0x43')]=qs[_0x6dc0('0x44')](_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x44')]);_0x4873db[_0x6dc0('0x46')]=qs['filters'](_[_0x6dc0('0x58')](_0x2a4c68[_0x6dc0('0x3c')],_0x111870['filters']));if(_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x45')]){_0x4873db[_0x6dc0('0x46')]=_['merge'](_0x4873db[_0x6dc0('0x46')],{'$or':_[_0x6dc0('0x38')](_0x4873db[_0x6dc0('0x3f')],function(_0x3ff6e0){var _0xd2c4a0={};_0xd2c4a0[_0x3ff6e0]={'$like':'%'+_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x45')]+'%'};return _0xd2c4a0;})});}_0x4873db=_['merge']({},_0x4873db,_0x2a4c68[_0x6dc0('0x49')]);return _0xbb733a[_0x6dc0('0x56')](_0x4873db);}})[_0x6dc0('0x1d')](function(_0x3d372d){if(_0x3d372d){_0x3cb84f=_0x3d372d[_0x6dc0('0x4e')];if(!_0x2a4c68[_0x6dc0('0x3c')]['hasOwnProperty'](_0x6dc0('0x55'))){_0x4873db[_0x6dc0('0x2c')]=qs['limit'](_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x2c')]);_0x4873db[_0x6dc0('0x2b')]=qs[_0x6dc0('0x2b')](_0x2a4c68[_0x6dc0('0x3c')][_0x6dc0('0x2b')]);}return _0xbb733a[_0x6dc0('0x56')](_0x4873db);}})[_0x6dc0('0x1d')](function(_0x506898){if(_0x506898){return _0x506898?{'count':_0x3cb84f,'rows':_0x506898}:null;}})[_0x6dc0('0x1d')](respondWithResult(_0x99682,null))[_0x6dc0('0x4b')](handleError(_0x99682,null));};exports[_0x6dc0('0x59')]=function(_0x3dd10b,_0x58beb6,_0x37d9ff){var _0x5da1af={};var _0x489278={};var _0x1f87f8;var _0x4760a6;return db[_0x6dc0('0x39')][_0x6dc0('0x57')]({'where':{'id':_0x3dd10b[_0x6dc0('0x4c')]['id']}})[_0x6dc0('0x1d')](handleEntityNotFound(_0x58beb6,null))[_0x6dc0('0x1d')](function(_0x38b2cc){if(_0x38b2cc){_0x1f87f8=_0x38b2cc;_0x489278['model']=_['keys'](db[_0x6dc0('0x54')][_0x6dc0('0x4d')]);_0x489278['query']=_['keys'](_0x3dd10b[_0x6dc0('0x3c')]);_0x489278['filters']=_['intersection'](_0x489278[_0x6dc0('0x3b')],_0x489278[_0x6dc0('0x3c')]);_0x5da1af[_0x6dc0('0x3f')]=_['intersection'](_0x489278[_0x6dc0('0x3b')],qs[_0x6dc0('0x41')](_0x3dd10b[_0x6dc0('0x3c')][_0x6dc0('0x41')]));_0x5da1af[_0x6dc0('0x3f')]=_0x5da1af[_0x6dc0('0x3f')][_0x6dc0('0x4e')]?_0x5da1af['attributes']:_0x489278[_0x6dc0('0x3b')];_0x5da1af[_0x6dc0('0x43')]=qs[_0x6dc0('0x44')](_0x3dd10b[_0x6dc0('0x3c')]['sort']);_0x5da1af[_0x6dc0('0x46')]=qs[_0x6dc0('0x3e')](_[_0x6dc0('0x58')](_0x3dd10b[_0x6dc0('0x3c')],_0x489278['filters']));if(_0x3dd10b[_0x6dc0('0x3c')][_0x6dc0('0x45')]){_0x5da1af[_0x6dc0('0x46')]=_[_0x6dc0('0x48')](_0x5da1af[_0x6dc0('0x46')],{'$or':_['map'](_0x5da1af[_0x6dc0('0x3f')],function(_0x3a8a0a){var _0x41b182={};_0x41b182[_0x3a8a0a]={'$like':'%'+_0x3dd10b[_0x6dc0('0x3c')][_0x6dc0('0x45')]+'%'};return _0x41b182;})});}_0x5da1af=_[_0x6dc0('0x48')]({},_0x5da1af,_0x3dd10b[_0x6dc0('0x49')]);return _0x1f87f8[_0x6dc0('0x59')](_0x5da1af);}})[_0x6dc0('0x1d')](function(_0x312863){if(_0x312863){_0x4760a6=_0x312863[_0x6dc0('0x4e')];if(!_0x3dd10b[_0x6dc0('0x3c')]['hasOwnProperty']('nolimit')){_0x5da1af[_0x6dc0('0x2c')]=qs[_0x6dc0('0x2c')](_0x3dd10b[_0x6dc0('0x3c')][_0x6dc0('0x2c')]);_0x5da1af[_0x6dc0('0x2b')]=qs[_0x6dc0('0x2b')](_0x3dd10b[_0x6dc0('0x3c')]['offset']);}return _0x1f87f8[_0x6dc0('0x59')](_0x5da1af);}})['then'](function(_0x1cd52e){if(_0x1cd52e){return _0x1cd52e?{'count':_0x4760a6,'rows':_0x1cd52e}:null;}})[_0x6dc0('0x1d')](respondWithResult(_0x58beb6,null))[_0x6dc0('0x4b')](handleError(_0x58beb6,null));};
\ No newline at end of file
+var _0x5546=['error','code','message','result','catch','sendStatus','status','end','json','offset','limit','Content-Range','reject','save','update','destroy','name','index','SugarcrmConfiguration','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','count','includeAll','include','rows','show','params','find','create','body','getFields','getSubjects','findOne','getDescriptions','SugarcrmField','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','to-csv','ejs','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','client','http','then','info','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s'];(function(_0x48849f,_0x5e6632){var _0x3c1d82=function(_0x5a0123){while(--_0x5a0123){_0x48849f['push'](_0x48849f['shift']());}};_0x3c1d82(++_0x5e6632);}(_0x5546,0x8e));var _0x6554=function(_0x4e2e49,_0x5a7f98){_0x4e2e49=_0x4e2e49-0x0;var _0x8a22ec=_0x5546[_0x4e2e49];return _0x8a22ec;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6554('0x0'));var rimraf=require(_0x6554('0x1'));var zipdir=require(_0x6554('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6554('0x3'));var moment=require(_0x6554('0x4'));var BPromise=require(_0x6554('0x5'));var Mustache=require('mustache');var util=require(_0x6554('0x6'));var path=require(_0x6554('0x7'));var sox=require('sox');var csv=require(_0x6554('0x8'));var ejs=require(_0x6554('0x9'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x6554('0xa'));var deskjs=require(_0x6554('0xb'));var toCsv=require(_0x6554('0x8'));var querystring=require(_0x6554('0xc'));var Papa=require(_0x6554('0xd'));var Redis=require(_0x6554('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x6554('0xf'));var as=require(_0x6554('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x6554('0x11'));var utils=require(_0x6554('0x12'));var config=require(_0x6554('0x13'));var licenseUtil=require(_0x6554('0x14'));var db=require(_0x6554('0x15'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x6554('0x16')][_0x6554('0x17')]({'port':0x232a});function respondWithRpcPromise(_0x2f4c45,_0x14cf9e,_0x1ed7cc,_0x17e4c6){return new BPromise(function(_0x366d09,_0x1948aa){var _0x323a3a=_0x17e4c6||client;return _0x323a3a['request'](_0x2f4c45,_0x1ed7cc)[_0x6554('0x18')](function(_0x94c91e){logger[_0x6554('0x19')](_0x6554('0x1a'),_0x14cf9e,_0x6554('0x1b'));logger[_0x6554('0x1c')](_0x6554('0x1d'),_0x14cf9e,_0x6554('0x1b'),JSON['stringify'](_0x94c91e));if(_0x94c91e[_0x6554('0x1e')]){if(_0x94c91e[_0x6554('0x1e')][_0x6554('0x1f')]===0x1f4){logger[_0x6554('0x1e')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x14cf9e,_0x94c91e[_0x6554('0x1e')]['message']);return _0x1948aa(_0x94c91e[_0x6554('0x1e')][_0x6554('0x20')]);}logger[_0x6554('0x1e')](_0x6554('0x1a'),_0x14cf9e,_0x94c91e['error']['message']);return _0x366d09(_0x94c91e[_0x6554('0x1e')]['message']);}else{logger[_0x6554('0x19')](_0x6554('0x1a'),_0x14cf9e,_0x6554('0x1b'));_0x366d09(_0x94c91e[_0x6554('0x21')]['message']);}})[_0x6554('0x22')](function(_0x3296b4){logger[_0x6554('0x1e')](_0x6554('0x1a'),_0x14cf9e,_0x3296b4);_0x1948aa(_0x3296b4);});});}function respondWithStatusCode(_0x528a97,_0x35f944){_0x35f944=_0x35f944||0xcc;return function(_0x581ef3){if(_0x581ef3){return _0x528a97[_0x6554('0x23')](_0x35f944);}return _0x528a97[_0x6554('0x24')](_0x35f944)[_0x6554('0x25')]();};}function respondWithResult(_0x433893,_0x22a7a0){_0x22a7a0=_0x22a7a0||0xc8;return function(_0x64fcf0){if(_0x64fcf0){return _0x433893['status'](_0x22a7a0)[_0x6554('0x26')](_0x64fcf0);}};}function respondWithFilteredResult(_0x7473a7,_0x3c5236){return function(_0x30b1a9){if(_0x30b1a9){var _0x45b3b3=_0x30b1a9['count'],_0xa16d65=_0x3c5236[_0x6554('0x27')],_0x37e4d7=_0x3c5236['offset']+_0x3c5236[_0x6554('0x28')],_0x56660d;if(_0x37e4d7>=_0x45b3b3){_0x37e4d7=_0x45b3b3;_0x56660d=0xc8;}else{_0x56660d=0xce;}_0x7473a7[_0x6554('0x24')](_0x56660d);return _0x7473a7['set'](_0x6554('0x29'),_0xa16d65+'-'+_0x37e4d7+'/'+_0x45b3b3)['json'](_0x30b1a9);}return null;};}function patchUpdates(_0x3bb19d){return function(_0x25f6ca){try{jsonpatch['apply'](_0x25f6ca,_0x3bb19d,!![]);}catch(_0x5b43d0){return BPromise[_0x6554('0x2a')](_0x5b43d0);}return _0x25f6ca[_0x6554('0x2b')]();};}function saveUpdates(_0x1ff3eb,_0x4a3f62){return function(_0x387592){if(_0x387592){return _0x387592[_0x6554('0x2c')](_0x1ff3eb)[_0x6554('0x18')](function(_0x48bd20){return _0x48bd20;});}return null;};}function removeEntity(_0x4feb85,_0x2e155e){return function(_0x3d5034){if(_0x3d5034){return _0x3d5034[_0x6554('0x2d')]()[_0x6554('0x18')](function(){_0x4feb85[_0x6554('0x24')](0xcc)[_0x6554('0x25')]();});}};}function handleEntityNotFound(_0x52f670,_0x470c78){return function(_0x2ad8cc){if(!_0x2ad8cc){_0x52f670['sendStatus'](0x194);}return _0x2ad8cc;};}function handleError(_0x39d165,_0x21d2ec){_0x21d2ec=_0x21d2ec||0x1f4;return function(_0x17c1c4){logger[_0x6554('0x1e')](_0x17c1c4['stack']);if(_0x17c1c4[_0x6554('0x2e')]){delete _0x17c1c4[_0x6554('0x2e')];}_0x39d165[_0x6554('0x24')](_0x21d2ec)['send'](_0x17c1c4);};}exports[_0x6554('0x2f')]=function(_0x5354cf,_0x1f2058){var _0x498a89={},_0x255b09={},_0xcc9bd2={'count':0x0,'rows':[]};var _0x506de9=_['map'](db[_0x6554('0x30')][_0x6554('0x31')],function(_0x4cc981){return{'name':_0x4cc981[_0x6554('0x32')],'type':_0x4cc981[_0x6554('0x33')][_0x6554('0x34')]};});_0x255b09[_0x6554('0x35')]=_[_0x6554('0x36')](_0x506de9,_0x6554('0x2e'));_0x255b09[_0x6554('0x37')]=_[_0x6554('0x38')](_0x5354cf[_0x6554('0x37')]);_0x255b09[_0x6554('0x39')]=_[_0x6554('0x3a')](_0x255b09[_0x6554('0x35')],_0x255b09[_0x6554('0x37')]);_0x498a89[_0x6554('0x3b')]=_[_0x6554('0x3a')](_0x255b09[_0x6554('0x35')],qs[_0x6554('0x3c')](_0x5354cf[_0x6554('0x37')][_0x6554('0x3c')]));_0x498a89[_0x6554('0x3b')]=_0x498a89[_0x6554('0x3b')][_0x6554('0x3d')]?_0x498a89[_0x6554('0x3b')]:_0x255b09[_0x6554('0x35')];if(!_0x5354cf[_0x6554('0x37')][_0x6554('0x3e')](_0x6554('0x3f'))){_0x498a89[_0x6554('0x28')]=qs[_0x6554('0x28')](_0x5354cf[_0x6554('0x37')][_0x6554('0x28')]);_0x498a89[_0x6554('0x27')]=qs[_0x6554('0x27')](_0x5354cf[_0x6554('0x37')][_0x6554('0x27')]);}_0x498a89[_0x6554('0x40')]=qs['sort'](_0x5354cf['query'][_0x6554('0x41')]);_0x498a89['where']=qs[_0x6554('0x39')](_[_0x6554('0x42')](_0x5354cf[_0x6554('0x37')],_0x255b09[_0x6554('0x39')]),_0x506de9);if(_0x5354cf[_0x6554('0x37')][_0x6554('0x43')]){_0x498a89[_0x6554('0x44')]=_[_0x6554('0x45')](_0x498a89[_0x6554('0x44')],{'$or':_[_0x6554('0x36')](_0x506de9,function(_0xc2ddb3){if(_0xc2ddb3['type']!==_0x6554('0x46')){var _0x5657d9={};_0x5657d9[_0xc2ddb3['name']]={'$like':'%'+_0x5354cf[_0x6554('0x37')][_0x6554('0x43')]+'%'};return _0x5657d9;}})});}_0x498a89=_['merge']({},_0x498a89,_0x5354cf[_0x6554('0x47')]);var _0x438fcb={'where':_0x498a89['where']};return db[_0x6554('0x30')][_0x6554('0x48')](_0x438fcb)[_0x6554('0x18')](function(_0x4b0933){_0xcc9bd2['count']=_0x4b0933;if(_0x5354cf[_0x6554('0x37')][_0x6554('0x49')]){_0x498a89[_0x6554('0x4a')]=[{'all':!![]}];}return db[_0x6554('0x30')]['findAll'](_0x498a89);})[_0x6554('0x18')](function(_0x3d411c){_0xcc9bd2[_0x6554('0x4b')]=_0x3d411c;return _0xcc9bd2;})[_0x6554('0x18')](respondWithFilteredResult(_0x1f2058,_0x498a89))['catch'](handleError(_0x1f2058,null));};exports[_0x6554('0x4c')]=function(_0x218466,_0x439647){var _0x5ede28={'raw':![],'where':{'id':_0x218466[_0x6554('0x4d')]['id']}},_0x21bd02={};_0x21bd02[_0x6554('0x35')]=_[_0x6554('0x38')](db[_0x6554('0x30')]['rawAttributes']);_0x21bd02[_0x6554('0x37')]=_[_0x6554('0x38')](_0x218466['query']);_0x21bd02[_0x6554('0x39')]=_[_0x6554('0x3a')](_0x21bd02[_0x6554('0x35')],_0x21bd02['query']);_0x5ede28['attributes']=_[_0x6554('0x3a')](_0x21bd02['model'],qs[_0x6554('0x3c')](_0x218466[_0x6554('0x37')][_0x6554('0x3c')]));_0x5ede28[_0x6554('0x3b')]=_0x5ede28[_0x6554('0x3b')]['length']?_0x5ede28['attributes']:_0x21bd02[_0x6554('0x35')];if(_0x218466[_0x6554('0x37')][_0x6554('0x49')]){_0x5ede28[_0x6554('0x4a')]=[{'all':!![]}];}_0x5ede28=_[_0x6554('0x45')]({},_0x5ede28,_0x218466[_0x6554('0x47')]);return db[_0x6554('0x30')][_0x6554('0x4e')](_0x5ede28)[_0x6554('0x18')](handleEntityNotFound(_0x439647,null))[_0x6554('0x18')](respondWithResult(_0x439647,null))[_0x6554('0x22')](handleError(_0x439647,null));};exports[_0x6554('0x4f')]=function(_0x50610d,_0x4ab1fc){return db[_0x6554('0x30')]['create'](_0x50610d[_0x6554('0x50')],{})[_0x6554('0x18')](respondWithResult(_0x4ab1fc,0xc9))[_0x6554('0x22')](handleError(_0x4ab1fc,null));};exports['update']=function(_0x552805,_0x214cc1){if(_0x552805['body']['id']){delete _0x552805[_0x6554('0x50')]['id'];}return db[_0x6554('0x30')]['find']({'where':{'id':_0x552805['params']['id']}})[_0x6554('0x18')](handleEntityNotFound(_0x214cc1,null))[_0x6554('0x18')](saveUpdates(_0x552805[_0x6554('0x50')],null))[_0x6554('0x18')](respondWithResult(_0x214cc1,null))[_0x6554('0x22')](handleError(_0x214cc1,null));};exports[_0x6554('0x2d')]=function(_0x261699,_0x2786c6){return db[_0x6554('0x30')][_0x6554('0x4e')]({'where':{'id':_0x261699[_0x6554('0x4d')]['id']}})['then'](handleEntityNotFound(_0x2786c6,null))[_0x6554('0x18')](removeEntity(_0x2786c6,null))[_0x6554('0x22')](handleError(_0x2786c6,null));};exports['getFields']=function(_0x3021b2,_0x4a1717,_0x330cbe){var _0x2b3eed={};var _0x2db378={};var _0x1a0500;var _0x5d0e3a;return db[_0x6554('0x30')]['findOne']({'where':{'id':_0x3021b2[_0x6554('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4a1717,null))[_0x6554('0x18')](function(_0x5c2f62){if(_0x5c2f62){_0x1a0500=_0x5c2f62;_0x2db378[_0x6554('0x35')]=_[_0x6554('0x38')](db['SugarcrmField']['rawAttributes']);_0x2db378[_0x6554('0x37')]=_[_0x6554('0x38')](_0x3021b2[_0x6554('0x37')]);_0x2db378['filters']=_[_0x6554('0x3a')](_0x2db378['model'],_0x2db378[_0x6554('0x37')]);_0x2b3eed[_0x6554('0x3b')]=_[_0x6554('0x3a')](_0x2db378[_0x6554('0x35')],qs[_0x6554('0x3c')](_0x3021b2[_0x6554('0x37')]['fields']));_0x2b3eed['attributes']=_0x2b3eed['attributes'][_0x6554('0x3d')]?_0x2b3eed[_0x6554('0x3b')]:_0x2db378[_0x6554('0x35')];_0x2b3eed[_0x6554('0x40')]=qs['sort'](_0x3021b2[_0x6554('0x37')][_0x6554('0x41')]);_0x2b3eed['where']=qs[_0x6554('0x39')](_['pick'](_0x3021b2[_0x6554('0x37')],_0x2db378[_0x6554('0x39')]));if(_0x3021b2['query']['filter']){_0x2b3eed[_0x6554('0x44')]=_[_0x6554('0x45')](_0x2b3eed[_0x6554('0x44')],{'$or':_[_0x6554('0x36')](_0x2b3eed[_0x6554('0x3b')],function(_0x3324f6){var _0x250e78={};_0x250e78[_0x3324f6]={'$like':'%'+_0x3021b2[_0x6554('0x37')]['filter']+'%'};return _0x250e78;})});}_0x2b3eed=_[_0x6554('0x45')]({},_0x2b3eed,_0x3021b2['options']);return _0x1a0500[_0x6554('0x51')](_0x2b3eed);}})[_0x6554('0x18')](function(_0x45ea3f){if(_0x45ea3f){_0x5d0e3a=_0x45ea3f[_0x6554('0x3d')];if(!_0x3021b2['query'][_0x6554('0x3e')](_0x6554('0x3f'))){_0x2b3eed[_0x6554('0x28')]=qs[_0x6554('0x28')](_0x3021b2[_0x6554('0x37')][_0x6554('0x28')]);_0x2b3eed[_0x6554('0x27')]=qs[_0x6554('0x27')](_0x3021b2[_0x6554('0x37')][_0x6554('0x27')]);}return _0x1a0500['getFields'](_0x2b3eed);}})[_0x6554('0x18')](function(_0xc6fd8b){if(_0xc6fd8b){return _0xc6fd8b?{'count':_0x5d0e3a,'rows':_0xc6fd8b}:null;}})['then'](respondWithResult(_0x4a1717,null))[_0x6554('0x22')](handleError(_0x4a1717,null));};exports[_0x6554('0x52')]=function(_0x5510a9,_0x3be5a9,_0x595979){var _0x37d50b={};var _0xd6c54b={};var _0x3f4ae2;var _0x2b52c2;return db[_0x6554('0x30')][_0x6554('0x53')]({'where':{'id':_0x5510a9[_0x6554('0x4d')]['id']}})[_0x6554('0x18')](handleEntityNotFound(_0x3be5a9,null))[_0x6554('0x18')](function(_0x495d8a){if(_0x495d8a){_0x3f4ae2=_0x495d8a;_0xd6c54b[_0x6554('0x35')]=_[_0x6554('0x38')](db['SugarcrmField']['rawAttributes']);_0xd6c54b[_0x6554('0x37')]=_[_0x6554('0x38')](_0x5510a9[_0x6554('0x37')]);_0xd6c54b[_0x6554('0x39')]=_['intersection'](_0xd6c54b['model'],_0xd6c54b[_0x6554('0x37')]);_0x37d50b[_0x6554('0x3b')]=_[_0x6554('0x3a')](_0xd6c54b[_0x6554('0x35')],qs[_0x6554('0x3c')](_0x5510a9[_0x6554('0x37')][_0x6554('0x3c')]));_0x37d50b['attributes']=_0x37d50b[_0x6554('0x3b')][_0x6554('0x3d')]?_0x37d50b[_0x6554('0x3b')]:_0xd6c54b[_0x6554('0x35')];_0x37d50b['order']=qs[_0x6554('0x41')](_0x5510a9[_0x6554('0x37')][_0x6554('0x41')]);_0x37d50b[_0x6554('0x44')]=qs[_0x6554('0x39')](_[_0x6554('0x42')](_0x5510a9[_0x6554('0x37')],_0xd6c54b[_0x6554('0x39')]));if(_0x5510a9[_0x6554('0x37')]['filter']){_0x37d50b[_0x6554('0x44')]=_['merge'](_0x37d50b[_0x6554('0x44')],{'$or':_[_0x6554('0x36')](_0x37d50b[_0x6554('0x3b')],function(_0x1e5196){var _0x41180b={};_0x41180b[_0x1e5196]={'$like':'%'+_0x5510a9['query'][_0x6554('0x43')]+'%'};return _0x41180b;})});}_0x37d50b=_[_0x6554('0x45')]({},_0x37d50b,_0x5510a9[_0x6554('0x47')]);return _0x3f4ae2[_0x6554('0x52')](_0x37d50b);}})[_0x6554('0x18')](function(_0x520323){if(_0x520323){_0x2b52c2=_0x520323[_0x6554('0x3d')];if(!_0x5510a9[_0x6554('0x37')][_0x6554('0x3e')](_0x6554('0x3f'))){_0x37d50b[_0x6554('0x28')]=qs[_0x6554('0x28')](_0x5510a9[_0x6554('0x37')][_0x6554('0x28')]);_0x37d50b['offset']=qs['offset'](_0x5510a9[_0x6554('0x37')][_0x6554('0x27')]);}return _0x3f4ae2[_0x6554('0x52')](_0x37d50b);}})[_0x6554('0x18')](function(_0x3c2ed7){if(_0x3c2ed7){return _0x3c2ed7?{'count':_0x2b52c2,'rows':_0x3c2ed7}:null;}})[_0x6554('0x18')](respondWithResult(_0x3be5a9,null))[_0x6554('0x22')](handleError(_0x3be5a9,null));};exports[_0x6554('0x54')]=function(_0x531779,_0x22bf3b,_0x3952a3){var _0x32012e={};var _0x31111d={};var _0x1cdc31;var _0x443522;return db[_0x6554('0x30')][_0x6554('0x53')]({'where':{'id':_0x531779[_0x6554('0x4d')]['id']}})['then'](handleEntityNotFound(_0x22bf3b,null))[_0x6554('0x18')](function(_0x5b7022){if(_0x5b7022){_0x1cdc31=_0x5b7022;_0x31111d[_0x6554('0x35')]=_[_0x6554('0x38')](db[_0x6554('0x55')][_0x6554('0x31')]);_0x31111d['query']=_[_0x6554('0x38')](_0x531779[_0x6554('0x37')]);_0x31111d['filters']=_[_0x6554('0x3a')](_0x31111d['model'],_0x31111d[_0x6554('0x37')]);_0x32012e[_0x6554('0x3b')]=_[_0x6554('0x3a')](_0x31111d[_0x6554('0x35')],qs[_0x6554('0x3c')](_0x531779[_0x6554('0x37')][_0x6554('0x3c')]));_0x32012e[_0x6554('0x3b')]=_0x32012e[_0x6554('0x3b')][_0x6554('0x3d')]?_0x32012e[_0x6554('0x3b')]:_0x31111d[_0x6554('0x35')];_0x32012e['order']=qs[_0x6554('0x41')](_0x531779[_0x6554('0x37')][_0x6554('0x41')]);_0x32012e[_0x6554('0x44')]=qs['filters'](_[_0x6554('0x42')](_0x531779[_0x6554('0x37')],_0x31111d[_0x6554('0x39')]));if(_0x531779[_0x6554('0x37')][_0x6554('0x43')]){_0x32012e[_0x6554('0x44')]=_[_0x6554('0x45')](_0x32012e[_0x6554('0x44')],{'$or':_[_0x6554('0x36')](_0x32012e[_0x6554('0x3b')],function(_0x3fc57f){var _0x4febca={};_0x4febca[_0x3fc57f]={'$like':'%'+_0x531779['query']['filter']+'%'};return _0x4febca;})});}_0x32012e=_[_0x6554('0x45')]({},_0x32012e,_0x531779['options']);return _0x1cdc31[_0x6554('0x54')](_0x32012e);}})['then'](function(_0x3cd73e){if(_0x3cd73e){_0x443522=_0x3cd73e[_0x6554('0x3d')];if(!_0x531779['query'][_0x6554('0x3e')](_0x6554('0x3f'))){_0x32012e[_0x6554('0x28')]=qs[_0x6554('0x28')](_0x531779[_0x6554('0x37')][_0x6554('0x28')]);_0x32012e[_0x6554('0x27')]=qs['offset'](_0x531779['query']['offset']);}return _0x1cdc31[_0x6554('0x54')](_0x32012e);}})[_0x6554('0x18')](function(_0x808b66){if(_0x808b66){return _0x808b66?{'count':_0x443522,'rows':_0x808b66}:null;}})[_0x6554('0x18')](respondWithResult(_0x22bf3b,null))[_0x6554('0x22')](handleError(_0x22bf3b,null));};
\ No newline at end of file