Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index 1d69c23..ff26489 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x60a9=['result','sendStatus','status','end','count','offset','set','reject','save','update','destroy','stack','name','map','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','limit','order','sort','filter','where','merge','options','includeAll','include','SugarcrmConfiguration','rows','catch','show','params','rawAttributes','create','body','find','getFields','findOne','pick','getSubjects','SugarcrmField','nolimit','getDescriptions','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','client','http','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~!@#$%^&-_=+[{]}.','request','then','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info'];(function(_0x18ff31,_0x30a38d){var _0x216dfa=function(_0x2bf5fe){while(--_0x2bf5fe){_0x18ff31['push'](_0x18ff31['shift']());}};_0x216dfa(++_0x30a38d);}(_0x60a9,0x197));var _0x960a=function(_0x1c96b6,_0x5636c7){_0x1c96b6=_0x1c96b6-0x0;var _0x313fbc=_0x60a9[_0x1c96b6];return _0x313fbc;};'use strict';var pdf=require(_0x960a('0x0'));var emlformat=require(_0x960a('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x960a('0x2'));var jsonpatch=require(_0x960a('0x3'));var rp=require(_0x960a('0x4'));var moment=require('moment');var BPromise=require(_0x960a('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x960a('0x6'));var sox=require(_0x960a('0x7'));var csv=require(_0x960a('0x8'));var ejs=require(_0x960a('0x9'));var fs=require('fs');var _=require(_0x960a('0xa'));var squel=require(_0x960a('0xb'));var crypto=require(_0x960a('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x960a('0xd'));var toCsv=require(_0x960a('0x8'));var querystring=require(_0x960a('0xe'));var Papa=require(_0x960a('0xf'));var Redis=require('ioredis');var authService=require(_0x960a('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x960a('0x11'));var hardwareService=require(_0x960a('0x12'));var logger=require('../../config/logger')(_0x960a('0x13'));var utils=require(_0x960a('0x14'));var config=require(_0x960a('0x15'));var db=require(_0x960a('0x16'))['db'];var jayson=require(_0x960a('0x17'));var client=jayson[_0x960a('0x18')][_0x960a('0x19')]({'port':0x232a});function checkPasswordPattern(_0x5b0ae0,_0x4c746e,_0x3cb00b){if(_0x3cb00b){var _0x4a1dfb=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4a1dfb['test'](_0x4c746e)){return _0x5b0ae0;}else{throw new db[(_0x960a('0x1a'))][(_0x960a('0x1b'))](_0x960a('0x1c'));}}else{return _0x5b0ae0;}}function respondWithRpcPromise(_0x5efba8,_0x51f56b,_0x373915,_0x2616f2){return new BPromise(function(_0x90ea4d,_0x227ec6){var _0x260d00=_0x2616f2||client;return _0x260d00[_0x960a('0x1d')](_0x5efba8,_0x373915)[_0x960a('0x1e')](function(_0x15001c){logger['info'](_0x960a('0x1f'),_0x51f56b,_0x960a('0x20'));logger[_0x960a('0x21')]('SugarcrmConfiguration,\x20%s,\x20%s,\x20%s',_0x51f56b,_0x960a('0x20'),JSON[_0x960a('0x22')](_0x15001c));if(_0x15001c[_0x960a('0x23')]){if(_0x15001c[_0x960a('0x23')]['code']===0x1f4){logger[_0x960a('0x23')](_0x960a('0x1f'),_0x51f56b,_0x15001c[_0x960a('0x23')]['message']);return _0x227ec6(_0x15001c['error'][_0x960a('0x24')]);}logger[_0x960a('0x23')](_0x960a('0x1f'),_0x51f56b,_0x15001c[_0x960a('0x23')][_0x960a('0x24')]);return _0x90ea4d(_0x15001c[_0x960a('0x23')][_0x960a('0x24')]);}else{logger[_0x960a('0x25')](_0x960a('0x1f'),_0x51f56b,_0x960a('0x20'));_0x90ea4d(_0x15001c[_0x960a('0x26')][_0x960a('0x24')]);}})['catch'](function(_0x1577ef){logger[_0x960a('0x23')](_0x960a('0x1f'),_0x51f56b,_0x1577ef);_0x227ec6(_0x1577ef);});});}function respondWithStatusCode(_0x4ff0b6,_0x2a844d){_0x2a844d=_0x2a844d||0xcc;return function(_0x4c8c2a){if(_0x4c8c2a){return _0x4ff0b6[_0x960a('0x27')](_0x2a844d);}return _0x4ff0b6[_0x960a('0x28')](_0x2a844d)[_0x960a('0x29')]();};}function respondWithResult(_0x7ce08d,_0x37d29e){_0x37d29e=_0x37d29e||0xc8;return function(_0x44823c){if(_0x44823c){return _0x7ce08d[_0x960a('0x28')](_0x37d29e)['json'](_0x44823c);}};}function respondWithFilteredResult(_0x1520a1,_0x278b17){return function(_0x261513){if(_0x261513){var _0x491254=_0x261513[_0x960a('0x2a')],_0x30488b=_0x278b17[_0x960a('0x2b')],_0x13f13d=_0x278b17['offset']+_0x278b17['limit'],_0x14d69f;if(_0x13f13d>=_0x491254){_0x13f13d=_0x491254;_0x14d69f=0xc8;}else{_0x14d69f=0xce;}_0x1520a1[_0x960a('0x28')](_0x14d69f);return _0x1520a1[_0x960a('0x2c')]('Content-Range',_0x30488b+'-'+_0x13f13d+'/'+_0x491254)['json'](_0x261513);}return null;};}function patchUpdates(_0x2c50ff){return function(_0x410b6d){try{jsonpatch['apply'](_0x410b6d,_0x2c50ff,!![]);}catch(_0x26e852){return BPromise[_0x960a('0x2d')](_0x26e852);}return _0x410b6d[_0x960a('0x2e')]();};}function saveUpdates(_0x2aaaa4,_0x578aef){return function(_0x243366){if(_0x243366){return _0x243366[_0x960a('0x2f')](_0x2aaaa4)[_0x960a('0x1e')](function(_0x9ab931){return _0x9ab931;});}return null;};}function removeEntity(_0x11ed03,_0x5d20fe){return function(_0x121a1f){if(_0x121a1f){return _0x121a1f[_0x960a('0x30')]()['then'](function(){_0x11ed03[_0x960a('0x28')](0xcc)[_0x960a('0x29')]();});}};}function handleEntityNotFound(_0x5e3c0a,_0x594ded){return function(_0xed0c46){if(!_0xed0c46){_0x5e3c0a[_0x960a('0x27')](0x194);}return _0xed0c46;};}function handleError(_0x24164e,_0xf9f222){_0xf9f222=_0xf9f222||0x1f4;return function(_0x3bbce7){logger[_0x960a('0x23')](_0x3bbce7[_0x960a('0x31')]);if(_0x3bbce7['name']){delete _0x3bbce7[_0x960a('0x32')];}_0x24164e[_0x960a('0x28')](_0xf9f222)['send'](_0x3bbce7);};}exports['index']=function(_0x114d86,_0x146434){var _0x3bf835={},_0x260f8a={},_0x5619ea={'count':0x0,'rows':[]};var _0x59147c=_[_0x960a('0x33')](db['SugarcrmConfiguration']['rawAttributes'],function(_0x313dd5){return{'name':_0x313dd5[_0x960a('0x34')],'type':_0x313dd5[_0x960a('0x35')][_0x960a('0x36')]};});_0x260f8a['model']=_[_0x960a('0x33')](_0x59147c,_0x960a('0x32'));_0x260f8a[_0x960a('0x37')]=_[_0x960a('0x38')](_0x114d86[_0x960a('0x37')]);_0x260f8a[_0x960a('0x39')]=_[_0x960a('0x3a')](_0x260f8a[_0x960a('0x3b')],_0x260f8a[_0x960a('0x37')]);_0x3bf835['attributes']=_[_0x960a('0x3a')](_0x260f8a[_0x960a('0x3b')],qs[_0x960a('0x3c')](_0x114d86[_0x960a('0x37')]['fields']));_0x3bf835[_0x960a('0x3d')]=_0x3bf835['attributes'][_0x960a('0x3e')]?_0x3bf835['attributes']:_0x260f8a[_0x960a('0x3b')];if(!_0x114d86[_0x960a('0x37')][_0x960a('0x3f')]('nolimit')){_0x3bf835[_0x960a('0x40')]=qs[_0x960a('0x40')](_0x114d86['query']['limit']);_0x3bf835[_0x960a('0x2b')]=qs[_0x960a('0x2b')](_0x114d86[_0x960a('0x37')][_0x960a('0x2b')]);}_0x3bf835[_0x960a('0x41')]=qs[_0x960a('0x42')](_0x114d86[_0x960a('0x37')]['sort']);_0x3bf835['where']=qs[_0x960a('0x39')](_['pick'](_0x114d86[_0x960a('0x37')],_0x260f8a[_0x960a('0x39')]),_0x59147c);if(_0x114d86['query'][_0x960a('0x43')]){_0x3bf835[_0x960a('0x44')]=_[_0x960a('0x45')](_0x3bf835[_0x960a('0x44')],{'$or':_['map'](_0x59147c,function(_0x4a4a25){if(_0x4a4a25[_0x960a('0x35')]!=='VIRTUAL'){var _0xd0b5f0={};_0xd0b5f0[_0x4a4a25[_0x960a('0x32')]]={'$like':'%'+_0x114d86[_0x960a('0x37')][_0x960a('0x43')]+'%'};return _0xd0b5f0;}})});}_0x3bf835=_['merge']({},_0x3bf835,_0x114d86[_0x960a('0x46')]);var _0x346a3a={'where':_0x3bf835[_0x960a('0x44')]};return db['SugarcrmConfiguration']['count'](_0x346a3a)[_0x960a('0x1e')](function(_0x53d3ed){_0x5619ea['count']=_0x53d3ed;if(_0x114d86[_0x960a('0x37')][_0x960a('0x47')]){_0x3bf835[_0x960a('0x48')]=[{'all':!![]}];}return db[_0x960a('0x49')]['findAll'](_0x3bf835);})['then'](function(_0x5af2cb){_0x5619ea[_0x960a('0x4a')]=_0x5af2cb;return _0x5619ea;})[_0x960a('0x1e')](respondWithFilteredResult(_0x146434,_0x3bf835))[_0x960a('0x4b')](handleError(_0x146434,null));};exports[_0x960a('0x4c')]=function(_0x3cbe05,_0x4f9220){var _0xac9bc8={'raw':![],'where':{'id':_0x3cbe05[_0x960a('0x4d')]['id']}},_0x2c3beb={};_0x2c3beb['model']=_[_0x960a('0x38')](db[_0x960a('0x49')][_0x960a('0x4e')]);_0x2c3beb['query']=_['keys'](_0x3cbe05[_0x960a('0x37')]);_0x2c3beb['filters']=_[_0x960a('0x3a')](_0x2c3beb['model'],_0x2c3beb[_0x960a('0x37')]);_0xac9bc8[_0x960a('0x3d')]=_[_0x960a('0x3a')](_0x2c3beb['model'],qs[_0x960a('0x3c')](_0x3cbe05[_0x960a('0x37')][_0x960a('0x3c')]));_0xac9bc8[_0x960a('0x3d')]=_0xac9bc8[_0x960a('0x3d')][_0x960a('0x3e')]?_0xac9bc8[_0x960a('0x3d')]:_0x2c3beb[_0x960a('0x3b')];if(_0x3cbe05[_0x960a('0x37')][_0x960a('0x47')]){_0xac9bc8[_0x960a('0x48')]=[{'all':!![]}];}_0xac9bc8=_[_0x960a('0x45')]({},_0xac9bc8,_0x3cbe05[_0x960a('0x46')]);return db[_0x960a('0x49')]['find'](_0xac9bc8)['then'](handleEntityNotFound(_0x4f9220,null))[_0x960a('0x1e')](respondWithResult(_0x4f9220,null))[_0x960a('0x4b')](handleError(_0x4f9220,null));};exports[_0x960a('0x4f')]=function(_0x177d1e,_0x1c347c){return db['SugarcrmConfiguration']['create'](_0x177d1e['body'],{})[_0x960a('0x1e')](respondWithResult(_0x1c347c,0xc9))[_0x960a('0x4b')](handleError(_0x1c347c,null));};exports[_0x960a('0x2f')]=function(_0x269483,_0x45e9c9){if(_0x269483['body']['id']){delete _0x269483[_0x960a('0x50')]['id'];}return db[_0x960a('0x49')][_0x960a('0x51')]({'where':{'id':_0x269483['params']['id']}})[_0x960a('0x1e')](handleEntityNotFound(_0x45e9c9,null))[_0x960a('0x1e')](saveUpdates(_0x269483['body'],null))[_0x960a('0x1e')](respondWithResult(_0x45e9c9,null))[_0x960a('0x4b')](handleError(_0x45e9c9,null));};exports[_0x960a('0x30')]=function(_0x58d1d3,_0x2a4cc8){return db[_0x960a('0x49')][_0x960a('0x51')]({'where':{'id':_0x58d1d3[_0x960a('0x4d')]['id']}})[_0x960a('0x1e')](handleEntityNotFound(_0x2a4cc8,null))[_0x960a('0x1e')](removeEntity(_0x2a4cc8,null))[_0x960a('0x4b')](handleError(_0x2a4cc8,null));};exports[_0x960a('0x52')]=function(_0x570d21,_0x282eb3,_0x451aa2){var _0x5dc09e={};var _0x220307={};var _0x5f3d6a;var _0x548290;return db[_0x960a('0x49')][_0x960a('0x53')]({'where':{'id':_0x570d21[_0x960a('0x4d')]['id']}})[_0x960a('0x1e')](handleEntityNotFound(_0x282eb3,null))[_0x960a('0x1e')](function(_0x47c507){if(_0x47c507){_0x5f3d6a=_0x47c507;_0x220307[_0x960a('0x3b')]=_[_0x960a('0x38')](db['SugarcrmField']['rawAttributes']);_0x220307[_0x960a('0x37')]=_[_0x960a('0x38')](_0x570d21[_0x960a('0x37')]);_0x220307['filters']=_[_0x960a('0x3a')](_0x220307[_0x960a('0x3b')],_0x220307[_0x960a('0x37')]);_0x5dc09e[_0x960a('0x3d')]=_[_0x960a('0x3a')](_0x220307[_0x960a('0x3b')],qs[_0x960a('0x3c')](_0x570d21[_0x960a('0x37')]['fields']));_0x5dc09e['attributes']=_0x5dc09e[_0x960a('0x3d')][_0x960a('0x3e')]?_0x5dc09e[_0x960a('0x3d')]:_0x220307['model'];_0x5dc09e[_0x960a('0x41')]=qs[_0x960a('0x42')](_0x570d21[_0x960a('0x37')][_0x960a('0x42')]);_0x5dc09e[_0x960a('0x44')]=qs['filters'](_[_0x960a('0x54')](_0x570d21['query'],_0x220307[_0x960a('0x39')]));if(_0x570d21['query'][_0x960a('0x43')]){_0x5dc09e[_0x960a('0x44')]=_[_0x960a('0x45')](_0x5dc09e['where'],{'$or':_[_0x960a('0x33')](_0x5dc09e[_0x960a('0x3d')],function(_0x3b1f05){var _0x8b805a={};_0x8b805a[_0x3b1f05]={'$like':'%'+_0x570d21[_0x960a('0x37')]['filter']+'%'};return _0x8b805a;})});}_0x5dc09e=_['merge']({},_0x5dc09e,_0x570d21[_0x960a('0x46')]);return _0x5f3d6a[_0x960a('0x52')](_0x5dc09e);}})[_0x960a('0x1e')](function(_0x4c5058){if(_0x4c5058){_0x548290=_0x4c5058[_0x960a('0x3e')];if(!_0x570d21[_0x960a('0x37')]['hasOwnProperty']('nolimit')){_0x5dc09e['limit']=qs[_0x960a('0x40')](_0x570d21['query'][_0x960a('0x40')]);_0x5dc09e[_0x960a('0x2b')]=qs[_0x960a('0x2b')](_0x570d21[_0x960a('0x37')][_0x960a('0x2b')]);}return _0x5f3d6a['getFields'](_0x5dc09e);}})[_0x960a('0x1e')](function(_0x55df34){if(_0x55df34){return _0x55df34?{'count':_0x548290,'rows':_0x55df34}:null;}})[_0x960a('0x1e')](respondWithResult(_0x282eb3,null))[_0x960a('0x4b')](handleError(_0x282eb3,null));};exports[_0x960a('0x55')]=function(_0x1401f3,_0x48b661,_0x2cf8c5){var _0x4ae1bd={};var _0x20d45a={};var _0x5a8842;var _0x10d8b0;return db[_0x960a('0x49')]['findOne']({'where':{'id':_0x1401f3['params']['id']}})[_0x960a('0x1e')](handleEntityNotFound(_0x48b661,null))[_0x960a('0x1e')](function(_0x1b3ab8){if(_0x1b3ab8){_0x5a8842=_0x1b3ab8;_0x20d45a[_0x960a('0x3b')]=_[_0x960a('0x38')](db[_0x960a('0x56')][_0x960a('0x4e')]);_0x20d45a['query']=_[_0x960a('0x38')](_0x1401f3[_0x960a('0x37')]);_0x20d45a[_0x960a('0x39')]=_['intersection'](_0x20d45a[_0x960a('0x3b')],_0x20d45a[_0x960a('0x37')]);_0x4ae1bd[_0x960a('0x3d')]=_[_0x960a('0x3a')](_0x20d45a[_0x960a('0x3b')],qs[_0x960a('0x3c')](_0x1401f3['query'][_0x960a('0x3c')]));_0x4ae1bd[_0x960a('0x3d')]=_0x4ae1bd['attributes'][_0x960a('0x3e')]?_0x4ae1bd['attributes']:_0x20d45a[_0x960a('0x3b')];_0x4ae1bd[_0x960a('0x41')]=qs[_0x960a('0x42')](_0x1401f3['query']['sort']);_0x4ae1bd[_0x960a('0x44')]=qs[_0x960a('0x39')](_[_0x960a('0x54')](_0x1401f3[_0x960a('0x37')],_0x20d45a[_0x960a('0x39')]));if(_0x1401f3[_0x960a('0x37')][_0x960a('0x43')]){_0x4ae1bd[_0x960a('0x44')]=_['merge'](_0x4ae1bd[_0x960a('0x44')],{'$or':_[_0x960a('0x33')](_0x4ae1bd[_0x960a('0x3d')],function(_0x1d0c11){var _0x164a6d={};_0x164a6d[_0x1d0c11]={'$like':'%'+_0x1401f3[_0x960a('0x37')]['filter']+'%'};return _0x164a6d;})});}_0x4ae1bd=_[_0x960a('0x45')]({},_0x4ae1bd,_0x1401f3[_0x960a('0x46')]);return _0x5a8842[_0x960a('0x55')](_0x4ae1bd);}})[_0x960a('0x1e')](function(_0x5a8e38){if(_0x5a8e38){_0x10d8b0=_0x5a8e38[_0x960a('0x3e')];if(!_0x1401f3['query'][_0x960a('0x3f')](_0x960a('0x57'))){_0x4ae1bd[_0x960a('0x40')]=qs[_0x960a('0x40')](_0x1401f3[_0x960a('0x37')][_0x960a('0x40')]);_0x4ae1bd['offset']=qs[_0x960a('0x2b')](_0x1401f3[_0x960a('0x37')][_0x960a('0x2b')]);}return _0x5a8842['getSubjects'](_0x4ae1bd);}})[_0x960a('0x1e')](function(_0x50323b){if(_0x50323b){return _0x50323b?{'count':_0x10d8b0,'rows':_0x50323b}:null;}})[_0x960a('0x1e')](respondWithResult(_0x48b661,null))[_0x960a('0x4b')](handleError(_0x48b661,null));};exports[_0x960a('0x58')]=function(_0x482fd6,_0x3aecae,_0x552811){var _0xeb1f6={};var _0x316433={};var _0x332079;var _0x20154c;return db['SugarcrmConfiguration'][_0x960a('0x53')]({'where':{'id':_0x482fd6[_0x960a('0x4d')]['id']}})[_0x960a('0x1e')](handleEntityNotFound(_0x3aecae,null))[_0x960a('0x1e')](function(_0x1c7a0b){if(_0x1c7a0b){_0x332079=_0x1c7a0b;_0x316433['model']=_['keys'](db[_0x960a('0x56')][_0x960a('0x4e')]);_0x316433[_0x960a('0x37')]=_[_0x960a('0x38')](_0x482fd6['query']);_0x316433['filters']=_[_0x960a('0x3a')](_0x316433['model'],_0x316433[_0x960a('0x37')]);_0xeb1f6[_0x960a('0x3d')]=_[_0x960a('0x3a')](_0x316433[_0x960a('0x3b')],qs[_0x960a('0x3c')](_0x482fd6['query'][_0x960a('0x3c')]));_0xeb1f6[_0x960a('0x3d')]=_0xeb1f6[_0x960a('0x3d')][_0x960a('0x3e')]?_0xeb1f6[_0x960a('0x3d')]:_0x316433[_0x960a('0x3b')];_0xeb1f6['order']=qs['sort'](_0x482fd6['query']['sort']);_0xeb1f6[_0x960a('0x44')]=qs[_0x960a('0x39')](_[_0x960a('0x54')](_0x482fd6[_0x960a('0x37')],_0x316433[_0x960a('0x39')]));if(_0x482fd6[_0x960a('0x37')]['filter']){_0xeb1f6['where']=_[_0x960a('0x45')](_0xeb1f6[_0x960a('0x44')],{'$or':_[_0x960a('0x33')](_0xeb1f6[_0x960a('0x3d')],function(_0x1c79c2){var _0x1ac1e1={};_0x1ac1e1[_0x1c79c2]={'$like':'%'+_0x482fd6[_0x960a('0x37')][_0x960a('0x43')]+'%'};return _0x1ac1e1;})});}_0xeb1f6=_['merge']({},_0xeb1f6,_0x482fd6[_0x960a('0x46')]);return _0x332079[_0x960a('0x58')](_0xeb1f6);}})[_0x960a('0x1e')](function(_0x3defc0){if(_0x3defc0){_0x20154c=_0x3defc0[_0x960a('0x3e')];if(!_0x482fd6[_0x960a('0x37')]['hasOwnProperty'](_0x960a('0x57'))){_0xeb1f6[_0x960a('0x40')]=qs['limit'](_0x482fd6[_0x960a('0x37')]['limit']);_0xeb1f6[_0x960a('0x2b')]=qs[_0x960a('0x2b')](_0x482fd6[_0x960a('0x37')][_0x960a('0x2b')]);}return _0x332079[_0x960a('0x58')](_0xeb1f6);}})[_0x960a('0x1e')](function(_0x349388){if(_0x349388){return _0x349388?{'count':_0x20154c,'rows':_0x349388}:null;}})[_0x960a('0x1e')](respondWithResult(_0x3aecae,null))[_0x960a('0x4b')](handleError(_0x3aecae,null));};
\ No newline at end of file
+var _0xf428=['../../config/license/util','../../mysqldb','client','request','then','info','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','end','status','json','count','offset','set','Content-Range','destroy','stack','index','map','SugarcrmConfiguration','rawAttributes','type','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','limit','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','show','params','create','body','update','find','getFields','findOne','SugarcrmField','order','pick','nolimit','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf428,0x1f2));var _0x8f42=function(_0xd86b32,_0x3c525a){_0xd86b32=_0xd86b32-0x0;var _0x455841=_0xf428[_0xd86b32];return _0x455841;};'use strict';var pdf=require(_0x8f42('0x0'));var emlformat=require(_0x8f42('0x1'));var rimraf=require(_0x8f42('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8f42('0x3'));var rp=require(_0x8f42('0x4'));var moment=require(_0x8f42('0x5'));var BPromise=require(_0x8f42('0x6'));var Mustache=require(_0x8f42('0x7'));var util=require('util');var path=require(_0x8f42('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x8f42('0x9'));var fs=require('fs');var _=require(_0x8f42('0xa'));var squel=require(_0x8f42('0xb'));var crypto=require(_0x8f42('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x8f42('0xd'));var toCsv=require(_0x8f42('0xe'));var querystring=require(_0x8f42('0xf'));var Papa=require(_0x8f42('0x10'));var Redis=require(_0x8f42('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x8f42('0x12'));var hardwareService=require(_0x8f42('0x13'));var logger=require(_0x8f42('0x14'))(_0x8f42('0x15'));var utils=require(_0x8f42('0x16'));var config=require(_0x8f42('0x17'));var licenseUtil=require(_0x8f42('0x18'));var db=require(_0x8f42('0x19'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x8f42('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1f00ca,_0x4f94ad,_0x52b450,_0x2d422e){return new BPromise(function(_0x11342d,_0x544771){var _0x1b5e3d=_0x2d422e||client;return _0x1b5e3d[_0x8f42('0x1b')](_0x1f00ca,_0x52b450)[_0x8f42('0x1c')](function(_0x3e82c2){logger[_0x8f42('0x1d')](_0x8f42('0x1e'),_0x4f94ad,_0x8f42('0x1f'));logger[_0x8f42('0x20')](_0x8f42('0x21'),_0x4f94ad,'request\x20sent',JSON[_0x8f42('0x22')](_0x3e82c2));if(_0x3e82c2[_0x8f42('0x23')]){if(_0x3e82c2['error'][_0x8f42('0x24')]===0x1f4){logger[_0x8f42('0x23')](_0x8f42('0x1e'),_0x4f94ad,_0x3e82c2[_0x8f42('0x23')]['message']);return _0x544771(_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);}logger[_0x8f42('0x23')](_0x8f42('0x1e'),_0x4f94ad,_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);return _0x11342d(_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);}else{logger[_0x8f42('0x1d')](_0x8f42('0x1e'),_0x4f94ad,_0x8f42('0x1f'));_0x11342d(_0x3e82c2['result'][_0x8f42('0x25')]);}})[_0x8f42('0x26')](function(_0x1d83ea){logger[_0x8f42('0x23')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4f94ad,_0x1d83ea);_0x544771(_0x1d83ea);});});}function respondWithStatusCode(_0x2b70,_0x32669d){_0x32669d=_0x32669d||0xcc;return function(_0x123671){if(_0x123671){return _0x2b70[_0x8f42('0x27')](_0x32669d);}return _0x2b70['status'](_0x32669d)[_0x8f42('0x28')]();};}function respondWithResult(_0x3e8a3b,_0x2e3c58){_0x2e3c58=_0x2e3c58||0xc8;return function(_0x431761){if(_0x431761){return _0x3e8a3b[_0x8f42('0x29')](_0x2e3c58)[_0x8f42('0x2a')](_0x431761);}};}function respondWithFilteredResult(_0x5dbd3a,_0x315b47){return function(_0x48eae0){if(_0x48eae0){var _0x3854ef=_0x48eae0[_0x8f42('0x2b')],_0x1955ab=_0x315b47[_0x8f42('0x2c')],_0x548b4a=_0x315b47['offset']+_0x315b47['limit'],_0xe542ed;if(_0x548b4a>=_0x3854ef){_0x548b4a=_0x3854ef;_0xe542ed=0xc8;}else{_0xe542ed=0xce;}_0x5dbd3a['status'](_0xe542ed);return _0x5dbd3a[_0x8f42('0x2d')](_0x8f42('0x2e'),_0x1955ab+'-'+_0x548b4a+'/'+_0x3854ef)[_0x8f42('0x2a')](_0x48eae0);}return null;};}function patchUpdates(_0x40d77e){return function(_0x4a00a8){try{jsonpatch['apply'](_0x4a00a8,_0x40d77e,!![]);}catch(_0x47f181){return BPromise['reject'](_0x47f181);}return _0x4a00a8['save']();};}function saveUpdates(_0xb71c04,_0x11be0f){return function(_0x14dc97){if(_0x14dc97){return _0x14dc97['update'](_0xb71c04)[_0x8f42('0x1c')](function(_0x45e637){return _0x45e637;});}return null;};}function removeEntity(_0x3a0bd6,_0x3daf1d){return function(_0x49b74c){if(_0x49b74c){return _0x49b74c[_0x8f42('0x2f')]()[_0x8f42('0x1c')](function(){_0x3a0bd6[_0x8f42('0x29')](0xcc)[_0x8f42('0x28')]();});}};}function handleEntityNotFound(_0x4d3858,_0x458d63){return function(_0x254afd){if(!_0x254afd){_0x4d3858['sendStatus'](0x194);}return _0x254afd;};}function handleError(_0x271de9,_0x37ef30){_0x37ef30=_0x37ef30||0x1f4;return function(_0x43b6f5){logger[_0x8f42('0x23')](_0x43b6f5[_0x8f42('0x30')]);if(_0x43b6f5['name']){delete _0x43b6f5['name'];}_0x271de9[_0x8f42('0x29')](_0x37ef30)['send'](_0x43b6f5);};}exports[_0x8f42('0x31')]=function(_0x48df3e,_0x47a4dc){var _0x5740b8={},_0x49d741={},_0x23e0e8={'count':0x0,'rows':[]};var _0x1bae7f=_[_0x8f42('0x32')](db[_0x8f42('0x33')][_0x8f42('0x34')],function(_0x32fb35){return{'name':_0x32fb35['fieldName'],'type':_0x32fb35[_0x8f42('0x35')]['key']};});_0x49d741[_0x8f42('0x36')]=_['map'](_0x1bae7f,'name');_0x49d741['query']=_[_0x8f42('0x37')](_0x48df3e[_0x8f42('0x38')]);_0x49d741[_0x8f42('0x39')]=_['intersection'](_0x49d741[_0x8f42('0x36')],_0x49d741['query']);_0x5740b8[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x49d741['model'],qs[_0x8f42('0x3c')](_0x48df3e['query'][_0x8f42('0x3c')]));_0x5740b8[_0x8f42('0x3a')]=_0x5740b8['attributes'][_0x8f42('0x3d')]?_0x5740b8[_0x8f42('0x3a')]:_0x49d741['model'];if(!_0x48df3e[_0x8f42('0x38')][_0x8f42('0x3e')]('nolimit')){_0x5740b8[_0x8f42('0x3f')]=qs[_0x8f42('0x3f')](_0x48df3e[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x5740b8[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x48df3e['query'][_0x8f42('0x2c')]);}_0x5740b8['order']=qs[_0x8f42('0x40')](_0x48df3e[_0x8f42('0x38')][_0x8f42('0x40')]);_0x5740b8[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_['pick'](_0x48df3e[_0x8f42('0x38')],_0x49d741[_0x8f42('0x39')]),_0x1bae7f);if(_0x48df3e['query'][_0x8f42('0x42')]){_0x5740b8[_0x8f42('0x41')]=_[_0x8f42('0x43')](_0x5740b8[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x1bae7f,function(_0x4372ca){if(_0x4372ca[_0x8f42('0x35')]!==_0x8f42('0x44')){var _0x33a57e={};_0x33a57e[_0x4372ca['name']]={'$like':'%'+_0x48df3e[_0x8f42('0x38')]['filter']+'%'};return _0x33a57e;}})});}_0x5740b8=_[_0x8f42('0x43')]({},_0x5740b8,_0x48df3e[_0x8f42('0x45')]);var _0x1c6a05={'where':_0x5740b8[_0x8f42('0x41')]};return db['SugarcrmConfiguration'][_0x8f42('0x2b')](_0x1c6a05)[_0x8f42('0x1c')](function(_0x35a5c7){_0x23e0e8[_0x8f42('0x2b')]=_0x35a5c7;if(_0x48df3e[_0x8f42('0x38')][_0x8f42('0x46')]){_0x5740b8[_0x8f42('0x47')]=[{'all':!![]}];}return db[_0x8f42('0x33')]['findAll'](_0x5740b8);})[_0x8f42('0x1c')](function(_0x15c62b){_0x23e0e8[_0x8f42('0x48')]=_0x15c62b;return _0x23e0e8;})[_0x8f42('0x1c')](respondWithFilteredResult(_0x47a4dc,_0x5740b8))[_0x8f42('0x26')](handleError(_0x47a4dc,null));};exports[_0x8f42('0x49')]=function(_0x3f2af2,_0x3ef3e1){var _0x2ac359={'raw':![],'where':{'id':_0x3f2af2[_0x8f42('0x4a')]['id']}},_0x1d1fd0={};_0x1d1fd0[_0x8f42('0x36')]=_['keys'](db[_0x8f42('0x33')][_0x8f42('0x34')]);_0x1d1fd0[_0x8f42('0x38')]=_[_0x8f42('0x37')](_0x3f2af2[_0x8f42('0x38')]);_0x1d1fd0[_0x8f42('0x39')]=_[_0x8f42('0x3b')](_0x1d1fd0[_0x8f42('0x36')],_0x1d1fd0['query']);_0x2ac359[_0x8f42('0x3a')]=_['intersection'](_0x1d1fd0[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x3f2af2['query'][_0x8f42('0x3c')]));_0x2ac359[_0x8f42('0x3a')]=_0x2ac359[_0x8f42('0x3a')]['length']?_0x2ac359[_0x8f42('0x3a')]:_0x1d1fd0[_0x8f42('0x36')];if(_0x3f2af2[_0x8f42('0x38')][_0x8f42('0x46')]){_0x2ac359[_0x8f42('0x47')]=[{'all':!![]}];}_0x2ac359=_[_0x8f42('0x43')]({},_0x2ac359,_0x3f2af2['options']);return db[_0x8f42('0x33')]['find'](_0x2ac359)[_0x8f42('0x1c')](handleEntityNotFound(_0x3ef3e1,null))[_0x8f42('0x1c')](respondWithResult(_0x3ef3e1,null))[_0x8f42('0x26')](handleError(_0x3ef3e1,null));};exports[_0x8f42('0x4b')]=function(_0x6a58d8,_0x2e8f79){return db['SugarcrmConfiguration'][_0x8f42('0x4b')](_0x6a58d8[_0x8f42('0x4c')],{})[_0x8f42('0x1c')](respondWithResult(_0x2e8f79,0xc9))['catch'](handleError(_0x2e8f79,null));};exports[_0x8f42('0x4d')]=function(_0x3f2832,_0x23c551){if(_0x3f2832[_0x8f42('0x4c')]['id']){delete _0x3f2832[_0x8f42('0x4c')]['id'];}return db[_0x8f42('0x33')][_0x8f42('0x4e')]({'where':{'id':_0x3f2832[_0x8f42('0x4a')]['id']}})['then'](handleEntityNotFound(_0x23c551,null))[_0x8f42('0x1c')](saveUpdates(_0x3f2832[_0x8f42('0x4c')],null))[_0x8f42('0x1c')](respondWithResult(_0x23c551,null))[_0x8f42('0x26')](handleError(_0x23c551,null));};exports[_0x8f42('0x2f')]=function(_0x19133f,_0x13e50a){return db['SugarcrmConfiguration'][_0x8f42('0x4e')]({'where':{'id':_0x19133f[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x13e50a,null))[_0x8f42('0x1c')](removeEntity(_0x13e50a,null))[_0x8f42('0x26')](handleError(_0x13e50a,null));};exports[_0x8f42('0x4f')]=function(_0x141d03,_0x532b18,_0xea79bb){var _0x2aaa9e={};var _0x37b533={};var _0x43c10a;var _0x2b8db5;return db[_0x8f42('0x33')][_0x8f42('0x50')]({'where':{'id':_0x141d03[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x532b18,null))[_0x8f42('0x1c')](function(_0x33c11a){if(_0x33c11a){_0x43c10a=_0x33c11a;_0x37b533[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')][_0x8f42('0x34')]);_0x37b533['query']=_[_0x8f42('0x37')](_0x141d03['query']);_0x37b533[_0x8f42('0x39')]=_[_0x8f42('0x3b')](_0x37b533[_0x8f42('0x36')],_0x37b533[_0x8f42('0x38')]);_0x2aaa9e[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x37b533[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x3c')]));_0x2aaa9e[_0x8f42('0x3a')]=_0x2aaa9e[_0x8f42('0x3a')][_0x8f42('0x3d')]?_0x2aaa9e[_0x8f42('0x3a')]:_0x37b533[_0x8f42('0x36')];_0x2aaa9e[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x40')]);_0x2aaa9e[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x141d03['query'],_0x37b533['filters']));if(_0x141d03[_0x8f42('0x38')][_0x8f42('0x42')]){_0x2aaa9e[_0x8f42('0x41')]=_['merge'](_0x2aaa9e[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x2aaa9e[_0x8f42('0x3a')],function(_0x4128ec){var _0x1f209e={};_0x1f209e[_0x4128ec]={'$like':'%'+_0x141d03[_0x8f42('0x38')][_0x8f42('0x42')]+'%'};return _0x1f209e;})});}_0x2aaa9e=_[_0x8f42('0x43')]({},_0x2aaa9e,_0x141d03[_0x8f42('0x45')]);return _0x43c10a[_0x8f42('0x4f')](_0x2aaa9e);}})[_0x8f42('0x1c')](function(_0x144c8f){if(_0x144c8f){_0x2b8db5=_0x144c8f[_0x8f42('0x3d')];if(!_0x141d03['query']['hasOwnProperty'](_0x8f42('0x54'))){_0x2aaa9e['limit']=qs[_0x8f42('0x3f')](_0x141d03[_0x8f42('0x38')]['limit']);_0x2aaa9e['offset']=qs[_0x8f42('0x2c')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0x43c10a['getFields'](_0x2aaa9e);}})['then'](function(_0x374bfd){if(_0x374bfd){return _0x374bfd?{'count':_0x2b8db5,'rows':_0x374bfd}:null;}})[_0x8f42('0x1c')](respondWithResult(_0x532b18,null))[_0x8f42('0x26')](handleError(_0x532b18,null));};exports[_0x8f42('0x55')]=function(_0x33f7a7,_0xf27c06,_0x2d842f){var _0x4d9915={};var _0x5bf018={};var _0xaf214b;var _0x2f2efb;return db[_0x8f42('0x33')][_0x8f42('0x50')]({'where':{'id':_0x33f7a7[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0xf27c06,null))['then'](function(_0x2b9c72){if(_0x2b9c72){_0xaf214b=_0x2b9c72;_0x5bf018[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')][_0x8f42('0x34')]);_0x5bf018['query']=_[_0x8f42('0x37')](_0x33f7a7[_0x8f42('0x38')]);_0x5bf018[_0x8f42('0x39')]=_['intersection'](_0x5bf018[_0x8f42('0x36')],_0x5bf018['query']);_0x4d9915['attributes']=_[_0x8f42('0x3b')](_0x5bf018[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x33f7a7[_0x8f42('0x38')]['fields']));_0x4d9915[_0x8f42('0x3a')]=_0x4d9915[_0x8f42('0x3a')]['length']?_0x4d9915['attributes']:_0x5bf018[_0x8f42('0x36')];_0x4d9915[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x33f7a7['query'][_0x8f42('0x40')]);_0x4d9915['where']=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x33f7a7[_0x8f42('0x38')],_0x5bf018['filters']));if(_0x33f7a7[_0x8f42('0x38')]['filter']){_0x4d9915['where']=_[_0x8f42('0x43')](_0x4d9915[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x4d9915[_0x8f42('0x3a')],function(_0x327d5f){var _0x351c2e={};_0x351c2e[_0x327d5f]={'$like':'%'+_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x42')]+'%'};return _0x351c2e;})});}_0x4d9915=_['merge']({},_0x4d9915,_0x33f7a7[_0x8f42('0x45')]);return _0xaf214b[_0x8f42('0x55')](_0x4d9915);}})[_0x8f42('0x1c')](function(_0x5dff48){if(_0x5dff48){_0x2f2efb=_0x5dff48[_0x8f42('0x3d')];if(!_0x33f7a7['query']['hasOwnProperty'](_0x8f42('0x54'))){_0x4d9915['limit']=qs['limit'](_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x4d9915[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0xaf214b[_0x8f42('0x55')](_0x4d9915);}})[_0x8f42('0x1c')](function(_0x1fb013){if(_0x1fb013){return _0x1fb013?{'count':_0x2f2efb,'rows':_0x1fb013}:null;}})[_0x8f42('0x1c')](respondWithResult(_0xf27c06,null))[_0x8f42('0x26')](handleError(_0xf27c06,null));};exports[_0x8f42('0x56')]=function(_0x5c5b1c,_0x4ca880,_0x404b3b){var _0x766bc6={};var _0x563706={};var _0x387170;var _0x4778ff;return db['SugarcrmConfiguration'][_0x8f42('0x50')]({'where':{'id':_0x5c5b1c[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x4ca880,null))[_0x8f42('0x1c')](function(_0x12d138){if(_0x12d138){_0x387170=_0x12d138;_0x563706[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')]['rawAttributes']);_0x563706['query']=_[_0x8f42('0x37')](_0x5c5b1c[_0x8f42('0x38')]);_0x563706[_0x8f42('0x39')]=_['intersection'](_0x563706[_0x8f42('0x36')],_0x563706[_0x8f42('0x38')]);_0x766bc6[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x563706[_0x8f42('0x36')],qs['fields'](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x3c')]));_0x766bc6[_0x8f42('0x3a')]=_0x766bc6[_0x8f42('0x3a')]['length']?_0x766bc6[_0x8f42('0x3a')]:_0x563706[_0x8f42('0x36')];_0x766bc6[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x5c5b1c['query'][_0x8f42('0x40')]);_0x766bc6[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x5c5b1c[_0x8f42('0x38')],_0x563706['filters']));if(_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x42')]){_0x766bc6[_0x8f42('0x41')]=_[_0x8f42('0x43')](_0x766bc6[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x766bc6[_0x8f42('0x3a')],function(_0x1b526e){var _0x324197={};_0x324197[_0x1b526e]={'$like':'%'+_0x5c5b1c['query'][_0x8f42('0x42')]+'%'};return _0x324197;})});}_0x766bc6=_[_0x8f42('0x43')]({},_0x766bc6,_0x5c5b1c[_0x8f42('0x45')]);return _0x387170[_0x8f42('0x56')](_0x766bc6);}})[_0x8f42('0x1c')](function(_0xbba0d){if(_0xbba0d){_0x4778ff=_0xbba0d[_0x8f42('0x3d')];if(!_0x5c5b1c['query'][_0x8f42('0x3e')](_0x8f42('0x54'))){_0x766bc6[_0x8f42('0x3f')]=qs[_0x8f42('0x3f')](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x766bc6[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0x387170[_0x8f42('0x56')](_0x766bc6);}})['then'](function(_0xd6da6c){if(_0xd6da6c){return _0xd6da6c?{'count':_0x4778ff,'rows':_0xd6da6c}:null;}})[_0x8f42('0x1c')](respondWithResult(_0x4ca880,null))[_0x8f42('0x26')](handleError(_0x4ca880,null));};
\ No newline at end of file