Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index bcbe0ff..c8fa50a 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 _0xf364=['catch','params','keys','rawAttributes','length','includeAll','find','body','getFields','findOne','VtigerField','hasOwnProperty','getSubjects','getDescriptions','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','status','end','offset','undefined','limit','count','set','Content-Range','json','save','update','then','destroy','sendStatus','name','send','index','VtigerConfiguration','fieldName','type','key','model','map','query','filters','intersection','attributes','fields','nolimit','order','sort','where','pick','filter','merge','options','include','rows'];(function(_0xf35bc1,_0x510803){var _0xa6b162=function(_0x1e5cc8){while(--_0x1e5cc8){_0xf35bc1['push'](_0xf35bc1['shift']());}};_0xa6b162(++_0x510803);}(_0xf364,0x194));var _0x4f36=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0xf364[_0x46aff0];return _0x9d78cf;};'use strict';var emlformat=require(_0x4f36('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4f36('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4f36('0x2'));var moment=require(_0x4f36('0x3'));var BPromise=require(_0x4f36('0x4'));var Mustache=require(_0x4f36('0x5'));var util=require(_0x4f36('0x6'));var path=require(_0x4f36('0x7'));var sox=require(_0x4f36('0x8'));var csv=require(_0x4f36('0x9'));var ejs=require(_0x4f36('0xa'));var fs=require('fs');var fs_extra=require(_0x4f36('0xb'));var _=require('lodash');var squel=require(_0x4f36('0xc'));var crypto=require(_0x4f36('0xd'));var jsforce=require(_0x4f36('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x4f36('0x9'));var querystring=require(_0x4f36('0xf'));var Papa=require(_0x4f36('0x10'));var Redis=require(_0x4f36('0x11'));var authService=require(_0x4f36('0x12'));var qs=require(_0x4f36('0x13'));var as=require(_0x4f36('0x14'));var hardwareService=require(_0x4f36('0x15'));var logger=require(_0x4f36('0x16'))(_0x4f36('0x17'));var utils=require(_0x4f36('0x18'));var config=require(_0x4f36('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x597b0,_0x3c4990){_0x3c4990=_0x3c4990||0xcc;return function(_0x45bc73){if(_0x45bc73){return _0x597b0['sendStatus'](_0x3c4990);}return _0x597b0[_0x4f36('0x1a')](_0x3c4990)[_0x4f36('0x1b')]();};}function respondWithResult(_0x133cc1,_0x3f3638){_0x3f3638=_0x3f3638||0xc8;return function(_0x54fdfe){if(_0x54fdfe){return _0x133cc1['status'](_0x3f3638)['json'](_0x54fdfe);}};}function respondWithFilteredResult(_0x4c4dfe,_0x16dd5f){return function(_0x35b723){if(_0x35b723){var _0x45b5b2=typeof _0x16dd5f[_0x4f36('0x1c')]===_0x4f36('0x1d')&&typeof _0x16dd5f[_0x4f36('0x1e')]===_0x4f36('0x1d');var _0x1218f8=_0x35b723[_0x4f36('0x1f')];var _0x27a4e4=_0x45b5b2?0x0:_0x16dd5f[_0x4f36('0x1c')];var _0x4d759b=_0x45b5b2?_0x35b723[_0x4f36('0x1f')]:_0x16dd5f[_0x4f36('0x1c')]+_0x16dd5f['limit'];var _0x44a0e6;if(_0x4d759b>=_0x1218f8){_0x4d759b=_0x1218f8;_0x44a0e6=0xc8;}else{_0x44a0e6=0xce;}_0x4c4dfe['status'](_0x44a0e6);return _0x4c4dfe[_0x4f36('0x20')](_0x4f36('0x21'),_0x27a4e4+'-'+_0x4d759b+'/'+_0x1218f8)[_0x4f36('0x22')](_0x35b723);}return null;};}function patchUpdates(_0x1e7dac){return function(_0x2f1e9a){try{jsonpatch['apply'](_0x2f1e9a,_0x1e7dac,!![]);}catch(_0x3573b6){return BPromise['reject'](_0x3573b6);}return _0x2f1e9a[_0x4f36('0x23')]();};}function saveUpdates(_0x10a3fa,_0x445d0d){return function(_0x191540){if(_0x191540){return _0x191540[_0x4f36('0x24')](_0x10a3fa)[_0x4f36('0x25')](function(_0x4480d3){return _0x4480d3;});}return null;};}function removeEntity(_0x2be18f,_0x1534ad){return function(_0x2c3c6c){if(_0x2c3c6c){return _0x2c3c6c[_0x4f36('0x26')]()['then'](function(){_0x2be18f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5b3385,_0x13edc5){return function(_0x1efc0c){if(!_0x1efc0c){_0x5b3385[_0x4f36('0x27')](0x194);}return _0x1efc0c;};}function handleError(_0xe958bc,_0x548d7c){_0x548d7c=_0x548d7c||0x1f4;return function(_0x2d84a8){logger['error'](_0x2d84a8['stack']);if(_0x2d84a8[_0x4f36('0x28')]){delete _0x2d84a8['name'];}_0xe958bc[_0x4f36('0x1a')](_0x548d7c)[_0x4f36('0x29')](_0x2d84a8);};}exports[_0x4f36('0x2a')]=function(_0x6b5fd2,_0x59fd98){var _0x456ced={},_0xc060e2={},_0x12c86f={'count':0x0,'rows':[]};var _0x592edd=_['map'](db[_0x4f36('0x2b')]['rawAttributes'],function(_0x1552d2){return{'name':_0x1552d2[_0x4f36('0x2c')],'type':_0x1552d2[_0x4f36('0x2d')][_0x4f36('0x2e')]};});_0xc060e2[_0x4f36('0x2f')]=_[_0x4f36('0x30')](_0x592edd,_0x4f36('0x28'));_0xc060e2[_0x4f36('0x31')]=_['keys'](_0x6b5fd2[_0x4f36('0x31')]);_0xc060e2[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0xc060e2[_0x4f36('0x2f')],_0xc060e2[_0x4f36('0x31')]);_0x456ced[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0xc060e2[_0x4f36('0x2f')],qs['fields'](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x35')]));_0x456ced['attributes']=_0x456ced[_0x4f36('0x34')]['length']?_0x456ced['attributes']:_0xc060e2[_0x4f36('0x2f')];if(!_0x6b5fd2[_0x4f36('0x31')]['hasOwnProperty'](_0x4f36('0x36'))){_0x456ced[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x1e')]);_0x456ced[_0x4f36('0x1c')]=qs[_0x4f36('0x1c')](_0x6b5fd2[_0x4f36('0x31')]['offset']);}_0x456ced[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x38')]);_0x456ced[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_[_0x4f36('0x3a')](_0x6b5fd2[_0x4f36('0x31')],_0xc060e2['filters']),_0x592edd);if(_0x6b5fd2['query'][_0x4f36('0x3b')]){_0x456ced[_0x4f36('0x39')]=_[_0x4f36('0x3c')](_0x456ced['where'],{'$or':_['map'](_0x592edd,function(_0x2352cb){if(_0x2352cb['type']!=='VIRTUAL'){var _0x24fd88={};_0x24fd88[_0x2352cb[_0x4f36('0x28')]]={'$like':'%'+_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x24fd88;}})});}_0x456ced=_[_0x4f36('0x3c')]({},_0x456ced,_0x6b5fd2[_0x4f36('0x3d')]);var _0x1d1a17={'where':_0x456ced[_0x4f36('0x39')]};return db[_0x4f36('0x2b')][_0x4f36('0x1f')](_0x1d1a17)[_0x4f36('0x25')](function(_0x40abc4){_0x12c86f[_0x4f36('0x1f')]=_0x40abc4;if(_0x6b5fd2['query']['includeAll']){_0x456ced[_0x4f36('0x3e')]=[{'all':!![]}];}return db['VtigerConfiguration']['findAll'](_0x456ced);})[_0x4f36('0x25')](function(_0x1224af){_0x12c86f[_0x4f36('0x3f')]=_0x1224af;return _0x12c86f;})[_0x4f36('0x25')](respondWithFilteredResult(_0x59fd98,_0x456ced))[_0x4f36('0x40')](handleError(_0x59fd98,null));};exports['show']=function(_0x37586f,_0x5d33ae){var _0x5351bc={'raw':![],'where':{'id':_0x37586f[_0x4f36('0x41')]['id']}},_0x35ba28={};_0x35ba28[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db['VtigerConfiguration'][_0x4f36('0x43')]);_0x35ba28['query']=_[_0x4f36('0x42')](_0x37586f[_0x4f36('0x31')]);_0x35ba28['filters']=_[_0x4f36('0x33')](_0x35ba28[_0x4f36('0x2f')],_0x35ba28[_0x4f36('0x31')]);_0x5351bc[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x35ba28[_0x4f36('0x2f')],qs['fields'](_0x37586f[_0x4f36('0x31')][_0x4f36('0x35')]));_0x5351bc['attributes']=_0x5351bc[_0x4f36('0x34')][_0x4f36('0x44')]?_0x5351bc[_0x4f36('0x34')]:_0x35ba28[_0x4f36('0x2f')];if(_0x37586f[_0x4f36('0x31')][_0x4f36('0x45')]){_0x5351bc[_0x4f36('0x3e')]=[{'all':!![]}];}_0x5351bc=_[_0x4f36('0x3c')]({},_0x5351bc,_0x37586f['options']);return db['VtigerConfiguration'][_0x4f36('0x46')](_0x5351bc)[_0x4f36('0x25')](handleEntityNotFound(_0x5d33ae,null))[_0x4f36('0x25')](respondWithResult(_0x5d33ae,null))[_0x4f36('0x40')](handleError(_0x5d33ae,null));};exports['create']=function(_0x3a9cac,_0x223055){return db['VtigerConfiguration']['create'](_0x3a9cac[_0x4f36('0x47')],{})[_0x4f36('0x25')](respondWithResult(_0x223055,0xc9))[_0x4f36('0x40')](handleError(_0x223055,null));};exports[_0x4f36('0x24')]=function(_0x58ff54,_0x3ecf86){if(_0x58ff54[_0x4f36('0x47')]['id']){delete _0x58ff54['body']['id'];}return db[_0x4f36('0x2b')][_0x4f36('0x46')]({'where':{'id':_0x58ff54[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x3ecf86,null))[_0x4f36('0x25')](saveUpdates(_0x58ff54[_0x4f36('0x47')],null))['then'](respondWithResult(_0x3ecf86,null))[_0x4f36('0x40')](handleError(_0x3ecf86,null));};exports[_0x4f36('0x26')]=function(_0x17899b,_0x3b7347){return db[_0x4f36('0x2b')][_0x4f36('0x46')]({'where':{'id':_0x17899b['params']['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x3b7347,null))[_0x4f36('0x25')](removeEntity(_0x3b7347,null))[_0x4f36('0x40')](handleError(_0x3b7347,null));};exports[_0x4f36('0x48')]=function(_0x523f64,_0x54dca6,_0x3e37f8){var _0x267b06={};var _0x1a7417={};var _0xa07cc0;var _0xa3bc25;return db[_0x4f36('0x2b')][_0x4f36('0x49')]({'where':{'id':_0x523f64['params']['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x54dca6,null))[_0x4f36('0x25')](function(_0x6baf9f){if(_0x6baf9f){_0xa07cc0=_0x6baf9f;_0x1a7417[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db[_0x4f36('0x4a')][_0x4f36('0x43')]);_0x1a7417[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x523f64[_0x4f36('0x31')]);_0x1a7417[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0x1a7417[_0x4f36('0x2f')],_0x1a7417['query']);_0x267b06[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x1a7417[_0x4f36('0x2f')],qs['fields'](_0x523f64[_0x4f36('0x31')][_0x4f36('0x35')]));_0x267b06[_0x4f36('0x34')]=_0x267b06[_0x4f36('0x34')]['length']?_0x267b06['attributes']:_0x1a7417[_0x4f36('0x2f')];_0x267b06[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x523f64['query'][_0x4f36('0x38')]);_0x267b06[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_['pick'](_0x523f64[_0x4f36('0x31')],_0x1a7417[_0x4f36('0x32')]));if(_0x523f64[_0x4f36('0x31')][_0x4f36('0x3b')]){_0x267b06[_0x4f36('0x39')]=_['merge'](_0x267b06[_0x4f36('0x39')],{'$or':_[_0x4f36('0x30')](_0x267b06['attributes'],function(_0x3abdb4){var _0x400fc2={};_0x400fc2[_0x3abdb4]={'$like':'%'+_0x523f64['query'][_0x4f36('0x3b')]+'%'};return _0x400fc2;})});}_0x267b06=_[_0x4f36('0x3c')]({},_0x267b06,_0x523f64[_0x4f36('0x3d')]);return _0xa07cc0[_0x4f36('0x48')](_0x267b06);}})[_0x4f36('0x25')](function(_0x214410){if(_0x214410){_0xa3bc25=_0x214410['length'];if(!_0x523f64[_0x4f36('0x31')][_0x4f36('0x4b')](_0x4f36('0x36'))){_0x267b06[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x523f64['query'][_0x4f36('0x1e')]);_0x267b06[_0x4f36('0x1c')]=qs[_0x4f36('0x1c')](_0x523f64[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0xa07cc0[_0x4f36('0x48')](_0x267b06);}})[_0x4f36('0x25')](function(_0x165b2f){if(_0x165b2f){return _0x165b2f?{'count':_0xa3bc25,'rows':_0x165b2f}:null;}})[_0x4f36('0x25')](respondWithResult(_0x54dca6,null))[_0x4f36('0x40')](handleError(_0x54dca6,null));};exports['getSubjects']=function(_0x13758b,_0x4b7f57,_0x814cc4){var _0x30d4df={};var _0x47e611={};var _0x17d772;var _0x725ea0;return db[_0x4f36('0x2b')][_0x4f36('0x49')]({'where':{'id':_0x13758b[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x4b7f57,null))[_0x4f36('0x25')](function(_0x569e4c){if(_0x569e4c){_0x17d772=_0x569e4c;_0x47e611[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db['VtigerField']['rawAttributes']);_0x47e611[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x13758b[_0x4f36('0x31')]);_0x47e611['filters']=_[_0x4f36('0x33')](_0x47e611[_0x4f36('0x2f')],_0x47e611[_0x4f36('0x31')]);_0x30d4df[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x47e611[_0x4f36('0x2f')],qs[_0x4f36('0x35')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x35')]));_0x30d4df['attributes']=_0x30d4df[_0x4f36('0x34')]['length']?_0x30d4df[_0x4f36('0x34')]:_0x47e611[_0x4f36('0x2f')];_0x30d4df[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x13758b[_0x4f36('0x31')]['sort']);_0x30d4df[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_['pick'](_0x13758b[_0x4f36('0x31')],_0x47e611[_0x4f36('0x32')]));if(_0x13758b[_0x4f36('0x31')]['filter']){_0x30d4df['where']=_[_0x4f36('0x3c')](_0x30d4df[_0x4f36('0x39')],{'$or':_['map'](_0x30d4df[_0x4f36('0x34')],function(_0x1c6b10){var _0x1089d4={};_0x1089d4[_0x1c6b10]={'$like':'%'+_0x13758b[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x1089d4;})});}_0x30d4df=_['merge']({},_0x30d4df,_0x13758b[_0x4f36('0x3d')]);return _0x17d772[_0x4f36('0x4c')](_0x30d4df);}})[_0x4f36('0x25')](function(_0x47f166){if(_0x47f166){_0x725ea0=_0x47f166[_0x4f36('0x44')];if(!_0x13758b[_0x4f36('0x31')][_0x4f36('0x4b')](_0x4f36('0x36'))){_0x30d4df[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x1e')]);_0x30d4df['offset']=qs[_0x4f36('0x1c')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0x17d772['getSubjects'](_0x30d4df);}})['then'](function(_0x666658){if(_0x666658){return _0x666658?{'count':_0x725ea0,'rows':_0x666658}:null;}})['then'](respondWithResult(_0x4b7f57,null))[_0x4f36('0x40')](handleError(_0x4b7f57,null));};exports[_0x4f36('0x4d')]=function(_0x543a4e,_0x392de7,_0xb78356){var _0x2db9f3={};var _0x440f03={};var _0x492c64;var _0x1def89;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x543a4e[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x392de7,null))[_0x4f36('0x25')](function(_0x3f03af){if(_0x3f03af){_0x492c64=_0x3f03af;_0x440f03[_0x4f36('0x2f')]=_['keys'](db[_0x4f36('0x4a')][_0x4f36('0x43')]);_0x440f03[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x543a4e['query']);_0x440f03[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0x440f03[_0x4f36('0x2f')],_0x440f03[_0x4f36('0x31')]);_0x2db9f3[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x440f03['model'],qs[_0x4f36('0x35')](_0x543a4e[_0x4f36('0x31')]['fields']));_0x2db9f3[_0x4f36('0x34')]=_0x2db9f3[_0x4f36('0x34')][_0x4f36('0x44')]?_0x2db9f3[_0x4f36('0x34')]:_0x440f03[_0x4f36('0x2f')];_0x2db9f3[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x543a4e[_0x4f36('0x31')][_0x4f36('0x38')]);_0x2db9f3['where']=qs[_0x4f36('0x32')](_[_0x4f36('0x3a')](_0x543a4e[_0x4f36('0x31')],_0x440f03[_0x4f36('0x32')]));if(_0x543a4e[_0x4f36('0x31')][_0x4f36('0x3b')]){_0x2db9f3[_0x4f36('0x39')]=_[_0x4f36('0x3c')](_0x2db9f3[_0x4f36('0x39')],{'$or':_[_0x4f36('0x30')](_0x2db9f3[_0x4f36('0x34')],function(_0x18c27b){var _0x199a00={};_0x199a00[_0x18c27b]={'$like':'%'+_0x543a4e[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x199a00;})});}_0x2db9f3=_[_0x4f36('0x3c')]({},_0x2db9f3,_0x543a4e[_0x4f36('0x3d')]);return _0x492c64[_0x4f36('0x4d')](_0x2db9f3);}})['then'](function(_0xdff4ae){if(_0xdff4ae){_0x1def89=_0xdff4ae[_0x4f36('0x44')];if(!_0x543a4e[_0x4f36('0x31')][_0x4f36('0x4b')]('nolimit')){_0x2db9f3['limit']=qs[_0x4f36('0x1e')](_0x543a4e[_0x4f36('0x31')]['limit']);_0x2db9f3[_0x4f36('0x1c')]=qs['offset'](_0x543a4e[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0x492c64[_0x4f36('0x4d')](_0x2db9f3);}})['then'](function(_0x4dfaaf){if(_0x4dfaaf){return _0x4dfaaf?{'count':_0x1def89,'rows':_0x4dfaaf}:null;}})[_0x4f36('0x25')](respondWithResult(_0x392de7,null))['catch'](handleError(_0x392de7,null));};
\ No newline at end of file