Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / intVtigerAccount / intVtigerAccount.controller.js
index 7b788d1..34bec6e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8470=['request','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug','VtigerAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','status','end','json','offset','limit','Content-Range','apply','reject','update','destroy','sendStatus','stack','name','send','index','map','VtigerAccount','rawAttributes','fieldName','keys','filters','model','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','count','includeAll','include','findAll','rows','catch','show','length','create','body','params','find','getConfigurations','findOne','VtigerConfiguration','channel','type','Descriptions','getDescriptions','VtigerField','Subjects','md5','getFields','username','description','moduleName','remoteUri','serverUrl','accessKey','slice','substring','lastIndexOf','format','GET','getchallenge','POST','result','describe','success','autogenerated','reference','remove','includes','editable','false','startsWith','cf_','picklistValues','label','value','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../components/integrations/configuration','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.'];(function(_0xc78df3,_0xf1ca58){var _0x2893b7=function(_0x2483f5){while(--_0x2483f5){_0xc78df3['push'](_0xc78df3['shift']());}};_0x2893b7(++_0xf1ca58);}(_0x8470,0x160));var _0x0847=function(_0x42279e,_0x299494){_0x42279e=_0x42279e-0x0;var _0x4bd0a4=_0x8470[_0x42279e];return _0x4bd0a4;};'use strict';var pdf=require(_0x0847('0x0'));var emlformat=require(_0x0847('0x1'));var rimraf=require(_0x0847('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0847('0x3'));var rp=require(_0x0847('0x4'));var moment=require(_0x0847('0x5'));var BPromise=require(_0x0847('0x6'));var Mustache=require(_0x0847('0x7'));var util=require(_0x0847('0x8'));var path=require(_0x0847('0x9'));var sox=require('sox');var csv=require(_0x0847('0xa'));var ejs=require(_0x0847('0xb'));var fs=require('fs');var _=require(_0x0847('0xc'));var squel=require('squel');var crypto=require(_0x0847('0xd'));var jsforce=require(_0x0847('0xe'));var deskjs=require(_0x0847('0xf'));var toCsv=require(_0x0847('0xa'));var querystring=require(_0x0847('0x10'));var Papa=require(_0x0847('0x11'));var Redis=require(_0x0847('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x0847('0x13'));var as=require(_0x0847('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0847('0x15'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];var integrations=require(_0x0847('0x16'));var jayson=require('jayson/promise');var client=jayson[_0x0847('0x17')][_0x0847('0x18')]({'port':0x232a});function checkPasswordPattern(_0x1b8ff5,_0x2e9667,_0x239f2a){if(_0x239f2a){var _0x392068=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x392068[_0x0847('0x19')](_0x2e9667)){return _0x1b8ff5;}else{throw new db[(_0x0847('0x1a'))][(_0x0847('0x1b'))](_0x0847('0x1c'));}}else{return _0x1b8ff5;}}function respondWithRpcPromise(_0x531f2c,_0x1f2d38,_0x56d1eb,_0x20f235){return new BPromise(function(_0x1b7291,_0x568381){var _0x465391=_0x20f235||client;return _0x465391[_0x0847('0x1d')](_0x531f2c,_0x56d1eb)[_0x0847('0x1e')](function(_0x4fe554){logger[_0x0847('0x1f')](_0x0847('0x20'),_0x1f2d38,_0x0847('0x21'));logger[_0x0847('0x22')](_0x0847('0x23'),_0x1f2d38,_0x0847('0x21'),JSON[_0x0847('0x24')](_0x4fe554));if(_0x4fe554[_0x0847('0x25')]){if(_0x4fe554[_0x0847('0x25')]['code']===0x1f4){logger[_0x0847('0x25')]('VtigerAccount,\x20%s,\x20%s',_0x1f2d38,_0x4fe554[_0x0847('0x25')][_0x0847('0x26')]);return _0x568381(_0x4fe554[_0x0847('0x25')][_0x0847('0x26')]);}logger[_0x0847('0x25')](_0x0847('0x20'),_0x1f2d38,_0x4fe554[_0x0847('0x25')][_0x0847('0x26')]);return _0x1b7291(_0x4fe554[_0x0847('0x25')][_0x0847('0x26')]);}else{logger[_0x0847('0x1f')](_0x0847('0x20'),_0x1f2d38,_0x0847('0x21'));_0x1b7291(_0x4fe554['result'][_0x0847('0x26')]);}})['catch'](function(_0x3d8778){logger[_0x0847('0x25')]('VtigerAccount,\x20%s,\x20%s',_0x1f2d38,_0x3d8778);_0x568381(_0x3d8778);});});}function respondWithStatusCode(_0x5769e6,_0x213e1f){_0x213e1f=_0x213e1f||0xcc;return function(_0x5b4660){if(_0x5b4660){return _0x5769e6['sendStatus'](_0x213e1f);}return _0x5769e6[_0x0847('0x27')](_0x213e1f)[_0x0847('0x28')]();};}function respondWithResult(_0x3dd08f,_0x44a77f){_0x44a77f=_0x44a77f||0xc8;return function(_0x4487d3){if(_0x4487d3){return _0x3dd08f[_0x0847('0x27')](_0x44a77f)[_0x0847('0x29')](_0x4487d3);}};}function respondWithFilteredResult(_0x260d9b,_0x119b55){return function(_0x5450dc){if(_0x5450dc){var _0x5b1d62=_0x5450dc['count'],_0x5ac98d=_0x119b55['offset'],_0x4cb4c6=_0x119b55[_0x0847('0x2a')]+_0x119b55[_0x0847('0x2b')],_0x10379e;if(_0x4cb4c6>=_0x5b1d62){_0x4cb4c6=_0x5b1d62;_0x10379e=0xc8;}else{_0x10379e=0xce;}_0x260d9b[_0x0847('0x27')](_0x10379e);return _0x260d9b['set'](_0x0847('0x2c'),_0x5ac98d+'-'+_0x4cb4c6+'/'+_0x5b1d62)['json'](_0x5450dc);}return null;};}function patchUpdates(_0x3047d){return function(_0x45bc3c){try{jsonpatch[_0x0847('0x2d')](_0x45bc3c,_0x3047d,!![]);}catch(_0x45bb5b){return BPromise[_0x0847('0x2e')](_0x45bb5b);}return _0x45bc3c['save']();};}function saveUpdates(_0xaecd88,_0x1b2b13){return function(_0x509f58){if(_0x509f58){return _0x509f58[_0x0847('0x2f')](_0xaecd88)[_0x0847('0x1e')](function(_0x59437a){return _0x59437a;});}return null;};}function removeEntity(_0x3a018b,_0x450fb9){return function(_0x8d3c3a){if(_0x8d3c3a){return _0x8d3c3a[_0x0847('0x30')]()['then'](function(){_0x3a018b[_0x0847('0x27')](0xcc)[_0x0847('0x28')]();});}};}function handleEntityNotFound(_0x5990cb,_0xdaba81){return function(_0x3c0b64){if(!_0x3c0b64){_0x5990cb[_0x0847('0x31')](0x194);}return _0x3c0b64;};}function handleError(_0x6516f2,_0x146a7c){_0x146a7c=_0x146a7c||0x1f4;return function(_0x32e1a8){logger[_0x0847('0x25')](_0x32e1a8[_0x0847('0x32')]);if(_0x32e1a8[_0x0847('0x33')]){delete _0x32e1a8[_0x0847('0x33')];}_0x6516f2[_0x0847('0x27')](_0x146a7c)[_0x0847('0x34')](_0x32e1a8);};}exports[_0x0847('0x35')]=function(_0x1ef0d7,_0x516a23){var _0x2b2996={},_0x27ee69={},_0x269b6a={'count':0x0,'rows':[]};var _0xae229f=_[_0x0847('0x36')](db[_0x0847('0x37')][_0x0847('0x38')],function(_0x38b861){return{'name':_0x38b861[_0x0847('0x39')],'type':_0x38b861['type']['key']};});_0x27ee69['model']=_[_0x0847('0x36')](_0xae229f,'name');_0x27ee69['query']=_[_0x0847('0x3a')](_0x1ef0d7['query']);_0x27ee69[_0x0847('0x3b')]=_['intersection'](_0x27ee69[_0x0847('0x3c')],_0x27ee69[_0x0847('0x3d')]);_0x2b2996['attributes']=_[_0x0847('0x3e')](_0x27ee69[_0x0847('0x3c')],qs[_0x0847('0x3f')](_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x3f')]));_0x2b2996[_0x0847('0x40')]=_0x2b2996['attributes']['length']?_0x2b2996['attributes']:_0x27ee69[_0x0847('0x3c')];if(!_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x41')](_0x0847('0x42'))){_0x2b2996['limit']=qs[_0x0847('0x2b')](_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x2b')]);_0x2b2996[_0x0847('0x2a')]=qs[_0x0847('0x2a')](_0x1ef0d7['query'][_0x0847('0x2a')]);}_0x2b2996[_0x0847('0x43')]=qs[_0x0847('0x44')](_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x44')]);_0x2b2996[_0x0847('0x45')]=qs[_0x0847('0x3b')](_[_0x0847('0x46')](_0x1ef0d7['query'],_0x27ee69[_0x0847('0x3b')]),_0xae229f);if(_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x47')]){_0x2b2996['where']=_[_0x0847('0x48')](_0x2b2996['where'],{'$or':_[_0x0847('0x36')](_0xae229f,function(_0x25d336){if(_0x25d336['type']!=='VIRTUAL'){var _0x4ea80e={};_0x4ea80e[_0x25d336[_0x0847('0x33')]]={'$like':'%'+_0x1ef0d7['query'][_0x0847('0x47')]+'%'};return _0x4ea80e;}})});}_0x2b2996=_[_0x0847('0x48')]({},_0x2b2996,_0x1ef0d7[_0x0847('0x49')]);var _0x1994b0={'where':_0x2b2996['where']};return db[_0x0847('0x37')][_0x0847('0x4a')](_0x1994b0)[_0x0847('0x1e')](function(_0x4e4992){_0x269b6a[_0x0847('0x4a')]=_0x4e4992;if(_0x1ef0d7[_0x0847('0x3d')][_0x0847('0x4b')]){_0x2b2996[_0x0847('0x4c')]=[{'all':!![]}];}return db[_0x0847('0x37')][_0x0847('0x4d')](_0x2b2996);})[_0x0847('0x1e')](function(_0x31560d){_0x269b6a[_0x0847('0x4e')]=_0x31560d;return _0x269b6a;})[_0x0847('0x1e')](respondWithFilteredResult(_0x516a23,_0x2b2996))[_0x0847('0x4f')](handleError(_0x516a23,null));};exports[_0x0847('0x50')]=function(_0x25e42a,_0x33c7ff){var _0x100274={'raw':![],'where':{'id':_0x25e42a['params']['id']}},_0x4f041d={};_0x4f041d[_0x0847('0x3c')]=_[_0x0847('0x3a')](db[_0x0847('0x37')][_0x0847('0x38')]);_0x4f041d[_0x0847('0x3d')]=_[_0x0847('0x3a')](_0x25e42a['query']);_0x4f041d['filters']=_['intersection'](_0x4f041d[_0x0847('0x3c')],_0x4f041d[_0x0847('0x3d')]);_0x100274[_0x0847('0x40')]=_[_0x0847('0x3e')](_0x4f041d[_0x0847('0x3c')],qs['fields'](_0x25e42a[_0x0847('0x3d')][_0x0847('0x3f')]));_0x100274[_0x0847('0x40')]=_0x100274[_0x0847('0x40')][_0x0847('0x51')]?_0x100274[_0x0847('0x40')]:_0x4f041d['model'];if(_0x25e42a[_0x0847('0x3d')][_0x0847('0x4b')]){_0x100274[_0x0847('0x4c')]=[{'all':!![]}];}_0x100274=_[_0x0847('0x48')]({},_0x100274,_0x25e42a[_0x0847('0x49')]);return db[_0x0847('0x37')]['find'](_0x100274)['then'](handleEntityNotFound(_0x33c7ff,null))[_0x0847('0x1e')](respondWithResult(_0x33c7ff,null))[_0x0847('0x4f')](handleError(_0x33c7ff,null));};exports['create']=function(_0x6b1d42,_0x3b6056){return db[_0x0847('0x37')][_0x0847('0x52')](_0x6b1d42[_0x0847('0x53')],{})[_0x0847('0x1e')](respondWithResult(_0x3b6056,0xc9))[_0x0847('0x4f')](handleError(_0x3b6056,null));};exports['update']=function(_0x412c72,_0x16302a){if(_0x412c72[_0x0847('0x53')]['id']){delete _0x412c72[_0x0847('0x53')]['id'];}return db[_0x0847('0x37')]['find']({'where':{'id':_0x412c72[_0x0847('0x54')]['id']}})[_0x0847('0x1e')](handleEntityNotFound(_0x16302a,null))[_0x0847('0x1e')](saveUpdates(_0x412c72[_0x0847('0x53')],null))['then'](respondWithResult(_0x16302a,null))['catch'](handleError(_0x16302a,null));};exports[_0x0847('0x30')]=function(_0x57303b,_0x1e8d3a){return db[_0x0847('0x37')][_0x0847('0x55')]({'where':{'id':_0x57303b['params']['id']}})[_0x0847('0x1e')](handleEntityNotFound(_0x1e8d3a,null))['then'](removeEntity(_0x1e8d3a,null))[_0x0847('0x4f')](handleError(_0x1e8d3a,null));};exports[_0x0847('0x56')]=function(_0x1bc5b6,_0x4b0dd5,_0x2d90d0){var _0x332d6c={};var _0x11aa46={};var _0x134c0a;var _0x37bdc6;return db[_0x0847('0x37')][_0x0847('0x57')]({'where':{'id':_0x1bc5b6[_0x0847('0x54')]['id']}})[_0x0847('0x1e')](handleEntityNotFound(_0x4b0dd5,null))[_0x0847('0x1e')](function(_0x5a7a93){if(_0x5a7a93){_0x134c0a=_0x5a7a93;_0x11aa46[_0x0847('0x3c')]=_[_0x0847('0x3a')](db[_0x0847('0x58')][_0x0847('0x38')]);_0x11aa46['query']=_[_0x0847('0x3a')](_0x1bc5b6[_0x0847('0x3d')]);_0x11aa46[_0x0847('0x3b')]=_[_0x0847('0x3e')](_0x11aa46[_0x0847('0x3c')],_0x11aa46[_0x0847('0x3d')]);_0x332d6c[_0x0847('0x40')]=_['intersection'](_0x11aa46['model'],qs[_0x0847('0x3f')](_0x1bc5b6[_0x0847('0x3d')][_0x0847('0x3f')]));_0x332d6c[_0x0847('0x40')]=_0x332d6c[_0x0847('0x40')][_0x0847('0x51')]?_0x332d6c[_0x0847('0x40')]:_0x11aa46[_0x0847('0x3c')];_0x332d6c[_0x0847('0x43')]=qs[_0x0847('0x44')](_0x1bc5b6[_0x0847('0x3d')][_0x0847('0x44')]);_0x332d6c['where']=qs[_0x0847('0x3b')](_[_0x0847('0x46')](_0x1bc5b6[_0x0847('0x3d')],_0x11aa46[_0x0847('0x3b')]));if(_0x1bc5b6[_0x0847('0x3d')]['filter']){_0x332d6c[_0x0847('0x45')]=_['merge'](_0x332d6c[_0x0847('0x45')],{'$or':_[_0x0847('0x36')](_0x332d6c[_0x0847('0x40')],function(_0x5c9f74){var _0x2c8947={};_0x2c8947[_0x5c9f74]={'$like':'%'+_0x1bc5b6[_0x0847('0x3d')]['filter']+'%'};return _0x2c8947;})});}_0x332d6c=_[_0x0847('0x48')]({},_0x332d6c,_0x1bc5b6[_0x0847('0x49')]);return _0x134c0a[_0x0847('0x56')](_0x332d6c);}})[_0x0847('0x1e')](function(_0x1a7707){if(_0x1a7707){_0x37bdc6=_0x1a7707['length'];if(!_0x1bc5b6[_0x0847('0x3d')]['hasOwnProperty'](_0x0847('0x42'))){_0x332d6c[_0x0847('0x2b')]=qs[_0x0847('0x2b')](_0x1bc5b6['query'][_0x0847('0x2b')]);_0x332d6c[_0x0847('0x2a')]=qs[_0x0847('0x2a')](_0x1bc5b6[_0x0847('0x3d')]['offset']);}return _0x134c0a['getConfigurations'](_0x332d6c);}})[_0x0847('0x1e')](function(_0x491dd2){if(_0x491dd2){return _0x491dd2?{'count':_0x37bdc6,'rows':_0x491dd2}:null;}})['then'](respondWithResult(_0x4b0dd5,null))[_0x0847('0x4f')](handleError(_0x4b0dd5,null));};exports['addConfiguration']=function(_0x1ea726,_0x403564,_0x30bbdb){if(_0x1ea726[_0x0847('0x53')]['id']){delete _0x1ea726[_0x0847('0x53')]['id'];}return db[_0x0847('0x37')][_0x0847('0x57')]({'where':{'id':_0x1ea726[_0x0847('0x54')]['id']}})[_0x0847('0x1e')](handleEntityNotFound(_0x403564,null))[_0x0847('0x1e')](function(_0x5c16d0){if(_0x5c16d0){_0x1ea726[_0x0847('0x53')]['AccountId']=_0x5c16d0['id'];_0x1ea726[_0x0847('0x53')]['Subjects']=integrations['getSubjects'](_0x1ea726[_0x0847('0x53')][_0x0847('0x59')],_0x1ea726[_0x0847('0x53')][_0x0847('0x5a')]);_0x1ea726[_0x0847('0x53')][_0x0847('0x5b')]=integrations[_0x0847('0x5c')](_0x1ea726[_0x0847('0x53')]['channel'],_0x1ea726[_0x0847('0x53')][_0x0847('0x5a')]);return db[_0x0847('0x58')][_0x0847('0x52')](_0x1ea726[_0x0847('0x53')],{'include':[{'model':db[_0x0847('0x5d')],'as':_0x0847('0x5e')},{'model':db[_0x0847('0x5d')],'as':_0x0847('0x5b')}]});}return null;})[_0x0847('0x1e')](respondWithResult(_0x403564,null))[_0x0847('0x4f')](handleError(_0x403564,null));};var md5=require(_0x0847('0x5f'));exports[_0x0847('0x60')]=function(_0x11994f,_0x5d1ed3,_0x1fbedd){var _0x39de99=null;var _0x352464=null;var _0x55b922=null;var _0x3f5ff0=null;var _0x407d5e='';return db[_0x0847('0x37')][_0x0847('0x57')]({'where':{'id':_0x11994f[_0x0847('0x54')]['id']},'attributes':['id',_0x0847('0x33'),_0x0847('0x61'),_0x0847('0x62'),_0x0847('0x63'),_0x0847('0x64'),_0x0847('0x65'),_0x0847('0x66')]})[_0x0847('0x1e')](handleEntityNotFound(_0x5d1ed3,null))[_0x0847('0x1e')](function(_0x3f85d8){if(_0x3f85d8){_0x39de99=_0x3f85d8[_0x0847('0x61')];_0x352464=_0x3f85d8[_0x0847('0x66')];_0x55b922=_0x3f85d8[_0x0847('0x63')];_0x407d5e=_0x3f85d8[_0x0847('0x64')];var _0xface3d=_0x407d5e[_0x0847('0x67')](-0x1);if(_0xface3d==='/'){_0x407d5e=_0x407d5e[_0x0847('0x68')](0x0,_0x407d5e[_0x0847('0x69')](_0xface3d));}_0x3f5ff0=util[_0x0847('0x6a')]('%s/webservice.php',_0x407d5e);var _0x4ea6b0={'method':_0x0847('0x6b'),'uri':_0x3f5ff0,'qs':{'operation':_0x0847('0x6c'),'username':_0x3f85d8['username']},'json':!![]};return rp(_0x4ea6b0);}})[_0x0847('0x1e')](function(_0x289f81){if(_0x289f81['success']){var _0x47cfc2={'method':_0x0847('0x6d'),'uri':_0x3f5ff0,'form':{'operation':'login','username':_0x39de99,'accessKey':md5(_0x289f81[_0x0847('0x6e')]['token']+_0x352464)},'json':!![]};return rp(_0x47cfc2);}})[_0x0847('0x1e')](function(_0x446c4d){if(_0x446c4d['success']){var _0x2353da={'method':_0x0847('0x6b'),'uri':_0x3f5ff0,'qs':{'operation':_0x0847('0x6f'),'username':_0x39de99,'sessionName':_0x446c4d[_0x0847('0x6e')]['sessionName'],'elementType':_0x55b922},'json':!![]};return rp(_0x2353da);}})[_0x0847('0x1e')](function(_0x6768a9){if(_0x6768a9[_0x0847('0x70')]){var _0x151a7f=[_0x0847('0x71'),_0x0847('0x72'),'owner'];_[_0x0847('0x73')](_0x6768a9[_0x0847('0x6e')][_0x0847('0x3f')],function(_0x52c1f7){return _0x151a7f[_0x0847('0x74')](_0x52c1f7[_0x0847('0x5a')]['name']);});_[_0x0847('0x73')](_0x6768a9['result'][_0x0847('0x3f')],function(_0xdd1c27){return _0xdd1c27[_0x0847('0x75')]===_0x0847('0x76');});return{'count':_0x6768a9[_0x0847('0x6e')][_0x0847('0x3f')][_0x0847('0x51')],'rows':_[_0x0847('0x36')](_0x6768a9[_0x0847('0x6e')][_0x0847('0x3f')],function(_0x2082c9){return{'id':_0x2082c9[_0x0847('0x33')],'name':_0x2082c9['label'],'custom':_[_0x0847('0x77')](_0x2082c9[_0x0847('0x33')],_0x0847('0x78'))?!![]:![],'options':_0x2082c9[_0x0847('0x5a')][_0x0847('0x33')]==='picklist'&&_0x2082c9[_0x0847('0x5a')][_0x0847('0x79')][_0x0847('0x51')]>0x0?_[_0x0847('0x36')](_0x2082c9['type'][_0x0847('0x79')],function(_0x1c0630){return{'name':_0x1c0630[_0x0847('0x7a')],'value':_0x1c0630[_0x0847('0x7b')]};}):[]};})};}})['then'](respondWithResult(_0x5d1ed3,null))[_0x0847('0x4f')](function(_0x589fa1){console['log']('vTiger\x20error:\x20'+_0x589fa1);var _0x60ba45=_0x11994f['query']['test']?0x1f4:_0x589fa1[_0x0847('0x7c')]||0x1f4;logger['error'](_0x0847('0x7d'),'getFields',_0x60ba45,JSON[_0x0847('0x24')](_0x589fa1));delete _0x589fa1['name'];if(_0x60ba45===0x191){_0x60ba45=0x190;}_0x5d1ed3[_0x0847('0x27')](_0x60ba45)[_0x0847('0x34')](_0x11994f[_0x0847('0x3d')][_0x0847('0x19')]?{'message':_0x0847('0x7e'),'statusCode':_0x589fa1[_0x0847('0x7c')]}:_0x589fa1);});};
\ No newline at end of file
+var _0xd0a9=['../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','sendStatus','status','end','undefined','limit','offset','count','Content-Range','apply','update','then','error','name','send','index','VtigerAccount','fieldName','model','map','query','keys','intersection','attributes','fields','nolimit','order','sort','filters','pick','filter','where','type','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','length','find','create','body','destroy','getConfigurations','findOne','VtigerConfiguration','rawAttributes','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','VtigerField','Descriptions','md5','getFields','username','description','serverUrl','accessKey','moduleName','substring','format','%s/webservice.php','getchallenge','success','POST','login','result','token','GET','describe','sessionName','autogenerated','reference','owner','remove','includes','false','label','cf_','picklist','picklistValues','value','log','vTiger\x20error:\x20','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse'];(function(_0x57e843,_0x1aed2d){var _0x54d548=function(_0x26185e){while(--_0x26185e){_0x57e843['push'](_0x57e843['shift']());}};_0x54d548(++_0x1aed2d);}(_0xd0a9,0x158));var _0x9d0a=function(_0xd1c39b,_0x16f0c6){_0xd1c39b=_0xd1c39b-0x0;var _0x58f5bc=_0xd0a9[_0xd1c39b];return _0x58f5bc;};'use strict';var emlformat=require(_0x9d0a('0x0'));var rimraf=require(_0x9d0a('0x1'));var zipdir=require(_0x9d0a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9d0a('0x3'));var moment=require(_0x9d0a('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x9d0a('0x5'));var util=require(_0x9d0a('0x6'));var path=require('path');var sox=require(_0x9d0a('0x7'));var csv=require(_0x9d0a('0x8'));var ejs=require(_0x9d0a('0x9'));var fs=require('fs');var fs_extra=require(_0x9d0a('0xa'));var _=require('lodash');var squel=require(_0x9d0a('0xb'));var crypto=require(_0x9d0a('0xc'));var jsforce=require(_0x9d0a('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x9d0a('0xe'));var Papa=require(_0x9d0a('0xf'));var Redis=require('ioredis');var authService=require(_0x9d0a('0x10'));var qs=require(_0x9d0a('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9d0a('0x12'));var logger=require('../../config/logger')(_0x9d0a('0x13'));var utils=require(_0x9d0a('0x14'));var config=require(_0x9d0a('0x15'));var licenseUtil=require(_0x9d0a('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0x9d0a('0x17'));function respondWithStatusCode(_0x1c8646,_0x14acc7){_0x14acc7=_0x14acc7||0xcc;return function(_0x56c1d8){if(_0x56c1d8){return _0x1c8646[_0x9d0a('0x18')](_0x14acc7);}return _0x1c8646[_0x9d0a('0x19')](_0x14acc7)[_0x9d0a('0x1a')]();};}function respondWithResult(_0x58b0c2,_0x5e6703){_0x5e6703=_0x5e6703||0xc8;return function(_0x16732a){if(_0x16732a){return _0x58b0c2[_0x9d0a('0x19')](_0x5e6703)['json'](_0x16732a);}};}function respondWithFilteredResult(_0x431b57,_0x1120ef){return function(_0x160608){if(_0x160608){var _0x237aee=typeof _0x1120ef['offset']===_0x9d0a('0x1b')&&typeof _0x1120ef[_0x9d0a('0x1c')]===_0x9d0a('0x1b');var _0x5006c3=_0x160608['count'];var _0x93eba5=_0x237aee?0x0:_0x1120ef[_0x9d0a('0x1d')];var _0x5b1591=_0x237aee?_0x160608[_0x9d0a('0x1e')]:_0x1120ef[_0x9d0a('0x1d')]+_0x1120ef[_0x9d0a('0x1c')];var _0x47d2a7;if(_0x5b1591>=_0x5006c3){_0x5b1591=_0x5006c3;_0x47d2a7=0xc8;}else{_0x47d2a7=0xce;}_0x431b57[_0x9d0a('0x19')](_0x47d2a7);return _0x431b57['set'](_0x9d0a('0x1f'),_0x93eba5+'-'+_0x5b1591+'/'+_0x5006c3)['json'](_0x160608);}return null;};}function patchUpdates(_0x16486a){return function(_0x5d173c){try{jsonpatch[_0x9d0a('0x20')](_0x5d173c,_0x16486a,!![]);}catch(_0xb64d0a){return BPromise['reject'](_0xb64d0a);}return _0x5d173c['save']();};}function saveUpdates(_0xf50c3e,_0x443b94){return function(_0x37c9e4){if(_0x37c9e4){return _0x37c9e4[_0x9d0a('0x21')](_0xf50c3e)[_0x9d0a('0x22')](function(_0x37c22e){return _0x37c22e;});}return null;};}function removeEntity(_0x3d3c56,_0xfce821){return function(_0x1da412){if(_0x1da412){return _0x1da412['destroy']()['then'](function(){_0x3d3c56[_0x9d0a('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3549e2,_0x3d3c2f){return function(_0xc4ca98){if(!_0xc4ca98){_0x3549e2[_0x9d0a('0x18')](0x194);}return _0xc4ca98;};}function handleError(_0x11a0d9,_0x830b9c){_0x830b9c=_0x830b9c||0x1f4;return function(_0x554df2){logger[_0x9d0a('0x23')](_0x554df2['stack']);if(_0x554df2[_0x9d0a('0x24')]){delete _0x554df2['name'];}_0x11a0d9[_0x9d0a('0x19')](_0x830b9c)[_0x9d0a('0x25')](_0x554df2);};}exports[_0x9d0a('0x26')]=function(_0x479846,_0x26364b){var _0x40155c={},_0x280be0={},_0x2a8ef7={'count':0x0,'rows':[]};var _0x28eeab=_['map'](db[_0x9d0a('0x27')]['rawAttributes'],function(_0xee6881){return{'name':_0xee6881[_0x9d0a('0x28')],'type':_0xee6881['type']['key']};});_0x280be0[_0x9d0a('0x29')]=_[_0x9d0a('0x2a')](_0x28eeab,_0x9d0a('0x24'));_0x280be0[_0x9d0a('0x2b')]=_[_0x9d0a('0x2c')](_0x479846[_0x9d0a('0x2b')]);_0x280be0['filters']=_[_0x9d0a('0x2d')](_0x280be0[_0x9d0a('0x29')],_0x280be0[_0x9d0a('0x2b')]);_0x40155c[_0x9d0a('0x2e')]=_[_0x9d0a('0x2d')](_0x280be0[_0x9d0a('0x29')],qs['fields'](_0x479846[_0x9d0a('0x2b')][_0x9d0a('0x2f')]));_0x40155c[_0x9d0a('0x2e')]=_0x40155c['attributes']['length']?_0x40155c[_0x9d0a('0x2e')]:_0x280be0['model'];if(!_0x479846[_0x9d0a('0x2b')]['hasOwnProperty'](_0x9d0a('0x30'))){_0x40155c[_0x9d0a('0x1c')]=qs[_0x9d0a('0x1c')](_0x479846[_0x9d0a('0x2b')]['limit']);_0x40155c[_0x9d0a('0x1d')]=qs[_0x9d0a('0x1d')](_0x479846['query'][_0x9d0a('0x1d')]);}_0x40155c[_0x9d0a('0x31')]=qs[_0x9d0a('0x32')](_0x479846[_0x9d0a('0x2b')][_0x9d0a('0x32')]);_0x40155c['where']=qs[_0x9d0a('0x33')](_[_0x9d0a('0x34')](_0x479846[_0x9d0a('0x2b')],_0x280be0['filters']),_0x28eeab);if(_0x479846[_0x9d0a('0x2b')][_0x9d0a('0x35')]){_0x40155c[_0x9d0a('0x36')]=_['merge'](_0x40155c['where'],{'$or':_['map'](_0x28eeab,function(_0x343e35){if(_0x343e35[_0x9d0a('0x37')]!==_0x9d0a('0x38')){var _0x4574e3={};_0x4574e3[_0x343e35[_0x9d0a('0x24')]]={'$like':'%'+_0x479846['query'][_0x9d0a('0x35')]+'%'};return _0x4574e3;}})});}_0x40155c=_[_0x9d0a('0x39')]({},_0x40155c,_0x479846[_0x9d0a('0x3a')]);var _0x532c71={'where':_0x40155c[_0x9d0a('0x36')]};return db[_0x9d0a('0x27')][_0x9d0a('0x1e')](_0x532c71)[_0x9d0a('0x22')](function(_0x23e423){_0x2a8ef7['count']=_0x23e423;if(_0x479846[_0x9d0a('0x2b')][_0x9d0a('0x3b')]){_0x40155c[_0x9d0a('0x3c')]=[{'all':!![]}];}return db['VtigerAccount'][_0x9d0a('0x3d')](_0x40155c);})[_0x9d0a('0x22')](function(_0x3389dd){_0x2a8ef7[_0x9d0a('0x3e')]=_0x3389dd;return _0x2a8ef7;})[_0x9d0a('0x22')](respondWithFilteredResult(_0x26364b,_0x40155c))[_0x9d0a('0x3f')](handleError(_0x26364b,null));};exports[_0x9d0a('0x40')]=function(_0x23469b,_0x44e2a9){var _0x3956f1={'raw':![],'where':{'id':_0x23469b[_0x9d0a('0x41')]['id']}},_0x59cba7={};_0x59cba7[_0x9d0a('0x29')]=_[_0x9d0a('0x2c')](db[_0x9d0a('0x27')]['rawAttributes']);_0x59cba7['query']=_[_0x9d0a('0x2c')](_0x23469b['query']);_0x59cba7[_0x9d0a('0x33')]=_['intersection'](_0x59cba7['model'],_0x59cba7['query']);_0x3956f1[_0x9d0a('0x2e')]=_[_0x9d0a('0x2d')](_0x59cba7[_0x9d0a('0x29')],qs[_0x9d0a('0x2f')](_0x23469b[_0x9d0a('0x2b')]['fields']));_0x3956f1[_0x9d0a('0x2e')]=_0x3956f1[_0x9d0a('0x2e')][_0x9d0a('0x42')]?_0x3956f1[_0x9d0a('0x2e')]:_0x59cba7[_0x9d0a('0x29')];if(_0x23469b['query'][_0x9d0a('0x3b')]){_0x3956f1[_0x9d0a('0x3c')]=[{'all':!![]}];}_0x3956f1=_[_0x9d0a('0x39')]({},_0x3956f1,_0x23469b[_0x9d0a('0x3a')]);return db[_0x9d0a('0x27')][_0x9d0a('0x43')](_0x3956f1)[_0x9d0a('0x22')](handleEntityNotFound(_0x44e2a9,null))[_0x9d0a('0x22')](respondWithResult(_0x44e2a9,null))[_0x9d0a('0x3f')](handleError(_0x44e2a9,null));};exports[_0x9d0a('0x44')]=function(_0x1f760f,_0x5c1280){return db[_0x9d0a('0x27')][_0x9d0a('0x44')](_0x1f760f[_0x9d0a('0x45')],{})[_0x9d0a('0x22')](respondWithResult(_0x5c1280,0xc9))[_0x9d0a('0x3f')](handleError(_0x5c1280,null));};exports[_0x9d0a('0x21')]=function(_0x22b10a,_0x52c941){if(_0x22b10a[_0x9d0a('0x45')]['id']){delete _0x22b10a[_0x9d0a('0x45')]['id'];}return db['VtigerAccount'][_0x9d0a('0x43')]({'where':{'id':_0x22b10a[_0x9d0a('0x41')]['id']}})[_0x9d0a('0x22')](handleEntityNotFound(_0x52c941,null))[_0x9d0a('0x22')](saveUpdates(_0x22b10a[_0x9d0a('0x45')],null))[_0x9d0a('0x22')](respondWithResult(_0x52c941,null))['catch'](handleError(_0x52c941,null));};exports[_0x9d0a('0x46')]=function(_0x4d7f4a,_0xf7a404){return db[_0x9d0a('0x27')]['find']({'where':{'id':_0x4d7f4a['params']['id']}})[_0x9d0a('0x22')](handleEntityNotFound(_0xf7a404,null))['then'](removeEntity(_0xf7a404,null))['catch'](handleError(_0xf7a404,null));};exports[_0x9d0a('0x47')]=function(_0x420c33,_0x14bd64,_0x1153b0){var _0x154329={};var _0x467b01={};var _0x23ba39;var _0x2a217f;return db['VtigerAccount'][_0x9d0a('0x48')]({'where':{'id':_0x420c33[_0x9d0a('0x41')]['id']}})['then'](handleEntityNotFound(_0x14bd64,null))[_0x9d0a('0x22')](function(_0x35df66){if(_0x35df66){_0x23ba39=_0x35df66;_0x467b01[_0x9d0a('0x29')]=_[_0x9d0a('0x2c')](db[_0x9d0a('0x49')][_0x9d0a('0x4a')]);_0x467b01[_0x9d0a('0x2b')]=_['keys'](_0x420c33[_0x9d0a('0x2b')]);_0x467b01[_0x9d0a('0x33')]=_[_0x9d0a('0x2d')](_0x467b01[_0x9d0a('0x29')],_0x467b01[_0x9d0a('0x2b')]);_0x154329['attributes']=_[_0x9d0a('0x2d')](_0x467b01[_0x9d0a('0x29')],qs['fields'](_0x420c33[_0x9d0a('0x2b')][_0x9d0a('0x2f')]));_0x154329[_0x9d0a('0x2e')]=_0x154329[_0x9d0a('0x2e')][_0x9d0a('0x42')]?_0x154329['attributes']:_0x467b01[_0x9d0a('0x29')];_0x154329[_0x9d0a('0x31')]=qs[_0x9d0a('0x32')](_0x420c33[_0x9d0a('0x2b')]['sort']);_0x154329[_0x9d0a('0x36')]=qs[_0x9d0a('0x33')](_['pick'](_0x420c33['query'],_0x467b01[_0x9d0a('0x33')]));if(_0x420c33[_0x9d0a('0x2b')][_0x9d0a('0x35')]){_0x154329['where']=_[_0x9d0a('0x39')](_0x154329['where'],{'$or':_[_0x9d0a('0x2a')](_0x154329[_0x9d0a('0x2e')],function(_0x30e3b4){var _0x4f3b49={};_0x4f3b49[_0x30e3b4]={'$like':'%'+_0x420c33[_0x9d0a('0x2b')]['filter']+'%'};return _0x4f3b49;})});}_0x154329=_['merge']({},_0x154329,_0x420c33['options']);return _0x23ba39['getConfigurations'](_0x154329);}})[_0x9d0a('0x22')](function(_0x118cb4){if(_0x118cb4){_0x2a217f=_0x118cb4[_0x9d0a('0x42')];if(!_0x420c33[_0x9d0a('0x2b')]['hasOwnProperty'](_0x9d0a('0x30'))){_0x154329['limit']=qs[_0x9d0a('0x1c')](_0x420c33[_0x9d0a('0x2b')][_0x9d0a('0x1c')]);_0x154329[_0x9d0a('0x1d')]=qs[_0x9d0a('0x1d')](_0x420c33[_0x9d0a('0x2b')][_0x9d0a('0x1d')]);}return _0x23ba39['getConfigurations'](_0x154329);}})[_0x9d0a('0x22')](function(_0x31433f){if(_0x31433f){return _0x31433f?{'count':_0x2a217f,'rows':_0x31433f}:null;}})['then'](respondWithResult(_0x14bd64,null))[_0x9d0a('0x3f')](handleError(_0x14bd64,null));};exports[_0x9d0a('0x4b')]=function(_0x3d49c4,_0x1429af,_0x45f0dd){if(_0x3d49c4[_0x9d0a('0x45')]['id']){delete _0x3d49c4['body']['id'];}return db[_0x9d0a('0x27')][_0x9d0a('0x48')]({'where':{'id':_0x3d49c4[_0x9d0a('0x41')]['id']}})['then'](handleEntityNotFound(_0x1429af,null))[_0x9d0a('0x22')](function(_0x5e9456){if(_0x5e9456){_0x3d49c4[_0x9d0a('0x45')][_0x9d0a('0x4c')]=_0x5e9456['id'];_0x3d49c4[_0x9d0a('0x45')][_0x9d0a('0x4d')]=integrations[_0x9d0a('0x4e')](_0x3d49c4['body'][_0x9d0a('0x4f')],_0x3d49c4[_0x9d0a('0x45')][_0x9d0a('0x37')]);_0x3d49c4[_0x9d0a('0x45')]['Descriptions']=integrations[_0x9d0a('0x50')](_0x3d49c4[_0x9d0a('0x45')][_0x9d0a('0x4f')],_0x3d49c4[_0x9d0a('0x45')][_0x9d0a('0x37')]);return db[_0x9d0a('0x49')][_0x9d0a('0x44')](_0x3d49c4[_0x9d0a('0x45')],{'include':[{'model':db[_0x9d0a('0x51')],'as':'Subjects'},{'model':db[_0x9d0a('0x51')],'as':_0x9d0a('0x52')}]});}return null;})[_0x9d0a('0x22')](respondWithResult(_0x1429af,null))[_0x9d0a('0x3f')](handleError(_0x1429af,null));};var md5=require(_0x9d0a('0x53'));exports[_0x9d0a('0x54')]=function(_0x650e79,_0x202d3f,_0x29692c){var _0x4908ed=null;var _0x5ed66d=null;var _0x82c82f=null;var _0x1f9fb7=null;var _0x5e5fc1='';return db[_0x9d0a('0x27')][_0x9d0a('0x48')]({'where':{'id':_0x650e79[_0x9d0a('0x41')]['id']},'attributes':['id',_0x9d0a('0x24'),_0x9d0a('0x55'),_0x9d0a('0x56'),'moduleName','remoteUri',_0x9d0a('0x57'),_0x9d0a('0x58')]})[_0x9d0a('0x22')](handleEntityNotFound(_0x202d3f,null))[_0x9d0a('0x22')](function(_0x52c00f){if(_0x52c00f){_0x4908ed=_0x52c00f['username'];_0x5ed66d=_0x52c00f[_0x9d0a('0x58')];_0x82c82f=_0x52c00f[_0x9d0a('0x59')];_0x5e5fc1=_0x52c00f['remoteUri'];var _0x15817b=_0x5e5fc1['slice'](-0x1);if(_0x15817b==='/'){_0x5e5fc1=_0x5e5fc1[_0x9d0a('0x5a')](0x0,_0x5e5fc1['lastIndexOf'](_0x15817b));}_0x1f9fb7=util[_0x9d0a('0x5b')](_0x9d0a('0x5c'),_0x5e5fc1);var _0x5a4db3={'method':'GET','uri':_0x1f9fb7,'qs':{'operation':_0x9d0a('0x5d'),'username':_0x52c00f['username']},'json':!![]};return rp(_0x5a4db3);}})[_0x9d0a('0x22')](function(_0x5b2cb8){if(_0x5b2cb8[_0x9d0a('0x5e')]){var _0xd12ea6={'method':_0x9d0a('0x5f'),'uri':_0x1f9fb7,'form':{'operation':_0x9d0a('0x60'),'username':_0x4908ed,'accessKey':md5(_0x5b2cb8[_0x9d0a('0x61')][_0x9d0a('0x62')]+_0x5ed66d)},'json':!![]};return rp(_0xd12ea6);}})[_0x9d0a('0x22')](function(_0x2de5bf){if(_0x2de5bf[_0x9d0a('0x5e')]){var _0x1c9407={'method':_0x9d0a('0x63'),'uri':_0x1f9fb7,'qs':{'operation':_0x9d0a('0x64'),'username':_0x4908ed,'sessionName':_0x2de5bf['result'][_0x9d0a('0x65')],'elementType':_0x82c82f},'json':!![]};return rp(_0x1c9407);}})[_0x9d0a('0x22')](function(_0x560050){if(_0x560050[_0x9d0a('0x5e')]){var _0x319175=[_0x9d0a('0x66'),_0x9d0a('0x67'),_0x9d0a('0x68')];_[_0x9d0a('0x69')](_0x560050['result'][_0x9d0a('0x2f')],function(_0x2677f3){return _0x319175[_0x9d0a('0x6a')](_0x2677f3['type'][_0x9d0a('0x24')]);});_[_0x9d0a('0x69')](_0x560050[_0x9d0a('0x61')]['fields'],function(_0x5681c5){return _0x5681c5['editable']===_0x9d0a('0x6b');});return{'count':_0x560050[_0x9d0a('0x61')]['fields'][_0x9d0a('0x42')],'rows':_['map'](_0x560050[_0x9d0a('0x61')][_0x9d0a('0x2f')],function(_0xf929c6){return{'id':_0xf929c6[_0x9d0a('0x24')],'name':_0xf929c6[_0x9d0a('0x6c')],'custom':_['startsWith'](_0xf929c6[_0x9d0a('0x24')],_0x9d0a('0x6d'))?!![]:![],'options':_0xf929c6[_0x9d0a('0x37')][_0x9d0a('0x24')]===_0x9d0a('0x6e')&&_0xf929c6[_0x9d0a('0x37')][_0x9d0a('0x6f')][_0x9d0a('0x42')]>0x0?_[_0x9d0a('0x2a')](_0xf929c6['type'][_0x9d0a('0x6f')],function(_0xd17157){return{'name':_0xd17157['label'],'value':_0xd17157[_0x9d0a('0x70')]};}):[]};})};}})[_0x9d0a('0x22')](respondWithResult(_0x202d3f,null))[_0x9d0a('0x3f')](function(_0x35fbfd){console[_0x9d0a('0x71')](_0x9d0a('0x72')+_0x35fbfd);var _0x144e39=_0x650e79[_0x9d0a('0x2b')][_0x9d0a('0x73')]?0x1f4:_0x35fbfd[_0x9d0a('0x74')]||0x1f4;logger[_0x9d0a('0x23')](_0x9d0a('0x75'),_0x9d0a('0x54'),_0x144e39,JSON[_0x9d0a('0x76')](_0x35fbfd));delete _0x35fbfd['name'];if(_0x144e39===0x191){_0x144e39=0x190;}_0x202d3f[_0x9d0a('0x19')](_0x144e39)[_0x9d0a('0x25')](_0x650e79['query'][_0x9d0a('0x73')]?{'message':_0x9d0a('0x77'),'statusCode':_0x35fbfd['statusCode']}:_0x35fbfd);});};
\ No newline at end of file