Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 4244a05..c8fa50a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfe24=['name','send','index','map','VtigerConfiguration','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filters','pick','where','merge','VIRTUAL','includeAll','include','findAll','show','params','length','options','find','create','body','update','getFields','findOne','VtigerField','getSubjects','filter','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','jayson/promise','http','request','then','VtigerConfiguration,\x20%s,\x20%s','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','info','catch','sendStatus','end','status','json','undefined','offset','count','limit','set','Content-Range','apply','reject','save','destroy'];(function(_0x54f32d,_0x39a0a5){var _0x2b73c2=function(_0x4cc816){while(--_0x4cc816){_0x54f32d['push'](_0x54f32d['shift']());}};_0x2b73c2(++_0x39a0a5);}(_0xfe24,0xe5));var _0x4fe2=function(_0x50564d,_0x1b1075){_0x50564d=_0x50564d-0x0;var _0x3699a1=_0xfe24[_0x50564d];return _0x3699a1;};'use strict';var emlformat=require(_0x4fe2('0x0'));var rimraf=require(_0x4fe2('0x1'));var zipdir=require(_0x4fe2('0x2'));var jsonpatch=require(_0x4fe2('0x3'));var rp=require(_0x4fe2('0x4'));var moment=require(_0x4fe2('0x5'));var BPromise=require(_0x4fe2('0x6'));var Mustache=require(_0x4fe2('0x7'));var util=require('util');var path=require('path');var sox=require(_0x4fe2('0x8'));var csv=require(_0x4fe2('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4fe2('0xa'));var _=require(_0x4fe2('0xb'));var squel=require('squel');var crypto=require(_0x4fe2('0xc'));var jsforce=require(_0x4fe2('0xd'));var deskjs=require(_0x4fe2('0xe'));var toCsv=require(_0x4fe2('0x9'));var querystring=require('querystring');var Papa=require(_0x4fe2('0xf'));var Redis=require(_0x4fe2('0x10'));var authService=require(_0x4fe2('0x11'));var qs=require(_0x4fe2('0x12'));var as=require(_0x4fe2('0x13'));var hardwareService=require(_0x4fe2('0x14'));var logger=require(_0x4fe2('0x15'))(_0x4fe2('0x16'));var utils=require('../../config/utils');var config=require(_0x4fe2('0x17'));var licenseUtil=require(_0x4fe2('0x18'));var db=require('../../mysqldb')['db'];var jayson=require(_0x4fe2('0x19'));var client=jayson['client'][_0x4fe2('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x19c618,_0x360ea3,_0x570002,_0x261b0a){return new BPromise(function(_0x2dae0f,_0x881071){var _0x2378f6=_0x261b0a||client;return _0x2378f6[_0x4fe2('0x1b')](_0x19c618,_0x570002)[_0x4fe2('0x1c')](function(_0xccba4e){logger['info'](_0x4fe2('0x1d'),_0x360ea3,'request\x20sent');logger[_0x4fe2('0x1e')](_0x4fe2('0x1f'),_0x360ea3,_0x4fe2('0x20'),JSON[_0x4fe2('0x21')](_0xccba4e));if(_0xccba4e['error']){if(_0xccba4e['error'][_0x4fe2('0x22')]===0x1f4){logger[_0x4fe2('0x23')](_0x4fe2('0x1d'),_0x360ea3,_0xccba4e[_0x4fe2('0x23')][_0x4fe2('0x24')]);return _0x881071(_0xccba4e[_0x4fe2('0x23')][_0x4fe2('0x24')]);}logger[_0x4fe2('0x23')](_0x4fe2('0x1d'),_0x360ea3,_0xccba4e[_0x4fe2('0x23')][_0x4fe2('0x24')]);return _0x2dae0f(_0xccba4e[_0x4fe2('0x23')]['message']);}else{logger[_0x4fe2('0x25')]('VtigerConfiguration,\x20%s,\x20%s',_0x360ea3,'request\x20sent');_0x2dae0f(_0xccba4e['result'][_0x4fe2('0x24')]);}})[_0x4fe2('0x26')](function(_0x2fa9c5){logger[_0x4fe2('0x23')]('VtigerConfiguration,\x20%s,\x20%s',_0x360ea3,_0x2fa9c5);_0x881071(_0x2fa9c5);});});}function respondWithStatusCode(_0x54b8f6,_0x4e44bf){_0x4e44bf=_0x4e44bf||0xcc;return function(_0x13c585){if(_0x13c585){return _0x54b8f6[_0x4fe2('0x27')](_0x4e44bf);}return _0x54b8f6['status'](_0x4e44bf)[_0x4fe2('0x28')]();};}function respondWithResult(_0x12776d,_0x4c4d13){_0x4c4d13=_0x4c4d13||0xc8;return function(_0x147415){if(_0x147415){return _0x12776d[_0x4fe2('0x29')](_0x4c4d13)[_0x4fe2('0x2a')](_0x147415);}};}function respondWithFilteredResult(_0xaabe3a,_0x562b0e){return function(_0x2a3e49){if(_0x2a3e49){var _0x207deb=typeof _0x562b0e['offset']===_0x4fe2('0x2b')&&typeof _0x562b0e['limit']===_0x4fe2('0x2b');var _0x57a728=_0x2a3e49['count'];var _0x57b6fc=_0x207deb?0x0:_0x562b0e[_0x4fe2('0x2c')];var _0x3df4be=_0x207deb?_0x2a3e49[_0x4fe2('0x2d')]:_0x562b0e[_0x4fe2('0x2c')]+_0x562b0e[_0x4fe2('0x2e')];var _0x15267a;if(_0x3df4be>=_0x57a728){_0x3df4be=_0x57a728;_0x15267a=0xc8;}else{_0x15267a=0xce;}_0xaabe3a[_0x4fe2('0x29')](_0x15267a);return _0xaabe3a[_0x4fe2('0x2f')](_0x4fe2('0x30'),_0x57b6fc+'-'+_0x3df4be+'/'+_0x57a728)[_0x4fe2('0x2a')](_0x2a3e49);}return null;};}function patchUpdates(_0x309da8){return function(_0x308936){try{jsonpatch[_0x4fe2('0x31')](_0x308936,_0x309da8,!![]);}catch(_0x2badfe){return BPromise[_0x4fe2('0x32')](_0x2badfe);}return _0x308936[_0x4fe2('0x33')]();};}function saveUpdates(_0x1ae2ae,_0x3aa09d){return function(_0x299125){if(_0x299125){return _0x299125['update'](_0x1ae2ae)['then'](function(_0x5481f0){return _0x5481f0;});}return null;};}function removeEntity(_0x3e9b20,_0x3458d5){return function(_0x71c901){if(_0x71c901){return _0x71c901[_0x4fe2('0x34')]()[_0x4fe2('0x1c')](function(){_0x3e9b20[_0x4fe2('0x29')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5848bb,_0x5d8596){return function(_0xb5fb6b){if(!_0xb5fb6b){_0x5848bb[_0x4fe2('0x27')](0x194);}return _0xb5fb6b;};}function handleError(_0x57fe1c,_0x22ab46){_0x22ab46=_0x22ab46||0x1f4;return function(_0x17a6c5){logger['error'](_0x17a6c5['stack']);if(_0x17a6c5[_0x4fe2('0x35')]){delete _0x17a6c5[_0x4fe2('0x35')];}_0x57fe1c['status'](_0x22ab46)[_0x4fe2('0x36')](_0x17a6c5);};}exports[_0x4fe2('0x37')]=function(_0x3476fe,_0x32bdf9){var _0x36ea0c={},_0x37e4ef={},_0x5c6a15={'count':0x0,'rows':[]};var _0x2e9446=_[_0x4fe2('0x38')](db[_0x4fe2('0x39')][_0x4fe2('0x3a')],function(_0x43718a){return{'name':_0x43718a[_0x4fe2('0x3b')],'type':_0x43718a[_0x4fe2('0x3c')][_0x4fe2('0x3d')]};});_0x37e4ef[_0x4fe2('0x3e')]=_[_0x4fe2('0x38')](_0x2e9446,'name');_0x37e4ef[_0x4fe2('0x3f')]=_[_0x4fe2('0x40')](_0x3476fe[_0x4fe2('0x3f')]);_0x37e4ef['filters']=_[_0x4fe2('0x41')](_0x37e4ef[_0x4fe2('0x3e')],_0x37e4ef[_0x4fe2('0x3f')]);_0x36ea0c[_0x4fe2('0x42')]=_[_0x4fe2('0x41')](_0x37e4ef[_0x4fe2('0x3e')],qs[_0x4fe2('0x43')](_0x3476fe[_0x4fe2('0x3f')]['fields']));_0x36ea0c[_0x4fe2('0x42')]=_0x36ea0c['attributes']['length']?_0x36ea0c[_0x4fe2('0x42')]:_0x37e4ef[_0x4fe2('0x3e')];if(!_0x3476fe[_0x4fe2('0x3f')][_0x4fe2('0x44')](_0x4fe2('0x45'))){_0x36ea0c[_0x4fe2('0x2e')]=qs[_0x4fe2('0x2e')](_0x3476fe[_0x4fe2('0x3f')][_0x4fe2('0x2e')]);_0x36ea0c[_0x4fe2('0x2c')]=qs[_0x4fe2('0x2c')](_0x3476fe[_0x4fe2('0x3f')][_0x4fe2('0x2c')]);}_0x36ea0c[_0x4fe2('0x46')]=qs[_0x4fe2('0x47')](_0x3476fe[_0x4fe2('0x3f')][_0x4fe2('0x47')]);_0x36ea0c['where']=qs[_0x4fe2('0x48')](_[_0x4fe2('0x49')](_0x3476fe[_0x4fe2('0x3f')],_0x37e4ef['filters']),_0x2e9446);if(_0x3476fe[_0x4fe2('0x3f')]['filter']){_0x36ea0c[_0x4fe2('0x4a')]=_[_0x4fe2('0x4b')](_0x36ea0c[_0x4fe2('0x4a')],{'$or':_[_0x4fe2('0x38')](_0x2e9446,function(_0x1cfa46){if(_0x1cfa46['type']!==_0x4fe2('0x4c')){var _0x3fc2b6={};_0x3fc2b6[_0x1cfa46[_0x4fe2('0x35')]]={'$like':'%'+_0x3476fe[_0x4fe2('0x3f')]['filter']+'%'};return _0x3fc2b6;}})});}_0x36ea0c=_['merge']({},_0x36ea0c,_0x3476fe['options']);var _0x3d8449={'where':_0x36ea0c[_0x4fe2('0x4a')]};return db[_0x4fe2('0x39')][_0x4fe2('0x2d')](_0x3d8449)[_0x4fe2('0x1c')](function(_0x40e351){_0x5c6a15[_0x4fe2('0x2d')]=_0x40e351;if(_0x3476fe[_0x4fe2('0x3f')][_0x4fe2('0x4d')]){_0x36ea0c[_0x4fe2('0x4e')]=[{'all':!![]}];}return db[_0x4fe2('0x39')][_0x4fe2('0x4f')](_0x36ea0c);})[_0x4fe2('0x1c')](function(_0x1121f6){_0x5c6a15['rows']=_0x1121f6;return _0x5c6a15;})['then'](respondWithFilteredResult(_0x32bdf9,_0x36ea0c))[_0x4fe2('0x26')](handleError(_0x32bdf9,null));};exports[_0x4fe2('0x50')]=function(_0x52c6e5,_0x18c103){var _0x18c1a3={'raw':![],'where':{'id':_0x52c6e5[_0x4fe2('0x51')]['id']}},_0x3a4b06={};_0x3a4b06['model']=_[_0x4fe2('0x40')](db['VtigerConfiguration']['rawAttributes']);_0x3a4b06['query']=_[_0x4fe2('0x40')](_0x52c6e5[_0x4fe2('0x3f')]);_0x3a4b06[_0x4fe2('0x48')]=_[_0x4fe2('0x41')](_0x3a4b06['model'],_0x3a4b06[_0x4fe2('0x3f')]);_0x18c1a3[_0x4fe2('0x42')]=_[_0x4fe2('0x41')](_0x3a4b06[_0x4fe2('0x3e')],qs[_0x4fe2('0x43')](_0x52c6e5['query'][_0x4fe2('0x43')]));_0x18c1a3['attributes']=_0x18c1a3[_0x4fe2('0x42')][_0x4fe2('0x52')]?_0x18c1a3[_0x4fe2('0x42')]:_0x3a4b06[_0x4fe2('0x3e')];if(_0x52c6e5[_0x4fe2('0x3f')][_0x4fe2('0x4d')]){_0x18c1a3[_0x4fe2('0x4e')]=[{'all':!![]}];}_0x18c1a3=_[_0x4fe2('0x4b')]({},_0x18c1a3,_0x52c6e5[_0x4fe2('0x53')]);return db[_0x4fe2('0x39')][_0x4fe2('0x54')](_0x18c1a3)[_0x4fe2('0x1c')](handleEntityNotFound(_0x18c103,null))[_0x4fe2('0x1c')](respondWithResult(_0x18c103,null))['catch'](handleError(_0x18c103,null));};exports[_0x4fe2('0x55')]=function(_0x1d96a6,_0x2ec945){return db[_0x4fe2('0x39')][_0x4fe2('0x55')](_0x1d96a6[_0x4fe2('0x56')],{})[_0x4fe2('0x1c')](respondWithResult(_0x2ec945,0xc9))['catch'](handleError(_0x2ec945,null));};exports[_0x4fe2('0x57')]=function(_0x54f947,_0x4fd7e1){if(_0x54f947[_0x4fe2('0x56')]['id']){delete _0x54f947['body']['id'];}return db[_0x4fe2('0x39')][_0x4fe2('0x54')]({'where':{'id':_0x54f947['params']['id']}})['then'](handleEntityNotFound(_0x4fd7e1,null))[_0x4fe2('0x1c')](saveUpdates(_0x54f947[_0x4fe2('0x56')],null))[_0x4fe2('0x1c')](respondWithResult(_0x4fd7e1,null))['catch'](handleError(_0x4fd7e1,null));};exports[_0x4fe2('0x34')]=function(_0x57c57b,_0x19a9c9){return db[_0x4fe2('0x39')][_0x4fe2('0x54')]({'where':{'id':_0x57c57b[_0x4fe2('0x51')]['id']}})[_0x4fe2('0x1c')](handleEntityNotFound(_0x19a9c9,null))[_0x4fe2('0x1c')](removeEntity(_0x19a9c9,null))[_0x4fe2('0x26')](handleError(_0x19a9c9,null));};exports[_0x4fe2('0x58')]=function(_0x4ab597,_0x31a740,_0x594c9f){var _0x5b7d1a={};var _0x4d1590={};var _0x5f4f67;var _0x6dfa28;return db[_0x4fe2('0x39')][_0x4fe2('0x59')]({'where':{'id':_0x4ab597[_0x4fe2('0x51')]['id']}})[_0x4fe2('0x1c')](handleEntityNotFound(_0x31a740,null))[_0x4fe2('0x1c')](function(_0x1024aa){if(_0x1024aa){_0x5f4f67=_0x1024aa;_0x4d1590[_0x4fe2('0x3e')]=_[_0x4fe2('0x40')](db[_0x4fe2('0x5a')][_0x4fe2('0x3a')]);_0x4d1590[_0x4fe2('0x3f')]=_[_0x4fe2('0x40')](_0x4ab597[_0x4fe2('0x3f')]);_0x4d1590[_0x4fe2('0x48')]=_[_0x4fe2('0x41')](_0x4d1590['model'],_0x4d1590[_0x4fe2('0x3f')]);_0x5b7d1a[_0x4fe2('0x42')]=_[_0x4fe2('0x41')](_0x4d1590['model'],qs['fields'](_0x4ab597['query'][_0x4fe2('0x43')]));_0x5b7d1a[_0x4fe2('0x42')]=_0x5b7d1a['attributes'][_0x4fe2('0x52')]?_0x5b7d1a['attributes']:_0x4d1590[_0x4fe2('0x3e')];_0x5b7d1a[_0x4fe2('0x46')]=qs[_0x4fe2('0x47')](_0x4ab597[_0x4fe2('0x3f')][_0x4fe2('0x47')]);_0x5b7d1a['where']=qs['filters'](_[_0x4fe2('0x49')](_0x4ab597['query'],_0x4d1590[_0x4fe2('0x48')]));if(_0x4ab597[_0x4fe2('0x3f')]['filter']){_0x5b7d1a[_0x4fe2('0x4a')]=_[_0x4fe2('0x4b')](_0x5b7d1a[_0x4fe2('0x4a')],{'$or':_[_0x4fe2('0x38')](_0x5b7d1a['attributes'],function(_0xa4f59e){var _0x5d5327={};_0x5d5327[_0xa4f59e]={'$like':'%'+_0x4ab597[_0x4fe2('0x3f')]['filter']+'%'};return _0x5d5327;})});}_0x5b7d1a=_[_0x4fe2('0x4b')]({},_0x5b7d1a,_0x4ab597['options']);return _0x5f4f67[_0x4fe2('0x58')](_0x5b7d1a);}})[_0x4fe2('0x1c')](function(_0x23cd42){if(_0x23cd42){_0x6dfa28=_0x23cd42['length'];if(!_0x4ab597[_0x4fe2('0x3f')][_0x4fe2('0x44')](_0x4fe2('0x45'))){_0x5b7d1a[_0x4fe2('0x2e')]=qs[_0x4fe2('0x2e')](_0x4ab597[_0x4fe2('0x3f')][_0x4fe2('0x2e')]);_0x5b7d1a[_0x4fe2('0x2c')]=qs[_0x4fe2('0x2c')](_0x4ab597['query']['offset']);}return _0x5f4f67['getFields'](_0x5b7d1a);}})[_0x4fe2('0x1c')](function(_0x23bb97){if(_0x23bb97){return _0x23bb97?{'count':_0x6dfa28,'rows':_0x23bb97}:null;}})[_0x4fe2('0x1c')](respondWithResult(_0x31a740,null))[_0x4fe2('0x26')](handleError(_0x31a740,null));};exports[_0x4fe2('0x5b')]=function(_0x58254f,_0x2ea3a7,_0x44be51){var _0x52bbda={};var _0x167b82={};var _0x71ea3c;var _0x432fa8;return db[_0x4fe2('0x39')][_0x4fe2('0x59')]({'where':{'id':_0x58254f[_0x4fe2('0x51')]['id']}})[_0x4fe2('0x1c')](handleEntityNotFound(_0x2ea3a7,null))[_0x4fe2('0x1c')](function(_0x2a8156){if(_0x2a8156){_0x71ea3c=_0x2a8156;_0x167b82[_0x4fe2('0x3e')]=_[_0x4fe2('0x40')](db[_0x4fe2('0x5a')]['rawAttributes']);_0x167b82[_0x4fe2('0x3f')]=_[_0x4fe2('0x40')](_0x58254f[_0x4fe2('0x3f')]);_0x167b82[_0x4fe2('0x48')]=_[_0x4fe2('0x41')](_0x167b82[_0x4fe2('0x3e')],_0x167b82[_0x4fe2('0x3f')]);_0x52bbda[_0x4fe2('0x42')]=_[_0x4fe2('0x41')](_0x167b82['model'],qs[_0x4fe2('0x43')](_0x58254f['query'][_0x4fe2('0x43')]));_0x52bbda[_0x4fe2('0x42')]=_0x52bbda[_0x4fe2('0x42')][_0x4fe2('0x52')]?_0x52bbda[_0x4fe2('0x42')]:_0x167b82[_0x4fe2('0x3e')];_0x52bbda[_0x4fe2('0x46')]=qs[_0x4fe2('0x47')](_0x58254f[_0x4fe2('0x3f')][_0x4fe2('0x47')]);_0x52bbda[_0x4fe2('0x4a')]=qs[_0x4fe2('0x48')](_[_0x4fe2('0x49')](_0x58254f['query'],_0x167b82['filters']));if(_0x58254f[_0x4fe2('0x3f')][_0x4fe2('0x5c')]){_0x52bbda['where']=_[_0x4fe2('0x4b')](_0x52bbda['where'],{'$or':_[_0x4fe2('0x38')](_0x52bbda['attributes'],function(_0xe43ab4){var _0x25b1bb={};_0x25b1bb[_0xe43ab4]={'$like':'%'+_0x58254f['query']['filter']+'%'};return _0x25b1bb;})});}_0x52bbda=_['merge']({},_0x52bbda,_0x58254f[_0x4fe2('0x53')]);return _0x71ea3c['getSubjects'](_0x52bbda);}})[_0x4fe2('0x1c')](function(_0xfca86d){if(_0xfca86d){_0x432fa8=_0xfca86d['length'];if(!_0x58254f[_0x4fe2('0x3f')]['hasOwnProperty'](_0x4fe2('0x45'))){_0x52bbda['limit']=qs['limit'](_0x58254f[_0x4fe2('0x3f')][_0x4fe2('0x2e')]);_0x52bbda[_0x4fe2('0x2c')]=qs['offset'](_0x58254f[_0x4fe2('0x3f')][_0x4fe2('0x2c')]);}return _0x71ea3c['getSubjects'](_0x52bbda);}})[_0x4fe2('0x1c')](function(_0x11c7ea){if(_0x11c7ea){return _0x11c7ea?{'count':_0x432fa8,'rows':_0x11c7ea}:null;}})[_0x4fe2('0x1c')](respondWithResult(_0x2ea3a7,null))[_0x4fe2('0x26')](handleError(_0x2ea3a7,null));};exports['getDescriptions']=function(_0x45533b,_0x46c094,_0x3366c1){var _0x46dc61={};var _0x3b6175={};var _0x4e9642;var _0x1536fa;return db[_0x4fe2('0x39')][_0x4fe2('0x59')]({'where':{'id':_0x45533b['params']['id']}})[_0x4fe2('0x1c')](handleEntityNotFound(_0x46c094,null))[_0x4fe2('0x1c')](function(_0x133970){if(_0x133970){_0x4e9642=_0x133970;_0x3b6175['model']=_['keys'](db['VtigerField']['rawAttributes']);_0x3b6175[_0x4fe2('0x3f')]=_[_0x4fe2('0x40')](_0x45533b[_0x4fe2('0x3f')]);_0x3b6175[_0x4fe2('0x48')]=_[_0x4fe2('0x41')](_0x3b6175['model'],_0x3b6175[_0x4fe2('0x3f')]);_0x46dc61[_0x4fe2('0x42')]=_['intersection'](_0x3b6175[_0x4fe2('0x3e')],qs[_0x4fe2('0x43')](_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x43')]));_0x46dc61['attributes']=_0x46dc61[_0x4fe2('0x42')][_0x4fe2('0x52')]?_0x46dc61['attributes']:_0x3b6175[_0x4fe2('0x3e')];_0x46dc61[_0x4fe2('0x46')]=qs[_0x4fe2('0x47')](_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x47')]);_0x46dc61['where']=qs['filters'](_[_0x4fe2('0x49')](_0x45533b[_0x4fe2('0x3f')],_0x3b6175[_0x4fe2('0x48')]));if(_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x5c')]){_0x46dc61[_0x4fe2('0x4a')]=_[_0x4fe2('0x4b')](_0x46dc61['where'],{'$or':_[_0x4fe2('0x38')](_0x46dc61[_0x4fe2('0x42')],function(_0x4ec20f){var _0x472442={};_0x472442[_0x4ec20f]={'$like':'%'+_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x5c')]+'%'};return _0x472442;})});}_0x46dc61=_[_0x4fe2('0x4b')]({},_0x46dc61,_0x45533b[_0x4fe2('0x53')]);return _0x4e9642[_0x4fe2('0x5d')](_0x46dc61);}})[_0x4fe2('0x1c')](function(_0x317db7){if(_0x317db7){_0x1536fa=_0x317db7[_0x4fe2('0x52')];if(!_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x44')]('nolimit')){_0x46dc61[_0x4fe2('0x2e')]=qs[_0x4fe2('0x2e')](_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x2e')]);_0x46dc61['offset']=qs[_0x4fe2('0x2c')](_0x45533b[_0x4fe2('0x3f')][_0x4fe2('0x2c')]);}return _0x4e9642[_0x4fe2('0x5d')](_0x46dc61);}})['then'](function(_0x568001){if(_0x568001){return _0x568001?{'count':_0x1536fa,'rows':_0x568001}:null;}})[_0x4fe2('0x1c')](respondWithResult(_0x46c094,null))['catch'](handleError(_0x46c094,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