Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index bcbe0ff..fe417c6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf2f4=['intersection','fields','length','nolimit','where','filters','pick','filter','merge','VIRTUAL','options','VtigerConfiguration','findAll','rows','catch','params','include','create','body','find','getFields','findOne','VtigerField','order','hasOwnProperty','getSubjects','sort','getDescriptions','eml-format','fast-json-patch','moment','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','client','request','then','info','VtigerConfiguration,\x20%s,\x20%s','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','result','sendStatus','end','status','count','offset','limit','set','json','apply','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','query','attributes'];(function(_0x79ba6b,_0x57e634){var _0x349d1e=function(_0x11cb2e){while(--_0x11cb2e){_0x79ba6b['push'](_0x79ba6b['shift']());}};_0x349d1e(++_0x57e634);}(_0xf2f4,0x71));var _0x4f2f=function(_0x4b73a2,_0x40b5fe){_0x4b73a2=_0x4b73a2-0x0;var _0x383c66=_0xf2f4[_0x4b73a2];return _0x383c66;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x4f2f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x4f2f('0x1'));var rp=require('request-promise');var moment=require(_0x4f2f('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x4f2f('0x3'));var util=require(_0x4f2f('0x4'));var path=require(_0x4f2f('0x5'));var sox=require('sox');var csv=require(_0x4f2f('0x6'));var ejs=require(_0x4f2f('0x7'));var fs=require('fs');var _=require(_0x4f2f('0x8'));var squel=require(_0x4f2f('0x9'));var crypto=require(_0x4f2f('0xa'));var jsforce=require(_0x4f2f('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x4f2f('0x6'));var querystring=require(_0x4f2f('0xc'));var Papa=require(_0x4f2f('0xd'));var Redis=require(_0x4f2f('0xe'));var authService=require(_0x4f2f('0xf'));var qs=require(_0x4f2f('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4f2f('0x11'));var logger=require('../../config/logger')(_0x4f2f('0x12'));var utils=require(_0x4f2f('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x4f2f('0x14'));var db=require(_0x4f2f('0x15'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x4f2f('0x16')]['http']({'port':0x232a});function respondWithRpcPromise(_0x50a436,_0x52d305,_0x456ee4,_0x38691e){return new BPromise(function(_0x547602,_0x251011){var _0x222b81=_0x38691e||client;return _0x222b81[_0x4f2f('0x17')](_0x50a436,_0x456ee4)[_0x4f2f('0x18')](function(_0x46206d){logger[_0x4f2f('0x19')](_0x4f2f('0x1a'),_0x52d305,'request\x20sent');logger[_0x4f2f('0x1b')](_0x4f2f('0x1c'),_0x52d305,'request\x20sent',JSON[_0x4f2f('0x1d')](_0x46206d));if(_0x46206d[_0x4f2f('0x1e')]){if(_0x46206d['error']['code']===0x1f4){logger[_0x4f2f('0x1e')](_0x4f2f('0x1a'),_0x52d305,_0x46206d[_0x4f2f('0x1e')][_0x4f2f('0x1f')]);return _0x251011(_0x46206d[_0x4f2f('0x1e')]['message']);}logger[_0x4f2f('0x1e')](_0x4f2f('0x1a'),_0x52d305,_0x46206d[_0x4f2f('0x1e')][_0x4f2f('0x1f')]);return _0x547602(_0x46206d[_0x4f2f('0x1e')]['message']);}else{logger[_0x4f2f('0x19')](_0x4f2f('0x1a'),_0x52d305,_0x4f2f('0x20'));_0x547602(_0x46206d[_0x4f2f('0x21')][_0x4f2f('0x1f')]);}})['catch'](function(_0x3bd372){logger[_0x4f2f('0x1e')](_0x4f2f('0x1a'),_0x52d305,_0x3bd372);_0x251011(_0x3bd372);});});}function respondWithStatusCode(_0x4bfe38,_0x38b572){_0x38b572=_0x38b572||0xcc;return function(_0x5b9ca1){if(_0x5b9ca1){return _0x4bfe38[_0x4f2f('0x22')](_0x38b572);}return _0x4bfe38['status'](_0x38b572)[_0x4f2f('0x23')]();};}function respondWithResult(_0xa42016,_0x38b591){_0x38b591=_0x38b591||0xc8;return function(_0x121562){if(_0x121562){return _0xa42016[_0x4f2f('0x24')](_0x38b591)['json'](_0x121562);}};}function respondWithFilteredResult(_0x14f480,_0x5b1073){return function(_0x5b1872){if(_0x5b1872){var _0x51ecc4=_0x5b1872[_0x4f2f('0x25')],_0x12c602=_0x5b1073[_0x4f2f('0x26')],_0x378dde=_0x5b1073[_0x4f2f('0x26')]+_0x5b1073[_0x4f2f('0x27')],_0xc01c7;if(_0x378dde>=_0x51ecc4){_0x378dde=_0x51ecc4;_0xc01c7=0xc8;}else{_0xc01c7=0xce;}_0x14f480[_0x4f2f('0x24')](_0xc01c7);return _0x14f480[_0x4f2f('0x28')]('Content-Range',_0x12c602+'-'+_0x378dde+'/'+_0x51ecc4)[_0x4f2f('0x29')](_0x5b1872);}return null;};}function patchUpdates(_0x3895cb){return function(_0x5eb148){try{jsonpatch[_0x4f2f('0x2a')](_0x5eb148,_0x3895cb,!![]);}catch(_0xd5be62){return BPromise['reject'](_0xd5be62);}return _0x5eb148['save']();};}function saveUpdates(_0x38ca79,_0x1fa466){return function(_0x523a25){if(_0x523a25){return _0x523a25['update'](_0x38ca79)['then'](function(_0x552a0b){return _0x552a0b;});}return null;};}function removeEntity(_0x595c28,_0x205ae9){return function(_0x29a77b){if(_0x29a77b){return _0x29a77b[_0x4f2f('0x2b')]()['then'](function(){_0x595c28[_0x4f2f('0x24')](0xcc)[_0x4f2f('0x23')]();});}};}function handleEntityNotFound(_0x2cd2e8,_0x255b37){return function(_0x11e326){if(!_0x11e326){_0x2cd2e8[_0x4f2f('0x22')](0x194);}return _0x11e326;};}function handleError(_0x52bf53,_0x2f0c5b){_0x2f0c5b=_0x2f0c5b||0x1f4;return function(_0x52d5f1){logger[_0x4f2f('0x1e')](_0x52d5f1[_0x4f2f('0x2c')]);if(_0x52d5f1[_0x4f2f('0x2d')]){delete _0x52d5f1[_0x4f2f('0x2d')];}_0x52bf53[_0x4f2f('0x24')](_0x2f0c5b)[_0x4f2f('0x2e')](_0x52d5f1);};}exports[_0x4f2f('0x2f')]=function(_0x74bdd1,_0x263095){var _0x4fd365={},_0x59d919={},_0x4b9474={'count':0x0,'rows':[]};var _0x1d2e2c=_[_0x4f2f('0x30')](db['VtigerConfiguration'][_0x4f2f('0x31')],function(_0x301637){return{'name':_0x301637[_0x4f2f('0x32')],'type':_0x301637[_0x4f2f('0x33')][_0x4f2f('0x34')]};});_0x59d919[_0x4f2f('0x35')]=_[_0x4f2f('0x30')](_0x1d2e2c,_0x4f2f('0x2d'));_0x59d919['query']=_[_0x4f2f('0x36')](_0x74bdd1[_0x4f2f('0x37')]);_0x59d919['filters']=_['intersection'](_0x59d919[_0x4f2f('0x35')],_0x59d919[_0x4f2f('0x37')]);_0x4fd365[_0x4f2f('0x38')]=_[_0x4f2f('0x39')](_0x59d919['model'],qs[_0x4f2f('0x3a')](_0x74bdd1['query'][_0x4f2f('0x3a')]));_0x4fd365[_0x4f2f('0x38')]=_0x4fd365[_0x4f2f('0x38')][_0x4f2f('0x3b')]?_0x4fd365[_0x4f2f('0x38')]:_0x59d919[_0x4f2f('0x35')];if(!_0x74bdd1[_0x4f2f('0x37')]['hasOwnProperty'](_0x4f2f('0x3c'))){_0x4fd365[_0x4f2f('0x27')]=qs[_0x4f2f('0x27')](_0x74bdd1[_0x4f2f('0x37')][_0x4f2f('0x27')]);_0x4fd365[_0x4f2f('0x26')]=qs[_0x4f2f('0x26')](_0x74bdd1[_0x4f2f('0x37')]['offset']);}_0x4fd365['order']=qs['sort'](_0x74bdd1[_0x4f2f('0x37')]['sort']);_0x4fd365[_0x4f2f('0x3d')]=qs[_0x4f2f('0x3e')](_[_0x4f2f('0x3f')](_0x74bdd1[_0x4f2f('0x37')],_0x59d919[_0x4f2f('0x3e')]),_0x1d2e2c);if(_0x74bdd1['query'][_0x4f2f('0x40')]){_0x4fd365[_0x4f2f('0x3d')]=_[_0x4f2f('0x41')](_0x4fd365[_0x4f2f('0x3d')],{'$or':_[_0x4f2f('0x30')](_0x1d2e2c,function(_0x4a3817){if(_0x4a3817['type']!==_0x4f2f('0x42')){var _0x50c5d9={};_0x50c5d9[_0x4a3817[_0x4f2f('0x2d')]]={'$like':'%'+_0x74bdd1[_0x4f2f('0x37')][_0x4f2f('0x40')]+'%'};return _0x50c5d9;}})});}_0x4fd365=_[_0x4f2f('0x41')]({},_0x4fd365,_0x74bdd1[_0x4f2f('0x43')]);var _0x2cbae1={'where':_0x4fd365[_0x4f2f('0x3d')]};return db[_0x4f2f('0x44')]['count'](_0x2cbae1)[_0x4f2f('0x18')](function(_0x4b175b){_0x4b9474['count']=_0x4b175b;if(_0x74bdd1[_0x4f2f('0x37')]['includeAll']){_0x4fd365['include']=[{'all':!![]}];}return db['VtigerConfiguration'][_0x4f2f('0x45')](_0x4fd365);})[_0x4f2f('0x18')](function(_0x1943cf){_0x4b9474[_0x4f2f('0x46')]=_0x1943cf;return _0x4b9474;})['then'](respondWithFilteredResult(_0x263095,_0x4fd365))[_0x4f2f('0x47')](handleError(_0x263095,null));};exports['show']=function(_0xda4748,_0x42091c){var _0x3eedd8={'raw':![],'where':{'id':_0xda4748[_0x4f2f('0x48')]['id']}},_0x362dcb={};_0x362dcb[_0x4f2f('0x35')]=_[_0x4f2f('0x36')](db[_0x4f2f('0x44')][_0x4f2f('0x31')]);_0x362dcb[_0x4f2f('0x37')]=_[_0x4f2f('0x36')](_0xda4748[_0x4f2f('0x37')]);_0x362dcb[_0x4f2f('0x3e')]=_['intersection'](_0x362dcb[_0x4f2f('0x35')],_0x362dcb[_0x4f2f('0x37')]);_0x3eedd8[_0x4f2f('0x38')]=_[_0x4f2f('0x39')](_0x362dcb[_0x4f2f('0x35')],qs[_0x4f2f('0x3a')](_0xda4748[_0x4f2f('0x37')][_0x4f2f('0x3a')]));_0x3eedd8[_0x4f2f('0x38')]=_0x3eedd8[_0x4f2f('0x38')]['length']?_0x3eedd8[_0x4f2f('0x38')]:_0x362dcb[_0x4f2f('0x35')];if(_0xda4748['query']['includeAll']){_0x3eedd8[_0x4f2f('0x49')]=[{'all':!![]}];}_0x3eedd8=_['merge']({},_0x3eedd8,_0xda4748[_0x4f2f('0x43')]);return db[_0x4f2f('0x44')]['find'](_0x3eedd8)[_0x4f2f('0x18')](handleEntityNotFound(_0x42091c,null))[_0x4f2f('0x18')](respondWithResult(_0x42091c,null))['catch'](handleError(_0x42091c,null));};exports['create']=function(_0x1218cc,_0x5b6f09){return db[_0x4f2f('0x44')][_0x4f2f('0x4a')](_0x1218cc['body'],{})[_0x4f2f('0x18')](respondWithResult(_0x5b6f09,0xc9))[_0x4f2f('0x47')](handleError(_0x5b6f09,null));};exports['update']=function(_0x10a925,_0x478c04){if(_0x10a925[_0x4f2f('0x4b')]['id']){delete _0x10a925['body']['id'];}return db[_0x4f2f('0x44')][_0x4f2f('0x4c')]({'where':{'id':_0x10a925[_0x4f2f('0x48')]['id']}})[_0x4f2f('0x18')](handleEntityNotFound(_0x478c04,null))[_0x4f2f('0x18')](saveUpdates(_0x10a925[_0x4f2f('0x4b')],null))[_0x4f2f('0x18')](respondWithResult(_0x478c04,null))['catch'](handleError(_0x478c04,null));};exports['destroy']=function(_0x416647,_0x5167a3){return db[_0x4f2f('0x44')][_0x4f2f('0x4c')]({'where':{'id':_0x416647[_0x4f2f('0x48')]['id']}})[_0x4f2f('0x18')](handleEntityNotFound(_0x5167a3,null))[_0x4f2f('0x18')](removeEntity(_0x5167a3,null))[_0x4f2f('0x47')](handleError(_0x5167a3,null));};exports[_0x4f2f('0x4d')]=function(_0x140194,_0x1eb3a3,_0xc86018){var _0x18eef5={};var _0x51cd8f={};var _0x4bba73;var _0x9deb77;return db['VtigerConfiguration'][_0x4f2f('0x4e')]({'where':{'id':_0x140194[_0x4f2f('0x48')]['id']}})[_0x4f2f('0x18')](handleEntityNotFound(_0x1eb3a3,null))['then'](function(_0x5240f2){if(_0x5240f2){_0x4bba73=_0x5240f2;_0x51cd8f[_0x4f2f('0x35')]=_[_0x4f2f('0x36')](db[_0x4f2f('0x4f')]['rawAttributes']);_0x51cd8f[_0x4f2f('0x37')]=_[_0x4f2f('0x36')](_0x140194[_0x4f2f('0x37')]);_0x51cd8f['filters']=_[_0x4f2f('0x39')](_0x51cd8f[_0x4f2f('0x35')],_0x51cd8f[_0x4f2f('0x37')]);_0x18eef5['attributes']=_[_0x4f2f('0x39')](_0x51cd8f['model'],qs['fields'](_0x140194['query']['fields']));_0x18eef5[_0x4f2f('0x38')]=_0x18eef5[_0x4f2f('0x38')][_0x4f2f('0x3b')]?_0x18eef5['attributes']:_0x51cd8f[_0x4f2f('0x35')];_0x18eef5[_0x4f2f('0x50')]=qs['sort'](_0x140194['query']['sort']);_0x18eef5['where']=qs[_0x4f2f('0x3e')](_[_0x4f2f('0x3f')](_0x140194['query'],_0x51cd8f['filters']));if(_0x140194[_0x4f2f('0x37')][_0x4f2f('0x40')]){_0x18eef5[_0x4f2f('0x3d')]=_[_0x4f2f('0x41')](_0x18eef5['where'],{'$or':_[_0x4f2f('0x30')](_0x18eef5['attributes'],function(_0x39f59a){var _0x2b507e={};_0x2b507e[_0x39f59a]={'$like':'%'+_0x140194['query'][_0x4f2f('0x40')]+'%'};return _0x2b507e;})});}_0x18eef5=_['merge']({},_0x18eef5,_0x140194[_0x4f2f('0x43')]);return _0x4bba73[_0x4f2f('0x4d')](_0x18eef5);}})[_0x4f2f('0x18')](function(_0x113683){if(_0x113683){_0x9deb77=_0x113683[_0x4f2f('0x3b')];if(!_0x140194['query'][_0x4f2f('0x51')](_0x4f2f('0x3c'))){_0x18eef5[_0x4f2f('0x27')]=qs['limit'](_0x140194[_0x4f2f('0x37')][_0x4f2f('0x27')]);_0x18eef5[_0x4f2f('0x26')]=qs['offset'](_0x140194[_0x4f2f('0x37')][_0x4f2f('0x26')]);}return _0x4bba73['getFields'](_0x18eef5);}})['then'](function(_0x7e3e9a){if(_0x7e3e9a){return _0x7e3e9a?{'count':_0x9deb77,'rows':_0x7e3e9a}:null;}})['then'](respondWithResult(_0x1eb3a3,null))[_0x4f2f('0x47')](handleError(_0x1eb3a3,null));};exports[_0x4f2f('0x52')]=function(_0x57ec37,_0x2033f7,_0x5010e1){var _0x51cae1={};var _0x1c11a2={};var _0x2f8472;var _0x42398f;return db[_0x4f2f('0x44')][_0x4f2f('0x4e')]({'where':{'id':_0x57ec37[_0x4f2f('0x48')]['id']}})[_0x4f2f('0x18')](handleEntityNotFound(_0x2033f7,null))['then'](function(_0x4fa41a){if(_0x4fa41a){_0x2f8472=_0x4fa41a;_0x1c11a2['model']=_['keys'](db[_0x4f2f('0x4f')][_0x4f2f('0x31')]);_0x1c11a2[_0x4f2f('0x37')]=_['keys'](_0x57ec37[_0x4f2f('0x37')]);_0x1c11a2[_0x4f2f('0x3e')]=_[_0x4f2f('0x39')](_0x1c11a2[_0x4f2f('0x35')],_0x1c11a2[_0x4f2f('0x37')]);_0x51cae1[_0x4f2f('0x38')]=_[_0x4f2f('0x39')](_0x1c11a2[_0x4f2f('0x35')],qs[_0x4f2f('0x3a')](_0x57ec37[_0x4f2f('0x37')][_0x4f2f('0x3a')]));_0x51cae1[_0x4f2f('0x38')]=_0x51cae1['attributes'][_0x4f2f('0x3b')]?_0x51cae1['attributes']:_0x1c11a2['model'];_0x51cae1[_0x4f2f('0x50')]=qs[_0x4f2f('0x53')](_0x57ec37[_0x4f2f('0x37')][_0x4f2f('0x53')]);_0x51cae1[_0x4f2f('0x3d')]=qs[_0x4f2f('0x3e')](_[_0x4f2f('0x3f')](_0x57ec37[_0x4f2f('0x37')],_0x1c11a2[_0x4f2f('0x3e')]));if(_0x57ec37[_0x4f2f('0x37')]['filter']){_0x51cae1[_0x4f2f('0x3d')]=_[_0x4f2f('0x41')](_0x51cae1[_0x4f2f('0x3d')],{'$or':_[_0x4f2f('0x30')](_0x51cae1[_0x4f2f('0x38')],function(_0x487bdc){var _0x2d577d={};_0x2d577d[_0x487bdc]={'$like':'%'+_0x57ec37[_0x4f2f('0x37')][_0x4f2f('0x40')]+'%'};return _0x2d577d;})});}_0x51cae1=_['merge']({},_0x51cae1,_0x57ec37['options']);return _0x2f8472['getSubjects'](_0x51cae1);}})['then'](function(_0x2501c7){if(_0x2501c7){_0x42398f=_0x2501c7['length'];if(!_0x57ec37[_0x4f2f('0x37')][_0x4f2f('0x51')](_0x4f2f('0x3c'))){_0x51cae1[_0x4f2f('0x27')]=qs[_0x4f2f('0x27')](_0x57ec37[_0x4f2f('0x37')][_0x4f2f('0x27')]);_0x51cae1[_0x4f2f('0x26')]=qs[_0x4f2f('0x26')](_0x57ec37[_0x4f2f('0x37')]['offset']);}return _0x2f8472[_0x4f2f('0x52')](_0x51cae1);}})[_0x4f2f('0x18')](function(_0xdeb38e){if(_0xdeb38e){return _0xdeb38e?{'count':_0x42398f,'rows':_0xdeb38e}:null;}})[_0x4f2f('0x18')](respondWithResult(_0x2033f7,null))[_0x4f2f('0x47')](handleError(_0x2033f7,null));};exports[_0x4f2f('0x54')]=function(_0x341662,_0x1d30df,_0x3bae5a){var _0x33dbfa={};var _0x5ef1e3={};var _0x182d4e;var _0x5a4068;return db[_0x4f2f('0x44')][_0x4f2f('0x4e')]({'where':{'id':_0x341662[_0x4f2f('0x48')]['id']}})['then'](handleEntityNotFound(_0x1d30df,null))[_0x4f2f('0x18')](function(_0x5dbff9){if(_0x5dbff9){_0x182d4e=_0x5dbff9;_0x5ef1e3[_0x4f2f('0x35')]=_['keys'](db[_0x4f2f('0x4f')][_0x4f2f('0x31')]);_0x5ef1e3[_0x4f2f('0x37')]=_['keys'](_0x341662[_0x4f2f('0x37')]);_0x5ef1e3[_0x4f2f('0x3e')]=_[_0x4f2f('0x39')](_0x5ef1e3[_0x4f2f('0x35')],_0x5ef1e3['query']);_0x33dbfa[_0x4f2f('0x38')]=_[_0x4f2f('0x39')](_0x5ef1e3[_0x4f2f('0x35')],qs[_0x4f2f('0x3a')](_0x341662[_0x4f2f('0x37')][_0x4f2f('0x3a')]));_0x33dbfa['attributes']=_0x33dbfa[_0x4f2f('0x38')][_0x4f2f('0x3b')]?_0x33dbfa[_0x4f2f('0x38')]:_0x5ef1e3[_0x4f2f('0x35')];_0x33dbfa['order']=qs['sort'](_0x341662[_0x4f2f('0x37')][_0x4f2f('0x53')]);_0x33dbfa['where']=qs[_0x4f2f('0x3e')](_['pick'](_0x341662[_0x4f2f('0x37')],_0x5ef1e3['filters']));if(_0x341662[_0x4f2f('0x37')][_0x4f2f('0x40')]){_0x33dbfa[_0x4f2f('0x3d')]=_[_0x4f2f('0x41')](_0x33dbfa[_0x4f2f('0x3d')],{'$or':_[_0x4f2f('0x30')](_0x33dbfa[_0x4f2f('0x38')],function(_0xa86d88){var _0x47a2aa={};_0x47a2aa[_0xa86d88]={'$like':'%'+_0x341662[_0x4f2f('0x37')][_0x4f2f('0x40')]+'%'};return _0x47a2aa;})});}_0x33dbfa=_['merge']({},_0x33dbfa,_0x341662[_0x4f2f('0x43')]);return _0x182d4e[_0x4f2f('0x54')](_0x33dbfa);}})[_0x4f2f('0x18')](function(_0x2c27ea){if(_0x2c27ea){_0x5a4068=_0x2c27ea[_0x4f2f('0x3b')];if(!_0x341662[_0x4f2f('0x37')][_0x4f2f('0x51')](_0x4f2f('0x3c'))){_0x33dbfa[_0x4f2f('0x27')]=qs['limit'](_0x341662[_0x4f2f('0x37')][_0x4f2f('0x27')]);_0x33dbfa[_0x4f2f('0x26')]=qs[_0x4f2f('0x26')](_0x341662[_0x4f2f('0x37')][_0x4f2f('0x26')]);}return _0x182d4e[_0x4f2f('0x54')](_0x33dbfa);}})[_0x4f2f('0x18')](function(_0x32b990){if(_0x32b990){return _0x32b990?{'count':_0x5a4068,'rows':_0x32b990}:null;}})[_0x4f2f('0x18')](respondWithResult(_0x1d30df,null))[_0x4f2f('0x47')](handleError(_0x1d30df,null));};
\ No newline at end of file
+var _0x60c4=['update','then','destroy','sendStatus','error','map','VtigerConfiguration','rawAttributes','key','name','keys','query','filters','intersection','model','attributes','fields','nolimit','order','where','pick','filter','type','merge','options','include','findAll','catch','show','length','includeAll','find','create','body','params','getFields','findOne','VtigerField','sort','getSubjects','hasOwnProperty','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x60c4,0x10e));var _0x460c=function(_0x1a3cf8,_0x2c9d0c){_0x1a3cf8=_0x1a3cf8-0x0;var _0x5b0ced=_0x60c4[_0x1a3cf8];return _0x5b0ced;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x460c('0x0'));var zipdir=require(_0x460c('0x1'));var jsonpatch=require(_0x460c('0x2'));var rp=require(_0x460c('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x460c('0x4'));var util=require('util');var path=require(_0x460c('0x5'));var sox=require('sox');var csv=require(_0x460c('0x6'));var ejs=require(_0x460c('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x460c('0x8'));var squel=require(_0x460c('0x9'));var crypto=require(_0x460c('0xa'));var jsforce=require(_0x460c('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x460c('0x6'));var querystring=require('querystring');var Papa=require(_0x460c('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x460c('0xd'));var as=require(_0x460c('0xe'));var hardwareService=require(_0x460c('0xf'));var logger=require(_0x460c('0x10'))(_0x460c('0x11'));var utils=require(_0x460c('0x12'));var config=require(_0x460c('0x13'));var licenseUtil=require(_0x460c('0x14'));var db=require(_0x460c('0x15'))['db'];function respondWithStatusCode(_0x4472ef,_0x9f976e){_0x9f976e=_0x9f976e||0xcc;return function(_0x4b4293){if(_0x4b4293){return _0x4472ef['sendStatus'](_0x9f976e);}return _0x4472ef[_0x460c('0x16')](_0x9f976e)[_0x460c('0x17')]();};}function respondWithResult(_0x4aad07,_0x127f3f){_0x127f3f=_0x127f3f||0xc8;return function(_0x272cbd){if(_0x272cbd){return _0x4aad07[_0x460c('0x16')](_0x127f3f)[_0x460c('0x18')](_0x272cbd);}};}function respondWithFilteredResult(_0x14a935,_0x3012e9){return function(_0x4f7443){if(_0x4f7443){var _0x180c09=typeof _0x3012e9[_0x460c('0x19')]===_0x460c('0x1a')&&typeof _0x3012e9[_0x460c('0x1b')]===_0x460c('0x1a');var _0x13088f=_0x4f7443[_0x460c('0x1c')];var _0x17f2ee=_0x180c09?0x0:_0x3012e9[_0x460c('0x19')];var _0x187bc7=_0x180c09?_0x4f7443['count']:_0x3012e9[_0x460c('0x19')]+_0x3012e9[_0x460c('0x1b')];var _0x17e4d;if(_0x187bc7>=_0x13088f){_0x187bc7=_0x13088f;_0x17e4d=0xc8;}else{_0x17e4d=0xce;}_0x14a935[_0x460c('0x16')](_0x17e4d);return _0x14a935[_0x460c('0x1d')](_0x460c('0x1e'),_0x17f2ee+'-'+_0x187bc7+'/'+_0x13088f)[_0x460c('0x18')](_0x4f7443);}return null;};}function patchUpdates(_0x29bf23){return function(_0x22584d){try{jsonpatch[_0x460c('0x1f')](_0x22584d,_0x29bf23,!![]);}catch(_0x3b42ac){return BPromise[_0x460c('0x20')](_0x3b42ac);}return _0x22584d[_0x460c('0x21')]();};}function saveUpdates(_0x44630a,_0x2900f8){return function(_0x11e3a9){if(_0x11e3a9){return _0x11e3a9[_0x460c('0x22')](_0x44630a)[_0x460c('0x23')](function(_0x53c02d){return _0x53c02d;});}return null;};}function removeEntity(_0x20c56c,_0x4d0ac8){return function(_0x29145a){if(_0x29145a){return _0x29145a[_0x460c('0x24')]()[_0x460c('0x23')](function(){_0x20c56c[_0x460c('0x16')](0xcc)[_0x460c('0x17')]();});}};}function handleEntityNotFound(_0x1b8f0e,_0x1832ab){return function(_0x359174){if(!_0x359174){_0x1b8f0e[_0x460c('0x25')](0x194);}return _0x359174;};}function handleError(_0x106cb3,_0x8cf5fa){_0x8cf5fa=_0x8cf5fa||0x1f4;return function(_0x89800){logger[_0x460c('0x26')](_0x89800['stack']);if(_0x89800['name']){delete _0x89800['name'];}_0x106cb3[_0x460c('0x16')](_0x8cf5fa)['send'](_0x89800);};}exports['index']=function(_0x35d129,_0x4a18d0){var _0x302657={},_0x2f49ed={},_0x1aa227={'count':0x0,'rows':[]};var _0x323b4f=_[_0x460c('0x27')](db[_0x460c('0x28')][_0x460c('0x29')],function(_0x450a10){return{'name':_0x450a10['fieldName'],'type':_0x450a10['type'][_0x460c('0x2a')]};});_0x2f49ed['model']=_[_0x460c('0x27')](_0x323b4f,_0x460c('0x2b'));_0x2f49ed['query']=_[_0x460c('0x2c')](_0x35d129[_0x460c('0x2d')]);_0x2f49ed[_0x460c('0x2e')]=_[_0x460c('0x2f')](_0x2f49ed[_0x460c('0x30')],_0x2f49ed[_0x460c('0x2d')]);_0x302657[_0x460c('0x31')]=_['intersection'](_0x2f49ed[_0x460c('0x30')],qs[_0x460c('0x32')](_0x35d129[_0x460c('0x2d')][_0x460c('0x32')]));_0x302657['attributes']=_0x302657[_0x460c('0x31')]['length']?_0x302657['attributes']:_0x2f49ed[_0x460c('0x30')];if(!_0x35d129['query']['hasOwnProperty'](_0x460c('0x33'))){_0x302657[_0x460c('0x1b')]=qs[_0x460c('0x1b')](_0x35d129[_0x460c('0x2d')][_0x460c('0x1b')]);_0x302657[_0x460c('0x19')]=qs[_0x460c('0x19')](_0x35d129['query']['offset']);}_0x302657[_0x460c('0x34')]=qs['sort'](_0x35d129[_0x460c('0x2d')]['sort']);_0x302657[_0x460c('0x35')]=qs[_0x460c('0x2e')](_[_0x460c('0x36')](_0x35d129[_0x460c('0x2d')],_0x2f49ed[_0x460c('0x2e')]),_0x323b4f);if(_0x35d129[_0x460c('0x2d')][_0x460c('0x37')]){_0x302657[_0x460c('0x35')]=_['merge'](_0x302657[_0x460c('0x35')],{'$or':_[_0x460c('0x27')](_0x323b4f,function(_0x2e5b6d){if(_0x2e5b6d[_0x460c('0x38')]!=='VIRTUAL'){var _0x207057={};_0x207057[_0x2e5b6d['name']]={'$like':'%'+_0x35d129[_0x460c('0x2d')]['filter']+'%'};return _0x207057;}})});}_0x302657=_[_0x460c('0x39')]({},_0x302657,_0x35d129[_0x460c('0x3a')]);var _0x3f4a8a={'where':_0x302657[_0x460c('0x35')]};return db[_0x460c('0x28')][_0x460c('0x1c')](_0x3f4a8a)[_0x460c('0x23')](function(_0x4cad65){_0x1aa227[_0x460c('0x1c')]=_0x4cad65;if(_0x35d129['query']['includeAll']){_0x302657[_0x460c('0x3b')]=[{'all':!![]}];}return db[_0x460c('0x28')][_0x460c('0x3c')](_0x302657);})[_0x460c('0x23')](function(_0x5c61bb){_0x1aa227['rows']=_0x5c61bb;return _0x1aa227;})['then'](respondWithFilteredResult(_0x4a18d0,_0x302657))[_0x460c('0x3d')](handleError(_0x4a18d0,null));};exports[_0x460c('0x3e')]=function(_0x1b305e,_0x3f5fec){var _0x516b01={'raw':![],'where':{'id':_0x1b305e['params']['id']}},_0x446d4a={};_0x446d4a[_0x460c('0x30')]=_[_0x460c('0x2c')](db[_0x460c('0x28')]['rawAttributes']);_0x446d4a[_0x460c('0x2d')]=_[_0x460c('0x2c')](_0x1b305e['query']);_0x446d4a[_0x460c('0x2e')]=_[_0x460c('0x2f')](_0x446d4a['model'],_0x446d4a[_0x460c('0x2d')]);_0x516b01[_0x460c('0x31')]=_[_0x460c('0x2f')](_0x446d4a[_0x460c('0x30')],qs[_0x460c('0x32')](_0x1b305e[_0x460c('0x2d')][_0x460c('0x32')]));_0x516b01['attributes']=_0x516b01['attributes'][_0x460c('0x3f')]?_0x516b01[_0x460c('0x31')]:_0x446d4a[_0x460c('0x30')];if(_0x1b305e[_0x460c('0x2d')][_0x460c('0x40')]){_0x516b01[_0x460c('0x3b')]=[{'all':!![]}];}_0x516b01=_[_0x460c('0x39')]({},_0x516b01,_0x1b305e[_0x460c('0x3a')]);return db[_0x460c('0x28')][_0x460c('0x41')](_0x516b01)['then'](handleEntityNotFound(_0x3f5fec,null))[_0x460c('0x23')](respondWithResult(_0x3f5fec,null))[_0x460c('0x3d')](handleError(_0x3f5fec,null));};exports[_0x460c('0x42')]=function(_0x586247,_0x4d8a93){return db['VtigerConfiguration'][_0x460c('0x42')](_0x586247['body'],{})['then'](respondWithResult(_0x4d8a93,0xc9))[_0x460c('0x3d')](handleError(_0x4d8a93,null));};exports['update']=function(_0x1241a8,_0x21a10b){if(_0x1241a8[_0x460c('0x43')]['id']){delete _0x1241a8['body']['id'];}return db[_0x460c('0x28')]['find']({'where':{'id':_0x1241a8[_0x460c('0x44')]['id']}})[_0x460c('0x23')](handleEntityNotFound(_0x21a10b,null))[_0x460c('0x23')](saveUpdates(_0x1241a8['body'],null))[_0x460c('0x23')](respondWithResult(_0x21a10b,null))[_0x460c('0x3d')](handleError(_0x21a10b,null));};exports['destroy']=function(_0x4aa99c,_0x201a3a){return db[_0x460c('0x28')]['find']({'where':{'id':_0x4aa99c['params']['id']}})[_0x460c('0x23')](handleEntityNotFound(_0x201a3a,null))[_0x460c('0x23')](removeEntity(_0x201a3a,null))[_0x460c('0x3d')](handleError(_0x201a3a,null));};exports[_0x460c('0x45')]=function(_0x1ca61c,_0x59671a,_0x315707){var _0x317fd4={};var _0x3ff9d9={};var _0x40a2a8;var _0xd3ecf1;return db[_0x460c('0x28')][_0x460c('0x46')]({'where':{'id':_0x1ca61c[_0x460c('0x44')]['id']}})[_0x460c('0x23')](handleEntityNotFound(_0x59671a,null))[_0x460c('0x23')](function(_0x2437a0){if(_0x2437a0){_0x40a2a8=_0x2437a0;_0x3ff9d9[_0x460c('0x30')]=_[_0x460c('0x2c')](db[_0x460c('0x47')][_0x460c('0x29')]);_0x3ff9d9[_0x460c('0x2d')]=_['keys'](_0x1ca61c[_0x460c('0x2d')]);_0x3ff9d9['filters']=_[_0x460c('0x2f')](_0x3ff9d9[_0x460c('0x30')],_0x3ff9d9[_0x460c('0x2d')]);_0x317fd4['attributes']=_[_0x460c('0x2f')](_0x3ff9d9['model'],qs[_0x460c('0x32')](_0x1ca61c[_0x460c('0x2d')]['fields']));_0x317fd4[_0x460c('0x31')]=_0x317fd4[_0x460c('0x31')][_0x460c('0x3f')]?_0x317fd4[_0x460c('0x31')]:_0x3ff9d9[_0x460c('0x30')];_0x317fd4[_0x460c('0x34')]=qs[_0x460c('0x48')](_0x1ca61c[_0x460c('0x2d')][_0x460c('0x48')]);_0x317fd4['where']=qs[_0x460c('0x2e')](_[_0x460c('0x36')](_0x1ca61c[_0x460c('0x2d')],_0x3ff9d9['filters']));if(_0x1ca61c[_0x460c('0x2d')][_0x460c('0x37')]){_0x317fd4['where']=_[_0x460c('0x39')](_0x317fd4['where'],{'$or':_[_0x460c('0x27')](_0x317fd4[_0x460c('0x31')],function(_0x487925){var _0x599166={};_0x599166[_0x487925]={'$like':'%'+_0x1ca61c[_0x460c('0x2d')][_0x460c('0x37')]+'%'};return _0x599166;})});}_0x317fd4=_[_0x460c('0x39')]({},_0x317fd4,_0x1ca61c[_0x460c('0x3a')]);return _0x40a2a8[_0x460c('0x45')](_0x317fd4);}})['then'](function(_0x4a1fd9){if(_0x4a1fd9){_0xd3ecf1=_0x4a1fd9[_0x460c('0x3f')];if(!_0x1ca61c[_0x460c('0x2d')]['hasOwnProperty'](_0x460c('0x33'))){_0x317fd4[_0x460c('0x1b')]=qs[_0x460c('0x1b')](_0x1ca61c[_0x460c('0x2d')][_0x460c('0x1b')]);_0x317fd4[_0x460c('0x19')]=qs[_0x460c('0x19')](_0x1ca61c[_0x460c('0x2d')]['offset']);}return _0x40a2a8[_0x460c('0x45')](_0x317fd4);}})[_0x460c('0x23')](function(_0x36602a){if(_0x36602a){return _0x36602a?{'count':_0xd3ecf1,'rows':_0x36602a}:null;}})[_0x460c('0x23')](respondWithResult(_0x59671a,null))[_0x460c('0x3d')](handleError(_0x59671a,null));};exports[_0x460c('0x49')]=function(_0x4732dd,_0x2eb629,_0xfd144e){var _0x230ca0={};var _0x1e72a6={};var _0x394427;var _0x500434;return db[_0x460c('0x28')]['findOne']({'where':{'id':_0x4732dd[_0x460c('0x44')]['id']}})[_0x460c('0x23')](handleEntityNotFound(_0x2eb629,null))[_0x460c('0x23')](function(_0x114b97){if(_0x114b97){_0x394427=_0x114b97;_0x1e72a6['model']=_[_0x460c('0x2c')](db[_0x460c('0x47')]['rawAttributes']);_0x1e72a6['query']=_[_0x460c('0x2c')](_0x4732dd['query']);_0x1e72a6[_0x460c('0x2e')]=_[_0x460c('0x2f')](_0x1e72a6['model'],_0x1e72a6['query']);_0x230ca0['attributes']=_[_0x460c('0x2f')](_0x1e72a6[_0x460c('0x30')],qs['fields'](_0x4732dd['query'][_0x460c('0x32')]));_0x230ca0[_0x460c('0x31')]=_0x230ca0[_0x460c('0x31')][_0x460c('0x3f')]?_0x230ca0[_0x460c('0x31')]:_0x1e72a6[_0x460c('0x30')];_0x230ca0[_0x460c('0x34')]=qs[_0x460c('0x48')](_0x4732dd['query'][_0x460c('0x48')]);_0x230ca0['where']=qs[_0x460c('0x2e')](_[_0x460c('0x36')](_0x4732dd[_0x460c('0x2d')],_0x1e72a6[_0x460c('0x2e')]));if(_0x4732dd[_0x460c('0x2d')]['filter']){_0x230ca0[_0x460c('0x35')]=_['merge'](_0x230ca0['where'],{'$or':_['map'](_0x230ca0['attributes'],function(_0x1bb71e){var _0x1052b6={};_0x1052b6[_0x1bb71e]={'$like':'%'+_0x4732dd[_0x460c('0x2d')][_0x460c('0x37')]+'%'};return _0x1052b6;})});}_0x230ca0=_[_0x460c('0x39')]({},_0x230ca0,_0x4732dd[_0x460c('0x3a')]);return _0x394427[_0x460c('0x49')](_0x230ca0);}})['then'](function(_0x19a07f){if(_0x19a07f){_0x500434=_0x19a07f[_0x460c('0x3f')];if(!_0x4732dd[_0x460c('0x2d')][_0x460c('0x4a')](_0x460c('0x33'))){_0x230ca0[_0x460c('0x1b')]=qs[_0x460c('0x1b')](_0x4732dd[_0x460c('0x2d')][_0x460c('0x1b')]);_0x230ca0['offset']=qs[_0x460c('0x19')](_0x4732dd[_0x460c('0x2d')][_0x460c('0x19')]);}return _0x394427[_0x460c('0x49')](_0x230ca0);}})[_0x460c('0x23')](function(_0x3d119d){if(_0x3d119d){return _0x3d119d?{'count':_0x500434,'rows':_0x3d119d}:null;}})['then'](respondWithResult(_0x2eb629,null))[_0x460c('0x3d')](handleError(_0x2eb629,null));};exports[_0x460c('0x4b')]=function(_0x36d5bc,_0x3098ee,_0x5a7af3){var _0xcdd9be={};var _0x225884={};var _0x382093;var _0xc75b36;return db[_0x460c('0x28')]['findOne']({'where':{'id':_0x36d5bc[_0x460c('0x44')]['id']}})['then'](handleEntityNotFound(_0x3098ee,null))[_0x460c('0x23')](function(_0xb635f4){if(_0xb635f4){_0x382093=_0xb635f4;_0x225884[_0x460c('0x30')]=_[_0x460c('0x2c')](db[_0x460c('0x47')][_0x460c('0x29')]);_0x225884[_0x460c('0x2d')]=_['keys'](_0x36d5bc[_0x460c('0x2d')]);_0x225884['filters']=_['intersection'](_0x225884[_0x460c('0x30')],_0x225884[_0x460c('0x2d')]);_0xcdd9be[_0x460c('0x31')]=_[_0x460c('0x2f')](_0x225884[_0x460c('0x30')],qs[_0x460c('0x32')](_0x36d5bc[_0x460c('0x2d')][_0x460c('0x32')]));_0xcdd9be[_0x460c('0x31')]=_0xcdd9be[_0x460c('0x31')]['length']?_0xcdd9be[_0x460c('0x31')]:_0x225884['model'];_0xcdd9be[_0x460c('0x34')]=qs[_0x460c('0x48')](_0x36d5bc['query'][_0x460c('0x48')]);_0xcdd9be[_0x460c('0x35')]=qs['filters'](_[_0x460c('0x36')](_0x36d5bc[_0x460c('0x2d')],_0x225884[_0x460c('0x2e')]));if(_0x36d5bc[_0x460c('0x2d')][_0x460c('0x37')]){_0xcdd9be[_0x460c('0x35')]=_['merge'](_0xcdd9be[_0x460c('0x35')],{'$or':_[_0x460c('0x27')](_0xcdd9be[_0x460c('0x31')],function(_0x54b060){var _0x3fba00={};_0x3fba00[_0x54b060]={'$like':'%'+_0x36d5bc['query']['filter']+'%'};return _0x3fba00;})});}_0xcdd9be=_[_0x460c('0x39')]({},_0xcdd9be,_0x36d5bc[_0x460c('0x3a')]);return _0x382093[_0x460c('0x4b')](_0xcdd9be);}})[_0x460c('0x23')](function(_0x51b5eb){if(_0x51b5eb){_0xc75b36=_0x51b5eb[_0x460c('0x3f')];if(!_0x36d5bc[_0x460c('0x2d')][_0x460c('0x4a')](_0x460c('0x33'))){_0xcdd9be[_0x460c('0x1b')]=qs[_0x460c('0x1b')](_0x36d5bc[_0x460c('0x2d')]['limit']);_0xcdd9be['offset']=qs['offset'](_0x36d5bc[_0x460c('0x2d')][_0x460c('0x19')]);}return _0x382093['getDescriptions'](_0xcdd9be);}})[_0x460c('0x23')](function(_0xbafe6b){if(_0xbafe6b){return _0xbafe6b?{'count':_0xc75b36,'rows':_0xbafe6b}:null;}})[_0x460c('0x23')](respondWithResult(_0x3098ee,null))['catch'](handleError(_0x3098ee,null));};
\ No newline at end of file