Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index ee0a64f..7dcc66a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x97b5=['update','destroy','sendStatus','name','send','index','map','rawAttributes','fieldName','type','keys','filters','model','query','attributes','intersection','fields','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VtigerConfiguration','count','includeAll','rows','catch','show','params','length','include','find','create','body','getFields','VtigerField','hasOwnProperty','getSubjects','findOne','getDescriptions','eml-format','zip-dir','request-promise','moment','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','jayson/promise','http','test','Sequelize','then','info','request\x20sent','debug','error','code','VtigerConfiguration,\x20%s,\x20%s','message','result','status','offset','limit','set','Content-Range','json','apply','reject','save'];(function(_0xf8054a,_0x18488e){var _0x44aacf=function(_0x20ac2e){while(--_0x20ac2e){_0xf8054a['push'](_0xf8054a['shift']());}};_0x44aacf(++_0x18488e);}(_0x97b5,0x137));var _0x597b=function(_0x5e8fe9,_0x1d3d88){_0x5e8fe9=_0x5e8fe9-0x0;var _0x5158b9=_0x97b5[_0x5e8fe9];return _0x5158b9;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x597b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x597b('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x597b('0x2'));var moment=require(_0x597b('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x597b('0x4'));var util=require('util');var path=require(_0x597b('0x5'));var sox=require(_0x597b('0x6'));var csv=require(_0x597b('0x7'));var ejs=require(_0x597b('0x8'));var fs=require('fs');var _=require(_0x597b('0x9'));var squel=require(_0x597b('0xa'));var crypto=require(_0x597b('0xb'));var jsforce=require(_0x597b('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x597b('0xd'));var Papa=require('papaparse');var Redis=require(_0x597b('0xe'));var authService=require(_0x597b('0xf'));var qs=require(_0x597b('0x10'));var as=require(_0x597b('0x11'));var hardwareService=require(_0x597b('0x12'));var logger=require(_0x597b('0x13'))(_0x597b('0x14'));var utils=require(_0x597b('0x15'));var config=require(_0x597b('0x16'));var db=require('../../mysqldb')['db'];var jayson=require(_0x597b('0x17'));var client=jayson['client'][_0x597b('0x18')]({'port':0x232a});function checkPasswordPattern(_0x3bda57,_0xcc8d68,_0xfd0f9c){if(_0xfd0f9c){var _0x6b3e66=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x6b3e66[_0x597b('0x19')](_0xcc8d68)){return _0x3bda57;}else{throw new db[(_0x597b('0x1a'))]['ValidationError']('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x3bda57;}}function respondWithRpcPromise(_0x9f8035,_0x3a18c3,_0x412703,_0x5611d3){return new BPromise(function(_0x58a4db,_0x153834){var _0x1c6f71=_0x5611d3||client;return _0x1c6f71['request'](_0x9f8035,_0x412703)[_0x597b('0x1b')](function(_0x1cfe7e){logger[_0x597b('0x1c')]('VtigerConfiguration,\x20%s,\x20%s',_0x3a18c3,_0x597b('0x1d'));logger[_0x597b('0x1e')]('VtigerConfiguration,\x20%s,\x20%s,\x20%s',_0x3a18c3,_0x597b('0x1d'),JSON['stringify'](_0x1cfe7e));if(_0x1cfe7e[_0x597b('0x1f')]){if(_0x1cfe7e[_0x597b('0x1f')][_0x597b('0x20')]===0x1f4){logger['error'](_0x597b('0x21'),_0x3a18c3,_0x1cfe7e[_0x597b('0x1f')]['message']);return _0x153834(_0x1cfe7e[_0x597b('0x1f')][_0x597b('0x22')]);}logger['error']('VtigerConfiguration,\x20%s,\x20%s',_0x3a18c3,_0x1cfe7e[_0x597b('0x1f')]['message']);return _0x58a4db(_0x1cfe7e[_0x597b('0x1f')]['message']);}else{logger[_0x597b('0x1c')](_0x597b('0x21'),_0x3a18c3,_0x597b('0x1d'));_0x58a4db(_0x1cfe7e[_0x597b('0x23')][_0x597b('0x22')]);}})['catch'](function(_0x3277e6){logger[_0x597b('0x1f')](_0x597b('0x21'),_0x3a18c3,_0x3277e6);_0x153834(_0x3277e6);});});}function respondWithStatusCode(_0xa5176d,_0x32b0e9){_0x32b0e9=_0x32b0e9||0xcc;return function(_0x427909){if(_0x427909){return _0xa5176d['sendStatus'](_0x32b0e9);}return _0xa5176d[_0x597b('0x24')](_0x32b0e9)['end']();};}function respondWithResult(_0x445b55,_0x50a68c){_0x50a68c=_0x50a68c||0xc8;return function(_0x3baabe){if(_0x3baabe){return _0x445b55[_0x597b('0x24')](_0x50a68c)['json'](_0x3baabe);}};}function respondWithFilteredResult(_0x4fd49d,_0x3f7389){return function(_0x78ebab){if(_0x78ebab){var _0x362665=_0x78ebab['count'],_0x3ee68c=_0x3f7389[_0x597b('0x25')],_0x15a89d=_0x3f7389[_0x597b('0x25')]+_0x3f7389[_0x597b('0x26')],_0xdbe1a8;if(_0x15a89d>=_0x362665){_0x15a89d=_0x362665;_0xdbe1a8=0xc8;}else{_0xdbe1a8=0xce;}_0x4fd49d[_0x597b('0x24')](_0xdbe1a8);return _0x4fd49d[_0x597b('0x27')](_0x597b('0x28'),_0x3ee68c+'-'+_0x15a89d+'/'+_0x362665)[_0x597b('0x29')](_0x78ebab);}return null;};}function patchUpdates(_0x18c98b){return function(_0x5d6a68){try{jsonpatch[_0x597b('0x2a')](_0x5d6a68,_0x18c98b,!![]);}catch(_0x4603b1){return BPromise[_0x597b('0x2b')](_0x4603b1);}return _0x5d6a68[_0x597b('0x2c')]();};}function saveUpdates(_0x181fa3,_0x52435f){return function(_0x1d1e0f){if(_0x1d1e0f){return _0x1d1e0f[_0x597b('0x2d')](_0x181fa3)[_0x597b('0x1b')](function(_0x3de9ca){return _0x3de9ca;});}return null;};}function removeEntity(_0x4859aa,_0x3cce96){return function(_0x2011a2){if(_0x2011a2){return _0x2011a2[_0x597b('0x2e')]()[_0x597b('0x1b')](function(){_0x4859aa[_0x597b('0x24')](0xcc)['end']();});}};}function handleEntityNotFound(_0x18ee59,_0x5e8ac7){return function(_0x3c32f6){if(!_0x3c32f6){_0x18ee59[_0x597b('0x2f')](0x194);}return _0x3c32f6;};}function handleError(_0xfa2154,_0x18bbab){_0x18bbab=_0x18bbab||0x1f4;return function(_0x1e57f3){logger['error'](_0x1e57f3['stack']);if(_0x1e57f3[_0x597b('0x30')]){delete _0x1e57f3['name'];}_0xfa2154[_0x597b('0x24')](_0x18bbab)[_0x597b('0x31')](_0x1e57f3);};}exports[_0x597b('0x32')]=function(_0xe35030,_0x1a7434){var _0x3bcb8a={},_0xe86425={},_0x299493={'count':0x0,'rows':[]};var _0x227b0a=_[_0x597b('0x33')](db['VtigerConfiguration'][_0x597b('0x34')],function(_0x1e9a65){return{'name':_0x1e9a65[_0x597b('0x35')],'type':_0x1e9a65[_0x597b('0x36')]['key']};});_0xe86425['model']=_[_0x597b('0x33')](_0x227b0a,_0x597b('0x30'));_0xe86425['query']=_[_0x597b('0x37')](_0xe35030['query']);_0xe86425[_0x597b('0x38')]=_['intersection'](_0xe86425[_0x597b('0x39')],_0xe86425[_0x597b('0x3a')]);_0x3bcb8a[_0x597b('0x3b')]=_[_0x597b('0x3c')](_0xe86425['model'],qs[_0x597b('0x3d')](_0xe35030['query'][_0x597b('0x3d')]));_0x3bcb8a[_0x597b('0x3b')]=_0x3bcb8a[_0x597b('0x3b')]['length']?_0x3bcb8a[_0x597b('0x3b')]:_0xe86425[_0x597b('0x39')];if(!_0xe35030[_0x597b('0x3a')]['hasOwnProperty'](_0x597b('0x3e'))){_0x3bcb8a[_0x597b('0x26')]=qs[_0x597b('0x26')](_0xe35030[_0x597b('0x3a')][_0x597b('0x26')]);_0x3bcb8a[_0x597b('0x25')]=qs[_0x597b('0x25')](_0xe35030['query'][_0x597b('0x25')]);}_0x3bcb8a[_0x597b('0x3f')]=qs['sort'](_0xe35030[_0x597b('0x3a')][_0x597b('0x40')]);_0x3bcb8a[_0x597b('0x41')]=qs[_0x597b('0x38')](_[_0x597b('0x42')](_0xe35030[_0x597b('0x3a')],_0xe86425[_0x597b('0x38')]));if(_0xe35030[_0x597b('0x3a')][_0x597b('0x43')]){_0x3bcb8a[_0x597b('0x41')]=_[_0x597b('0x44')](_0x3bcb8a[_0x597b('0x41')],{'$or':_[_0x597b('0x33')](_0x227b0a,function(_0x36805){if(_0x36805[_0x597b('0x36')]!==_0x597b('0x45')){var _0xbb4b1e={};_0xbb4b1e[_0x36805[_0x597b('0x30')]]={'$like':'%'+_0xe35030[_0x597b('0x3a')]['filter']+'%'};return _0xbb4b1e;}})});}_0x3bcb8a=_[_0x597b('0x44')]({},_0x3bcb8a,_0xe35030[_0x597b('0x46')]);var _0x3e9dfd={'where':_0x3bcb8a[_0x597b('0x41')]};return db[_0x597b('0x47')]['count'](_0x3e9dfd)['then'](function(_0x1ab8b1){_0x299493[_0x597b('0x48')]=_0x1ab8b1;if(_0xe35030[_0x597b('0x3a')][_0x597b('0x49')]){_0x3bcb8a['include']=[{'all':!![]}];}return db[_0x597b('0x47')]['findAll'](_0x3bcb8a);})[_0x597b('0x1b')](function(_0xdc5421){_0x299493[_0x597b('0x4a')]=_0xdc5421;return _0x299493;})[_0x597b('0x1b')](respondWithFilteredResult(_0x1a7434,_0x3bcb8a))[_0x597b('0x4b')](handleError(_0x1a7434,null));};exports[_0x597b('0x4c')]=function(_0x57ddc8,_0x5b6c86){var _0x4972b4={'raw':![],'where':{'id':_0x57ddc8[_0x597b('0x4d')]['id']}},_0x5f2a2a={};_0x5f2a2a[_0x597b('0x39')]=_['keys'](db['VtigerConfiguration'][_0x597b('0x34')]);_0x5f2a2a[_0x597b('0x3a')]=_[_0x597b('0x37')](_0x57ddc8[_0x597b('0x3a')]);_0x5f2a2a[_0x597b('0x38')]=_[_0x597b('0x3c')](_0x5f2a2a[_0x597b('0x39')],_0x5f2a2a['query']);_0x4972b4[_0x597b('0x3b')]=_['intersection'](_0x5f2a2a['model'],qs[_0x597b('0x3d')](_0x57ddc8['query'][_0x597b('0x3d')]));_0x4972b4[_0x597b('0x3b')]=_0x4972b4[_0x597b('0x3b')][_0x597b('0x4e')]?_0x4972b4['attributes']:_0x5f2a2a[_0x597b('0x39')];if(_0x57ddc8['query']['includeAll']){_0x4972b4[_0x597b('0x4f')]=[{'all':!![]}];}_0x4972b4=_[_0x597b('0x44')]({},_0x4972b4,_0x57ddc8['options']);return db[_0x597b('0x47')][_0x597b('0x50')](_0x4972b4)[_0x597b('0x1b')](handleEntityNotFound(_0x5b6c86,null))[_0x597b('0x1b')](respondWithResult(_0x5b6c86,null))[_0x597b('0x4b')](handleError(_0x5b6c86,null));};exports[_0x597b('0x51')]=function(_0x1de423,_0x1d5061){return db[_0x597b('0x47')][_0x597b('0x51')](_0x1de423[_0x597b('0x52')],{})[_0x597b('0x1b')](respondWithResult(_0x1d5061,0xc9))[_0x597b('0x4b')](handleError(_0x1d5061,null));};exports[_0x597b('0x2d')]=function(_0x26f47e,_0x1af3cc){if(_0x26f47e[_0x597b('0x52')]['id']){delete _0x26f47e['body']['id'];}return db[_0x597b('0x47')][_0x597b('0x50')]({'where':{'id':_0x26f47e[_0x597b('0x4d')]['id']}})[_0x597b('0x1b')](handleEntityNotFound(_0x1af3cc,null))['then'](saveUpdates(_0x26f47e[_0x597b('0x52')],null))[_0x597b('0x1b')](respondWithResult(_0x1af3cc,null))[_0x597b('0x4b')](handleError(_0x1af3cc,null));};exports[_0x597b('0x2e')]=function(_0xf6b97d,_0x20e155){return db[_0x597b('0x47')][_0x597b('0x50')]({'where':{'id':_0xf6b97d['params']['id']}})[_0x597b('0x1b')](handleEntityNotFound(_0x20e155,null))[_0x597b('0x1b')](removeEntity(_0x20e155,null))['catch'](handleError(_0x20e155,null));};exports[_0x597b('0x53')]=function(_0x2393e1,_0x19a740,_0x40f0c8){var _0x5bd699={};var _0x4affce={};var _0x218afb;var _0x40d2e9;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x2393e1['params']['id']}})[_0x597b('0x1b')](handleEntityNotFound(_0x19a740,null))['then'](function(_0x371774){if(_0x371774){_0x218afb=_0x371774;_0x4affce[_0x597b('0x39')]=_[_0x597b('0x37')](db[_0x597b('0x54')][_0x597b('0x34')]);_0x4affce[_0x597b('0x3a')]=_[_0x597b('0x37')](_0x2393e1[_0x597b('0x3a')]);_0x4affce[_0x597b('0x38')]=_[_0x597b('0x3c')](_0x4affce[_0x597b('0x39')],_0x4affce['query']);_0x5bd699[_0x597b('0x3b')]=_[_0x597b('0x3c')](_0x4affce[_0x597b('0x39')],qs[_0x597b('0x3d')](_0x2393e1[_0x597b('0x3a')][_0x597b('0x3d')]));_0x5bd699[_0x597b('0x3b')]=_0x5bd699['attributes'][_0x597b('0x4e')]?_0x5bd699[_0x597b('0x3b')]:_0x4affce[_0x597b('0x39')];_0x5bd699['order']=qs[_0x597b('0x40')](_0x2393e1[_0x597b('0x3a')][_0x597b('0x40')]);_0x5bd699['where']=qs['filters'](_[_0x597b('0x42')](_0x2393e1['query'],_0x4affce[_0x597b('0x38')]));if(_0x2393e1['query'][_0x597b('0x43')]){_0x5bd699[_0x597b('0x41')]=_['merge'](_0x5bd699[_0x597b('0x41')],{'$or':_[_0x597b('0x33')](_0x5bd699[_0x597b('0x3b')],function(_0xc5f8a0){var _0x22b2b1={};_0x22b2b1[_0xc5f8a0]={'$like':'%'+_0x2393e1[_0x597b('0x3a')][_0x597b('0x43')]+'%'};return _0x22b2b1;})});}_0x5bd699=_[_0x597b('0x44')]({},_0x5bd699,_0x2393e1[_0x597b('0x46')]);return _0x218afb[_0x597b('0x53')](_0x5bd699);}})[_0x597b('0x1b')](function(_0x10b107){if(_0x10b107){_0x40d2e9=_0x10b107[_0x597b('0x4e')];if(!_0x2393e1[_0x597b('0x3a')][_0x597b('0x55')]('nolimit')){_0x5bd699[_0x597b('0x26')]=qs[_0x597b('0x26')](_0x2393e1[_0x597b('0x3a')]['limit']);_0x5bd699['offset']=qs['offset'](_0x2393e1[_0x597b('0x3a')][_0x597b('0x25')]);}return _0x218afb[_0x597b('0x53')](_0x5bd699);}})[_0x597b('0x1b')](function(_0x55f34d){if(_0x55f34d){return _0x55f34d?{'count':_0x40d2e9,'rows':_0x55f34d}:null;}})[_0x597b('0x1b')](respondWithResult(_0x19a740,null))[_0x597b('0x4b')](handleError(_0x19a740,null));};exports[_0x597b('0x56')]=function(_0x1b1443,_0x44d106,_0x29e5dc){var _0x3ed4cb={};var _0x590fc6={};var _0x46a34f;var _0x2720a1;return db[_0x597b('0x47')][_0x597b('0x57')]({'where':{'id':_0x1b1443[_0x597b('0x4d')]['id']}})['then'](handleEntityNotFound(_0x44d106,null))[_0x597b('0x1b')](function(_0x1bb8c2){if(_0x1bb8c2){_0x46a34f=_0x1bb8c2;_0x590fc6[_0x597b('0x39')]=_[_0x597b('0x37')](db[_0x597b('0x54')]['rawAttributes']);_0x590fc6[_0x597b('0x3a')]=_['keys'](_0x1b1443[_0x597b('0x3a')]);_0x590fc6[_0x597b('0x38')]=_[_0x597b('0x3c')](_0x590fc6[_0x597b('0x39')],_0x590fc6[_0x597b('0x3a')]);_0x3ed4cb[_0x597b('0x3b')]=_[_0x597b('0x3c')](_0x590fc6[_0x597b('0x39')],qs[_0x597b('0x3d')](_0x1b1443['query'][_0x597b('0x3d')]));_0x3ed4cb['attributes']=_0x3ed4cb[_0x597b('0x3b')]['length']?_0x3ed4cb['attributes']:_0x590fc6[_0x597b('0x39')];_0x3ed4cb['order']=qs[_0x597b('0x40')](_0x1b1443[_0x597b('0x3a')]['sort']);_0x3ed4cb[_0x597b('0x41')]=qs[_0x597b('0x38')](_[_0x597b('0x42')](_0x1b1443[_0x597b('0x3a')],_0x590fc6[_0x597b('0x38')]));if(_0x1b1443[_0x597b('0x3a')]['filter']){_0x3ed4cb['where']=_[_0x597b('0x44')](_0x3ed4cb[_0x597b('0x41')],{'$or':_[_0x597b('0x33')](_0x3ed4cb[_0x597b('0x3b')],function(_0x44d4d5){var _0x50d055={};_0x50d055[_0x44d4d5]={'$like':'%'+_0x1b1443[_0x597b('0x3a')]['filter']+'%'};return _0x50d055;})});}_0x3ed4cb=_['merge']({},_0x3ed4cb,_0x1b1443[_0x597b('0x46')]);return _0x46a34f['getSubjects'](_0x3ed4cb);}})[_0x597b('0x1b')](function(_0x2bb8f3){if(_0x2bb8f3){_0x2720a1=_0x2bb8f3[_0x597b('0x4e')];if(!_0x1b1443[_0x597b('0x3a')][_0x597b('0x55')](_0x597b('0x3e'))){_0x3ed4cb['limit']=qs['limit'](_0x1b1443[_0x597b('0x3a')]['limit']);_0x3ed4cb['offset']=qs[_0x597b('0x25')](_0x1b1443['query'][_0x597b('0x25')]);}return _0x46a34f['getSubjects'](_0x3ed4cb);}})[_0x597b('0x1b')](function(_0x2fc1bd){if(_0x2fc1bd){return _0x2fc1bd?{'count':_0x2720a1,'rows':_0x2fc1bd}:null;}})[_0x597b('0x1b')](respondWithResult(_0x44d106,null))[_0x597b('0x4b')](handleError(_0x44d106,null));};exports[_0x597b('0x58')]=function(_0x330da9,_0x3c5d53,_0x11d8d4){var _0x24e2a7={};var _0x23f252={};var _0x45aa89;var _0x30fafb;return db[_0x597b('0x47')][_0x597b('0x57')]({'where':{'id':_0x330da9[_0x597b('0x4d')]['id']}})[_0x597b('0x1b')](handleEntityNotFound(_0x3c5d53,null))[_0x597b('0x1b')](function(_0x4c0f90){if(_0x4c0f90){_0x45aa89=_0x4c0f90;_0x23f252[_0x597b('0x39')]=_[_0x597b('0x37')](db[_0x597b('0x54')][_0x597b('0x34')]);_0x23f252['query']=_['keys'](_0x330da9['query']);_0x23f252[_0x597b('0x38')]=_[_0x597b('0x3c')](_0x23f252[_0x597b('0x39')],_0x23f252[_0x597b('0x3a')]);_0x24e2a7[_0x597b('0x3b')]=_[_0x597b('0x3c')](_0x23f252[_0x597b('0x39')],qs[_0x597b('0x3d')](_0x330da9[_0x597b('0x3a')]['fields']));_0x24e2a7[_0x597b('0x3b')]=_0x24e2a7[_0x597b('0x3b')][_0x597b('0x4e')]?_0x24e2a7['attributes']:_0x23f252[_0x597b('0x39')];_0x24e2a7['order']=qs[_0x597b('0x40')](_0x330da9[_0x597b('0x3a')]['sort']);_0x24e2a7['where']=qs[_0x597b('0x38')](_[_0x597b('0x42')](_0x330da9[_0x597b('0x3a')],_0x23f252[_0x597b('0x38')]));if(_0x330da9[_0x597b('0x3a')]['filter']){_0x24e2a7[_0x597b('0x41')]=_['merge'](_0x24e2a7[_0x597b('0x41')],{'$or':_[_0x597b('0x33')](_0x24e2a7['attributes'],function(_0x5c7c9d){var _0x2c1e8c={};_0x2c1e8c[_0x5c7c9d]={'$like':'%'+_0x330da9[_0x597b('0x3a')][_0x597b('0x43')]+'%'};return _0x2c1e8c;})});}_0x24e2a7=_[_0x597b('0x44')]({},_0x24e2a7,_0x330da9['options']);return _0x45aa89[_0x597b('0x58')](_0x24e2a7);}})[_0x597b('0x1b')](function(_0x5f32f6){if(_0x5f32f6){_0x30fafb=_0x5f32f6[_0x597b('0x4e')];if(!_0x330da9[_0x597b('0x3a')]['hasOwnProperty']('nolimit')){_0x24e2a7[_0x597b('0x26')]=qs[_0x597b('0x26')](_0x330da9[_0x597b('0x3a')][_0x597b('0x26')]);_0x24e2a7['offset']=qs[_0x597b('0x25')](_0x330da9[_0x597b('0x3a')][_0x597b('0x25')]);}return _0x45aa89[_0x597b('0x58')](_0x24e2a7);}})[_0x597b('0x1b')](function(_0xd1f18d){if(_0xd1f18d){return _0xd1f18d?{'count':_0x30fafb,'rows':_0xd1f18d}:null;}})[_0x597b('0x1b')](respondWithResult(_0x3c5d53,null))[_0x597b('0x4b')](handleError(_0x3c5d53,null));};
\ No newline at end of file
+var _0xf71b=['ejs','lodash','squel','crypto','querystring','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/environment','../../mysqldb','sendStatus','end','offset','undefined','limit','count','status','set','Content-Range','json','apply','update','destroy','then','error','stack','name','send','map','VtigerConfiguration','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','includeAll','findAll','rows','catch','show','params','keys','options','find','create','body','getFields','findOne','VtigerField','order','getSubjects','pick','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv'];(function(_0xa763c1,_0xb5e51){var _0x3774c0=function(_0x30d0dc){while(--_0x30d0dc){_0xa763c1['push'](_0xa763c1['shift']());}};_0x3774c0(++_0xb5e51);}(_0xf71b,0x8e));var _0xbf71=function(_0x50924b,_0x56851c){_0x50924b=_0x50924b-0x0;var _0x1815a4=_0xf71b[_0x50924b];return _0x1815a4;};'use strict';var emlformat=require(_0xbf71('0x0'));var rimraf=require(_0xbf71('0x1'));var zipdir=require(_0xbf71('0x2'));var jsonpatch=require(_0xbf71('0x3'));var rp=require(_0xbf71('0x4'));var moment=require(_0xbf71('0x5'));var BPromise=require(_0xbf71('0x6'));var Mustache=require('mustache');var util=require(_0xbf71('0x7'));var path=require('path');var sox=require(_0xbf71('0x8'));var csv=require(_0xbf71('0x9'));var ejs=require(_0xbf71('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbf71('0xb'));var squel=require(_0xbf71('0xc'));var crypto=require(_0xbf71('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xbf71('0x9'));var querystring=require(_0xbf71('0xe'));var Papa=require('papaparse');var Redis=require(_0xbf71('0xf'));var authService=require(_0xbf71('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbf71('0x11'));var logger=require('../../config/logger')(_0xbf71('0x12'));var utils=require('../../config/utils');var config=require(_0xbf71('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0xbf71('0x14'))['db'];function respondWithStatusCode(_0x5bb27c,_0x59756a){_0x59756a=_0x59756a||0xcc;return function(_0x1f7527){if(_0x1f7527){return _0x5bb27c[_0xbf71('0x15')](_0x59756a);}return _0x5bb27c['status'](_0x59756a)[_0xbf71('0x16')]();};}function respondWithResult(_0x3a6955,_0x3c93cd){_0x3c93cd=_0x3c93cd||0xc8;return function(_0x443d02){if(_0x443d02){return _0x3a6955['status'](_0x3c93cd)['json'](_0x443d02);}};}function respondWithFilteredResult(_0x1f7074,_0x1709b6){return function(_0x4e0f2c){if(_0x4e0f2c){var _0x55c2bf=typeof _0x1709b6[_0xbf71('0x17')]===_0xbf71('0x18')&&typeof _0x1709b6[_0xbf71('0x19')]===_0xbf71('0x18');var _0x5ef59d=_0x4e0f2c[_0xbf71('0x1a')];var _0x3db5e4=_0x55c2bf?0x0:_0x1709b6[_0xbf71('0x17')];var _0x490cb=_0x55c2bf?_0x4e0f2c[_0xbf71('0x1a')]:_0x1709b6[_0xbf71('0x17')]+_0x1709b6[_0xbf71('0x19')];var _0x476e52;if(_0x490cb>=_0x5ef59d){_0x490cb=_0x5ef59d;_0x476e52=0xc8;}else{_0x476e52=0xce;}_0x1f7074[_0xbf71('0x1b')](_0x476e52);return _0x1f7074[_0xbf71('0x1c')](_0xbf71('0x1d'),_0x3db5e4+'-'+_0x490cb+'/'+_0x5ef59d)[_0xbf71('0x1e')](_0x4e0f2c);}return null;};}function patchUpdates(_0xc2d725){return function(_0x375aab){try{jsonpatch[_0xbf71('0x1f')](_0x375aab,_0xc2d725,!![]);}catch(_0x1561c0){return BPromise['reject'](_0x1561c0);}return _0x375aab['save']();};}function saveUpdates(_0x525498,_0x4144e0){return function(_0x25b10e){if(_0x25b10e){return _0x25b10e[_0xbf71('0x20')](_0x525498)['then'](function(_0x47573e){return _0x47573e;});}return null;};}function removeEntity(_0x327220,_0x117a8a){return function(_0x48556a){if(_0x48556a){return _0x48556a[_0xbf71('0x21')]()[_0xbf71('0x22')](function(){_0x327220[_0xbf71('0x1b')](0xcc)[_0xbf71('0x16')]();});}};}function handleEntityNotFound(_0x2056b6,_0x207686){return function(_0x4cba63){if(!_0x4cba63){_0x2056b6['sendStatus'](0x194);}return _0x4cba63;};}function handleError(_0x158654,_0x5c324a){_0x5c324a=_0x5c324a||0x1f4;return function(_0x30790d){logger[_0xbf71('0x23')](_0x30790d[_0xbf71('0x24')]);if(_0x30790d[_0xbf71('0x25')]){delete _0x30790d[_0xbf71('0x25')];}_0x158654[_0xbf71('0x1b')](_0x5c324a)[_0xbf71('0x26')](_0x30790d);};}exports['index']=function(_0x523119,_0x165198){var _0x292869={},_0x5a4564={},_0x5aaefc={'count':0x0,'rows':[]};var _0x223382=_[_0xbf71('0x27')](db[_0xbf71('0x28')][_0xbf71('0x29')],function(_0x5227b1){return{'name':_0x5227b1[_0xbf71('0x2a')],'type':_0x5227b1[_0xbf71('0x2b')]['key']};});_0x5a4564[_0xbf71('0x2c')]=_[_0xbf71('0x27')](_0x223382,_0xbf71('0x25'));_0x5a4564[_0xbf71('0x2d')]=_['keys'](_0x523119[_0xbf71('0x2d')]);_0x5a4564[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x5a4564['model'],_0x5a4564[_0xbf71('0x2d')]);_0x292869[_0xbf71('0x30')]=_[_0xbf71('0x2f')](_0x5a4564[_0xbf71('0x2c')],qs[_0xbf71('0x31')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x292869['attributes']=_0x292869['attributes'][_0xbf71('0x32')]?_0x292869[_0xbf71('0x30')]:_0x5a4564[_0xbf71('0x2c')];if(!_0x523119['query'][_0xbf71('0x33')](_0xbf71('0x34'))){_0x292869['limit']=qs['limit'](_0x523119[_0xbf71('0x2d')][_0xbf71('0x19')]);_0x292869['offset']=qs[_0xbf71('0x17')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x17')]);}_0x292869['order']=qs[_0xbf71('0x35')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x35')]);_0x292869[_0xbf71('0x36')]=qs[_0xbf71('0x2e')](_['pick'](_0x523119[_0xbf71('0x2d')],_0x5a4564[_0xbf71('0x2e')]),_0x223382);if(_0x523119[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x292869[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x292869[_0xbf71('0x36')],{'$or':_[_0xbf71('0x27')](_0x223382,function(_0x16d1e7){if(_0x16d1e7['type']!==_0xbf71('0x39')){var _0x343d6c={};_0x343d6c[_0x16d1e7[_0xbf71('0x25')]]={'$like':'%'+_0x523119['query'][_0xbf71('0x37')]+'%'};return _0x343d6c;}})});}_0x292869=_[_0xbf71('0x38')]({},_0x292869,_0x523119['options']);var _0x301cc9={'where':_0x292869['where']};return db[_0xbf71('0x28')]['count'](_0x301cc9)[_0xbf71('0x22')](function(_0x20148c){_0x5aaefc['count']=_0x20148c;if(_0x523119[_0xbf71('0x2d')][_0xbf71('0x3a')]){_0x292869['include']=[{'all':!![]}];}return db[_0xbf71('0x28')][_0xbf71('0x3b')](_0x292869);})[_0xbf71('0x22')](function(_0x51a720){_0x5aaefc[_0xbf71('0x3c')]=_0x51a720;return _0x5aaefc;})[_0xbf71('0x22')](respondWithFilteredResult(_0x165198,_0x292869))[_0xbf71('0x3d')](handleError(_0x165198,null));};exports[_0xbf71('0x3e')]=function(_0x46d7a4,_0x4976bc){var _0x561d41={'raw':![],'where':{'id':_0x46d7a4[_0xbf71('0x3f')]['id']}},_0x290eef={};_0x290eef[_0xbf71('0x2c')]=_['keys'](db['VtigerConfiguration'][_0xbf71('0x29')]);_0x290eef[_0xbf71('0x2d')]=_[_0xbf71('0x40')](_0x46d7a4['query']);_0x290eef[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x290eef[_0xbf71('0x2c')],_0x290eef[_0xbf71('0x2d')]);_0x561d41[_0xbf71('0x30')]=_[_0xbf71('0x2f')](_0x290eef['model'],qs[_0xbf71('0x31')](_0x46d7a4[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x561d41['attributes']=_0x561d41[_0xbf71('0x30')]['length']?_0x561d41[_0xbf71('0x30')]:_0x290eef[_0xbf71('0x2c')];if(_0x46d7a4[_0xbf71('0x2d')][_0xbf71('0x3a')]){_0x561d41['include']=[{'all':!![]}];}_0x561d41=_[_0xbf71('0x38')]({},_0x561d41,_0x46d7a4[_0xbf71('0x41')]);return db[_0xbf71('0x28')][_0xbf71('0x42')](_0x561d41)[_0xbf71('0x22')](handleEntityNotFound(_0x4976bc,null))[_0xbf71('0x22')](respondWithResult(_0x4976bc,null))[_0xbf71('0x3d')](handleError(_0x4976bc,null));};exports[_0xbf71('0x43')]=function(_0x268901,_0x5adb13){return db[_0xbf71('0x28')]['create'](_0x268901['body'],{})['then'](respondWithResult(_0x5adb13,0xc9))['catch'](handleError(_0x5adb13,null));};exports[_0xbf71('0x20')]=function(_0x398d05,_0x554fd0){if(_0x398d05[_0xbf71('0x44')]['id']){delete _0x398d05['body']['id'];}return db[_0xbf71('0x28')][_0xbf71('0x42')]({'where':{'id':_0x398d05[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x554fd0,null))[_0xbf71('0x22')](saveUpdates(_0x398d05[_0xbf71('0x44')],null))[_0xbf71('0x22')](respondWithResult(_0x554fd0,null))[_0xbf71('0x3d')](handleError(_0x554fd0,null));};exports['destroy']=function(_0x47070a,_0x345515){return db[_0xbf71('0x28')]['find']({'where':{'id':_0x47070a[_0xbf71('0x3f')]['id']}})['then'](handleEntityNotFound(_0x345515,null))['then'](removeEntity(_0x345515,null))[_0xbf71('0x3d')](handleError(_0x345515,null));};exports[_0xbf71('0x45')]=function(_0x571536,_0x21a55c,_0x266049){var _0xedd86b={};var _0xf51ff8={};var _0xafd18b;var _0x2c01a6;return db[_0xbf71('0x28')][_0xbf71('0x46')]({'where':{'id':_0x571536['params']['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x21a55c,null))['then'](function(_0x12ccc3){if(_0x12ccc3){_0xafd18b=_0x12ccc3;_0xf51ff8['model']=_['keys'](db[_0xbf71('0x47')][_0xbf71('0x29')]);_0xf51ff8[_0xbf71('0x2d')]=_['keys'](_0x571536[_0xbf71('0x2d')]);_0xf51ff8['filters']=_[_0xbf71('0x2f')](_0xf51ff8[_0xbf71('0x2c')],_0xf51ff8[_0xbf71('0x2d')]);_0xedd86b['attributes']=_['intersection'](_0xf51ff8['model'],qs[_0xbf71('0x31')](_0x571536['query'][_0xbf71('0x31')]));_0xedd86b[_0xbf71('0x30')]=_0xedd86b[_0xbf71('0x30')][_0xbf71('0x32')]?_0xedd86b['attributes']:_0xf51ff8['model'];_0xedd86b[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0x571536[_0xbf71('0x2d')][_0xbf71('0x35')]);_0xedd86b['where']=qs[_0xbf71('0x2e')](_['pick'](_0x571536[_0xbf71('0x2d')],_0xf51ff8[_0xbf71('0x2e')]));if(_0x571536['query'][_0xbf71('0x37')]){_0xedd86b[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0xedd86b['where'],{'$or':_[_0xbf71('0x27')](_0xedd86b[_0xbf71('0x30')],function(_0x42192a){var _0x22fdf8={};_0x22fdf8[_0x42192a]={'$like':'%'+_0x571536[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x22fdf8;})});}_0xedd86b=_[_0xbf71('0x38')]({},_0xedd86b,_0x571536['options']);return _0xafd18b[_0xbf71('0x45')](_0xedd86b);}})['then'](function(_0x56c772){if(_0x56c772){_0x2c01a6=_0x56c772[_0xbf71('0x32')];if(!_0x571536[_0xbf71('0x2d')]['hasOwnProperty'](_0xbf71('0x34'))){_0xedd86b[_0xbf71('0x19')]=qs['limit'](_0x571536['query']['limit']);_0xedd86b['offset']=qs[_0xbf71('0x17')](_0x571536[_0xbf71('0x2d')]['offset']);}return _0xafd18b[_0xbf71('0x45')](_0xedd86b);}})['then'](function(_0x8ce0b2){if(_0x8ce0b2){return _0x8ce0b2?{'count':_0x2c01a6,'rows':_0x8ce0b2}:null;}})[_0xbf71('0x22')](respondWithResult(_0x21a55c,null))[_0xbf71('0x3d')](handleError(_0x21a55c,null));};exports[_0xbf71('0x49')]=function(_0xc8ab3d,_0x26a13d,_0xdecd2e){var _0x3ff8f9={};var _0x32ecf0={};var _0xff1859;var _0x3df669;return db[_0xbf71('0x28')]['findOne']({'where':{'id':_0xc8ab3d[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x26a13d,null))['then'](function(_0x2f9106){if(_0x2f9106){_0xff1859=_0x2f9106;_0x32ecf0[_0xbf71('0x2c')]=_[_0xbf71('0x40')](db[_0xbf71('0x47')][_0xbf71('0x29')]);_0x32ecf0['query']=_[_0xbf71('0x40')](_0xc8ab3d[_0xbf71('0x2d')]);_0x32ecf0['filters']=_[_0xbf71('0x2f')](_0x32ecf0[_0xbf71('0x2c')],_0x32ecf0[_0xbf71('0x2d')]);_0x3ff8f9[_0xbf71('0x30')]=_['intersection'](_0x32ecf0[_0xbf71('0x2c')],qs['fields'](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x3ff8f9[_0xbf71('0x30')]=_0x3ff8f9[_0xbf71('0x30')][_0xbf71('0x32')]?_0x3ff8f9[_0xbf71('0x30')]:_0x32ecf0[_0xbf71('0x2c')];_0x3ff8f9[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x35')]);_0x3ff8f9['where']=qs['filters'](_[_0xbf71('0x4a')](_0xc8ab3d[_0xbf71('0x2d')],_0x32ecf0[_0xbf71('0x2e')]));if(_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x3ff8f9[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x3ff8f9[_0xbf71('0x36')],{'$or':_['map'](_0x3ff8f9['attributes'],function(_0x37f42d){var _0x12f993={};_0x12f993[_0x37f42d]={'$like':'%'+_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x12f993;})});}_0x3ff8f9=_[_0xbf71('0x38')]({},_0x3ff8f9,_0xc8ab3d[_0xbf71('0x41')]);return _0xff1859[_0xbf71('0x49')](_0x3ff8f9);}})[_0xbf71('0x22')](function(_0xeb4b98){if(_0xeb4b98){_0x3df669=_0xeb4b98[_0xbf71('0x32')];if(!_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x33')](_0xbf71('0x34'))){_0x3ff8f9['limit']=qs[_0xbf71('0x19')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x19')]);_0x3ff8f9['offset']=qs[_0xbf71('0x17')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x17')]);}return _0xff1859[_0xbf71('0x49')](_0x3ff8f9);}})[_0xbf71('0x22')](function(_0x2fe131){if(_0x2fe131){return _0x2fe131?{'count':_0x3df669,'rows':_0x2fe131}:null;}})[_0xbf71('0x22')](respondWithResult(_0x26a13d,null))['catch'](handleError(_0x26a13d,null));};exports['getDescriptions']=function(_0x5b074c,_0x41abe4,_0x1a75c8){var _0x4ec41e={};var _0x5a1fe1={};var _0x5468f0;var _0x3dfc55;return db[_0xbf71('0x28')][_0xbf71('0x46')]({'where':{'id':_0x5b074c[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x41abe4,null))[_0xbf71('0x22')](function(_0x5c0208){if(_0x5c0208){_0x5468f0=_0x5c0208;_0x5a1fe1[_0xbf71('0x2c')]=_[_0xbf71('0x40')](db[_0xbf71('0x47')]['rawAttributes']);_0x5a1fe1['query']=_[_0xbf71('0x40')](_0x5b074c['query']);_0x5a1fe1[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x5a1fe1['model'],_0x5a1fe1['query']);_0x4ec41e['attributes']=_[_0xbf71('0x2f')](_0x5a1fe1['model'],qs[_0xbf71('0x31')](_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x4ec41e[_0xbf71('0x30')]=_0x4ec41e[_0xbf71('0x30')]['length']?_0x4ec41e[_0xbf71('0x30')]:_0x5a1fe1['model'];_0x4ec41e[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0x5b074c[_0xbf71('0x2d')]['sort']);_0x4ec41e[_0xbf71('0x36')]=qs['filters'](_[_0xbf71('0x4a')](_0x5b074c[_0xbf71('0x2d')],_0x5a1fe1['filters']));if(_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x4ec41e[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x4ec41e[_0xbf71('0x36')],{'$or':_['map'](_0x4ec41e[_0xbf71('0x30')],function(_0x199890){var _0x14e4ce={};_0x14e4ce[_0x199890]={'$like':'%'+_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x14e4ce;})});}_0x4ec41e=_['merge']({},_0x4ec41e,_0x5b074c[_0xbf71('0x41')]);return _0x5468f0[_0xbf71('0x4b')](_0x4ec41e);}})[_0xbf71('0x22')](function(_0x3f22a3){if(_0x3f22a3){_0x3dfc55=_0x3f22a3[_0xbf71('0x32')];if(!_0x5b074c[_0xbf71('0x2d')]['hasOwnProperty'](_0xbf71('0x34'))){_0x4ec41e['limit']=qs[_0xbf71('0x19')](_0x5b074c['query'][_0xbf71('0x19')]);_0x4ec41e['offset']=qs[_0xbf71('0x17')](_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x17')]);}return _0x5468f0['getDescriptions'](_0x4ec41e);}})[_0xbf71('0x22')](function(_0x4123dc){if(_0x4123dc){return _0x4123dc?{'count':_0x3dfc55,'rows':_0x4123dc}:null;}})['then'](respondWithResult(_0x41abe4,null))[_0xbf71('0x3d')](handleError(_0x41abe4,null));};
\ No newline at end of file