Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 3d2b867..fae89b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf337=['desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','status','offset','undefined','limit','set','Content-Range','json','apply','save','update','then','error','stack','name','send','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','VtigerConfiguration','count','includeAll','include','catch','show','params','find','create','body','getFields','findOne','VtigerField','getSubjects','getDescriptions','rimraf','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce'];(function(_0x318256,_0xa773f3){var _0xb1e352=function(_0x4bb14e){while(--_0x4bb14e){_0x318256['push'](_0x318256['shift']());}};_0xb1e352(++_0xa773f3);}(_0xf337,0x174));var _0x7f33=function(_0x1a332f,_0x5e7365){_0x1a332f=_0x1a332f-0x0;var _0x611ed5=_0xf337[_0x1a332f];return _0x611ed5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7f33('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x7f33('0x1'));var moment=require(_0x7f33('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x7f33('0x3'));var util=require(_0x7f33('0x4'));var path=require(_0x7f33('0x5'));var sox=require(_0x7f33('0x6'));var csv=require(_0x7f33('0x7'));var ejs=require(_0x7f33('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7f33('0x9'));var squel=require(_0x7f33('0xa'));var crypto=require(_0x7f33('0xb'));var jsforce=require(_0x7f33('0xc'));var deskjs=require(_0x7f33('0xd'));var toCsv=require(_0x7f33('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x7f33('0xe'));var authService=require(_0x7f33('0xf'));var qs=require(_0x7f33('0x10'));var as=require(_0x7f33('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7f33('0x12'))('api');var utils=require(_0x7f33('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x7f33('0x14'));var db=require(_0x7f33('0x15'))['db'];function respondWithStatusCode(_0x38294e,_0x3617c5){_0x3617c5=_0x3617c5||0xcc;return function(_0x2b13a3){if(_0x2b13a3){return _0x38294e[_0x7f33('0x16')](_0x3617c5);}return _0x38294e['status'](_0x3617c5)[_0x7f33('0x17')]();};}function respondWithResult(_0x22f4d6,_0x17f699){_0x17f699=_0x17f699||0xc8;return function(_0x5c23e2){if(_0x5c23e2){return _0x22f4d6[_0x7f33('0x18')](_0x17f699)['json'](_0x5c23e2);}};}function respondWithFilteredResult(_0x5ea40f,_0x4c12d7){return function(_0x1f0ec8){if(_0x1f0ec8){var _0x4ef498=typeof _0x4c12d7[_0x7f33('0x19')]===_0x7f33('0x1a')&&typeof _0x4c12d7[_0x7f33('0x1b')]==='undefined';var _0x2bbf16=_0x1f0ec8['count'];var _0x1f7ce9=_0x4ef498?0x0:_0x4c12d7[_0x7f33('0x19')];var _0x5cb525=_0x4ef498?_0x1f0ec8['count']:_0x4c12d7[_0x7f33('0x19')]+_0x4c12d7[_0x7f33('0x1b')];var _0x13e0b2;if(_0x5cb525>=_0x2bbf16){_0x5cb525=_0x2bbf16;_0x13e0b2=0xc8;}else{_0x13e0b2=0xce;}_0x5ea40f[_0x7f33('0x18')](_0x13e0b2);return _0x5ea40f[_0x7f33('0x1c')](_0x7f33('0x1d'),_0x1f7ce9+'-'+_0x5cb525+'/'+_0x2bbf16)[_0x7f33('0x1e')](_0x1f0ec8);}return null;};}function patchUpdates(_0x2328ab){return function(_0xdc2610){try{jsonpatch[_0x7f33('0x1f')](_0xdc2610,_0x2328ab,!![]);}catch(_0x3d014b){return BPromise['reject'](_0x3d014b);}return _0xdc2610[_0x7f33('0x20')]();};}function saveUpdates(_0x22109e,_0x583e8d){return function(_0x75804a){if(_0x75804a){return _0x75804a[_0x7f33('0x21')](_0x22109e)[_0x7f33('0x22')](function(_0x31f1ec){return _0x31f1ec;});}return null;};}function removeEntity(_0xf5fa60,_0x137cb0){return function(_0x1961a3){if(_0x1961a3){return _0x1961a3['destroy']()[_0x7f33('0x22')](function(){_0xf5fa60[_0x7f33('0x18')](0xcc)[_0x7f33('0x17')]();});}};}function handleEntityNotFound(_0x154966,_0x1f80ad){return function(_0x17a00f){if(!_0x17a00f){_0x154966[_0x7f33('0x16')](0x194);}return _0x17a00f;};}function handleError(_0x4602a8,_0x576f50){_0x576f50=_0x576f50||0x1f4;return function(_0x4f1498){logger[_0x7f33('0x23')](_0x4f1498[_0x7f33('0x24')]);if(_0x4f1498[_0x7f33('0x25')]){delete _0x4f1498[_0x7f33('0x25')];}_0x4602a8[_0x7f33('0x18')](_0x576f50)[_0x7f33('0x26')](_0x4f1498);};}exports['index']=function(_0x4296c3,_0x58ba21){var _0x1661b5={},_0x256cc0={},_0x2095fe={'count':0x0,'rows':[]};var _0x527c86=_['map'](db['VtigerConfiguration'][_0x7f33('0x27')],function(_0x32b0ab){return{'name':_0x32b0ab[_0x7f33('0x28')],'type':_0x32b0ab[_0x7f33('0x29')][_0x7f33('0x2a')]};});_0x256cc0[_0x7f33('0x2b')]=_[_0x7f33('0x2c')](_0x527c86,_0x7f33('0x25'));_0x256cc0[_0x7f33('0x2d')]=_[_0x7f33('0x2e')](_0x4296c3[_0x7f33('0x2d')]);_0x256cc0[_0x7f33('0x2f')]=_[_0x7f33('0x30')](_0x256cc0[_0x7f33('0x2b')],_0x256cc0[_0x7f33('0x2d')]);_0x1661b5['attributes']=_[_0x7f33('0x30')](_0x256cc0[_0x7f33('0x2b')],qs[_0x7f33('0x31')](_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x31')]));_0x1661b5[_0x7f33('0x32')]=_0x1661b5[_0x7f33('0x32')][_0x7f33('0x33')]?_0x1661b5['attributes']:_0x256cc0[_0x7f33('0x2b')];if(!_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x34')](_0x7f33('0x35'))){_0x1661b5['limit']=qs[_0x7f33('0x1b')](_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x1b')]);_0x1661b5[_0x7f33('0x19')]=qs['offset'](_0x4296c3['query'][_0x7f33('0x19')]);}_0x1661b5[_0x7f33('0x36')]=qs[_0x7f33('0x37')](_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x37')]);_0x1661b5['where']=qs['filters'](_[_0x7f33('0x38')](_0x4296c3[_0x7f33('0x2d')],_0x256cc0['filters']),_0x527c86);if(_0x4296c3['query'][_0x7f33('0x39')]){_0x1661b5[_0x7f33('0x3a')]=_[_0x7f33('0x3b')](_0x1661b5[_0x7f33('0x3a')],{'$or':_[_0x7f33('0x2c')](_0x527c86,function(_0x4d5e3c){if(_0x4d5e3c[_0x7f33('0x29')]!==_0x7f33('0x3c')){var _0x15bd2b={};_0x15bd2b[_0x4d5e3c[_0x7f33('0x25')]]={'$like':'%'+_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x39')]+'%'};return _0x15bd2b;}})});}_0x1661b5=_[_0x7f33('0x3b')]({},_0x1661b5,_0x4296c3[_0x7f33('0x3d')]);var _0x33f5a9={'where':_0x1661b5[_0x7f33('0x3a')]};return db[_0x7f33('0x3e')]['count'](_0x33f5a9)[_0x7f33('0x22')](function(_0x4a84ef){_0x2095fe[_0x7f33('0x3f')]=_0x4a84ef;if(_0x4296c3[_0x7f33('0x2d')][_0x7f33('0x40')]){_0x1661b5[_0x7f33('0x41')]=[{'all':!![]}];}return db[_0x7f33('0x3e')]['findAll'](_0x1661b5);})[_0x7f33('0x22')](function(_0x1d3f4b){_0x2095fe['rows']=_0x1d3f4b;return _0x2095fe;})['then'](respondWithFilteredResult(_0x58ba21,_0x1661b5))[_0x7f33('0x42')](handleError(_0x58ba21,null));};exports[_0x7f33('0x43')]=function(_0x1ced77,_0x1a2ba9){var _0x3f418e={'raw':![],'where':{'id':_0x1ced77[_0x7f33('0x44')]['id']}},_0x4e2ae7={};_0x4e2ae7[_0x7f33('0x2b')]=_['keys'](db[_0x7f33('0x3e')][_0x7f33('0x27')]);_0x4e2ae7[_0x7f33('0x2d')]=_[_0x7f33('0x2e')](_0x1ced77[_0x7f33('0x2d')]);_0x4e2ae7[_0x7f33('0x2f')]=_[_0x7f33('0x30')](_0x4e2ae7[_0x7f33('0x2b')],_0x4e2ae7[_0x7f33('0x2d')]);_0x3f418e[_0x7f33('0x32')]=_[_0x7f33('0x30')](_0x4e2ae7[_0x7f33('0x2b')],qs['fields'](_0x1ced77[_0x7f33('0x2d')]['fields']));_0x3f418e[_0x7f33('0x32')]=_0x3f418e[_0x7f33('0x32')][_0x7f33('0x33')]?_0x3f418e[_0x7f33('0x32')]:_0x4e2ae7['model'];if(_0x1ced77[_0x7f33('0x2d')]['includeAll']){_0x3f418e['include']=[{'all':!![]}];}_0x3f418e=_['merge']({},_0x3f418e,_0x1ced77[_0x7f33('0x3d')]);return db[_0x7f33('0x3e')][_0x7f33('0x45')](_0x3f418e)['then'](handleEntityNotFound(_0x1a2ba9,null))[_0x7f33('0x22')](respondWithResult(_0x1a2ba9,null))['catch'](handleError(_0x1a2ba9,null));};exports[_0x7f33('0x46')]=function(_0x4bcddf,_0x4d42cb){return db[_0x7f33('0x3e')][_0x7f33('0x46')](_0x4bcddf['body'],{})[_0x7f33('0x22')](respondWithResult(_0x4d42cb,0xc9))[_0x7f33('0x42')](handleError(_0x4d42cb,null));};exports['update']=function(_0x4a9739,_0x3859ea){if(_0x4a9739[_0x7f33('0x47')]['id']){delete _0x4a9739['body']['id'];}return db[_0x7f33('0x3e')]['find']({'where':{'id':_0x4a9739[_0x7f33('0x44')]['id']}})[_0x7f33('0x22')](handleEntityNotFound(_0x3859ea,null))[_0x7f33('0x22')](saveUpdates(_0x4a9739[_0x7f33('0x47')],null))[_0x7f33('0x22')](respondWithResult(_0x3859ea,null))[_0x7f33('0x42')](handleError(_0x3859ea,null));};exports['destroy']=function(_0x20ccd9,_0x57c776){return db[_0x7f33('0x3e')][_0x7f33('0x45')]({'where':{'id':_0x20ccd9['params']['id']}})[_0x7f33('0x22')](handleEntityNotFound(_0x57c776,null))[_0x7f33('0x22')](removeEntity(_0x57c776,null))['catch'](handleError(_0x57c776,null));};exports[_0x7f33('0x48')]=function(_0x552126,_0x55e54e,_0x1d58b8){var _0x2b9449={};var _0x1a5380={};var _0x2be467;var _0x3fc225;return db[_0x7f33('0x3e')][_0x7f33('0x49')]({'where':{'id':_0x552126[_0x7f33('0x44')]['id']}})[_0x7f33('0x22')](handleEntityNotFound(_0x55e54e,null))[_0x7f33('0x22')](function(_0x567c60){if(_0x567c60){_0x2be467=_0x567c60;_0x1a5380[_0x7f33('0x2b')]=_['keys'](db[_0x7f33('0x4a')][_0x7f33('0x27')]);_0x1a5380[_0x7f33('0x2d')]=_[_0x7f33('0x2e')](_0x552126[_0x7f33('0x2d')]);_0x1a5380[_0x7f33('0x2f')]=_[_0x7f33('0x30')](_0x1a5380[_0x7f33('0x2b')],_0x1a5380[_0x7f33('0x2d')]);_0x2b9449[_0x7f33('0x32')]=_['intersection'](_0x1a5380[_0x7f33('0x2b')],qs[_0x7f33('0x31')](_0x552126[_0x7f33('0x2d')][_0x7f33('0x31')]));_0x2b9449['attributes']=_0x2b9449[_0x7f33('0x32')][_0x7f33('0x33')]?_0x2b9449[_0x7f33('0x32')]:_0x1a5380[_0x7f33('0x2b')];_0x2b9449[_0x7f33('0x36')]=qs['sort'](_0x552126[_0x7f33('0x2d')][_0x7f33('0x37')]);_0x2b9449[_0x7f33('0x3a')]=qs[_0x7f33('0x2f')](_[_0x7f33('0x38')](_0x552126[_0x7f33('0x2d')],_0x1a5380['filters']));if(_0x552126['query'][_0x7f33('0x39')]){_0x2b9449[_0x7f33('0x3a')]=_[_0x7f33('0x3b')](_0x2b9449[_0x7f33('0x3a')],{'$or':_[_0x7f33('0x2c')](_0x2b9449[_0x7f33('0x32')],function(_0x2fdb0c){var _0x2d46ea={};_0x2d46ea[_0x2fdb0c]={'$like':'%'+_0x552126[_0x7f33('0x2d')][_0x7f33('0x39')]+'%'};return _0x2d46ea;})});}_0x2b9449=_[_0x7f33('0x3b')]({},_0x2b9449,_0x552126[_0x7f33('0x3d')]);return _0x2be467[_0x7f33('0x48')](_0x2b9449);}})[_0x7f33('0x22')](function(_0x5963bc){if(_0x5963bc){_0x3fc225=_0x5963bc['length'];if(!_0x552126[_0x7f33('0x2d')][_0x7f33('0x34')](_0x7f33('0x35'))){_0x2b9449['limit']=qs['limit'](_0x552126[_0x7f33('0x2d')][_0x7f33('0x1b')]);_0x2b9449[_0x7f33('0x19')]=qs['offset'](_0x552126[_0x7f33('0x2d')][_0x7f33('0x19')]);}return _0x2be467[_0x7f33('0x48')](_0x2b9449);}})[_0x7f33('0x22')](function(_0x3f5e49){if(_0x3f5e49){return _0x3f5e49?{'count':_0x3fc225,'rows':_0x3f5e49}:null;}})[_0x7f33('0x22')](respondWithResult(_0x55e54e,null))[_0x7f33('0x42')](handleError(_0x55e54e,null));};exports[_0x7f33('0x4b')]=function(_0x5361f5,_0x4270a3,_0x3616c9){var _0x5e4da1={};var _0x5a9ef7={};var _0x1688b4;var _0xdc7f16;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x5361f5[_0x7f33('0x44')]['id']}})[_0x7f33('0x22')](handleEntityNotFound(_0x4270a3,null))[_0x7f33('0x22')](function(_0x869d58){if(_0x869d58){_0x1688b4=_0x869d58;_0x5a9ef7['model']=_[_0x7f33('0x2e')](db[_0x7f33('0x4a')][_0x7f33('0x27')]);_0x5a9ef7[_0x7f33('0x2d')]=_['keys'](_0x5361f5['query']);_0x5a9ef7[_0x7f33('0x2f')]=_['intersection'](_0x5a9ef7[_0x7f33('0x2b')],_0x5a9ef7['query']);_0x5e4da1['attributes']=_[_0x7f33('0x30')](_0x5a9ef7['model'],qs[_0x7f33('0x31')](_0x5361f5[_0x7f33('0x2d')][_0x7f33('0x31')]));_0x5e4da1[_0x7f33('0x32')]=_0x5e4da1[_0x7f33('0x32')][_0x7f33('0x33')]?_0x5e4da1[_0x7f33('0x32')]:_0x5a9ef7[_0x7f33('0x2b')];_0x5e4da1[_0x7f33('0x36')]=qs['sort'](_0x5361f5['query']['sort']);_0x5e4da1[_0x7f33('0x3a')]=qs[_0x7f33('0x2f')](_[_0x7f33('0x38')](_0x5361f5[_0x7f33('0x2d')],_0x5a9ef7['filters']));if(_0x5361f5['query']['filter']){_0x5e4da1[_0x7f33('0x3a')]=_['merge'](_0x5e4da1[_0x7f33('0x3a')],{'$or':_[_0x7f33('0x2c')](_0x5e4da1[_0x7f33('0x32')],function(_0x121b24){var _0x11096f={};_0x11096f[_0x121b24]={'$like':'%'+_0x5361f5[_0x7f33('0x2d')][_0x7f33('0x39')]+'%'};return _0x11096f;})});}_0x5e4da1=_[_0x7f33('0x3b')]({},_0x5e4da1,_0x5361f5[_0x7f33('0x3d')]);return _0x1688b4[_0x7f33('0x4b')](_0x5e4da1);}})[_0x7f33('0x22')](function(_0xac50cc){if(_0xac50cc){_0xdc7f16=_0xac50cc[_0x7f33('0x33')];if(!_0x5361f5[_0x7f33('0x2d')][_0x7f33('0x34')](_0x7f33('0x35'))){_0x5e4da1[_0x7f33('0x1b')]=qs['limit'](_0x5361f5['query'][_0x7f33('0x1b')]);_0x5e4da1[_0x7f33('0x19')]=qs[_0x7f33('0x19')](_0x5361f5[_0x7f33('0x2d')][_0x7f33('0x19')]);}return _0x1688b4[_0x7f33('0x4b')](_0x5e4da1);}})[_0x7f33('0x22')](function(_0x1ace34){if(_0x1ace34){return _0x1ace34?{'count':_0xdc7f16,'rows':_0x1ace34}:null;}})[_0x7f33('0x22')](respondWithResult(_0x4270a3,null))[_0x7f33('0x42')](handleError(_0x4270a3,null));};exports[_0x7f33('0x4c')]=function(_0x594f91,_0x22466e,_0x1cc46f){var _0x2d8947={};var _0x1c7a8f={};var _0x809a09;var _0x3ae171;return db[_0x7f33('0x3e')][_0x7f33('0x49')]({'where':{'id':_0x594f91['params']['id']}})['then'](handleEntityNotFound(_0x22466e,null))[_0x7f33('0x22')](function(_0x127aaf){if(_0x127aaf){_0x809a09=_0x127aaf;_0x1c7a8f[_0x7f33('0x2b')]=_[_0x7f33('0x2e')](db[_0x7f33('0x4a')][_0x7f33('0x27')]);_0x1c7a8f['query']=_[_0x7f33('0x2e')](_0x594f91['query']);_0x1c7a8f[_0x7f33('0x2f')]=_[_0x7f33('0x30')](_0x1c7a8f[_0x7f33('0x2b')],_0x1c7a8f[_0x7f33('0x2d')]);_0x2d8947[_0x7f33('0x32')]=_[_0x7f33('0x30')](_0x1c7a8f[_0x7f33('0x2b')],qs[_0x7f33('0x31')](_0x594f91[_0x7f33('0x2d')][_0x7f33('0x31')]));_0x2d8947[_0x7f33('0x32')]=_0x2d8947[_0x7f33('0x32')]['length']?_0x2d8947[_0x7f33('0x32')]:_0x1c7a8f['model'];_0x2d8947[_0x7f33('0x36')]=qs[_0x7f33('0x37')](_0x594f91[_0x7f33('0x2d')][_0x7f33('0x37')]);_0x2d8947[_0x7f33('0x3a')]=qs['filters'](_['pick'](_0x594f91[_0x7f33('0x2d')],_0x1c7a8f['filters']));if(_0x594f91[_0x7f33('0x2d')][_0x7f33('0x39')]){_0x2d8947['where']=_[_0x7f33('0x3b')](_0x2d8947['where'],{'$or':_[_0x7f33('0x2c')](_0x2d8947[_0x7f33('0x32')],function(_0x539407){var _0x12b047={};_0x12b047[_0x539407]={'$like':'%'+_0x594f91[_0x7f33('0x2d')][_0x7f33('0x39')]+'%'};return _0x12b047;})});}_0x2d8947=_[_0x7f33('0x3b')]({},_0x2d8947,_0x594f91['options']);return _0x809a09[_0x7f33('0x4c')](_0x2d8947);}})[_0x7f33('0x22')](function(_0xb6dfe6){if(_0xb6dfe6){_0x3ae171=_0xb6dfe6['length'];if(!_0x594f91[_0x7f33('0x2d')][_0x7f33('0x34')](_0x7f33('0x35'))){_0x2d8947[_0x7f33('0x1b')]=qs['limit'](_0x594f91[_0x7f33('0x2d')]['limit']);_0x2d8947['offset']=qs[_0x7f33('0x19')](_0x594f91['query'][_0x7f33('0x19')]);}return _0x809a09[_0x7f33('0x4c')](_0x2d8947);}})[_0x7f33('0x22')](function(_0x18e7e2){if(_0x18e7e2){return _0x18e7e2?{'count':_0x3ae171,'rows':_0x18e7e2}:null;}})[_0x7f33('0x22')](respondWithResult(_0x22466e,null))[_0x7f33('0x42')](handleError(_0x22466e,null));};
\ No newline at end of file
+var _0x2b88=['fields','attributes','length','sort','where','pick','filter','merge','VIRTUAL','name','options','includeAll','include','rows','show','params','find','catch','create','body','findOne','VtigerField','rawAttributes','order','getFields','nolimit','getSubjects','getDescriptions','hasOwnProperty','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','send','map','VtigerConfiguration','type','key','model','query','keys','filters','intersection'];(function(_0x2ad9f7,_0x5a6016){var _0x15e5b4=function(_0xec3eae){while(--_0xec3eae){_0x2ad9f7['push'](_0x2ad9f7['shift']());}};_0x15e5b4(++_0x5a6016);}(_0x2b88,0xc1));var _0x82b8=function(_0xc28702,_0x145b87){_0xc28702=_0xc28702-0x0;var _0x3b6e9e=_0x2b88[_0xc28702];return _0x3b6e9e;};'use strict';var emlformat=require(_0x82b8('0x0'));var rimraf=require(_0x82b8('0x1'));var zipdir=require(_0x82b8('0x2'));var jsonpatch=require(_0x82b8('0x3'));var rp=require(_0x82b8('0x4'));var moment=require(_0x82b8('0x5'));var BPromise=require(_0x82b8('0x6'));var Mustache=require(_0x82b8('0x7'));var util=require('util');var path=require(_0x82b8('0x8'));var sox=require(_0x82b8('0x9'));var csv=require(_0x82b8('0xa'));var ejs=require(_0x82b8('0xb'));var fs=require('fs');var fs_extra=require(_0x82b8('0xc'));var _=require(_0x82b8('0xd'));var squel=require(_0x82b8('0xe'));var crypto=require(_0x82b8('0xf'));var jsforce=require(_0x82b8('0x10'));var deskjs=require(_0x82b8('0x11'));var toCsv=require(_0x82b8('0xa'));var querystring=require(_0x82b8('0x12'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x82b8('0x13'));var qs=require(_0x82b8('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x82b8('0x15'));var utils=require(_0x82b8('0x16'));var config=require(_0x82b8('0x17'));var licenseUtil=require(_0x82b8('0x18'));var db=require(_0x82b8('0x19'))['db'];function respondWithStatusCode(_0x5a8877,_0x3d8b1e){_0x3d8b1e=_0x3d8b1e||0xcc;return function(_0x32b1bd){if(_0x32b1bd){return _0x5a8877[_0x82b8('0x1a')](_0x3d8b1e);}return _0x5a8877[_0x82b8('0x1b')](_0x3d8b1e)[_0x82b8('0x1c')]();};}function respondWithResult(_0x1153cb,_0x13edc0){_0x13edc0=_0x13edc0||0xc8;return function(_0x37464a){if(_0x37464a){return _0x1153cb[_0x82b8('0x1b')](_0x13edc0)[_0x82b8('0x1d')](_0x37464a);}};}function respondWithFilteredResult(_0x50b7cc,_0x507cab){return function(_0x2a5129){if(_0x2a5129){var _0x3851d5=typeof _0x507cab[_0x82b8('0x1e')]===_0x82b8('0x1f')&&typeof _0x507cab[_0x82b8('0x20')]==='undefined';var _0x505b41=_0x2a5129[_0x82b8('0x21')];var _0x3f9021=_0x3851d5?0x0:_0x507cab['offset'];var _0x3e5b4b=_0x3851d5?_0x2a5129[_0x82b8('0x21')]:_0x507cab[_0x82b8('0x1e')]+_0x507cab[_0x82b8('0x20')];var _0x1cedb2;if(_0x3e5b4b>=_0x505b41){_0x3e5b4b=_0x505b41;_0x1cedb2=0xc8;}else{_0x1cedb2=0xce;}_0x50b7cc['status'](_0x1cedb2);return _0x50b7cc[_0x82b8('0x22')](_0x82b8('0x23'),_0x3f9021+'-'+_0x3e5b4b+'/'+_0x505b41)[_0x82b8('0x1d')](_0x2a5129);}return null;};}function patchUpdates(_0x585680){return function(_0x43d39b){try{jsonpatch[_0x82b8('0x24')](_0x43d39b,_0x585680,!![]);}catch(_0x4dc025){return BPromise[_0x82b8('0x25')](_0x4dc025);}return _0x43d39b[_0x82b8('0x26')]();};}function saveUpdates(_0x4269ad,_0x23d7d4){return function(_0xb03527){if(_0xb03527){return _0xb03527[_0x82b8('0x27')](_0x4269ad)[_0x82b8('0x28')](function(_0x24de9f){return _0x24de9f;});}return null;};}function removeEntity(_0x5e83f5,_0x228ff6){return function(_0x235c7a){if(_0x235c7a){return _0x235c7a[_0x82b8('0x29')]()[_0x82b8('0x28')](function(){_0x5e83f5[_0x82b8('0x1b')](0xcc)[_0x82b8('0x1c')]();});}};}function handleEntityNotFound(_0x4b208d,_0x2d059c){return function(_0x33c817){if(!_0x33c817){_0x4b208d[_0x82b8('0x1a')](0x194);}return _0x33c817;};}function handleError(_0x192661,_0xc71270){_0xc71270=_0xc71270||0x1f4;return function(_0x5ed243){logger[_0x82b8('0x2a')](_0x5ed243['stack']);if(_0x5ed243['name']){delete _0x5ed243['name'];}_0x192661['status'](_0xc71270)[_0x82b8('0x2b')](_0x5ed243);};}exports['index']=function(_0x582d9c,_0x331929){var _0x4d4a4d={},_0xe041e9={},_0x5f020d={'count':0x0,'rows':[]};var _0x5aaa97=_[_0x82b8('0x2c')](db[_0x82b8('0x2d')]['rawAttributes'],function(_0xc872e9){return{'name':_0xc872e9['fieldName'],'type':_0xc872e9[_0x82b8('0x2e')][_0x82b8('0x2f')]};});_0xe041e9[_0x82b8('0x30')]=_['map'](_0x5aaa97,'name');_0xe041e9[_0x82b8('0x31')]=_[_0x82b8('0x32')](_0x582d9c[_0x82b8('0x31')]);_0xe041e9[_0x82b8('0x33')]=_[_0x82b8('0x34')](_0xe041e9[_0x82b8('0x30')],_0xe041e9[_0x82b8('0x31')]);_0x4d4a4d['attributes']=_[_0x82b8('0x34')](_0xe041e9[_0x82b8('0x30')],qs[_0x82b8('0x35')](_0x582d9c[_0x82b8('0x31')][_0x82b8('0x35')]));_0x4d4a4d[_0x82b8('0x36')]=_0x4d4a4d[_0x82b8('0x36')][_0x82b8('0x37')]?_0x4d4a4d[_0x82b8('0x36')]:_0xe041e9[_0x82b8('0x30')];if(!_0x582d9c[_0x82b8('0x31')]['hasOwnProperty']('nolimit')){_0x4d4a4d[_0x82b8('0x20')]=qs[_0x82b8('0x20')](_0x582d9c[_0x82b8('0x31')][_0x82b8('0x20')]);_0x4d4a4d['offset']=qs[_0x82b8('0x1e')](_0x582d9c[_0x82b8('0x31')]['offset']);}_0x4d4a4d['order']=qs[_0x82b8('0x38')](_0x582d9c[_0x82b8('0x31')][_0x82b8('0x38')]);_0x4d4a4d[_0x82b8('0x39')]=qs[_0x82b8('0x33')](_[_0x82b8('0x3a')](_0x582d9c[_0x82b8('0x31')],_0xe041e9[_0x82b8('0x33')]),_0x5aaa97);if(_0x582d9c['query'][_0x82b8('0x3b')]){_0x4d4a4d[_0x82b8('0x39')]=_[_0x82b8('0x3c')](_0x4d4a4d[_0x82b8('0x39')],{'$or':_[_0x82b8('0x2c')](_0x5aaa97,function(_0x192058){if(_0x192058[_0x82b8('0x2e')]!==_0x82b8('0x3d')){var _0x2537d8={};_0x2537d8[_0x192058[_0x82b8('0x3e')]]={'$like':'%'+_0x582d9c['query'][_0x82b8('0x3b')]+'%'};return _0x2537d8;}})});}_0x4d4a4d=_[_0x82b8('0x3c')]({},_0x4d4a4d,_0x582d9c[_0x82b8('0x3f')]);var _0x15baaf={'where':_0x4d4a4d[_0x82b8('0x39')]};return db['VtigerConfiguration'][_0x82b8('0x21')](_0x15baaf)[_0x82b8('0x28')](function(_0x1ba595){_0x5f020d[_0x82b8('0x21')]=_0x1ba595;if(_0x582d9c[_0x82b8('0x31')][_0x82b8('0x40')]){_0x4d4a4d[_0x82b8('0x41')]=[{'all':!![]}];}return db['VtigerConfiguration']['findAll'](_0x4d4a4d);})[_0x82b8('0x28')](function(_0x1ad32b){_0x5f020d[_0x82b8('0x42')]=_0x1ad32b;return _0x5f020d;})[_0x82b8('0x28')](respondWithFilteredResult(_0x331929,_0x4d4a4d))['catch'](handleError(_0x331929,null));};exports[_0x82b8('0x43')]=function(_0x52f505,_0x2b3d32){var _0x3e81b0={'raw':![],'where':{'id':_0x52f505[_0x82b8('0x44')]['id']}},_0x297bde={};_0x297bde['model']=_[_0x82b8('0x32')](db['VtigerConfiguration']['rawAttributes']);_0x297bde[_0x82b8('0x31')]=_[_0x82b8('0x32')](_0x52f505['query']);_0x297bde[_0x82b8('0x33')]=_[_0x82b8('0x34')](_0x297bde[_0x82b8('0x30')],_0x297bde['query']);_0x3e81b0[_0x82b8('0x36')]=_[_0x82b8('0x34')](_0x297bde[_0x82b8('0x30')],qs[_0x82b8('0x35')](_0x52f505[_0x82b8('0x31')][_0x82b8('0x35')]));_0x3e81b0[_0x82b8('0x36')]=_0x3e81b0[_0x82b8('0x36')]['length']?_0x3e81b0[_0x82b8('0x36')]:_0x297bde[_0x82b8('0x30')];if(_0x52f505[_0x82b8('0x31')][_0x82b8('0x40')]){_0x3e81b0[_0x82b8('0x41')]=[{'all':!![]}];}_0x3e81b0=_['merge']({},_0x3e81b0,_0x52f505[_0x82b8('0x3f')]);return db[_0x82b8('0x2d')][_0x82b8('0x45')](_0x3e81b0)[_0x82b8('0x28')](handleEntityNotFound(_0x2b3d32,null))[_0x82b8('0x28')](respondWithResult(_0x2b3d32,null))[_0x82b8('0x46')](handleError(_0x2b3d32,null));};exports[_0x82b8('0x47')]=function(_0x244d1,_0x1ea70e){return db[_0x82b8('0x2d')][_0x82b8('0x47')](_0x244d1[_0x82b8('0x48')],{})[_0x82b8('0x28')](respondWithResult(_0x1ea70e,0xc9))[_0x82b8('0x46')](handleError(_0x1ea70e,null));};exports['update']=function(_0xb68462,_0x3c3cc9){if(_0xb68462[_0x82b8('0x48')]['id']){delete _0xb68462[_0x82b8('0x48')]['id'];}return db['VtigerConfiguration'][_0x82b8('0x45')]({'where':{'id':_0xb68462[_0x82b8('0x44')]['id']}})[_0x82b8('0x28')](handleEntityNotFound(_0x3c3cc9,null))['then'](saveUpdates(_0xb68462[_0x82b8('0x48')],null))[_0x82b8('0x28')](respondWithResult(_0x3c3cc9,null))['catch'](handleError(_0x3c3cc9,null));};exports[_0x82b8('0x29')]=function(_0x28f662,_0x41507a){return db[_0x82b8('0x2d')][_0x82b8('0x45')]({'where':{'id':_0x28f662[_0x82b8('0x44')]['id']}})[_0x82b8('0x28')](handleEntityNotFound(_0x41507a,null))[_0x82b8('0x28')](removeEntity(_0x41507a,null))[_0x82b8('0x46')](handleError(_0x41507a,null));};exports['getFields']=function(_0x5d7e2b,_0x3ce3b0,_0x24b8f5){var _0x3bab4c={};var _0x1be69c={};var _0x47c5f5;var _0x2c33dd;return db[_0x82b8('0x2d')][_0x82b8('0x49')]({'where':{'id':_0x5d7e2b[_0x82b8('0x44')]['id']}})[_0x82b8('0x28')](handleEntityNotFound(_0x3ce3b0,null))['then'](function(_0x4e3c3f){if(_0x4e3c3f){_0x47c5f5=_0x4e3c3f;_0x1be69c[_0x82b8('0x30')]=_['keys'](db[_0x82b8('0x4a')][_0x82b8('0x4b')]);_0x1be69c[_0x82b8('0x31')]=_[_0x82b8('0x32')](_0x5d7e2b['query']);_0x1be69c[_0x82b8('0x33')]=_[_0x82b8('0x34')](_0x1be69c['model'],_0x1be69c[_0x82b8('0x31')]);_0x3bab4c[_0x82b8('0x36')]=_['intersection'](_0x1be69c[_0x82b8('0x30')],qs[_0x82b8('0x35')](_0x5d7e2b[_0x82b8('0x31')][_0x82b8('0x35')]));_0x3bab4c[_0x82b8('0x36')]=_0x3bab4c['attributes'][_0x82b8('0x37')]?_0x3bab4c[_0x82b8('0x36')]:_0x1be69c[_0x82b8('0x30')];_0x3bab4c[_0x82b8('0x4c')]=qs[_0x82b8('0x38')](_0x5d7e2b[_0x82b8('0x31')]['sort']);_0x3bab4c[_0x82b8('0x39')]=qs['filters'](_[_0x82b8('0x3a')](_0x5d7e2b[_0x82b8('0x31')],_0x1be69c[_0x82b8('0x33')]));if(_0x5d7e2b[_0x82b8('0x31')][_0x82b8('0x3b')]){_0x3bab4c[_0x82b8('0x39')]=_[_0x82b8('0x3c')](_0x3bab4c[_0x82b8('0x39')],{'$or':_[_0x82b8('0x2c')](_0x3bab4c['attributes'],function(_0x132bd5){var _0x44b1f2={};_0x44b1f2[_0x132bd5]={'$like':'%'+_0x5d7e2b[_0x82b8('0x31')][_0x82b8('0x3b')]+'%'};return _0x44b1f2;})});}_0x3bab4c=_['merge']({},_0x3bab4c,_0x5d7e2b[_0x82b8('0x3f')]);return _0x47c5f5[_0x82b8('0x4d')](_0x3bab4c);}})[_0x82b8('0x28')](function(_0x40775a){if(_0x40775a){_0x2c33dd=_0x40775a[_0x82b8('0x37')];if(!_0x5d7e2b[_0x82b8('0x31')]['hasOwnProperty'](_0x82b8('0x4e'))){_0x3bab4c[_0x82b8('0x20')]=qs[_0x82b8('0x20')](_0x5d7e2b[_0x82b8('0x31')][_0x82b8('0x20')]);_0x3bab4c[_0x82b8('0x1e')]=qs[_0x82b8('0x1e')](_0x5d7e2b[_0x82b8('0x31')][_0x82b8('0x1e')]);}return _0x47c5f5[_0x82b8('0x4d')](_0x3bab4c);}})[_0x82b8('0x28')](function(_0x15163b){if(_0x15163b){return _0x15163b?{'count':_0x2c33dd,'rows':_0x15163b}:null;}})[_0x82b8('0x28')](respondWithResult(_0x3ce3b0,null))[_0x82b8('0x46')](handleError(_0x3ce3b0,null));};exports[_0x82b8('0x4f')]=function(_0x55a86b,_0x1d0bad,_0x9494f3){var _0x34836d={};var _0x3688d0={};var _0x94aef4;var _0x4f98a4;return db[_0x82b8('0x2d')][_0x82b8('0x49')]({'where':{'id':_0x55a86b[_0x82b8('0x44')]['id']}})[_0x82b8('0x28')](handleEntityNotFound(_0x1d0bad,null))[_0x82b8('0x28')](function(_0x27638d){if(_0x27638d){_0x94aef4=_0x27638d;_0x3688d0[_0x82b8('0x30')]=_[_0x82b8('0x32')](db[_0x82b8('0x4a')][_0x82b8('0x4b')]);_0x3688d0[_0x82b8('0x31')]=_[_0x82b8('0x32')](_0x55a86b[_0x82b8('0x31')]);_0x3688d0[_0x82b8('0x33')]=_[_0x82b8('0x34')](_0x3688d0[_0x82b8('0x30')],_0x3688d0[_0x82b8('0x31')]);_0x34836d[_0x82b8('0x36')]=_[_0x82b8('0x34')](_0x3688d0[_0x82b8('0x30')],qs[_0x82b8('0x35')](_0x55a86b[_0x82b8('0x31')][_0x82b8('0x35')]));_0x34836d['attributes']=_0x34836d[_0x82b8('0x36')][_0x82b8('0x37')]?_0x34836d[_0x82b8('0x36')]:_0x3688d0[_0x82b8('0x30')];_0x34836d[_0x82b8('0x4c')]=qs[_0x82b8('0x38')](_0x55a86b[_0x82b8('0x31')][_0x82b8('0x38')]);_0x34836d[_0x82b8('0x39')]=qs[_0x82b8('0x33')](_[_0x82b8('0x3a')](_0x55a86b['query'],_0x3688d0[_0x82b8('0x33')]));if(_0x55a86b[_0x82b8('0x31')][_0x82b8('0x3b')]){_0x34836d['where']=_[_0x82b8('0x3c')](_0x34836d[_0x82b8('0x39')],{'$or':_[_0x82b8('0x2c')](_0x34836d['attributes'],function(_0x554e08){var _0xa19cb6={};_0xa19cb6[_0x554e08]={'$like':'%'+_0x55a86b[_0x82b8('0x31')][_0x82b8('0x3b')]+'%'};return _0xa19cb6;})});}_0x34836d=_[_0x82b8('0x3c')]({},_0x34836d,_0x55a86b[_0x82b8('0x3f')]);return _0x94aef4['getSubjects'](_0x34836d);}})['then'](function(_0x21efde){if(_0x21efde){_0x4f98a4=_0x21efde[_0x82b8('0x37')];if(!_0x55a86b['query']['hasOwnProperty'](_0x82b8('0x4e'))){_0x34836d[_0x82b8('0x20')]=qs[_0x82b8('0x20')](_0x55a86b[_0x82b8('0x31')][_0x82b8('0x20')]);_0x34836d['offset']=qs[_0x82b8('0x1e')](_0x55a86b[_0x82b8('0x31')][_0x82b8('0x1e')]);}return _0x94aef4[_0x82b8('0x4f')](_0x34836d);}})[_0x82b8('0x28')](function(_0x348d5f){if(_0x348d5f){return _0x348d5f?{'count':_0x4f98a4,'rows':_0x348d5f}:null;}})[_0x82b8('0x28')](respondWithResult(_0x1d0bad,null))['catch'](handleError(_0x1d0bad,null));};exports[_0x82b8('0x50')]=function(_0x418e49,_0x1312f8,_0x2f2dd4){var _0xbbff0c={};var _0x17910f={};var _0x2639ef;var _0x4aa8d4;return db[_0x82b8('0x2d')][_0x82b8('0x49')]({'where':{'id':_0x418e49[_0x82b8('0x44')]['id']}})['then'](handleEntityNotFound(_0x1312f8,null))[_0x82b8('0x28')](function(_0x79b893){if(_0x79b893){_0x2639ef=_0x79b893;_0x17910f[_0x82b8('0x30')]=_[_0x82b8('0x32')](db[_0x82b8('0x4a')][_0x82b8('0x4b')]);_0x17910f['query']=_[_0x82b8('0x32')](_0x418e49[_0x82b8('0x31')]);_0x17910f[_0x82b8('0x33')]=_[_0x82b8('0x34')](_0x17910f[_0x82b8('0x30')],_0x17910f[_0x82b8('0x31')]);_0xbbff0c[_0x82b8('0x36')]=_[_0x82b8('0x34')](_0x17910f[_0x82b8('0x30')],qs['fields'](_0x418e49[_0x82b8('0x31')][_0x82b8('0x35')]));_0xbbff0c['attributes']=_0xbbff0c[_0x82b8('0x36')][_0x82b8('0x37')]?_0xbbff0c[_0x82b8('0x36')]:_0x17910f[_0x82b8('0x30')];_0xbbff0c[_0x82b8('0x4c')]=qs[_0x82b8('0x38')](_0x418e49[_0x82b8('0x31')]['sort']);_0xbbff0c[_0x82b8('0x39')]=qs[_0x82b8('0x33')](_[_0x82b8('0x3a')](_0x418e49[_0x82b8('0x31')],_0x17910f[_0x82b8('0x33')]));if(_0x418e49[_0x82b8('0x31')][_0x82b8('0x3b')]){_0xbbff0c['where']=_[_0x82b8('0x3c')](_0xbbff0c[_0x82b8('0x39')],{'$or':_['map'](_0xbbff0c[_0x82b8('0x36')],function(_0x473473){var _0x5e769b={};_0x5e769b[_0x473473]={'$like':'%'+_0x418e49['query']['filter']+'%'};return _0x5e769b;})});}_0xbbff0c=_[_0x82b8('0x3c')]({},_0xbbff0c,_0x418e49[_0x82b8('0x3f')]);return _0x2639ef[_0x82b8('0x50')](_0xbbff0c);}})['then'](function(_0x588f94){if(_0x588f94){_0x4aa8d4=_0x588f94[_0x82b8('0x37')];if(!_0x418e49[_0x82b8('0x31')][_0x82b8('0x51')](_0x82b8('0x4e'))){_0xbbff0c[_0x82b8('0x20')]=qs[_0x82b8('0x20')](_0x418e49['query']['limit']);_0xbbff0c[_0x82b8('0x1e')]=qs[_0x82b8('0x1e')](_0x418e49['query'][_0x82b8('0x1e')]);}return _0x2639ef[_0x82b8('0x50')](_0xbbff0c);}})[_0x82b8('0x28')](function(_0x45729d){if(_0x45729d){return _0x45729d?{'count':_0x4aa8d4,'rows':_0x45729d}:null;}})[_0x82b8('0x28')](respondWithResult(_0x1312f8,null))[_0x82b8('0x46')](handleError(_0x1312f8,null));};
\ No newline at end of file