Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / intVtigerAccount / intVtigerAccount.controller.js
index 26d1006..8aeb3c8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9fb1=['lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','sendStatus','end','json','offset','status','set','Content-Range','apply','update','destroy','name','send','index','map','VtigerAccount','rawAttributes','type','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','count','include','findAll','rows','params','keys','find','create','body','getConfigurations','nolimit','addConfiguration','findOne','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','channel','VtigerConfiguration','VtigerField','getFields','username','description','remoteUri','serverUrl','accessKey','moduleName','substring','format','%s/webservice.php','GET','getchallenge','result','describe','sessionName','success','autogenerated','remove','editable','false','startsWith','cf_','value','log','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','statusCode','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv'];(function(_0x228e90,_0x12d534){var _0x161875=function(_0x185ea9){while(--_0x185ea9){_0x228e90['push'](_0x228e90['shift']());}};_0x161875(++_0x12d534);}(_0x9fb1,0xe6));var _0x19fb=function(_0x3e5086,_0x48f4a2){_0x3e5086=_0x3e5086-0x0;var _0xfeb102=_0x9fb1[_0x3e5086];return _0xfeb102;};'use strict';var pdf=require(_0x19fb('0x0'));var emlformat=require(_0x19fb('0x1'));var rimraf=require(_0x19fb('0x2'));var zipdir=require(_0x19fb('0x3'));var jsonpatch=require(_0x19fb('0x4'));var rp=require(_0x19fb('0x5'));var moment=require(_0x19fb('0x6'));var BPromise=require(_0x19fb('0x7'));var Mustache=require(_0x19fb('0x8'));var util=require('util');var path=require(_0x19fb('0x9'));var sox=require(_0x19fb('0xa'));var csv=require(_0x19fb('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x19fb('0xc'));var squel=require(_0x19fb('0xd'));var crypto=require(_0x19fb('0xe'));var jsforce=require(_0x19fb('0xf'));var deskjs=require(_0x19fb('0x10'));var toCsv=require(_0x19fb('0xb'));var querystring=require('querystring');var Papa=require(_0x19fb('0x11'));var Redis=require(_0x19fb('0x12'));var authService=require(_0x19fb('0x13'));var qs=require(_0x19fb('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x19fb('0x15'))(_0x19fb('0x16'));var utils=require(_0x19fb('0x17'));var config=require(_0x19fb('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x19fb('0x19'))['db'];var integrations=require(_0x19fb('0x1a'));var jayson=require(_0x19fb('0x1b'));var client=jayson[_0x19fb('0x1c')]['http']({'port':0x232a});function respondWithRpcPromise(_0x28a48d,_0x1ab47d,_0x30436c,_0x474990){return new BPromise(function(_0x1f5e51,_0x364411){var _0x488416=_0x474990||client;return _0x488416['request'](_0x28a48d,_0x30436c)[_0x19fb('0x1d')](function(_0x521689){logger[_0x19fb('0x1e')](_0x19fb('0x1f'),_0x1ab47d,_0x19fb('0x20'));logger[_0x19fb('0x21')]('VtigerAccount,\x20%s,\x20%s,\x20%s',_0x1ab47d,_0x19fb('0x20'),JSON[_0x19fb('0x22')](_0x521689));if(_0x521689['error']){if(_0x521689[_0x19fb('0x23')]['code']===0x1f4){logger[_0x19fb('0x23')](_0x19fb('0x1f'),_0x1ab47d,_0x521689[_0x19fb('0x23')][_0x19fb('0x24')]);return _0x364411(_0x521689[_0x19fb('0x23')][_0x19fb('0x24')]);}logger[_0x19fb('0x23')]('VtigerAccount,\x20%s,\x20%s',_0x1ab47d,_0x521689[_0x19fb('0x23')][_0x19fb('0x24')]);return _0x1f5e51(_0x521689[_0x19fb('0x23')][_0x19fb('0x24')]);}else{logger[_0x19fb('0x1e')](_0x19fb('0x1f'),_0x1ab47d,_0x19fb('0x20'));_0x1f5e51(_0x521689['result']['message']);}})[_0x19fb('0x25')](function(_0x4c9bd6){logger['error']('VtigerAccount,\x20%s,\x20%s',_0x1ab47d,_0x4c9bd6);_0x364411(_0x4c9bd6);});});}function respondWithStatusCode(_0xeab34b,_0x492721){_0x492721=_0x492721||0xcc;return function(_0x818ac0){if(_0x818ac0){return _0xeab34b[_0x19fb('0x26')](_0x492721);}return _0xeab34b['status'](_0x492721)[_0x19fb('0x27')]();};}function respondWithResult(_0x4c825b,_0xdf6404){_0xdf6404=_0xdf6404||0xc8;return function(_0x18bde1){if(_0x18bde1){return _0x4c825b['status'](_0xdf6404)[_0x19fb('0x28')](_0x18bde1);}};}function respondWithFilteredResult(_0x5b75af,_0x3b17a2){return function(_0x40e6db){if(_0x40e6db){var _0x827fc2=_0x40e6db['count'],_0x14623a=_0x3b17a2['offset'],_0x5269ce=_0x3b17a2[_0x19fb('0x29')]+_0x3b17a2['limit'],_0x2590e4;if(_0x5269ce>=_0x827fc2){_0x5269ce=_0x827fc2;_0x2590e4=0xc8;}else{_0x2590e4=0xce;}_0x5b75af[_0x19fb('0x2a')](_0x2590e4);return _0x5b75af[_0x19fb('0x2b')](_0x19fb('0x2c'),_0x14623a+'-'+_0x5269ce+'/'+_0x827fc2)[_0x19fb('0x28')](_0x40e6db);}return null;};}function patchUpdates(_0x55a612){return function(_0x3ccc90){try{jsonpatch[_0x19fb('0x2d')](_0x3ccc90,_0x55a612,!![]);}catch(_0x4d9472){return BPromise['reject'](_0x4d9472);}return _0x3ccc90['save']();};}function saveUpdates(_0x29041e,_0x56425a){return function(_0x412f92){if(_0x412f92){return _0x412f92[_0x19fb('0x2e')](_0x29041e)[_0x19fb('0x1d')](function(_0x3d8708){return _0x3d8708;});}return null;};}function removeEntity(_0x6523bf,_0x13d356){return function(_0x1dbaea){if(_0x1dbaea){return _0x1dbaea[_0x19fb('0x2f')]()[_0x19fb('0x1d')](function(){_0x6523bf[_0x19fb('0x2a')](0xcc)[_0x19fb('0x27')]();});}};}function handleEntityNotFound(_0x5aae8e,_0x4600f8){return function(_0xbb0d9){if(!_0xbb0d9){_0x5aae8e[_0x19fb('0x26')](0x194);}return _0xbb0d9;};}function handleError(_0x19619c,_0x3d7829){_0x3d7829=_0x3d7829||0x1f4;return function(_0x5c9d19){logger[_0x19fb('0x23')](_0x5c9d19['stack']);if(_0x5c9d19[_0x19fb('0x30')]){delete _0x5c9d19['name'];}_0x19619c[_0x19fb('0x2a')](_0x3d7829)[_0x19fb('0x31')](_0x5c9d19);};}exports[_0x19fb('0x32')]=function(_0x46e340,_0x1a03a5){var _0x4d7f07={},_0x363312={},_0xb62517={'count':0x0,'rows':[]};var _0x849aa0=_[_0x19fb('0x33')](db[_0x19fb('0x34')][_0x19fb('0x35')],function(_0x564533){return{'name':_0x564533['fieldName'],'type':_0x564533[_0x19fb('0x36')]['key']};});_0x363312['model']=_[_0x19fb('0x33')](_0x849aa0,_0x19fb('0x30'));_0x363312[_0x19fb('0x37')]=_['keys'](_0x46e340[_0x19fb('0x37')]);_0x363312[_0x19fb('0x38')]=_[_0x19fb('0x39')](_0x363312[_0x19fb('0x3a')],_0x363312['query']);_0x4d7f07[_0x19fb('0x3b')]=_[_0x19fb('0x39')](_0x363312['model'],qs[_0x19fb('0x3c')](_0x46e340['query'][_0x19fb('0x3c')]));_0x4d7f07[_0x19fb('0x3b')]=_0x4d7f07[_0x19fb('0x3b')][_0x19fb('0x3d')]?_0x4d7f07[_0x19fb('0x3b')]:_0x363312[_0x19fb('0x3a')];if(!_0x46e340[_0x19fb('0x37')][_0x19fb('0x3e')]('nolimit')){_0x4d7f07['limit']=qs[_0x19fb('0x3f')](_0x46e340['query']['limit']);_0x4d7f07['offset']=qs[_0x19fb('0x29')](_0x46e340[_0x19fb('0x37')][_0x19fb('0x29')]);}_0x4d7f07[_0x19fb('0x40')]=qs[_0x19fb('0x41')](_0x46e340['query'][_0x19fb('0x41')]);_0x4d7f07[_0x19fb('0x42')]=qs[_0x19fb('0x38')](_[_0x19fb('0x43')](_0x46e340[_0x19fb('0x37')],_0x363312[_0x19fb('0x38')]),_0x849aa0);if(_0x46e340[_0x19fb('0x37')][_0x19fb('0x44')]){_0x4d7f07[_0x19fb('0x42')]=_[_0x19fb('0x45')](_0x4d7f07[_0x19fb('0x42')],{'$or':_[_0x19fb('0x33')](_0x849aa0,function(_0x239e8c){if(_0x239e8c[_0x19fb('0x36')]!==_0x19fb('0x46')){var _0x2f22bb={};_0x2f22bb[_0x239e8c['name']]={'$like':'%'+_0x46e340[_0x19fb('0x37')][_0x19fb('0x44')]+'%'};return _0x2f22bb;}})});}_0x4d7f07=_[_0x19fb('0x45')]({},_0x4d7f07,_0x46e340[_0x19fb('0x47')]);var _0x1f8eca={'where':_0x4d7f07[_0x19fb('0x42')]};return db['VtigerAccount'][_0x19fb('0x48')](_0x1f8eca)[_0x19fb('0x1d')](function(_0x113857){_0xb62517[_0x19fb('0x48')]=_0x113857;if(_0x46e340[_0x19fb('0x37')]['includeAll']){_0x4d7f07[_0x19fb('0x49')]=[{'all':!![]}];}return db['VtigerAccount'][_0x19fb('0x4a')](_0x4d7f07);})['then'](function(_0x4b2939){_0xb62517[_0x19fb('0x4b')]=_0x4b2939;return _0xb62517;})[_0x19fb('0x1d')](respondWithFilteredResult(_0x1a03a5,_0x4d7f07))[_0x19fb('0x25')](handleError(_0x1a03a5,null));};exports['show']=function(_0x3e6b20,_0x1112c8){var _0x3b7732={'raw':![],'where':{'id':_0x3e6b20[_0x19fb('0x4c')]['id']}},_0x30a57c={};_0x30a57c[_0x19fb('0x3a')]=_[_0x19fb('0x4d')](db['VtigerAccount'][_0x19fb('0x35')]);_0x30a57c[_0x19fb('0x37')]=_[_0x19fb('0x4d')](_0x3e6b20[_0x19fb('0x37')]);_0x30a57c['filters']=_[_0x19fb('0x39')](_0x30a57c['model'],_0x30a57c[_0x19fb('0x37')]);_0x3b7732[_0x19fb('0x3b')]=_[_0x19fb('0x39')](_0x30a57c[_0x19fb('0x3a')],qs[_0x19fb('0x3c')](_0x3e6b20[_0x19fb('0x37')]['fields']));_0x3b7732['attributes']=_0x3b7732[_0x19fb('0x3b')]['length']?_0x3b7732[_0x19fb('0x3b')]:_0x30a57c[_0x19fb('0x3a')];if(_0x3e6b20['query']['includeAll']){_0x3b7732[_0x19fb('0x49')]=[{'all':!![]}];}_0x3b7732=_[_0x19fb('0x45')]({},_0x3b7732,_0x3e6b20[_0x19fb('0x47')]);return db[_0x19fb('0x34')][_0x19fb('0x4e')](_0x3b7732)['then'](handleEntityNotFound(_0x1112c8,null))['then'](respondWithResult(_0x1112c8,null))[_0x19fb('0x25')](handleError(_0x1112c8,null));};exports[_0x19fb('0x4f')]=function(_0x3fb562,_0x3c0931){return db[_0x19fb('0x34')]['create'](_0x3fb562['body'],{})[_0x19fb('0x1d')](respondWithResult(_0x3c0931,0xc9))['catch'](handleError(_0x3c0931,null));};exports[_0x19fb('0x2e')]=function(_0x4fe082,_0x4daffb){if(_0x4fe082[_0x19fb('0x50')]['id']){delete _0x4fe082[_0x19fb('0x50')]['id'];}return db[_0x19fb('0x34')][_0x19fb('0x4e')]({'where':{'id':_0x4fe082['params']['id']}})['then'](handleEntityNotFound(_0x4daffb,null))[_0x19fb('0x1d')](saveUpdates(_0x4fe082[_0x19fb('0x50')],null))[_0x19fb('0x1d')](respondWithResult(_0x4daffb,null))['catch'](handleError(_0x4daffb,null));};exports['destroy']=function(_0x40a16b,_0x16d387){return db[_0x19fb('0x34')][_0x19fb('0x4e')]({'where':{'id':_0x40a16b[_0x19fb('0x4c')]['id']}})[_0x19fb('0x1d')](handleEntityNotFound(_0x16d387,null))['then'](removeEntity(_0x16d387,null))[_0x19fb('0x25')](handleError(_0x16d387,null));};exports[_0x19fb('0x51')]=function(_0x164eb1,_0x4bc324,_0x508ae6){var _0x41387d={};var _0xd24565={};var _0x202f5c;var _0x153c16;return db[_0x19fb('0x34')]['findOne']({'where':{'id':_0x164eb1[_0x19fb('0x4c')]['id']}})[_0x19fb('0x1d')](handleEntityNotFound(_0x4bc324,null))[_0x19fb('0x1d')](function(_0x4d9a74){if(_0x4d9a74){_0x202f5c=_0x4d9a74;_0xd24565[_0x19fb('0x3a')]=_[_0x19fb('0x4d')](db['VtigerConfiguration'][_0x19fb('0x35')]);_0xd24565[_0x19fb('0x37')]=_['keys'](_0x164eb1[_0x19fb('0x37')]);_0xd24565[_0x19fb('0x38')]=_[_0x19fb('0x39')](_0xd24565['model'],_0xd24565[_0x19fb('0x37')]);_0x41387d[_0x19fb('0x3b')]=_[_0x19fb('0x39')](_0xd24565['model'],qs[_0x19fb('0x3c')](_0x164eb1['query']['fields']));_0x41387d[_0x19fb('0x3b')]=_0x41387d['attributes'][_0x19fb('0x3d')]?_0x41387d[_0x19fb('0x3b')]:_0xd24565[_0x19fb('0x3a')];_0x41387d[_0x19fb('0x40')]=qs[_0x19fb('0x41')](_0x164eb1[_0x19fb('0x37')][_0x19fb('0x41')]);_0x41387d[_0x19fb('0x42')]=qs['filters'](_[_0x19fb('0x43')](_0x164eb1['query'],_0xd24565[_0x19fb('0x38')]));if(_0x164eb1[_0x19fb('0x37')][_0x19fb('0x44')]){_0x41387d['where']=_['merge'](_0x41387d[_0x19fb('0x42')],{'$or':_[_0x19fb('0x33')](_0x41387d[_0x19fb('0x3b')],function(_0x33eede){var _0x38a7f4={};_0x38a7f4[_0x33eede]={'$like':'%'+_0x164eb1[_0x19fb('0x37')]['filter']+'%'};return _0x38a7f4;})});}_0x41387d=_[_0x19fb('0x45')]({},_0x41387d,_0x164eb1[_0x19fb('0x47')]);return _0x202f5c[_0x19fb('0x51')](_0x41387d);}})[_0x19fb('0x1d')](function(_0x37deeb){if(_0x37deeb){_0x153c16=_0x37deeb[_0x19fb('0x3d')];if(!_0x164eb1[_0x19fb('0x37')][_0x19fb('0x3e')](_0x19fb('0x52'))){_0x41387d[_0x19fb('0x3f')]=qs['limit'](_0x164eb1['query'][_0x19fb('0x3f')]);_0x41387d[_0x19fb('0x29')]=qs['offset'](_0x164eb1[_0x19fb('0x37')][_0x19fb('0x29')]);}return _0x202f5c[_0x19fb('0x51')](_0x41387d);}})[_0x19fb('0x1d')](function(_0x2159f1){if(_0x2159f1){return _0x2159f1?{'count':_0x153c16,'rows':_0x2159f1}:null;}})[_0x19fb('0x1d')](respondWithResult(_0x4bc324,null))[_0x19fb('0x25')](handleError(_0x4bc324,null));};exports[_0x19fb('0x53')]=function(_0x5bfefd,_0x536e56,_0x19a4ce){if(_0x5bfefd[_0x19fb('0x50')]['id']){delete _0x5bfefd[_0x19fb('0x50')]['id'];}return db[_0x19fb('0x34')][_0x19fb('0x54')]({'where':{'id':_0x5bfefd[_0x19fb('0x4c')]['id']}})[_0x19fb('0x1d')](handleEntityNotFound(_0x536e56,null))[_0x19fb('0x1d')](function(_0x5ec16c){if(_0x5ec16c){_0x5bfefd['body'][_0x19fb('0x55')]=_0x5ec16c['id'];_0x5bfefd[_0x19fb('0x50')][_0x19fb('0x56')]=integrations[_0x19fb('0x57')](_0x5bfefd[_0x19fb('0x50')]['channel'],_0x5bfefd[_0x19fb('0x50')]['type']);_0x5bfefd[_0x19fb('0x50')][_0x19fb('0x58')]=integrations[_0x19fb('0x59')](_0x5bfefd[_0x19fb('0x50')][_0x19fb('0x5a')],_0x5bfefd[_0x19fb('0x50')][_0x19fb('0x36')]);return db[_0x19fb('0x5b')][_0x19fb('0x4f')](_0x5bfefd['body'],{'include':[{'model':db['VtigerField'],'as':_0x19fb('0x56')},{'model':db[_0x19fb('0x5c')],'as':_0x19fb('0x58')}]});}return null;})[_0x19fb('0x1d')](respondWithResult(_0x536e56,null))[_0x19fb('0x25')](handleError(_0x536e56,null));};var md5=require('md5');exports[_0x19fb('0x5d')]=function(_0x38db77,_0x5b03e3,_0x1b3a1a){var _0x10b131=null;var _0x72437=null;var _0x5d8f8f=null;var _0x2e8f70=null;var _0xe91308='';return db[_0x19fb('0x34')][_0x19fb('0x54')]({'where':{'id':_0x38db77[_0x19fb('0x4c')]['id']},'attributes':['id',_0x19fb('0x30'),_0x19fb('0x5e'),_0x19fb('0x5f'),'moduleName',_0x19fb('0x60'),_0x19fb('0x61'),_0x19fb('0x62')]})['then'](handleEntityNotFound(_0x5b03e3,null))[_0x19fb('0x1d')](function(_0x27a92d){if(_0x27a92d){_0x10b131=_0x27a92d[_0x19fb('0x5e')];_0x72437=_0x27a92d[_0x19fb('0x62')];_0x5d8f8f=_0x27a92d[_0x19fb('0x63')];_0xe91308=_0x27a92d[_0x19fb('0x60')];var _0xdfea2e=_0xe91308['slice'](-0x1);if(_0xdfea2e==='/'){_0xe91308=_0xe91308[_0x19fb('0x64')](0x0,_0xe91308['lastIndexOf'](_0xdfea2e));}_0x2e8f70=util[_0x19fb('0x65')](_0x19fb('0x66'),_0xe91308);var _0x327592={'method':_0x19fb('0x67'),'uri':_0x2e8f70,'qs':{'operation':_0x19fb('0x68'),'username':_0x27a92d['username']},'json':!![]};return rp(_0x327592);}})[_0x19fb('0x1d')](function(_0x34532f){if(_0x34532f['success']){var _0x1c1fe5={'method':'POST','uri':_0x2e8f70,'form':{'operation':'login','username':_0x10b131,'accessKey':md5(_0x34532f[_0x19fb('0x69')]['token']+_0x72437)},'json':!![]};return rp(_0x1c1fe5);}})['then'](function(_0x42ab0b){if(_0x42ab0b['success']){var _0x4a0855={'method':_0x19fb('0x67'),'uri':_0x2e8f70,'qs':{'operation':_0x19fb('0x6a'),'username':_0x10b131,'sessionName':_0x42ab0b['result'][_0x19fb('0x6b')],'elementType':_0x5d8f8f},'json':!![]};return rp(_0x4a0855);}})[_0x19fb('0x1d')](function(_0x36b25a){if(_0x36b25a[_0x19fb('0x6c')]){var _0xc7dcdf=[_0x19fb('0x6d'),'reference','owner'];_[_0x19fb('0x6e')](_0x36b25a[_0x19fb('0x69')][_0x19fb('0x3c')],function(_0x30ecc8){return _0xc7dcdf['includes'](_0x30ecc8[_0x19fb('0x36')][_0x19fb('0x30')]);});_[_0x19fb('0x6e')](_0x36b25a[_0x19fb('0x69')][_0x19fb('0x3c')],function(_0x342354){return _0x342354[_0x19fb('0x6f')]===_0x19fb('0x70');});return{'count':_0x36b25a[_0x19fb('0x69')][_0x19fb('0x3c')][_0x19fb('0x3d')],'rows':_[_0x19fb('0x33')](_0x36b25a[_0x19fb('0x69')][_0x19fb('0x3c')],function(_0x2fcc05){return{'id':_0x2fcc05[_0x19fb('0x30')],'name':_0x2fcc05['label'],'custom':_[_0x19fb('0x71')](_0x2fcc05[_0x19fb('0x30')],_0x19fb('0x72'))?!![]:![],'options':_0x2fcc05[_0x19fb('0x36')][_0x19fb('0x30')]==='picklist'&&_0x2fcc05['type']['picklistValues'][_0x19fb('0x3d')]>0x0?_['map'](_0x2fcc05[_0x19fb('0x36')]['picklistValues'],function(_0x3201b3){return{'name':_0x3201b3['label'],'value':_0x3201b3[_0x19fb('0x73')]};}):[]};})};}})[_0x19fb('0x1d')](respondWithResult(_0x5b03e3,null))['catch'](function(_0x5c8946){console[_0x19fb('0x74')]('vTiger\x20error:\x20'+_0x5c8946);var _0x708085=_0x38db77[_0x19fb('0x37')]['test']?0x1f4:_0x5c8946['statusCode']||0x1f4;logger[_0x19fb('0x23')](_0x19fb('0x75'),_0x19fb('0x5d'),_0x708085,JSON[_0x19fb('0x22')](_0x5c8946));delete _0x5c8946['name'];if(_0x708085===0x191){_0x708085=0x190;}_0x5b03e3[_0x19fb('0x2a')](_0x708085)['send'](_0x38db77[_0x19fb('0x37')][_0x19fb('0x76')]?{'message':_0x19fb('0x77'),'statusCode':_0x5c8946[_0x19fb('0x78')]}:_0x5c8946);});};
\ No newline at end of file
+var _0xadbc=['picklistValues','value','log','vTiger\x20error:\x20','test','statusCode','error','stringify','Wrong\x20credentials','rimraf','zip-dir','request-promise','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','name','send','VtigerAccount','type','key','model','map','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','merge','VIRTUAL','options','include','show','keys','rawAttributes','includeAll','catch','create','body','update','find','params','destroy','getConfigurations','findOne','pick','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','VtigerConfiguration','VtigerField','getFields','username','description','moduleName','remoteUri','accessKey','slice','substring','%s/webservice.php','getchallenge','success','login','result','token','GET','describe','autogenerated','reference','owner','remove','label','cf_'];(function(_0x35a78f,_0x176145){var _0x891e08=function(_0xd26cb0){while(--_0xd26cb0){_0x35a78f['push'](_0x35a78f['shift']());}};_0x891e08(++_0x176145);}(_0xadbc,0x150));var _0xcadb=function(_0x4c0708,_0x58cdbd){_0x4c0708=_0x4c0708-0x0;var _0x4e2ddd=_0xadbc[_0x4c0708];return _0x4e2ddd;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xcadb('0x0'));var zipdir=require(_0xcadb('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcadb('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xcadb('0x3'));var path=require(_0xcadb('0x4'));var sox=require(_0xcadb('0x5'));var csv=require(_0xcadb('0x6'));var ejs=require(_0xcadb('0x7'));var fs=require('fs');var fs_extra=require(_0xcadb('0x8'));var _=require('lodash');var squel=require(_0xcadb('0x9'));var crypto=require(_0xcadb('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xcadb('0xb'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcadb('0xc'));var authService=require('../../components/auth/service');var qs=require(_0xcadb('0xd'));var as=require(_0xcadb('0xe'));var hardwareService=require(_0xcadb('0xf'));var logger=require('../../config/logger')(_0xcadb('0x10'));var utils=require('../../config/utils');var config=require(_0xcadb('0x11'));var licenseUtil=require('../../config/license/util');var db=require(_0xcadb('0x12'))['db'];var integrations=require(_0xcadb('0x13'));function respondWithStatusCode(_0x2c59e1,_0x4464b9){_0x4464b9=_0x4464b9||0xcc;return function(_0x516587){if(_0x516587){return _0x2c59e1[_0xcadb('0x14')](_0x4464b9);}return _0x2c59e1[_0xcadb('0x15')](_0x4464b9)[_0xcadb('0x16')]();};}function respondWithResult(_0x276e49,_0x4bc9ed){_0x4bc9ed=_0x4bc9ed||0xc8;return function(_0x4a17ff){if(_0x4a17ff){return _0x276e49[_0xcadb('0x15')](_0x4bc9ed)[_0xcadb('0x17')](_0x4a17ff);}};}function respondWithFilteredResult(_0x4fc203,_0xcbefcf){return function(_0x3938aa){if(_0x3938aa){var _0x8cfe0a=typeof _0xcbefcf[_0xcadb('0x18')]===_0xcadb('0x19')&&typeof _0xcbefcf[_0xcadb('0x1a')]===_0xcadb('0x19');var _0x499ee1=_0x3938aa[_0xcadb('0x1b')];var _0x4e91f3=_0x8cfe0a?0x0:_0xcbefcf[_0xcadb('0x18')];var _0x2a31fe=_0x8cfe0a?_0x3938aa[_0xcadb('0x1b')]:_0xcbefcf[_0xcadb('0x18')]+_0xcbefcf[_0xcadb('0x1a')];var _0x585519;if(_0x2a31fe>=_0x499ee1){_0x2a31fe=_0x499ee1;_0x585519=0xc8;}else{_0x585519=0xce;}_0x4fc203['status'](_0x585519);return _0x4fc203[_0xcadb('0x1c')](_0xcadb('0x1d'),_0x4e91f3+'-'+_0x2a31fe+'/'+_0x499ee1)['json'](_0x3938aa);}return null;};}function patchUpdates(_0x50b8fa){return function(_0x17fa83){try{jsonpatch[_0xcadb('0x1e')](_0x17fa83,_0x50b8fa,!![]);}catch(_0x473240){return BPromise[_0xcadb('0x1f')](_0x473240);}return _0x17fa83[_0xcadb('0x20')]();};}function saveUpdates(_0x16f3e6,_0x5a5437){return function(_0x2616a3){if(_0x2616a3){return _0x2616a3['update'](_0x16f3e6)[_0xcadb('0x21')](function(_0xe7a8ab){return _0xe7a8ab;});}return null;};}function removeEntity(_0x3f7666,_0x25630d){return function(_0x58a4a6){if(_0x58a4a6){return _0x58a4a6['destroy']()[_0xcadb('0x21')](function(){_0x3f7666[_0xcadb('0x15')](0xcc)[_0xcadb('0x16')]();});}};}function handleEntityNotFound(_0x55b41f,_0x36c405){return function(_0x1b7166){if(!_0x1b7166){_0x55b41f['sendStatus'](0x194);}return _0x1b7166;};}function handleError(_0x4d98b2,_0x1982bc){_0x1982bc=_0x1982bc||0x1f4;return function(_0x18e7a6){logger['error'](_0x18e7a6['stack']);if(_0x18e7a6[_0xcadb('0x22')]){delete _0x18e7a6[_0xcadb('0x22')];}_0x4d98b2['status'](_0x1982bc)[_0xcadb('0x23')](_0x18e7a6);};}exports['index']=function(_0x1b124b,_0x231f3e){var _0x2a9700={},_0x409203={},_0x5d4613={'count':0x0,'rows':[]};var _0xffe445=_['map'](db[_0xcadb('0x24')]['rawAttributes'],function(_0x253757){return{'name':_0x253757['fieldName'],'type':_0x253757[_0xcadb('0x25')][_0xcadb('0x26')]};});_0x409203[_0xcadb('0x27')]=_[_0xcadb('0x28')](_0xffe445,'name');_0x409203[_0xcadb('0x29')]=_['keys'](_0x1b124b[_0xcadb('0x29')]);_0x409203[_0xcadb('0x2a')]=_[_0xcadb('0x2b')](_0x409203[_0xcadb('0x27')],_0x409203[_0xcadb('0x29')]);_0x2a9700[_0xcadb('0x2c')]=_['intersection'](_0x409203[_0xcadb('0x27')],qs['fields'](_0x1b124b[_0xcadb('0x29')][_0xcadb('0x2d')]));_0x2a9700[_0xcadb('0x2c')]=_0x2a9700[_0xcadb('0x2c')][_0xcadb('0x2e')]?_0x2a9700[_0xcadb('0x2c')]:_0x409203[_0xcadb('0x27')];if(!_0x1b124b[_0xcadb('0x29')]['hasOwnProperty'](_0xcadb('0x2f'))){_0x2a9700[_0xcadb('0x1a')]=qs[_0xcadb('0x1a')](_0x1b124b[_0xcadb('0x29')][_0xcadb('0x1a')]);_0x2a9700[_0xcadb('0x18')]=qs[_0xcadb('0x18')](_0x1b124b['query'][_0xcadb('0x18')]);}_0x2a9700[_0xcadb('0x30')]=qs[_0xcadb('0x31')](_0x1b124b['query'][_0xcadb('0x31')]);_0x2a9700[_0xcadb('0x32')]=qs[_0xcadb('0x2a')](_['pick'](_0x1b124b['query'],_0x409203[_0xcadb('0x2a')]),_0xffe445);if(_0x1b124b[_0xcadb('0x29')][_0xcadb('0x33')]){_0x2a9700[_0xcadb('0x32')]=_[_0xcadb('0x34')](_0x2a9700['where'],{'$or':_['map'](_0xffe445,function(_0x56c121){if(_0x56c121[_0xcadb('0x25')]!==_0xcadb('0x35')){var _0x3b1955={};_0x3b1955[_0x56c121[_0xcadb('0x22')]]={'$like':'%'+_0x1b124b[_0xcadb('0x29')][_0xcadb('0x33')]+'%'};return _0x3b1955;}})});}_0x2a9700=_[_0xcadb('0x34')]({},_0x2a9700,_0x1b124b[_0xcadb('0x36')]);var _0x484877={'where':_0x2a9700[_0xcadb('0x32')]};return db['VtigerAccount']['count'](_0x484877)[_0xcadb('0x21')](function(_0x164de3){_0x5d4613[_0xcadb('0x1b')]=_0x164de3;if(_0x1b124b['query']['includeAll']){_0x2a9700[_0xcadb('0x37')]=[{'all':!![]}];}return db[_0xcadb('0x24')]['findAll'](_0x2a9700);})[_0xcadb('0x21')](function(_0x3bf176){_0x5d4613['rows']=_0x3bf176;return _0x5d4613;})[_0xcadb('0x21')](respondWithFilteredResult(_0x231f3e,_0x2a9700))['catch'](handleError(_0x231f3e,null));};exports[_0xcadb('0x38')]=function(_0x410dea,_0x4dd35b){var _0x9da22b={'raw':![],'where':{'id':_0x410dea['params']['id']}},_0x34d0c2={};_0x34d0c2[_0xcadb('0x27')]=_[_0xcadb('0x39')](db[_0xcadb('0x24')][_0xcadb('0x3a')]);_0x34d0c2[_0xcadb('0x29')]=_[_0xcadb('0x39')](_0x410dea['query']);_0x34d0c2[_0xcadb('0x2a')]=_['intersection'](_0x34d0c2['model'],_0x34d0c2[_0xcadb('0x29')]);_0x9da22b['attributes']=_[_0xcadb('0x2b')](_0x34d0c2[_0xcadb('0x27')],qs['fields'](_0x410dea['query'][_0xcadb('0x2d')]));_0x9da22b[_0xcadb('0x2c')]=_0x9da22b['attributes'][_0xcadb('0x2e')]?_0x9da22b[_0xcadb('0x2c')]:_0x34d0c2[_0xcadb('0x27')];if(_0x410dea[_0xcadb('0x29')][_0xcadb('0x3b')]){_0x9da22b['include']=[{'all':!![]}];}_0x9da22b=_[_0xcadb('0x34')]({},_0x9da22b,_0x410dea[_0xcadb('0x36')]);return db['VtigerAccount']['find'](_0x9da22b)[_0xcadb('0x21')](handleEntityNotFound(_0x4dd35b,null))[_0xcadb('0x21')](respondWithResult(_0x4dd35b,null))[_0xcadb('0x3c')](handleError(_0x4dd35b,null));};exports[_0xcadb('0x3d')]=function(_0x4984a9,_0x1299c9){return db[_0xcadb('0x24')][_0xcadb('0x3d')](_0x4984a9[_0xcadb('0x3e')],{})['then'](respondWithResult(_0x1299c9,0xc9))[_0xcadb('0x3c')](handleError(_0x1299c9,null));};exports[_0xcadb('0x3f')]=function(_0x28ffc2,_0x52014d){if(_0x28ffc2['body']['id']){delete _0x28ffc2['body']['id'];}return db[_0xcadb('0x24')][_0xcadb('0x40')]({'where':{'id':_0x28ffc2[_0xcadb('0x41')]['id']}})[_0xcadb('0x21')](handleEntityNotFound(_0x52014d,null))['then'](saveUpdates(_0x28ffc2[_0xcadb('0x3e')],null))[_0xcadb('0x21')](respondWithResult(_0x52014d,null))[_0xcadb('0x3c')](handleError(_0x52014d,null));};exports[_0xcadb('0x42')]=function(_0x3ed067,_0x2ebdeb){return db[_0xcadb('0x24')][_0xcadb('0x40')]({'where':{'id':_0x3ed067[_0xcadb('0x41')]['id']}})[_0xcadb('0x21')](handleEntityNotFound(_0x2ebdeb,null))[_0xcadb('0x21')](removeEntity(_0x2ebdeb,null))['catch'](handleError(_0x2ebdeb,null));};exports[_0xcadb('0x43')]=function(_0x14ac29,_0x4d675d,_0x211c11){var _0x50e843={};var _0x516f1f={};var _0x52e228;var _0x1692b5;return db['VtigerAccount'][_0xcadb('0x44')]({'where':{'id':_0x14ac29['params']['id']}})[_0xcadb('0x21')](handleEntityNotFound(_0x4d675d,null))[_0xcadb('0x21')](function(_0x3116aa){if(_0x3116aa){_0x52e228=_0x3116aa;_0x516f1f[_0xcadb('0x27')]=_['keys'](db['VtigerConfiguration']['rawAttributes']);_0x516f1f[_0xcadb('0x29')]=_[_0xcadb('0x39')](_0x14ac29[_0xcadb('0x29')]);_0x516f1f[_0xcadb('0x2a')]=_[_0xcadb('0x2b')](_0x516f1f[_0xcadb('0x27')],_0x516f1f[_0xcadb('0x29')]);_0x50e843[_0xcadb('0x2c')]=_[_0xcadb('0x2b')](_0x516f1f['model'],qs[_0xcadb('0x2d')](_0x14ac29[_0xcadb('0x29')]['fields']));_0x50e843[_0xcadb('0x2c')]=_0x50e843['attributes'][_0xcadb('0x2e')]?_0x50e843['attributes']:_0x516f1f['model'];_0x50e843[_0xcadb('0x30')]=qs['sort'](_0x14ac29[_0xcadb('0x29')][_0xcadb('0x31')]);_0x50e843[_0xcadb('0x32')]=qs[_0xcadb('0x2a')](_[_0xcadb('0x45')](_0x14ac29[_0xcadb('0x29')],_0x516f1f['filters']));if(_0x14ac29['query']['filter']){_0x50e843[_0xcadb('0x32')]=_[_0xcadb('0x34')](_0x50e843['where'],{'$or':_['map'](_0x50e843['attributes'],function(_0x7215d1){var _0x1f54fd={};_0x1f54fd[_0x7215d1]={'$like':'%'+_0x14ac29['query'][_0xcadb('0x33')]+'%'};return _0x1f54fd;})});}_0x50e843=_['merge']({},_0x50e843,_0x14ac29[_0xcadb('0x36')]);return _0x52e228[_0xcadb('0x43')](_0x50e843);}})[_0xcadb('0x21')](function(_0x1e3fb3){if(_0x1e3fb3){_0x1692b5=_0x1e3fb3[_0xcadb('0x2e')];if(!_0x14ac29['query']['hasOwnProperty']('nolimit')){_0x50e843['limit']=qs[_0xcadb('0x1a')](_0x14ac29[_0xcadb('0x29')][_0xcadb('0x1a')]);_0x50e843[_0xcadb('0x18')]=qs[_0xcadb('0x18')](_0x14ac29[_0xcadb('0x29')][_0xcadb('0x18')]);}return _0x52e228['getConfigurations'](_0x50e843);}})[_0xcadb('0x21')](function(_0x236fff){if(_0x236fff){return _0x236fff?{'count':_0x1692b5,'rows':_0x236fff}:null;}})[_0xcadb('0x21')](respondWithResult(_0x4d675d,null))[_0xcadb('0x3c')](handleError(_0x4d675d,null));};exports[_0xcadb('0x46')]=function(_0x313074,_0x270933,_0x42ab8b){if(_0x313074[_0xcadb('0x3e')]['id']){delete _0x313074[_0xcadb('0x3e')]['id'];}return db[_0xcadb('0x24')][_0xcadb('0x44')]({'where':{'id':_0x313074[_0xcadb('0x41')]['id']}})[_0xcadb('0x21')](handleEntityNotFound(_0x270933,null))['then'](function(_0x208d73){if(_0x208d73){_0x313074[_0xcadb('0x3e')][_0xcadb('0x47')]=_0x208d73['id'];_0x313074['body'][_0xcadb('0x48')]=integrations['getSubjects'](_0x313074[_0xcadb('0x3e')][_0xcadb('0x49')],_0x313074[_0xcadb('0x3e')]['type']);_0x313074[_0xcadb('0x3e')][_0xcadb('0x4a')]=integrations[_0xcadb('0x4b')](_0x313074[_0xcadb('0x3e')][_0xcadb('0x49')],_0x313074[_0xcadb('0x3e')][_0xcadb('0x25')]);return db[_0xcadb('0x4c')][_0xcadb('0x3d')](_0x313074[_0xcadb('0x3e')],{'include':[{'model':db[_0xcadb('0x4d')],'as':_0xcadb('0x48')},{'model':db[_0xcadb('0x4d')],'as':_0xcadb('0x4a')}]});}return null;})[_0xcadb('0x21')](respondWithResult(_0x270933,null))[_0xcadb('0x3c')](handleError(_0x270933,null));};var md5=require('md5');exports[_0xcadb('0x4e')]=function(_0x417654,_0x44bb2b,_0x31b424){var _0x1fd9dc=null;var _0x386a72=null;var _0x44ff17=null;var _0x645a90=null;var _0x40b0fa='';return db['VtigerAccount']['findOne']({'where':{'id':_0x417654[_0xcadb('0x41')]['id']},'attributes':['id',_0xcadb('0x22'),_0xcadb('0x4f'),_0xcadb('0x50'),_0xcadb('0x51'),_0xcadb('0x52'),'serverUrl',_0xcadb('0x53')]})[_0xcadb('0x21')](handleEntityNotFound(_0x44bb2b,null))[_0xcadb('0x21')](function(_0x82d434){if(_0x82d434){_0x1fd9dc=_0x82d434[_0xcadb('0x4f')];_0x386a72=_0x82d434[_0xcadb('0x53')];_0x44ff17=_0x82d434[_0xcadb('0x51')];_0x40b0fa=_0x82d434[_0xcadb('0x52')];var _0x4420e1=_0x40b0fa[_0xcadb('0x54')](-0x1);if(_0x4420e1==='/'){_0x40b0fa=_0x40b0fa[_0xcadb('0x55')](0x0,_0x40b0fa['lastIndexOf'](_0x4420e1));}_0x645a90=util['format'](_0xcadb('0x56'),_0x40b0fa);var _0xc13e10={'method':'GET','uri':_0x645a90,'qs':{'operation':_0xcadb('0x57'),'username':_0x82d434[_0xcadb('0x4f')]},'json':!![]};return rp(_0xc13e10);}})['then'](function(_0x5e18e1){if(_0x5e18e1[_0xcadb('0x58')]){var _0x3a5915={'method':'POST','uri':_0x645a90,'form':{'operation':_0xcadb('0x59'),'username':_0x1fd9dc,'accessKey':md5(_0x5e18e1[_0xcadb('0x5a')][_0xcadb('0x5b')]+_0x386a72)},'json':!![]};return rp(_0x3a5915);}})[_0xcadb('0x21')](function(_0x5efe61){if(_0x5efe61[_0xcadb('0x58')]){var _0x411cb9={'method':_0xcadb('0x5c'),'uri':_0x645a90,'qs':{'operation':_0xcadb('0x5d'),'username':_0x1fd9dc,'sessionName':_0x5efe61[_0xcadb('0x5a')]['sessionName'],'elementType':_0x44ff17},'json':!![]};return rp(_0x411cb9);}})['then'](function(_0x2c1209){if(_0x2c1209[_0xcadb('0x58')]){var _0x544fbd=[_0xcadb('0x5e'),_0xcadb('0x5f'),_0xcadb('0x60')];_[_0xcadb('0x61')](_0x2c1209['result'][_0xcadb('0x2d')],function(_0x7e4090){return _0x544fbd['includes'](_0x7e4090[_0xcadb('0x25')]['name']);});_[_0xcadb('0x61')](_0x2c1209[_0xcadb('0x5a')][_0xcadb('0x2d')],function(_0x3b9349){return _0x3b9349['editable']==='false';});return{'count':_0x2c1209[_0xcadb('0x5a')][_0xcadb('0x2d')][_0xcadb('0x2e')],'rows':_[_0xcadb('0x28')](_0x2c1209[_0xcadb('0x5a')][_0xcadb('0x2d')],function(_0x364d1e){return{'id':_0x364d1e[_0xcadb('0x22')],'name':_0x364d1e[_0xcadb('0x62')],'custom':_['startsWith'](_0x364d1e[_0xcadb('0x22')],_0xcadb('0x63'))?!![]:![],'options':_0x364d1e[_0xcadb('0x25')][_0xcadb('0x22')]==='picklist'&&_0x364d1e[_0xcadb('0x25')]['picklistValues'][_0xcadb('0x2e')]>0x0?_['map'](_0x364d1e[_0xcadb('0x25')][_0xcadb('0x64')],function(_0xb4fd1){return{'name':_0xb4fd1[_0xcadb('0x62')],'value':_0xb4fd1[_0xcadb('0x65')]};}):[]};})};}})['then'](respondWithResult(_0x44bb2b,null))[_0xcadb('0x3c')](function(_0x53352d){console[_0xcadb('0x66')](_0xcadb('0x67')+_0x53352d);var _0x203a52=_0x417654['query'][_0xcadb('0x68')]?0x1f4:_0x53352d[_0xcadb('0x69')]||0x1f4;logger[_0xcadb('0x6a')]('getFields,\x20%s,\x20%s,\x20%s',_0xcadb('0x4e'),_0x203a52,JSON[_0xcadb('0x6b')](_0x53352d));delete _0x53352d[_0xcadb('0x22')];if(_0x203a52===0x191){_0x203a52=0x190;}_0x44bb2b[_0xcadb('0x15')](_0x203a52)['send'](_0x417654['query'][_0xcadb('0x68')]?{'message':_0xcadb('0x6c'),'statusCode':_0x53352d['statusCode']}:_0x53352d);});};
\ No newline at end of file