Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intVtigerAccount / intVtigerAccount.controller.js
index 470ff49..5eb0b61 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf75f=['ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','sendStatus','error','stack','name','send','index','VtigerAccount','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','catch','show','create','update','body','params','find','getConfigurations','findOne','VtigerConfiguration','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','VtigerField','Descriptions','getFields','username','description','moduleName','serverUrl','accessKey','remoteUri','slice','substring','lastIndexOf','format','%s/webservice.php','GET','getchallenge','success','POST','login','result','token','describe','sessionName','autogenerated','reference','remove','includes','editable','false','label','startsWith','cf_','picklist','picklistValues','value','log','vTiger\x20error:\x20','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv'];(function(_0x44d849,_0x48f693){var _0x27b34c=function(_0x2af41c){while(--_0x2af41c){_0x44d849['push'](_0x44d849['shift']());}};_0x27b34c(++_0x48f693);}(_0xf75f,0xfb));var _0xff75=function(_0x4f383b,_0x1fe091){_0x4f383b=_0x4f383b-0x0;var _0x4fb439=_0xf75f[_0x4f383b];return _0x4fb439;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xff75('0x0'));var zipdir=require(_0xff75('0x1'));var jsonpatch=require(_0xff75('0x2'));var rp=require(_0xff75('0x3'));var moment=require('moment');var BPromise=require(_0xff75('0x4'));var Mustache=require(_0xff75('0x5'));var util=require(_0xff75('0x6'));var path=require('path');var sox=require(_0xff75('0x7'));var csv=require(_0xff75('0x8'));var ejs=require(_0xff75('0x9'));var fs=require('fs');var fs_extra=require(_0xff75('0xa'));var _=require(_0xff75('0xb'));var squel=require('squel');var crypto=require(_0xff75('0xc'));var jsforce=require(_0xff75('0xd'));var deskjs=require(_0xff75('0xe'));var toCsv=require(_0xff75('0x8'));var querystring=require('querystring');var Papa=require(_0xff75('0xf'));var Redis=require(_0xff75('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xff75('0x11'));var as=require(_0xff75('0x12'));var hardwareService=require(_0xff75('0x13'));var logger=require(_0xff75('0x14'))(_0xff75('0x15'));var utils=require('../../config/utils');var config=require(_0xff75('0x16'));var licenseUtil=require(_0xff75('0x17'));var db=require(_0xff75('0x18'))['db'];var integrations=require(_0xff75('0x19'));function respondWithStatusCode(_0x733649,_0x2fe067){_0x2fe067=_0x2fe067||0xcc;return function(_0x235cec){if(_0x235cec){return _0x733649['sendStatus'](_0x2fe067);}return _0x733649['status'](_0x2fe067)[_0xff75('0x1a')]();};}function respondWithResult(_0x2d17f8,_0x177235){_0x177235=_0x177235||0xc8;return function(_0x49e968){if(_0x49e968){return _0x2d17f8[_0xff75('0x1b')](_0x177235)[_0xff75('0x1c')](_0x49e968);}};}function respondWithFilteredResult(_0x16461f,_0x254fe2){return function(_0x369a78){if(_0x369a78){var _0xf7243e=typeof _0x254fe2[_0xff75('0x1d')]===_0xff75('0x1e')&&typeof _0x254fe2[_0xff75('0x1f')]==='undefined';var _0x5663f9=_0x369a78[_0xff75('0x20')];var _0x1aea08=_0xf7243e?0x0:_0x254fe2[_0xff75('0x1d')];var _0x4e7a60=_0xf7243e?_0x369a78[_0xff75('0x20')]:_0x254fe2['offset']+_0x254fe2[_0xff75('0x1f')];var _0x243441;if(_0x4e7a60>=_0x5663f9){_0x4e7a60=_0x5663f9;_0x243441=0xc8;}else{_0x243441=0xce;}_0x16461f['status'](_0x243441);return _0x16461f[_0xff75('0x21')](_0xff75('0x22'),_0x1aea08+'-'+_0x4e7a60+'/'+_0x5663f9)[_0xff75('0x1c')](_0x369a78);}return null;};}function patchUpdates(_0x3327b9){return function(_0x5ccb99){try{jsonpatch[_0xff75('0x23')](_0x5ccb99,_0x3327b9,!![]);}catch(_0x1ca7c7){return BPromise[_0xff75('0x24')](_0x1ca7c7);}return _0x5ccb99[_0xff75('0x25')]();};}function saveUpdates(_0x5a5320,_0xac7a85){return function(_0x100dd2){if(_0x100dd2){return _0x100dd2['update'](_0x5a5320)[_0xff75('0x26')](function(_0x5192b8){return _0x5192b8;});}return null;};}function removeEntity(_0x423e1c,_0x375138){return function(_0x2dd85b){if(_0x2dd85b){return _0x2dd85b[_0xff75('0x27')]()['then'](function(){_0x423e1c[_0xff75('0x1b')](0xcc)[_0xff75('0x1a')]();});}};}function handleEntityNotFound(_0x1bfa6b,_0x393f38){return function(_0x10f354){if(!_0x10f354){_0x1bfa6b[_0xff75('0x28')](0x194);}return _0x10f354;};}function handleError(_0xfa5014,_0x4ff4d6){_0x4ff4d6=_0x4ff4d6||0x1f4;return function(_0x53c6d0){logger[_0xff75('0x29')](_0x53c6d0[_0xff75('0x2a')]);if(_0x53c6d0[_0xff75('0x2b')]){delete _0x53c6d0['name'];}_0xfa5014[_0xff75('0x1b')](_0x4ff4d6)[_0xff75('0x2c')](_0x53c6d0);};}exports[_0xff75('0x2d')]=function(_0x15dba2,_0x1f49bf){var _0x4854a9={},_0x5c7ab1={},_0x40061c={'count':0x0,'rows':[]};var _0x3d9f37=_['map'](db[_0xff75('0x2e')][_0xff75('0x2f')],function(_0x1a8fa6){return{'name':_0x1a8fa6[_0xff75('0x30')],'type':_0x1a8fa6[_0xff75('0x31')][_0xff75('0x32')]};});_0x5c7ab1[_0xff75('0x33')]=_[_0xff75('0x34')](_0x3d9f37,_0xff75('0x2b'));_0x5c7ab1[_0xff75('0x35')]=_[_0xff75('0x36')](_0x15dba2[_0xff75('0x35')]);_0x5c7ab1[_0xff75('0x37')]=_[_0xff75('0x38')](_0x5c7ab1[_0xff75('0x33')],_0x5c7ab1[_0xff75('0x35')]);_0x4854a9[_0xff75('0x39')]=_['intersection'](_0x5c7ab1['model'],qs[_0xff75('0x3a')](_0x15dba2['query'][_0xff75('0x3a')]));_0x4854a9[_0xff75('0x39')]=_0x4854a9[_0xff75('0x39')][_0xff75('0x3b')]?_0x4854a9[_0xff75('0x39')]:_0x5c7ab1[_0xff75('0x33')];if(!_0x15dba2[_0xff75('0x35')]['hasOwnProperty'](_0xff75('0x3c'))){_0x4854a9[_0xff75('0x1f')]=qs[_0xff75('0x1f')](_0x15dba2['query'][_0xff75('0x1f')]);_0x4854a9['offset']=qs[_0xff75('0x1d')](_0x15dba2['query'][_0xff75('0x1d')]);}_0x4854a9[_0xff75('0x3d')]=qs[_0xff75('0x3e')](_0x15dba2[_0xff75('0x35')]['sort']);_0x4854a9[_0xff75('0x3f')]=qs[_0xff75('0x37')](_[_0xff75('0x40')](_0x15dba2['query'],_0x5c7ab1[_0xff75('0x37')]),_0x3d9f37);if(_0x15dba2[_0xff75('0x35')][_0xff75('0x41')]){_0x4854a9[_0xff75('0x3f')]=_[_0xff75('0x42')](_0x4854a9[_0xff75('0x3f')],{'$or':_[_0xff75('0x34')](_0x3d9f37,function(_0x375f7f){if(_0x375f7f[_0xff75('0x31')]!=='VIRTUAL'){var _0x5315c7={};_0x5315c7[_0x375f7f['name']]={'$like':'%'+_0x15dba2[_0xff75('0x35')]['filter']+'%'};return _0x5315c7;}})});}_0x4854a9=_['merge']({},_0x4854a9,_0x15dba2[_0xff75('0x43')]);var _0x3a4c2b={'where':_0x4854a9[_0xff75('0x3f')]};return db[_0xff75('0x2e')][_0xff75('0x20')](_0x3a4c2b)[_0xff75('0x26')](function(_0x377e5b){_0x40061c[_0xff75('0x20')]=_0x377e5b;if(_0x15dba2['query'][_0xff75('0x44')]){_0x4854a9[_0xff75('0x45')]=[{'all':!![]}];}return db[_0xff75('0x2e')][_0xff75('0x46')](_0x4854a9);})[_0xff75('0x26')](function(_0x36fe6a){_0x40061c['rows']=_0x36fe6a;return _0x40061c;})[_0xff75('0x26')](respondWithFilteredResult(_0x1f49bf,_0x4854a9))[_0xff75('0x47')](handleError(_0x1f49bf,null));};exports[_0xff75('0x48')]=function(_0x217b31,_0x388c46){var _0x13c39a={'raw':![],'where':{'id':_0x217b31['params']['id']}},_0x502231={};_0x502231[_0xff75('0x33')]=_['keys'](db[_0xff75('0x2e')][_0xff75('0x2f')]);_0x502231[_0xff75('0x35')]=_[_0xff75('0x36')](_0x217b31[_0xff75('0x35')]);_0x502231[_0xff75('0x37')]=_[_0xff75('0x38')](_0x502231[_0xff75('0x33')],_0x502231['query']);_0x13c39a[_0xff75('0x39')]=_['intersection'](_0x502231[_0xff75('0x33')],qs['fields'](_0x217b31[_0xff75('0x35')]['fields']));_0x13c39a[_0xff75('0x39')]=_0x13c39a['attributes'][_0xff75('0x3b')]?_0x13c39a[_0xff75('0x39')]:_0x502231['model'];if(_0x217b31[_0xff75('0x35')][_0xff75('0x44')]){_0x13c39a[_0xff75('0x45')]=[{'all':!![]}];}_0x13c39a=_[_0xff75('0x42')]({},_0x13c39a,_0x217b31[_0xff75('0x43')]);return db[_0xff75('0x2e')]['find'](_0x13c39a)[_0xff75('0x26')](handleEntityNotFound(_0x388c46,null))[_0xff75('0x26')](respondWithResult(_0x388c46,null))[_0xff75('0x47')](handleError(_0x388c46,null));};exports[_0xff75('0x49')]=function(_0x2877ad,_0x1bd1d9){return db[_0xff75('0x2e')][_0xff75('0x49')](_0x2877ad['body'],{})[_0xff75('0x26')](respondWithResult(_0x1bd1d9,0xc9))[_0xff75('0x47')](handleError(_0x1bd1d9,null));};exports[_0xff75('0x4a')]=function(_0x5d13fd,_0x1d1d83){if(_0x5d13fd[_0xff75('0x4b')]['id']){delete _0x5d13fd[_0xff75('0x4b')]['id'];}return db[_0xff75('0x2e')]['find']({'where':{'id':_0x5d13fd[_0xff75('0x4c')]['id']}})[_0xff75('0x26')](handleEntityNotFound(_0x1d1d83,null))[_0xff75('0x26')](saveUpdates(_0x5d13fd[_0xff75('0x4b')],null))[_0xff75('0x26')](respondWithResult(_0x1d1d83,null))[_0xff75('0x47')](handleError(_0x1d1d83,null));};exports['destroy']=function(_0x2cd902,_0xf88f45){return db[_0xff75('0x2e')][_0xff75('0x4d')]({'where':{'id':_0x2cd902[_0xff75('0x4c')]['id']}})[_0xff75('0x26')](handleEntityNotFound(_0xf88f45,null))[_0xff75('0x26')](removeEntity(_0xf88f45,null))['catch'](handleError(_0xf88f45,null));};exports[_0xff75('0x4e')]=function(_0x36150a,_0xe5ffa0,_0x1e437a){var _0x583fa5={};var _0x255267={};var _0x4f470d;var _0x160a4a;return db[_0xff75('0x2e')][_0xff75('0x4f')]({'where':{'id':_0x36150a['params']['id']}})[_0xff75('0x26')](handleEntityNotFound(_0xe5ffa0,null))['then'](function(_0x38045c){if(_0x38045c){_0x4f470d=_0x38045c;_0x255267[_0xff75('0x33')]=_[_0xff75('0x36')](db[_0xff75('0x50')][_0xff75('0x2f')]);_0x255267[_0xff75('0x35')]=_['keys'](_0x36150a[_0xff75('0x35')]);_0x255267[_0xff75('0x37')]=_[_0xff75('0x38')](_0x255267[_0xff75('0x33')],_0x255267['query']);_0x583fa5['attributes']=_['intersection'](_0x255267['model'],qs['fields'](_0x36150a['query'][_0xff75('0x3a')]));_0x583fa5[_0xff75('0x39')]=_0x583fa5[_0xff75('0x39')]['length']?_0x583fa5[_0xff75('0x39')]:_0x255267[_0xff75('0x33')];_0x583fa5[_0xff75('0x3d')]=qs[_0xff75('0x3e')](_0x36150a[_0xff75('0x35')][_0xff75('0x3e')]);_0x583fa5[_0xff75('0x3f')]=qs[_0xff75('0x37')](_['pick'](_0x36150a['query'],_0x255267['filters']));if(_0x36150a[_0xff75('0x35')]['filter']){_0x583fa5['where']=_[_0xff75('0x42')](_0x583fa5[_0xff75('0x3f')],{'$or':_[_0xff75('0x34')](_0x583fa5[_0xff75('0x39')],function(_0x529af4){var _0x25f40b={};_0x25f40b[_0x529af4]={'$like':'%'+_0x36150a[_0xff75('0x35')][_0xff75('0x41')]+'%'};return _0x25f40b;})});}_0x583fa5=_[_0xff75('0x42')]({},_0x583fa5,_0x36150a[_0xff75('0x43')]);return _0x4f470d[_0xff75('0x4e')](_0x583fa5);}})[_0xff75('0x26')](function(_0xe535e8){if(_0xe535e8){_0x160a4a=_0xe535e8[_0xff75('0x3b')];if(!_0x36150a[_0xff75('0x35')][_0xff75('0x51')](_0xff75('0x3c'))){_0x583fa5[_0xff75('0x1f')]=qs[_0xff75('0x1f')](_0x36150a[_0xff75('0x35')][_0xff75('0x1f')]);_0x583fa5[_0xff75('0x1d')]=qs[_0xff75('0x1d')](_0x36150a[_0xff75('0x35')][_0xff75('0x1d')]);}return _0x4f470d['getConfigurations'](_0x583fa5);}})[_0xff75('0x26')](function(_0x185ce4){if(_0x185ce4){return _0x185ce4?{'count':_0x160a4a,'rows':_0x185ce4}:null;}})['then'](respondWithResult(_0xe5ffa0,null))[_0xff75('0x47')](handleError(_0xe5ffa0,null));};exports[_0xff75('0x52')]=function(_0x128f0f,_0x471ffd,_0x1faf17){if(_0x128f0f[_0xff75('0x4b')]['id']){delete _0x128f0f[_0xff75('0x4b')]['id'];}return db[_0xff75('0x2e')]['findOne']({'where':{'id':_0x128f0f[_0xff75('0x4c')]['id']}})[_0xff75('0x26')](handleEntityNotFound(_0x471ffd,null))['then'](function(_0x2b6205){if(_0x2b6205){_0x128f0f[_0xff75('0x4b')][_0xff75('0x53')]=_0x2b6205['id'];_0x128f0f[_0xff75('0x4b')][_0xff75('0x54')]=integrations[_0xff75('0x55')](_0x128f0f[_0xff75('0x4b')][_0xff75('0x56')],_0x128f0f[_0xff75('0x4b')][_0xff75('0x31')]);_0x128f0f['body']['Descriptions']=integrations[_0xff75('0x57')](_0x128f0f[_0xff75('0x4b')][_0xff75('0x56')],_0x128f0f[_0xff75('0x4b')][_0xff75('0x31')]);return db[_0xff75('0x50')][_0xff75('0x49')](_0x128f0f[_0xff75('0x4b')],{'include':[{'model':db['VtigerField'],'as':'Subjects'},{'model':db[_0xff75('0x58')],'as':_0xff75('0x59')}]});}return null;})[_0xff75('0x26')](respondWithResult(_0x471ffd,null))[_0xff75('0x47')](handleError(_0x471ffd,null));};var md5=require('md5');exports[_0xff75('0x5a')]=function(_0x14e680,_0x1d8836,_0x394cbb){var _0x1d54f0=null;var _0x197a95=null;var _0xa2e129=null;var _0x5070b9=null;var _0x564351='';return db[_0xff75('0x2e')][_0xff75('0x4f')]({'where':{'id':_0x14e680[_0xff75('0x4c')]['id']},'attributes':['id',_0xff75('0x2b'),_0xff75('0x5b'),_0xff75('0x5c'),_0xff75('0x5d'),'remoteUri',_0xff75('0x5e'),_0xff75('0x5f')]})[_0xff75('0x26')](handleEntityNotFound(_0x1d8836,null))[_0xff75('0x26')](function(_0x5916d6){if(_0x5916d6){_0x1d54f0=_0x5916d6[_0xff75('0x5b')];_0x197a95=_0x5916d6['accessKey'];_0xa2e129=_0x5916d6['moduleName'];_0x564351=_0x5916d6[_0xff75('0x60')];var _0x3f91ff=_0x564351[_0xff75('0x61')](-0x1);if(_0x3f91ff==='/'){_0x564351=_0x564351[_0xff75('0x62')](0x0,_0x564351[_0xff75('0x63')](_0x3f91ff));}_0x5070b9=util[_0xff75('0x64')](_0xff75('0x65'),_0x564351);var _0x34a2e2={'method':_0xff75('0x66'),'uri':_0x5070b9,'qs':{'operation':_0xff75('0x67'),'username':_0x5916d6['username']},'json':!![]};return rp(_0x34a2e2);}})[_0xff75('0x26')](function(_0xbf92a8){if(_0xbf92a8[_0xff75('0x68')]){var _0x1bad4c={'method':_0xff75('0x69'),'uri':_0x5070b9,'form':{'operation':_0xff75('0x6a'),'username':_0x1d54f0,'accessKey':md5(_0xbf92a8[_0xff75('0x6b')][_0xff75('0x6c')]+_0x197a95)},'json':!![]};return rp(_0x1bad4c);}})['then'](function(_0x10d2a9){if(_0x10d2a9['success']){var _0x343535={'method':_0xff75('0x66'),'uri':_0x5070b9,'qs':{'operation':_0xff75('0x6d'),'username':_0x1d54f0,'sessionName':_0x10d2a9[_0xff75('0x6b')][_0xff75('0x6e')],'elementType':_0xa2e129},'json':!![]};return rp(_0x343535);}})[_0xff75('0x26')](function(_0x3f3d64){if(_0x3f3d64[_0xff75('0x68')]){var _0x477fef=[_0xff75('0x6f'),_0xff75('0x70'),'owner'];_[_0xff75('0x71')](_0x3f3d64[_0xff75('0x6b')][_0xff75('0x3a')],function(_0x2d637e){return _0x477fef[_0xff75('0x72')](_0x2d637e[_0xff75('0x31')][_0xff75('0x2b')]);});_[_0xff75('0x71')](_0x3f3d64['result'][_0xff75('0x3a')],function(_0x38a4bc){return _0x38a4bc[_0xff75('0x73')]===_0xff75('0x74');});return{'count':_0x3f3d64[_0xff75('0x6b')][_0xff75('0x3a')][_0xff75('0x3b')],'rows':_[_0xff75('0x34')](_0x3f3d64[_0xff75('0x6b')]['fields'],function(_0x3f8e48){return{'id':_0x3f8e48[_0xff75('0x2b')],'name':_0x3f8e48[_0xff75('0x75')],'custom':_[_0xff75('0x76')](_0x3f8e48[_0xff75('0x2b')],_0xff75('0x77'))?!![]:![],'options':_0x3f8e48[_0xff75('0x31')][_0xff75('0x2b')]===_0xff75('0x78')&&_0x3f8e48[_0xff75('0x31')][_0xff75('0x79')][_0xff75('0x3b')]>0x0?_[_0xff75('0x34')](_0x3f8e48[_0xff75('0x31')][_0xff75('0x79')],function(_0x30f693){return{'name':_0x30f693[_0xff75('0x75')],'value':_0x30f693[_0xff75('0x7a')]};}):[]};})};}})[_0xff75('0x26')](respondWithResult(_0x1d8836,null))[_0xff75('0x47')](function(_0x79abec){console[_0xff75('0x7b')](_0xff75('0x7c')+_0x79abec);var _0x18f576=_0x14e680[_0xff75('0x35')][_0xff75('0x7d')]?0x1f4:_0x79abec[_0xff75('0x7e')]||0x1f4;logger[_0xff75('0x29')](_0xff75('0x7f'),'getFields',_0x18f576,JSON[_0xff75('0x80')](_0x79abec));delete _0x79abec[_0xff75('0x2b')];if(_0x18f576===0x191){_0x18f576=0x190;}_0x1d8836[_0xff75('0x1b')](_0x18f576)[_0xff75('0x2c')](_0x14e680[_0xff75('0x35')]['test']?{'message':_0xff75('0x81'),'statusCode':_0x79abec['statusCode']}:_0x79abec);});};
\ No newline at end of file
+var _0x6490=['options','find','create','body','findOne','VtigerConfiguration','order','getConfigurations','addConfiguration','Subjects','getSubjects','VtigerField','Descriptions','md5','getFields','username','description','moduleName','serverUrl','accessKey','remoteUri','slice','substring','lastIndexOf','%s/webservice.php','GET','success','POST','login','result','token','describe','sessionName','autogenerated','owner','remove','editable','false','cf_','picklist','picklistValues','label','value','log','vTiger\x20error:\x20','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','VIRTUAL','VtigerAccount','includeAll','include','findAll','rows','catch','params'];(function(_0x57baa6,_0x3af298){var _0x303fbf=function(_0x24c318){while(--_0x24c318){_0x57baa6['push'](_0x57baa6['shift']());}};_0x303fbf(++_0x3af298);}(_0x6490,0xac));var _0x0649=function(_0x285800,_0x26765e){_0x285800=_0x285800-0x0;var _0x4b809e=_0x6490[_0x285800];return _0x4b809e;};'use strict';var emlformat=require(_0x0649('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0649('0x1'));var jsonpatch=require(_0x0649('0x2'));var rp=require(_0x0649('0x3'));var moment=require(_0x0649('0x4'));var BPromise=require(_0x0649('0x5'));var Mustache=require(_0x0649('0x6'));var util=require('util');var path=require(_0x0649('0x7'));var sox=require('sox');var csv=require(_0x0649('0x8'));var ejs=require(_0x0649('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0649('0xa'));var squel=require(_0x0649('0xb'));var crypto=require('crypto');var jsforce=require(_0x0649('0xc'));var deskjs=require(_0x0649('0xd'));var toCsv=require(_0x0649('0x8'));var querystring=require(_0x0649('0xe'));var Papa=require(_0x0649('0xf'));var Redis=require(_0x0649('0x10'));var authService=require(_0x0649('0x11'));var qs=require(_0x0649('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0649('0x13'));var logger=require(_0x0649('0x14'))(_0x0649('0x15'));var utils=require(_0x0649('0x16'));var config=require(_0x0649('0x17'));var licenseUtil=require(_0x0649('0x18'));var db=require(_0x0649('0x19'))['db'];var integrations=require(_0x0649('0x1a'));function respondWithStatusCode(_0x55262f,_0x3b4317){_0x3b4317=_0x3b4317||0xcc;return function(_0x277d28){if(_0x277d28){return _0x55262f[_0x0649('0x1b')](_0x3b4317);}return _0x55262f[_0x0649('0x1c')](_0x3b4317)[_0x0649('0x1d')]();};}function respondWithResult(_0x55369e,_0x35a2dc){_0x35a2dc=_0x35a2dc||0xc8;return function(_0xe60342){if(_0xe60342){return _0x55369e[_0x0649('0x1c')](_0x35a2dc)[_0x0649('0x1e')](_0xe60342);}};}function respondWithFilteredResult(_0x5d9bbe,_0xa68961){return function(_0x561662){if(_0x561662){var _0x45d6f8=typeof _0xa68961['offset']===_0x0649('0x1f')&&typeof _0xa68961[_0x0649('0x20')]==='undefined';var _0xfc8548=_0x561662['count'];var _0x4183ac=_0x45d6f8?0x0:_0xa68961[_0x0649('0x21')];var _0x3d48bb=_0x45d6f8?_0x561662[_0x0649('0x22')]:_0xa68961[_0x0649('0x21')]+_0xa68961['limit'];var _0x5d54f2;if(_0x3d48bb>=_0xfc8548){_0x3d48bb=_0xfc8548;_0x5d54f2=0xc8;}else{_0x5d54f2=0xce;}_0x5d9bbe[_0x0649('0x1c')](_0x5d54f2);return _0x5d9bbe[_0x0649('0x23')](_0x0649('0x24'),_0x4183ac+'-'+_0x3d48bb+'/'+_0xfc8548)[_0x0649('0x1e')](_0x561662);}return null;};}function patchUpdates(_0x9cb2bc){return function(_0x3041cc){try{jsonpatch[_0x0649('0x25')](_0x3041cc,_0x9cb2bc,!![]);}catch(_0x2a15b6){return BPromise[_0x0649('0x26')](_0x2a15b6);}return _0x3041cc[_0x0649('0x27')]();};}function saveUpdates(_0x29eb39,_0x1d6eab){return function(_0x5856aa){if(_0x5856aa){return _0x5856aa[_0x0649('0x28')](_0x29eb39)['then'](function(_0x3397fd){return _0x3397fd;});}return null;};}function removeEntity(_0x44ccdd,_0x29f4b9){return function(_0x5ecabe){if(_0x5ecabe){return _0x5ecabe[_0x0649('0x29')]()[_0x0649('0x2a')](function(){_0x44ccdd['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x255558,_0x1611a6){return function(_0x37a60d){if(!_0x37a60d){_0x255558[_0x0649('0x1b')](0x194);}return _0x37a60d;};}function handleError(_0x43c4e1,_0x2ad48a){_0x2ad48a=_0x2ad48a||0x1f4;return function(_0x377776){logger[_0x0649('0x2b')](_0x377776[_0x0649('0x2c')]);if(_0x377776[_0x0649('0x2d')]){delete _0x377776['name'];}_0x43c4e1[_0x0649('0x1c')](_0x2ad48a)['send'](_0x377776);};}exports['index']=function(_0x2e497e,_0x5ac1bc){var _0x258b94={},_0x394247={},_0x2e848c={'count':0x0,'rows':[]};var _0x4c11a5=_[_0x0649('0x2e')](db['VtigerAccount'][_0x0649('0x2f')],function(_0x2f70a5){return{'name':_0x2f70a5[_0x0649('0x30')],'type':_0x2f70a5[_0x0649('0x31')][_0x0649('0x32')]};});_0x394247[_0x0649('0x33')]=_['map'](_0x4c11a5,_0x0649('0x2d'));_0x394247[_0x0649('0x34')]=_[_0x0649('0x35')](_0x2e497e[_0x0649('0x34')]);_0x394247[_0x0649('0x36')]=_[_0x0649('0x37')](_0x394247[_0x0649('0x33')],_0x394247[_0x0649('0x34')]);_0x258b94[_0x0649('0x38')]=_[_0x0649('0x37')](_0x394247[_0x0649('0x33')],qs['fields'](_0x2e497e[_0x0649('0x34')][_0x0649('0x39')]));_0x258b94['attributes']=_0x258b94['attributes'][_0x0649('0x3a')]?_0x258b94[_0x0649('0x38')]:_0x394247[_0x0649('0x33')];if(!_0x2e497e[_0x0649('0x34')][_0x0649('0x3b')](_0x0649('0x3c'))){_0x258b94['limit']=qs[_0x0649('0x20')](_0x2e497e[_0x0649('0x34')][_0x0649('0x20')]);_0x258b94['offset']=qs[_0x0649('0x21')](_0x2e497e[_0x0649('0x34')][_0x0649('0x21')]);}_0x258b94['order']=qs[_0x0649('0x3d')](_0x2e497e[_0x0649('0x34')][_0x0649('0x3d')]);_0x258b94['where']=qs['filters'](_[_0x0649('0x3e')](_0x2e497e['query'],_0x394247[_0x0649('0x36')]),_0x4c11a5);if(_0x2e497e['query'][_0x0649('0x3f')]){_0x258b94[_0x0649('0x40')]=_[_0x0649('0x41')](_0x258b94['where'],{'$or':_[_0x0649('0x2e')](_0x4c11a5,function(_0x5854d3){if(_0x5854d3[_0x0649('0x31')]!==_0x0649('0x42')){var _0x4f8a27={};_0x4f8a27[_0x5854d3['name']]={'$like':'%'+_0x2e497e['query'][_0x0649('0x3f')]+'%'};return _0x4f8a27;}})});}_0x258b94=_[_0x0649('0x41')]({},_0x258b94,_0x2e497e['options']);var _0x565c1a={'where':_0x258b94[_0x0649('0x40')]};return db[_0x0649('0x43')][_0x0649('0x22')](_0x565c1a)['then'](function(_0x543353){_0x2e848c[_0x0649('0x22')]=_0x543353;if(_0x2e497e[_0x0649('0x34')][_0x0649('0x44')]){_0x258b94[_0x0649('0x45')]=[{'all':!![]}];}return db[_0x0649('0x43')][_0x0649('0x46')](_0x258b94);})[_0x0649('0x2a')](function(_0x34da8e){_0x2e848c[_0x0649('0x47')]=_0x34da8e;return _0x2e848c;})[_0x0649('0x2a')](respondWithFilteredResult(_0x5ac1bc,_0x258b94))[_0x0649('0x48')](handleError(_0x5ac1bc,null));};exports['show']=function(_0x5731f3,_0x1374d1){var _0x5651a5={'raw':![],'where':{'id':_0x5731f3[_0x0649('0x49')]['id']}},_0x4b12ba={};_0x4b12ba[_0x0649('0x33')]=_[_0x0649('0x35')](db['VtigerAccount'][_0x0649('0x2f')]);_0x4b12ba['query']=_[_0x0649('0x35')](_0x5731f3[_0x0649('0x34')]);_0x4b12ba['filters']=_['intersection'](_0x4b12ba[_0x0649('0x33')],_0x4b12ba[_0x0649('0x34')]);_0x5651a5[_0x0649('0x38')]=_[_0x0649('0x37')](_0x4b12ba[_0x0649('0x33')],qs['fields'](_0x5731f3[_0x0649('0x34')][_0x0649('0x39')]));_0x5651a5[_0x0649('0x38')]=_0x5651a5[_0x0649('0x38')][_0x0649('0x3a')]?_0x5651a5[_0x0649('0x38')]:_0x4b12ba[_0x0649('0x33')];if(_0x5731f3[_0x0649('0x34')][_0x0649('0x44')]){_0x5651a5['include']=[{'all':!![]}];}_0x5651a5=_['merge']({},_0x5651a5,_0x5731f3[_0x0649('0x4a')]);return db[_0x0649('0x43')][_0x0649('0x4b')](_0x5651a5)[_0x0649('0x2a')](handleEntityNotFound(_0x1374d1,null))['then'](respondWithResult(_0x1374d1,null))[_0x0649('0x48')](handleError(_0x1374d1,null));};exports['create']=function(_0x1223a1,_0x796205){return db['VtigerAccount'][_0x0649('0x4c')](_0x1223a1['body'],{})[_0x0649('0x2a')](respondWithResult(_0x796205,0xc9))[_0x0649('0x48')](handleError(_0x796205,null));};exports[_0x0649('0x28')]=function(_0x10e467,_0x3f663c){if(_0x10e467['body']['id']){delete _0x10e467[_0x0649('0x4d')]['id'];}return db[_0x0649('0x43')][_0x0649('0x4b')]({'where':{'id':_0x10e467[_0x0649('0x49')]['id']}})[_0x0649('0x2a')](handleEntityNotFound(_0x3f663c,null))[_0x0649('0x2a')](saveUpdates(_0x10e467[_0x0649('0x4d')],null))[_0x0649('0x2a')](respondWithResult(_0x3f663c,null))['catch'](handleError(_0x3f663c,null));};exports[_0x0649('0x29')]=function(_0x5f3c77,_0x486d80){return db[_0x0649('0x43')][_0x0649('0x4b')]({'where':{'id':_0x5f3c77[_0x0649('0x49')]['id']}})[_0x0649('0x2a')](handleEntityNotFound(_0x486d80,null))[_0x0649('0x2a')](removeEntity(_0x486d80,null))[_0x0649('0x48')](handleError(_0x486d80,null));};exports['getConfigurations']=function(_0x3dd8d5,_0x47c8ca,_0x464911){var _0x579f22={};var _0x3d4246={};var _0x1c76ac;var _0x34daa7;return db[_0x0649('0x43')][_0x0649('0x4e')]({'where':{'id':_0x3dd8d5[_0x0649('0x49')]['id']}})[_0x0649('0x2a')](handleEntityNotFound(_0x47c8ca,null))['then'](function(_0x5caf09){if(_0x5caf09){_0x1c76ac=_0x5caf09;_0x3d4246[_0x0649('0x33')]=_['keys'](db[_0x0649('0x4f')]['rawAttributes']);_0x3d4246['query']=_['keys'](_0x3dd8d5[_0x0649('0x34')]);_0x3d4246[_0x0649('0x36')]=_[_0x0649('0x37')](_0x3d4246[_0x0649('0x33')],_0x3d4246[_0x0649('0x34')]);_0x579f22[_0x0649('0x38')]=_[_0x0649('0x37')](_0x3d4246[_0x0649('0x33')],qs[_0x0649('0x39')](_0x3dd8d5[_0x0649('0x34')][_0x0649('0x39')]));_0x579f22['attributes']=_0x579f22['attributes']['length']?_0x579f22['attributes']:_0x3d4246[_0x0649('0x33')];_0x579f22[_0x0649('0x50')]=qs[_0x0649('0x3d')](_0x3dd8d5[_0x0649('0x34')]['sort']);_0x579f22[_0x0649('0x40')]=qs[_0x0649('0x36')](_[_0x0649('0x3e')](_0x3dd8d5['query'],_0x3d4246[_0x0649('0x36')]));if(_0x3dd8d5[_0x0649('0x34')][_0x0649('0x3f')]){_0x579f22[_0x0649('0x40')]=_[_0x0649('0x41')](_0x579f22['where'],{'$or':_['map'](_0x579f22['attributes'],function(_0x365337){var _0x26cd80={};_0x26cd80[_0x365337]={'$like':'%'+_0x3dd8d5['query']['filter']+'%'};return _0x26cd80;})});}_0x579f22=_['merge']({},_0x579f22,_0x3dd8d5[_0x0649('0x4a')]);return _0x1c76ac[_0x0649('0x51')](_0x579f22);}})[_0x0649('0x2a')](function(_0x1ab911){if(_0x1ab911){_0x34daa7=_0x1ab911[_0x0649('0x3a')];if(!_0x3dd8d5[_0x0649('0x34')][_0x0649('0x3b')](_0x0649('0x3c'))){_0x579f22[_0x0649('0x20')]=qs['limit'](_0x3dd8d5[_0x0649('0x34')]['limit']);_0x579f22[_0x0649('0x21')]=qs['offset'](_0x3dd8d5['query'][_0x0649('0x21')]);}return _0x1c76ac[_0x0649('0x51')](_0x579f22);}})[_0x0649('0x2a')](function(_0x3bf63b){if(_0x3bf63b){return _0x3bf63b?{'count':_0x34daa7,'rows':_0x3bf63b}:null;}})[_0x0649('0x2a')](respondWithResult(_0x47c8ca,null))[_0x0649('0x48')](handleError(_0x47c8ca,null));};exports[_0x0649('0x52')]=function(_0xde2a82,_0x2f9e0c,_0x2fbf24){if(_0xde2a82[_0x0649('0x4d')]['id']){delete _0xde2a82[_0x0649('0x4d')]['id'];}return db[_0x0649('0x43')]['findOne']({'where':{'id':_0xde2a82[_0x0649('0x49')]['id']}})['then'](handleEntityNotFound(_0x2f9e0c,null))[_0x0649('0x2a')](function(_0x2d86a8){if(_0x2d86a8){_0xde2a82[_0x0649('0x4d')]['AccountId']=_0x2d86a8['id'];_0xde2a82[_0x0649('0x4d')][_0x0649('0x53')]=integrations[_0x0649('0x54')](_0xde2a82[_0x0649('0x4d')]['channel'],_0xde2a82[_0x0649('0x4d')][_0x0649('0x31')]);_0xde2a82['body']['Descriptions']=integrations['getDescriptions'](_0xde2a82['body']['channel'],_0xde2a82[_0x0649('0x4d')][_0x0649('0x31')]);return db['VtigerConfiguration'][_0x0649('0x4c')](_0xde2a82[_0x0649('0x4d')],{'include':[{'model':db[_0x0649('0x55')],'as':_0x0649('0x53')},{'model':db[_0x0649('0x55')],'as':_0x0649('0x56')}]});}return null;})[_0x0649('0x2a')](respondWithResult(_0x2f9e0c,null))[_0x0649('0x48')](handleError(_0x2f9e0c,null));};var md5=require(_0x0649('0x57'));exports[_0x0649('0x58')]=function(_0x577f18,_0x2f6545,_0xd8dbdc){var _0x403e5a=null;var _0x13e23d=null;var _0x5798c0=null;var _0x154139=null;var _0x5b959a='';return db['VtigerAccount'][_0x0649('0x4e')]({'where':{'id':_0x577f18[_0x0649('0x49')]['id']},'attributes':['id','name',_0x0649('0x59'),_0x0649('0x5a'),_0x0649('0x5b'),'remoteUri',_0x0649('0x5c'),_0x0649('0x5d')]})[_0x0649('0x2a')](handleEntityNotFound(_0x2f6545,null))[_0x0649('0x2a')](function(_0x2af2e1){if(_0x2af2e1){_0x403e5a=_0x2af2e1[_0x0649('0x59')];_0x13e23d=_0x2af2e1['accessKey'];_0x5798c0=_0x2af2e1[_0x0649('0x5b')];_0x5b959a=_0x2af2e1[_0x0649('0x5e')];var _0x3c6f72=_0x5b959a[_0x0649('0x5f')](-0x1);if(_0x3c6f72==='/'){_0x5b959a=_0x5b959a[_0x0649('0x60')](0x0,_0x5b959a[_0x0649('0x61')](_0x3c6f72));}_0x154139=util['format'](_0x0649('0x62'),_0x5b959a);var _0x2eb02c={'method':_0x0649('0x63'),'uri':_0x154139,'qs':{'operation':'getchallenge','username':_0x2af2e1['username']},'json':!![]};return rp(_0x2eb02c);}})[_0x0649('0x2a')](function(_0x12ad33){if(_0x12ad33[_0x0649('0x64')]){var _0x3f868a={'method':_0x0649('0x65'),'uri':_0x154139,'form':{'operation':_0x0649('0x66'),'username':_0x403e5a,'accessKey':md5(_0x12ad33[_0x0649('0x67')][_0x0649('0x68')]+_0x13e23d)},'json':!![]};return rp(_0x3f868a);}})['then'](function(_0x56c5da){if(_0x56c5da[_0x0649('0x64')]){var _0x36637d={'method':_0x0649('0x63'),'uri':_0x154139,'qs':{'operation':_0x0649('0x69'),'username':_0x403e5a,'sessionName':_0x56c5da[_0x0649('0x67')][_0x0649('0x6a')],'elementType':_0x5798c0},'json':!![]};return rp(_0x36637d);}})[_0x0649('0x2a')](function(_0x1c2f11){if(_0x1c2f11[_0x0649('0x64')]){var _0x4e392c=[_0x0649('0x6b'),'reference',_0x0649('0x6c')];_[_0x0649('0x6d')](_0x1c2f11[_0x0649('0x67')][_0x0649('0x39')],function(_0x5a4c07){return _0x4e392c['includes'](_0x5a4c07[_0x0649('0x31')][_0x0649('0x2d')]);});_[_0x0649('0x6d')](_0x1c2f11['result'][_0x0649('0x39')],function(_0x286dac){return _0x286dac[_0x0649('0x6e')]===_0x0649('0x6f');});return{'count':_0x1c2f11['result']['fields']['length'],'rows':_['map'](_0x1c2f11[_0x0649('0x67')][_0x0649('0x39')],function(_0x200d8f){return{'id':_0x200d8f[_0x0649('0x2d')],'name':_0x200d8f['label'],'custom':_['startsWith'](_0x200d8f[_0x0649('0x2d')],_0x0649('0x70'))?!![]:![],'options':_0x200d8f[_0x0649('0x31')][_0x0649('0x2d')]===_0x0649('0x71')&&_0x200d8f[_0x0649('0x31')][_0x0649('0x72')][_0x0649('0x3a')]>0x0?_[_0x0649('0x2e')](_0x200d8f['type'][_0x0649('0x72')],function(_0x3e3fa7){return{'name':_0x3e3fa7[_0x0649('0x73')],'value':_0x3e3fa7[_0x0649('0x74')]};}):[]};})};}})[_0x0649('0x2a')](respondWithResult(_0x2f6545,null))[_0x0649('0x48')](function(_0x13e378){console[_0x0649('0x75')](_0x0649('0x76')+_0x13e378);var _0x2ed43a=_0x577f18[_0x0649('0x34')]['test']?0x1f4:_0x13e378[_0x0649('0x77')]||0x1f4;logger[_0x0649('0x2b')](_0x0649('0x78'),_0x0649('0x58'),_0x2ed43a,JSON['stringify'](_0x13e378));delete _0x13e378[_0x0649('0x2d')];if(_0x2ed43a===0x191){_0x2ed43a=0x190;}_0x2f6545[_0x0649('0x1c')](_0x2ed43a)[_0x0649('0x79')](_0x577f18[_0x0649('0x34')]['test']?{'message':_0x0649('0x7a'),'statusCode':_0x13e378[_0x0649('0x77')]}:_0x13e378);});};
\ No newline at end of file