Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index e1adb19..1126a74 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2fd0=['filter','merge','VIRTUAL','options','SugarcrmConfiguration','includeAll','findAll','show','include','find','create','body','params','getFields','SugarcrmField','findOne','pick','getSubjects','hasOwnProperty','getDescriptions','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','jayson/promise','request','then','info','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','SugarcrmConfiguration,\x20%s,\x20%s','message','request\x20sent','result','catch','end','json','count','offset','limit','status','set','Content-Range','apply','reject','save','update','destroy','sendStatus','stack','name','send','map','rawAttributes','type','key','model','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where'];(function(_0x1cf46e,_0xb30477){var _0x38548d=function(_0x2f6249){while(--_0x2f6249){_0x1cf46e['push'](_0x1cf46e['shift']());}};_0x38548d(++_0xb30477);}(_0x2fd0,0x73));var _0x02fd=function(_0x187bb2,_0x2f59bf){_0x187bb2=_0x187bb2-0x0;var _0x4af854=_0x2fd0[_0x187bb2];return _0x4af854;};'use strict';var pdf=require(_0x02fd('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x02fd('0x1'));var zipdir=require(_0x02fd('0x2'));var jsonpatch=require(_0x02fd('0x3'));var rp=require(_0x02fd('0x4'));var moment=require(_0x02fd('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x02fd('0x6'));var path=require(_0x02fd('0x7'));var sox=require(_0x02fd('0x8'));var csv=require(_0x02fd('0x9'));var ejs=require(_0x02fd('0xa'));var fs=require('fs');var _=require(_0x02fd('0xb'));var squel=require(_0x02fd('0xc'));var crypto=require(_0x02fd('0xd'));var jsforce=require(_0x02fd('0xe'));var deskjs=require(_0x02fd('0xf'));var toCsv=require(_0x02fd('0x9'));var querystring=require(_0x02fd('0x10'));var Papa=require(_0x02fd('0x11'));var Redis=require(_0x02fd('0x12'));var authService=require(_0x02fd('0x13'));var qs=require(_0x02fd('0x14'));var as=require(_0x02fd('0x15'));var hardwareService=require(_0x02fd('0x16'));var logger=require(_0x02fd('0x17'))(_0x02fd('0x18'));var utils=require(_0x02fd('0x19'));var config=require(_0x02fd('0x1a'));var licenseUtil=require(_0x02fd('0x1b'));var db=require('../../mysqldb')['db'];var jayson=require(_0x02fd('0x1c'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x39381a,_0x1b9a2d,_0x563cc8,_0xe95a44){return new BPromise(function(_0x4da0d6,_0x1c9fc5){var _0x297ffa=_0xe95a44||client;return _0x297ffa[_0x02fd('0x1d')](_0x39381a,_0x563cc8)[_0x02fd('0x1e')](function(_0xa7c25c){logger[_0x02fd('0x1f')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x1b9a2d,'request\x20sent');logger[_0x02fd('0x20')](_0x02fd('0x21'),_0x1b9a2d,'request\x20sent',JSON[_0x02fd('0x22')](_0xa7c25c));if(_0xa7c25c[_0x02fd('0x23')]){if(_0xa7c25c['error'][_0x02fd('0x24')]===0x1f4){logger[_0x02fd('0x23')](_0x02fd('0x25'),_0x1b9a2d,_0xa7c25c['error'][_0x02fd('0x26')]);return _0x1c9fc5(_0xa7c25c['error'][_0x02fd('0x26')]);}logger[_0x02fd('0x23')](_0x02fd('0x25'),_0x1b9a2d,_0xa7c25c[_0x02fd('0x23')][_0x02fd('0x26')]);return _0x4da0d6(_0xa7c25c['error'][_0x02fd('0x26')]);}else{logger['info'](_0x02fd('0x25'),_0x1b9a2d,_0x02fd('0x27'));_0x4da0d6(_0xa7c25c[_0x02fd('0x28')][_0x02fd('0x26')]);}})[_0x02fd('0x29')](function(_0x4f8bc5){logger[_0x02fd('0x23')](_0x02fd('0x25'),_0x1b9a2d,_0x4f8bc5);_0x1c9fc5(_0x4f8bc5);});});}function respondWithStatusCode(_0x3aaf18,_0x3d1a36){_0x3d1a36=_0x3d1a36||0xcc;return function(_0x1303a0){if(_0x1303a0){return _0x3aaf18['sendStatus'](_0x3d1a36);}return _0x3aaf18['status'](_0x3d1a36)[_0x02fd('0x2a')]();};}function respondWithResult(_0x4ac409,_0x5b07ac){_0x5b07ac=_0x5b07ac||0xc8;return function(_0x36b828){if(_0x36b828){return _0x4ac409['status'](_0x5b07ac)[_0x02fd('0x2b')](_0x36b828);}};}function respondWithFilteredResult(_0x3fe908,_0x2d7ca2){return function(_0x309b1e){if(_0x309b1e){var _0x3574d8=_0x309b1e[_0x02fd('0x2c')],_0x3cda5f=_0x2d7ca2['offset'],_0x3acb1d=_0x2d7ca2[_0x02fd('0x2d')]+_0x2d7ca2[_0x02fd('0x2e')],_0xc3819;if(_0x3acb1d>=_0x3574d8){_0x3acb1d=_0x3574d8;_0xc3819=0xc8;}else{_0xc3819=0xce;}_0x3fe908[_0x02fd('0x2f')](_0xc3819);return _0x3fe908[_0x02fd('0x30')](_0x02fd('0x31'),_0x3cda5f+'-'+_0x3acb1d+'/'+_0x3574d8)['json'](_0x309b1e);}return null;};}function patchUpdates(_0x4848af){return function(_0x499ab0){try{jsonpatch[_0x02fd('0x32')](_0x499ab0,_0x4848af,!![]);}catch(_0x2dad8c){return BPromise[_0x02fd('0x33')](_0x2dad8c);}return _0x499ab0[_0x02fd('0x34')]();};}function saveUpdates(_0x11e286,_0x32903c){return function(_0x3b6c2e){if(_0x3b6c2e){return _0x3b6c2e[_0x02fd('0x35')](_0x11e286)[_0x02fd('0x1e')](function(_0x1d1da9){return _0x1d1da9;});}return null;};}function removeEntity(_0x76572b,_0x26b2e6){return function(_0x1d3c02){if(_0x1d3c02){return _0x1d3c02[_0x02fd('0x36')]()[_0x02fd('0x1e')](function(){_0x76572b['status'](0xcc)[_0x02fd('0x2a')]();});}};}function handleEntityNotFound(_0x56555a,_0x1fdfe1){return function(_0x311359){if(!_0x311359){_0x56555a[_0x02fd('0x37')](0x194);}return _0x311359;};}function handleError(_0x2763da,_0x15cac7){_0x15cac7=_0x15cac7||0x1f4;return function(_0x232b5b){logger[_0x02fd('0x23')](_0x232b5b[_0x02fd('0x38')]);if(_0x232b5b[_0x02fd('0x39')]){delete _0x232b5b[_0x02fd('0x39')];}_0x2763da[_0x02fd('0x2f')](_0x15cac7)[_0x02fd('0x3a')](_0x232b5b);};}exports['index']=function(_0x36c478,_0x5c9489){var _0x4e115d={},_0x251870={},_0x425b05={'count':0x0,'rows':[]};var _0xbbdda=_[_0x02fd('0x3b')](db['SugarcrmConfiguration'][_0x02fd('0x3c')],function(_0x90eed3){return{'name':_0x90eed3['fieldName'],'type':_0x90eed3[_0x02fd('0x3d')][_0x02fd('0x3e')]};});_0x251870[_0x02fd('0x3f')]=_['map'](_0xbbdda,'name');_0x251870[_0x02fd('0x40')]=_[_0x02fd('0x41')](_0x36c478['query']);_0x251870[_0x02fd('0x42')]=_['intersection'](_0x251870[_0x02fd('0x3f')],_0x251870[_0x02fd('0x40')]);_0x4e115d['attributes']=_[_0x02fd('0x43')](_0x251870[_0x02fd('0x3f')],qs[_0x02fd('0x44')](_0x36c478[_0x02fd('0x40')][_0x02fd('0x44')]));_0x4e115d[_0x02fd('0x45')]=_0x4e115d[_0x02fd('0x45')][_0x02fd('0x46')]?_0x4e115d[_0x02fd('0x45')]:_0x251870['model'];if(!_0x36c478[_0x02fd('0x40')]['hasOwnProperty'](_0x02fd('0x47'))){_0x4e115d[_0x02fd('0x2e')]=qs[_0x02fd('0x2e')](_0x36c478[_0x02fd('0x40')][_0x02fd('0x2e')]);_0x4e115d[_0x02fd('0x2d')]=qs['offset'](_0x36c478['query']['offset']);}_0x4e115d[_0x02fd('0x48')]=qs[_0x02fd('0x49')](_0x36c478[_0x02fd('0x40')][_0x02fd('0x49')]);_0x4e115d[_0x02fd('0x4a')]=qs[_0x02fd('0x42')](_['pick'](_0x36c478['query'],_0x251870[_0x02fd('0x42')]),_0xbbdda);if(_0x36c478[_0x02fd('0x40')][_0x02fd('0x4b')]){_0x4e115d[_0x02fd('0x4a')]=_[_0x02fd('0x4c')](_0x4e115d[_0x02fd('0x4a')],{'$or':_[_0x02fd('0x3b')](_0xbbdda,function(_0x544ec0){if(_0x544ec0[_0x02fd('0x3d')]!==_0x02fd('0x4d')){var _0x2133fb={};_0x2133fb[_0x544ec0[_0x02fd('0x39')]]={'$like':'%'+_0x36c478[_0x02fd('0x40')][_0x02fd('0x4b')]+'%'};return _0x2133fb;}})});}_0x4e115d=_[_0x02fd('0x4c')]({},_0x4e115d,_0x36c478[_0x02fd('0x4e')]);var _0x2cfbe9={'where':_0x4e115d[_0x02fd('0x4a')]};return db[_0x02fd('0x4f')][_0x02fd('0x2c')](_0x2cfbe9)[_0x02fd('0x1e')](function(_0x40f029){_0x425b05[_0x02fd('0x2c')]=_0x40f029;if(_0x36c478[_0x02fd('0x40')][_0x02fd('0x50')]){_0x4e115d['include']=[{'all':!![]}];}return db[_0x02fd('0x4f')][_0x02fd('0x51')](_0x4e115d);})['then'](function(_0x5f5ac6){_0x425b05['rows']=_0x5f5ac6;return _0x425b05;})[_0x02fd('0x1e')](respondWithFilteredResult(_0x5c9489,_0x4e115d))[_0x02fd('0x29')](handleError(_0x5c9489,null));};exports[_0x02fd('0x52')]=function(_0x14e5e6,_0x59923f){var _0x17e75a={'raw':![],'where':{'id':_0x14e5e6['params']['id']}},_0x5746c5={};_0x5746c5[_0x02fd('0x3f')]=_['keys'](db[_0x02fd('0x4f')][_0x02fd('0x3c')]);_0x5746c5['query']=_[_0x02fd('0x41')](_0x14e5e6['query']);_0x5746c5[_0x02fd('0x42')]=_[_0x02fd('0x43')](_0x5746c5['model'],_0x5746c5[_0x02fd('0x40')]);_0x17e75a[_0x02fd('0x45')]=_['intersection'](_0x5746c5[_0x02fd('0x3f')],qs[_0x02fd('0x44')](_0x14e5e6[_0x02fd('0x40')][_0x02fd('0x44')]));_0x17e75a[_0x02fd('0x45')]=_0x17e75a[_0x02fd('0x45')][_0x02fd('0x46')]?_0x17e75a[_0x02fd('0x45')]:_0x5746c5[_0x02fd('0x3f')];if(_0x14e5e6[_0x02fd('0x40')][_0x02fd('0x50')]){_0x17e75a[_0x02fd('0x53')]=[{'all':!![]}];}_0x17e75a=_[_0x02fd('0x4c')]({},_0x17e75a,_0x14e5e6[_0x02fd('0x4e')]);return db[_0x02fd('0x4f')][_0x02fd('0x54')](_0x17e75a)[_0x02fd('0x1e')](handleEntityNotFound(_0x59923f,null))['then'](respondWithResult(_0x59923f,null))['catch'](handleError(_0x59923f,null));};exports[_0x02fd('0x55')]=function(_0x40afb1,_0x234f32){return db['SugarcrmConfiguration'][_0x02fd('0x55')](_0x40afb1[_0x02fd('0x56')],{})['then'](respondWithResult(_0x234f32,0xc9))['catch'](handleError(_0x234f32,null));};exports[_0x02fd('0x35')]=function(_0x506088,_0x367da5){if(_0x506088[_0x02fd('0x56')]['id']){delete _0x506088[_0x02fd('0x56')]['id'];}return db[_0x02fd('0x4f')][_0x02fd('0x54')]({'where':{'id':_0x506088[_0x02fd('0x57')]['id']}})[_0x02fd('0x1e')](handleEntityNotFound(_0x367da5,null))[_0x02fd('0x1e')](saveUpdates(_0x506088[_0x02fd('0x56')],null))[_0x02fd('0x1e')](respondWithResult(_0x367da5,null))['catch'](handleError(_0x367da5,null));};exports[_0x02fd('0x36')]=function(_0x3f317e,_0x50ce34){return db[_0x02fd('0x4f')]['find']({'where':{'id':_0x3f317e[_0x02fd('0x57')]['id']}})['then'](handleEntityNotFound(_0x50ce34,null))[_0x02fd('0x1e')](removeEntity(_0x50ce34,null))[_0x02fd('0x29')](handleError(_0x50ce34,null));};exports[_0x02fd('0x58')]=function(_0x4520cd,_0x1b3921,_0x2ebd11){var _0x469f3d={};var _0x46d6a2={};var _0x28be5b;var _0x3d461f;return db[_0x02fd('0x4f')]['findOne']({'where':{'id':_0x4520cd[_0x02fd('0x57')]['id']}})[_0x02fd('0x1e')](handleEntityNotFound(_0x1b3921,null))[_0x02fd('0x1e')](function(_0x3b3a8e){if(_0x3b3a8e){_0x28be5b=_0x3b3a8e;_0x46d6a2[_0x02fd('0x3f')]=_[_0x02fd('0x41')](db[_0x02fd('0x59')][_0x02fd('0x3c')]);_0x46d6a2['query']=_['keys'](_0x4520cd['query']);_0x46d6a2[_0x02fd('0x42')]=_[_0x02fd('0x43')](_0x46d6a2[_0x02fd('0x3f')],_0x46d6a2['query']);_0x469f3d[_0x02fd('0x45')]=_[_0x02fd('0x43')](_0x46d6a2[_0x02fd('0x3f')],qs['fields'](_0x4520cd[_0x02fd('0x40')][_0x02fd('0x44')]));_0x469f3d[_0x02fd('0x45')]=_0x469f3d[_0x02fd('0x45')][_0x02fd('0x46')]?_0x469f3d[_0x02fd('0x45')]:_0x46d6a2[_0x02fd('0x3f')];_0x469f3d[_0x02fd('0x48')]=qs[_0x02fd('0x49')](_0x4520cd[_0x02fd('0x40')][_0x02fd('0x49')]);_0x469f3d['where']=qs[_0x02fd('0x42')](_['pick'](_0x4520cd['query'],_0x46d6a2['filters']));if(_0x4520cd[_0x02fd('0x40')]['filter']){_0x469f3d['where']=_[_0x02fd('0x4c')](_0x469f3d[_0x02fd('0x4a')],{'$or':_['map'](_0x469f3d['attributes'],function(_0x35350a){var _0x4f5165={};_0x4f5165[_0x35350a]={'$like':'%'+_0x4520cd[_0x02fd('0x40')][_0x02fd('0x4b')]+'%'};return _0x4f5165;})});}_0x469f3d=_[_0x02fd('0x4c')]({},_0x469f3d,_0x4520cd['options']);return _0x28be5b[_0x02fd('0x58')](_0x469f3d);}})[_0x02fd('0x1e')](function(_0x3a2891){if(_0x3a2891){_0x3d461f=_0x3a2891[_0x02fd('0x46')];if(!_0x4520cd[_0x02fd('0x40')]['hasOwnProperty'](_0x02fd('0x47'))){_0x469f3d[_0x02fd('0x2e')]=qs[_0x02fd('0x2e')](_0x4520cd[_0x02fd('0x40')][_0x02fd('0x2e')]);_0x469f3d[_0x02fd('0x2d')]=qs['offset'](_0x4520cd[_0x02fd('0x40')]['offset']);}return _0x28be5b[_0x02fd('0x58')](_0x469f3d);}})[_0x02fd('0x1e')](function(_0x45859b){if(_0x45859b){return _0x45859b?{'count':_0x3d461f,'rows':_0x45859b}:null;}})['then'](respondWithResult(_0x1b3921,null))[_0x02fd('0x29')](handleError(_0x1b3921,null));};exports['getSubjects']=function(_0x4d0f13,_0xfab216,_0x4b298f){var _0x350ecb={};var _0x1d519f={};var _0x112f63;var _0x4d8ca5;return db[_0x02fd('0x4f')][_0x02fd('0x5a')]({'where':{'id':_0x4d0f13[_0x02fd('0x57')]['id']}})[_0x02fd('0x1e')](handleEntityNotFound(_0xfab216,null))['then'](function(_0x19dd11){if(_0x19dd11){_0x112f63=_0x19dd11;_0x1d519f['model']=_[_0x02fd('0x41')](db[_0x02fd('0x59')][_0x02fd('0x3c')]);_0x1d519f[_0x02fd('0x40')]=_[_0x02fd('0x41')](_0x4d0f13[_0x02fd('0x40')]);_0x1d519f[_0x02fd('0x42')]=_['intersection'](_0x1d519f[_0x02fd('0x3f')],_0x1d519f[_0x02fd('0x40')]);_0x350ecb[_0x02fd('0x45')]=_['intersection'](_0x1d519f[_0x02fd('0x3f')],qs['fields'](_0x4d0f13[_0x02fd('0x40')][_0x02fd('0x44')]));_0x350ecb[_0x02fd('0x45')]=_0x350ecb[_0x02fd('0x45')][_0x02fd('0x46')]?_0x350ecb[_0x02fd('0x45')]:_0x1d519f['model'];_0x350ecb[_0x02fd('0x48')]=qs[_0x02fd('0x49')](_0x4d0f13['query'][_0x02fd('0x49')]);_0x350ecb[_0x02fd('0x4a')]=qs['filters'](_[_0x02fd('0x5b')](_0x4d0f13[_0x02fd('0x40')],_0x1d519f['filters']));if(_0x4d0f13[_0x02fd('0x40')]['filter']){_0x350ecb[_0x02fd('0x4a')]=_[_0x02fd('0x4c')](_0x350ecb['where'],{'$or':_[_0x02fd('0x3b')](_0x350ecb[_0x02fd('0x45')],function(_0x7a8902){var _0x28b459={};_0x28b459[_0x7a8902]={'$like':'%'+_0x4d0f13[_0x02fd('0x40')][_0x02fd('0x4b')]+'%'};return _0x28b459;})});}_0x350ecb=_[_0x02fd('0x4c')]({},_0x350ecb,_0x4d0f13['options']);return _0x112f63[_0x02fd('0x5c')](_0x350ecb);}})[_0x02fd('0x1e')](function(_0xf84a1){if(_0xf84a1){_0x4d8ca5=_0xf84a1[_0x02fd('0x46')];if(!_0x4d0f13['query'][_0x02fd('0x5d')]('nolimit')){_0x350ecb[_0x02fd('0x2e')]=qs['limit'](_0x4d0f13[_0x02fd('0x40')]['limit']);_0x350ecb['offset']=qs[_0x02fd('0x2d')](_0x4d0f13[_0x02fd('0x40')]['offset']);}return _0x112f63[_0x02fd('0x5c')](_0x350ecb);}})[_0x02fd('0x1e')](function(_0x40e90e){if(_0x40e90e){return _0x40e90e?{'count':_0x4d8ca5,'rows':_0x40e90e}:null;}})[_0x02fd('0x1e')](respondWithResult(_0xfab216,null))['catch'](handleError(_0xfab216,null));};exports[_0x02fd('0x5e')]=function(_0x32f309,_0x55d827,_0x15d2a4){var _0x3a0fc6={};var _0x3555a0={};var _0x3b13e0;var _0x4cc846;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x32f309[_0x02fd('0x57')]['id']}})[_0x02fd('0x1e')](handleEntityNotFound(_0x55d827,null))['then'](function(_0x249cf7){if(_0x249cf7){_0x3b13e0=_0x249cf7;_0x3555a0[_0x02fd('0x3f')]=_['keys'](db[_0x02fd('0x59')]['rawAttributes']);_0x3555a0[_0x02fd('0x40')]=_[_0x02fd('0x41')](_0x32f309[_0x02fd('0x40')]);_0x3555a0[_0x02fd('0x42')]=_[_0x02fd('0x43')](_0x3555a0[_0x02fd('0x3f')],_0x3555a0['query']);_0x3a0fc6[_0x02fd('0x45')]=_[_0x02fd('0x43')](_0x3555a0[_0x02fd('0x3f')],qs['fields'](_0x32f309[_0x02fd('0x40')][_0x02fd('0x44')]));_0x3a0fc6[_0x02fd('0x45')]=_0x3a0fc6[_0x02fd('0x45')][_0x02fd('0x46')]?_0x3a0fc6[_0x02fd('0x45')]:_0x3555a0[_0x02fd('0x3f')];_0x3a0fc6[_0x02fd('0x48')]=qs[_0x02fd('0x49')](_0x32f309[_0x02fd('0x40')]['sort']);_0x3a0fc6[_0x02fd('0x4a')]=qs['filters'](_[_0x02fd('0x5b')](_0x32f309[_0x02fd('0x40')],_0x3555a0[_0x02fd('0x42')]));if(_0x32f309['query'][_0x02fd('0x4b')]){_0x3a0fc6['where']=_[_0x02fd('0x4c')](_0x3a0fc6[_0x02fd('0x4a')],{'$or':_[_0x02fd('0x3b')](_0x3a0fc6[_0x02fd('0x45')],function(_0x2f4d31){var _0x4ce0a0={};_0x4ce0a0[_0x2f4d31]={'$like':'%'+_0x32f309['query'][_0x02fd('0x4b')]+'%'};return _0x4ce0a0;})});}_0x3a0fc6=_['merge']({},_0x3a0fc6,_0x32f309[_0x02fd('0x4e')]);return _0x3b13e0[_0x02fd('0x5e')](_0x3a0fc6);}})[_0x02fd('0x1e')](function(_0x1829f9){if(_0x1829f9){_0x4cc846=_0x1829f9['length'];if(!_0x32f309[_0x02fd('0x40')][_0x02fd('0x5d')](_0x02fd('0x47'))){_0x3a0fc6[_0x02fd('0x2e')]=qs[_0x02fd('0x2e')](_0x32f309['query'][_0x02fd('0x2e')]);_0x3a0fc6[_0x02fd('0x2d')]=qs[_0x02fd('0x2d')](_0x32f309[_0x02fd('0x40')][_0x02fd('0x2d')]);}return _0x3b13e0[_0x02fd('0x5e')](_0x3a0fc6);}})[_0x02fd('0x1e')](function(_0x448760){if(_0x448760){return _0x448760?{'count':_0x4cc846,'rows':_0x448760}:null;}})[_0x02fd('0x1e')](respondWithResult(_0x55d827,null))[_0x02fd('0x29')](handleError(_0x55d827,null));};
\ No newline at end of file
+var _0x2ef4=['filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','filter','where','merge','type','VIRTUAL','includeAll','findAll','show','params','options','find','create','body','update','findOne','SugarcrmField','rawAttributes','length','order','pick','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','http','request','then','info','SugarcrmConfiguration,\x20%s,\x20%s','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','destroy','end','stack','name','send','index','map','SugarcrmConfiguration','fieldName','model','query','keys'];(function(_0x5e8d8b,_0x3defdb){var _0xc38051=function(_0x12dca7){while(--_0x12dca7){_0x5e8d8b['push'](_0x5e8d8b['shift']());}};_0xc38051(++_0x3defdb);}(_0x2ef4,0x1e0));var _0x42ef=function(_0x4c3953,_0x571b3a){_0x4c3953=_0x4c3953-0x0;var _0x28362e=_0x2ef4[_0x4c3953];return _0x28362e;};'use strict';var emlformat=require(_0x42ef('0x0'));var rimraf=require(_0x42ef('0x1'));var zipdir=require(_0x42ef('0x2'));var jsonpatch=require(_0x42ef('0x3'));var rp=require(_0x42ef('0x4'));var moment=require(_0x42ef('0x5'));var BPromise=require(_0x42ef('0x6'));var Mustache=require('mustache');var util=require(_0x42ef('0x7'));var path=require(_0x42ef('0x8'));var sox=require(_0x42ef('0x9'));var csv=require(_0x42ef('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x42ef('0xb'));var _=require('lodash');var squel=require(_0x42ef('0xc'));var crypto=require(_0x42ef('0xd'));var jsforce=require(_0x42ef('0xe'));var deskjs=require(_0x42ef('0xf'));var toCsv=require(_0x42ef('0xa'));var querystring=require('querystring');var Papa=require(_0x42ef('0x10'));var Redis=require('ioredis');var authService=require(_0x42ef('0x11'));var qs=require(_0x42ef('0x12'));var as=require(_0x42ef('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x42ef('0x14'))(_0x42ef('0x15'));var utils=require('../../config/utils');var config=require(_0x42ef('0x16'));var licenseUtil=require(_0x42ef('0x17'));var db=require(_0x42ef('0x18'))['db'];var jayson=require(_0x42ef('0x19'));var client=jayson['client'][_0x42ef('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x4b21f4,_0x35fab8,_0xa0560f,_0x50f5ca){return new BPromise(function(_0x1114fa,_0x52658a){var _0x5d501b=_0x50f5ca||client;return _0x5d501b[_0x42ef('0x1b')](_0x4b21f4,_0xa0560f)[_0x42ef('0x1c')](function(_0x1ebcac){logger[_0x42ef('0x1d')](_0x42ef('0x1e'),_0x35fab8,'request\x20sent');logger['debug'](_0x42ef('0x1f'),_0x35fab8,_0x42ef('0x20'),JSON[_0x42ef('0x21')](_0x1ebcac));if(_0x1ebcac[_0x42ef('0x22')]){if(_0x1ebcac['error'][_0x42ef('0x23')]===0x1f4){logger['error'](_0x42ef('0x1e'),_0x35fab8,_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);return _0x52658a(_0x1ebcac[_0x42ef('0x22')]['message']);}logger[_0x42ef('0x22')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x35fab8,_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);return _0x1114fa(_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);}else{logger[_0x42ef('0x1d')](_0x42ef('0x1e'),_0x35fab8,_0x42ef('0x20'));_0x1114fa(_0x1ebcac['result'][_0x42ef('0x24')]);}})[_0x42ef('0x25')](function(_0xca1345){logger[_0x42ef('0x22')](_0x42ef('0x1e'),_0x35fab8,_0xca1345);_0x52658a(_0xca1345);});});}function respondWithStatusCode(_0x285e21,_0x49e348){_0x49e348=_0x49e348||0xcc;return function(_0x3baede){if(_0x3baede){return _0x285e21[_0x42ef('0x26')](_0x49e348);}return _0x285e21[_0x42ef('0x27')](_0x49e348)['end']();};}function respondWithResult(_0x401a4f,_0x26e106){_0x26e106=_0x26e106||0xc8;return function(_0x5d327c){if(_0x5d327c){return _0x401a4f[_0x42ef('0x27')](_0x26e106)[_0x42ef('0x28')](_0x5d327c);}};}function respondWithFilteredResult(_0x2416d0,_0xa3e16a){return function(_0xfbb535){if(_0xfbb535){var _0x433f95=_0xfbb535[_0x42ef('0x29')],_0x3e0bab=_0xa3e16a[_0x42ef('0x2a')],_0x5ee9f9=_0xa3e16a['offset']+_0xa3e16a[_0x42ef('0x2b')],_0x2483e6;if(_0x5ee9f9>=_0x433f95){_0x5ee9f9=_0x433f95;_0x2483e6=0xc8;}else{_0x2483e6=0xce;}_0x2416d0[_0x42ef('0x27')](_0x2483e6);return _0x2416d0[_0x42ef('0x2c')](_0x42ef('0x2d'),_0x3e0bab+'-'+_0x5ee9f9+'/'+_0x433f95)[_0x42ef('0x28')](_0xfbb535);}return null;};}function patchUpdates(_0x2593ad){return function(_0x54f3cb){try{jsonpatch[_0x42ef('0x2e')](_0x54f3cb,_0x2593ad,!![]);}catch(_0x29216c){return BPromise[_0x42ef('0x2f')](_0x29216c);}return _0x54f3cb['save']();};}function saveUpdates(_0x157bca,_0x104a0c){return function(_0x22c996){if(_0x22c996){return _0x22c996['update'](_0x157bca)[_0x42ef('0x1c')](function(_0xaa4846){return _0xaa4846;});}return null;};}function removeEntity(_0x2ff201,_0x3b46f8){return function(_0x38d816){if(_0x38d816){return _0x38d816[_0x42ef('0x30')]()[_0x42ef('0x1c')](function(){_0x2ff201[_0x42ef('0x27')](0xcc)[_0x42ef('0x31')]();});}};}function handleEntityNotFound(_0x53584f,_0x1b1bc4){return function(_0x2e401f){if(!_0x2e401f){_0x53584f[_0x42ef('0x26')](0x194);}return _0x2e401f;};}function handleError(_0x2d15aa,_0x486a51){_0x486a51=_0x486a51||0x1f4;return function(_0x223ba2){logger[_0x42ef('0x22')](_0x223ba2[_0x42ef('0x32')]);if(_0x223ba2[_0x42ef('0x33')]){delete _0x223ba2[_0x42ef('0x33')];}_0x2d15aa[_0x42ef('0x27')](_0x486a51)[_0x42ef('0x34')](_0x223ba2);};}exports[_0x42ef('0x35')]=function(_0x26b88e,_0x2cdf19){var _0x577ec2={},_0x1499a5={},_0x387ff0={'count':0x0,'rows':[]};var _0x29c6b0=_[_0x42ef('0x36')](db[_0x42ef('0x37')]['rawAttributes'],function(_0x4dcdcc){return{'name':_0x4dcdcc[_0x42ef('0x38')],'type':_0x4dcdcc['type']['key']};});_0x1499a5[_0x42ef('0x39')]=_[_0x42ef('0x36')](_0x29c6b0,_0x42ef('0x33'));_0x1499a5[_0x42ef('0x3a')]=_[_0x42ef('0x3b')](_0x26b88e['query']);_0x1499a5[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x1499a5['model'],_0x1499a5['query']);_0x577ec2[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x1499a5['model'],qs[_0x42ef('0x3f')](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x3f')]));_0x577ec2[_0x42ef('0x3e')]=_0x577ec2[_0x42ef('0x3e')]['length']?_0x577ec2[_0x42ef('0x3e')]:_0x1499a5[_0x42ef('0x39')];if(!_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x40')](_0x42ef('0x41'))){_0x577ec2[_0x42ef('0x2b')]=qs['limit'](_0x26b88e[_0x42ef('0x3a')]['limit']);_0x577ec2[_0x42ef('0x2a')]=qs[_0x42ef('0x2a')](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x2a')]);}_0x577ec2['order']=qs['sort'](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x577ec2['where']=qs[_0x42ef('0x3c')](_['pick'](_0x26b88e['query'],_0x1499a5[_0x42ef('0x3c')]),_0x29c6b0);if(_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x43')]){_0x577ec2[_0x42ef('0x44')]=_[_0x42ef('0x45')](_0x577ec2[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x29c6b0,function(_0x29725d){if(_0x29725d[_0x42ef('0x46')]!==_0x42ef('0x47')){var _0x12c77d={};_0x12c77d[_0x29725d['name']]={'$like':'%'+_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x43')]+'%'};return _0x12c77d;}})});}_0x577ec2=_[_0x42ef('0x45')]({},_0x577ec2,_0x26b88e['options']);var _0x3c002e={'where':_0x577ec2['where']};return db[_0x42ef('0x37')]['count'](_0x3c002e)[_0x42ef('0x1c')](function(_0x19633d){_0x387ff0['count']=_0x19633d;if(_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x48')]){_0x577ec2['include']=[{'all':!![]}];}return db[_0x42ef('0x37')][_0x42ef('0x49')](_0x577ec2);})[_0x42ef('0x1c')](function(_0xc8722f){_0x387ff0['rows']=_0xc8722f;return _0x387ff0;})[_0x42ef('0x1c')](respondWithFilteredResult(_0x2cdf19,_0x577ec2))[_0x42ef('0x25')](handleError(_0x2cdf19,null));};exports[_0x42ef('0x4a')]=function(_0x11aecf,_0x5e5b39){var _0x36877e={'raw':![],'where':{'id':_0x11aecf[_0x42ef('0x4b')]['id']}},_0x7f3465={};_0x7f3465[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x37')]['rawAttributes']);_0x7f3465['query']=_['keys'](_0x11aecf[_0x42ef('0x3a')]);_0x7f3465[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x7f3465[_0x42ef('0x39')],_0x7f3465[_0x42ef('0x3a')]);_0x36877e[_0x42ef('0x3e')]=_['intersection'](_0x7f3465[_0x42ef('0x39')],qs[_0x42ef('0x3f')](_0x11aecf[_0x42ef('0x3a')]['fields']));_0x36877e['attributes']=_0x36877e[_0x42ef('0x3e')]['length']?_0x36877e[_0x42ef('0x3e')]:_0x7f3465['model'];if(_0x11aecf[_0x42ef('0x3a')]['includeAll']){_0x36877e['include']=[{'all':!![]}];}_0x36877e=_[_0x42ef('0x45')]({},_0x36877e,_0x11aecf[_0x42ef('0x4c')]);return db['SugarcrmConfiguration'][_0x42ef('0x4d')](_0x36877e)[_0x42ef('0x1c')](handleEntityNotFound(_0x5e5b39,null))[_0x42ef('0x1c')](respondWithResult(_0x5e5b39,null))['catch'](handleError(_0x5e5b39,null));};exports[_0x42ef('0x4e')]=function(_0x353ba6,_0x24b118){return db[_0x42ef('0x37')][_0x42ef('0x4e')](_0x353ba6[_0x42ef('0x4f')],{})['then'](respondWithResult(_0x24b118,0xc9))[_0x42ef('0x25')](handleError(_0x24b118,null));};exports[_0x42ef('0x50')]=function(_0x353b27,_0x76632b){if(_0x353b27['body']['id']){delete _0x353b27['body']['id'];}return db['SugarcrmConfiguration'][_0x42ef('0x4d')]({'where':{'id':_0x353b27[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x76632b,null))[_0x42ef('0x1c')](saveUpdates(_0x353b27['body'],null))[_0x42ef('0x1c')](respondWithResult(_0x76632b,null))[_0x42ef('0x25')](handleError(_0x76632b,null));};exports[_0x42ef('0x30')]=function(_0x382aa2,_0x34a8b7){return db[_0x42ef('0x37')][_0x42ef('0x4d')]({'where':{'id':_0x382aa2['params']['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x34a8b7,null))[_0x42ef('0x1c')](removeEntity(_0x34a8b7,null))['catch'](handleError(_0x34a8b7,null));};exports['getFields']=function(_0x566b62,_0x293417,_0x3acc31){var _0x1dd495={};var _0x4985bc={};var _0x4020d6;var _0x295cc4;return db[_0x42ef('0x37')][_0x42ef('0x51')]({'where':{'id':_0x566b62[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x293417,null))[_0x42ef('0x1c')](function(_0x303967){if(_0x303967){_0x4020d6=_0x303967;_0x4985bc[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x4985bc['query']=_[_0x42ef('0x3b')](_0x566b62[_0x42ef('0x3a')]);_0x4985bc[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x4985bc[_0x42ef('0x39')],_0x4985bc['query']);_0x1dd495[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x4985bc[_0x42ef('0x39')],qs[_0x42ef('0x3f')](_0x566b62[_0x42ef('0x3a')]['fields']));_0x1dd495[_0x42ef('0x3e')]=_0x1dd495[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x1dd495[_0x42ef('0x3e')]:_0x4985bc['model'];_0x1dd495[_0x42ef('0x55')]=qs['sort'](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x1dd495[_0x42ef('0x44')]=qs[_0x42ef('0x3c')](_[_0x42ef('0x56')](_0x566b62[_0x42ef('0x3a')],_0x4985bc['filters']));if(_0x566b62[_0x42ef('0x3a')][_0x42ef('0x43')]){_0x1dd495['where']=_[_0x42ef('0x45')](_0x1dd495[_0x42ef('0x44')],{'$or':_['map'](_0x1dd495[_0x42ef('0x3e')],function(_0x14355c){var _0x2c0659={};_0x2c0659[_0x14355c]={'$like':'%'+_0x566b62[_0x42ef('0x3a')]['filter']+'%'};return _0x2c0659;})});}_0x1dd495=_['merge']({},_0x1dd495,_0x566b62['options']);return _0x4020d6[_0x42ef('0x57')](_0x1dd495);}})[_0x42ef('0x1c')](function(_0xa2859d){if(_0xa2859d){_0x295cc4=_0xa2859d[_0x42ef('0x54')];if(!_0x566b62[_0x42ef('0x3a')][_0x42ef('0x40')](_0x42ef('0x41'))){_0x1dd495['limit']=qs[_0x42ef('0x2b')](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x2b')]);_0x1dd495['offset']=qs[_0x42ef('0x2a')](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x2a')]);}return _0x4020d6[_0x42ef('0x57')](_0x1dd495);}})[_0x42ef('0x1c')](function(_0x3f8b8c){if(_0x3f8b8c){return _0x3f8b8c?{'count':_0x295cc4,'rows':_0x3f8b8c}:null;}})['then'](respondWithResult(_0x293417,null))[_0x42ef('0x25')](handleError(_0x293417,null));};exports['getSubjects']=function(_0x514b89,_0x1488ed,_0x142e95){var _0x44f533={};var _0x18b752={};var _0x527766;var _0x1f18cb;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x514b89[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x1488ed,null))[_0x42ef('0x1c')](function(_0x384b75){if(_0x384b75){_0x527766=_0x384b75;_0x18b752[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x18b752[_0x42ef('0x3a')]=_['keys'](_0x514b89[_0x42ef('0x3a')]);_0x18b752[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x18b752[_0x42ef('0x39')],_0x18b752[_0x42ef('0x3a')]);_0x44f533[_0x42ef('0x3e')]=_['intersection'](_0x18b752[_0x42ef('0x39')],qs['fields'](_0x514b89[_0x42ef('0x3a')]['fields']));_0x44f533[_0x42ef('0x3e')]=_0x44f533[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x44f533[_0x42ef('0x3e')]:_0x18b752[_0x42ef('0x39')];_0x44f533['order']=qs[_0x42ef('0x42')](_0x514b89[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x44f533[_0x42ef('0x44')]=qs[_0x42ef('0x3c')](_[_0x42ef('0x56')](_0x514b89['query'],_0x18b752[_0x42ef('0x3c')]));if(_0x514b89[_0x42ef('0x3a')]['filter']){_0x44f533[_0x42ef('0x44')]=_[_0x42ef('0x45')](_0x44f533[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x44f533[_0x42ef('0x3e')],function(_0x5a16e4){var _0x2b3a30={};_0x2b3a30[_0x5a16e4]={'$like':'%'+_0x514b89[_0x42ef('0x3a')][_0x42ef('0x43')]+'%'};return _0x2b3a30;})});}_0x44f533=_['merge']({},_0x44f533,_0x514b89[_0x42ef('0x4c')]);return _0x527766[_0x42ef('0x58')](_0x44f533);}})[_0x42ef('0x1c')](function(_0x5d5330){if(_0x5d5330){_0x1f18cb=_0x5d5330[_0x42ef('0x54')];if(!_0x514b89['query'][_0x42ef('0x40')](_0x42ef('0x41'))){_0x44f533['limit']=qs[_0x42ef('0x2b')](_0x514b89[_0x42ef('0x3a')][_0x42ef('0x2b')]);_0x44f533[_0x42ef('0x2a')]=qs['offset'](_0x514b89['query'][_0x42ef('0x2a')]);}return _0x527766[_0x42ef('0x58')](_0x44f533);}})[_0x42ef('0x1c')](function(_0x44fc89){if(_0x44fc89){return _0x44fc89?{'count':_0x1f18cb,'rows':_0x44fc89}:null;}})[_0x42ef('0x1c')](respondWithResult(_0x1488ed,null))[_0x42ef('0x25')](handleError(_0x1488ed,null));};exports[_0x42ef('0x59')]=function(_0x355624,_0x3574cf,_0x4080b5){var _0x3789e3={};var _0x1e545a={};var _0x351614;var _0x13b730;return db[_0x42ef('0x37')][_0x42ef('0x51')]({'where':{'id':_0x355624[_0x42ef('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3574cf,null))[_0x42ef('0x1c')](function(_0x11fd43){if(_0x11fd43){_0x351614=_0x11fd43;_0x1e545a['model']=_['keys'](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x1e545a['query']=_[_0x42ef('0x3b')](_0x355624[_0x42ef('0x3a')]);_0x1e545a[_0x42ef('0x3c')]=_['intersection'](_0x1e545a[_0x42ef('0x39')],_0x1e545a[_0x42ef('0x3a')]);_0x3789e3[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x1e545a['model'],qs[_0x42ef('0x3f')](_0x355624[_0x42ef('0x3a')][_0x42ef('0x3f')]));_0x3789e3['attributes']=_0x3789e3[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x3789e3[_0x42ef('0x3e')]:_0x1e545a[_0x42ef('0x39')];_0x3789e3[_0x42ef('0x55')]=qs[_0x42ef('0x42')](_0x355624[_0x42ef('0x3a')]['sort']);_0x3789e3['where']=qs[_0x42ef('0x3c')](_['pick'](_0x355624[_0x42ef('0x3a')],_0x1e545a['filters']));if(_0x355624[_0x42ef('0x3a')]['filter']){_0x3789e3['where']=_[_0x42ef('0x45')](_0x3789e3[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x3789e3[_0x42ef('0x3e')],function(_0x20c76c){var _0x547147={};_0x547147[_0x20c76c]={'$like':'%'+_0x355624[_0x42ef('0x3a')]['filter']+'%'};return _0x547147;})});}_0x3789e3=_[_0x42ef('0x45')]({},_0x3789e3,_0x355624['options']);return _0x351614[_0x42ef('0x59')](_0x3789e3);}})['then'](function(_0x529a40){if(_0x529a40){_0x13b730=_0x529a40[_0x42ef('0x54')];if(!_0x355624['query']['hasOwnProperty']('nolimit')){_0x3789e3[_0x42ef('0x2b')]=qs['limit'](_0x355624[_0x42ef('0x3a')]['limit']);_0x3789e3[_0x42ef('0x2a')]=qs[_0x42ef('0x2a')](_0x355624[_0x42ef('0x3a')][_0x42ef('0x2a')]);}return _0x351614['getDescriptions'](_0x3789e3);}})[_0x42ef('0x1c')](function(_0x1a1eeb){if(_0x1a1eeb){return _0x1a1eeb?{'count':_0x13b730,'rows':_0x1a1eeb}:null;}})[_0x42ef('0x1c')](respondWithResult(_0x3574cf,null))['catch'](handleError(_0x3574cf,null));};
\ No newline at end of file