Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index c5a3442..0b7f2e4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xefbb=['offset','limit','undefined','count','set','Content-Range','apply','save','update','then','destroy','error','stack','name','send','index','rawAttributes','type','key','model','map','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','VtigerConfiguration','include','findAll','rows','catch','params','length','find','create','body','findOne','VtigerField','options','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','fs-extra','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json'];(function(_0x242dfd,_0x46bbb8){var _0x4005f7=function(_0x4b77c9){while(--_0x4b77c9){_0x242dfd['push'](_0x242dfd['shift']());}};_0x4005f7(++_0x46bbb8);}(_0xefbb,0x11b));var _0xbefb=function(_0x50b903,_0x5bddf5){_0x50b903=_0x50b903-0x0;var _0x9a105d=_0xefbb[_0x50b903];return _0x9a105d;};'use strict';var emlformat=require(_0xbefb('0x0'));var rimraf=require(_0xbefb('0x1'));var zipdir=require(_0xbefb('0x2'));var jsonpatch=require(_0xbefb('0x3'));var rp=require(_0xbefb('0x4'));var moment=require('moment');var BPromise=require(_0xbefb('0x5'));var Mustache=require(_0xbefb('0x6'));var util=require(_0xbefb('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbefb('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xbefb('0x9'));var toCsv=require(_0xbefb('0xa'));var querystring=require(_0xbefb('0xb'));var Papa=require(_0xbefb('0xc'));var Redis=require(_0xbefb('0xd'));var authService=require(_0xbefb('0xe'));var qs=require(_0xbefb('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbefb('0x10'));var logger=require('../../config/logger')(_0xbefb('0x11'));var utils=require(_0xbefb('0x12'));var config=require(_0xbefb('0x13'));var licenseUtil=require(_0xbefb('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x17e171,_0x26a956){_0x26a956=_0x26a956||0xcc;return function(_0x1be587){if(_0x1be587){return _0x17e171[_0xbefb('0x15')](_0x26a956);}return _0x17e171[_0xbefb('0x16')](_0x26a956)[_0xbefb('0x17')]();};}function respondWithResult(_0x1605c6,_0x468611){_0x468611=_0x468611||0xc8;return function(_0x46e0d2){if(_0x46e0d2){return _0x1605c6[_0xbefb('0x16')](_0x468611)[_0xbefb('0x18')](_0x46e0d2);}};}function respondWithFilteredResult(_0xb6e1ee,_0x3b466a){return function(_0x3092fd){if(_0x3092fd){var _0x552f44=typeof _0x3b466a[_0xbefb('0x19')]==='undefined'&&typeof _0x3b466a[_0xbefb('0x1a')]===_0xbefb('0x1b');var _0x422be1=_0x3092fd[_0xbefb('0x1c')];var _0x1ad15a=_0x552f44?0x0:_0x3b466a['offset'];var _0x53b462=_0x552f44?_0x3092fd[_0xbefb('0x1c')]:_0x3b466a[_0xbefb('0x19')]+_0x3b466a[_0xbefb('0x1a')];var _0x41af49;if(_0x53b462>=_0x422be1){_0x53b462=_0x422be1;_0x41af49=0xc8;}else{_0x41af49=0xce;}_0xb6e1ee[_0xbefb('0x16')](_0x41af49);return _0xb6e1ee[_0xbefb('0x1d')](_0xbefb('0x1e'),_0x1ad15a+'-'+_0x53b462+'/'+_0x422be1)[_0xbefb('0x18')](_0x3092fd);}return null;};}function patchUpdates(_0x186f1b){return function(_0x4a42c7){try{jsonpatch[_0xbefb('0x1f')](_0x4a42c7,_0x186f1b,!![]);}catch(_0x3c9198){return BPromise['reject'](_0x3c9198);}return _0x4a42c7[_0xbefb('0x20')]();};}function saveUpdates(_0x595e82,_0x38c0db){return function(_0x586a61){if(_0x586a61){return _0x586a61[_0xbefb('0x21')](_0x595e82)[_0xbefb('0x22')](function(_0x3188a8){return _0x3188a8;});}return null;};}function removeEntity(_0x19ae01,_0xfae7ee){return function(_0x24fa00){if(_0x24fa00){return _0x24fa00[_0xbefb('0x23')]()['then'](function(){_0x19ae01[_0xbefb('0x16')](0xcc)[_0xbefb('0x17')]();});}};}function handleEntityNotFound(_0x18e47c,_0x175a52){return function(_0x3c68b5){if(!_0x3c68b5){_0x18e47c['sendStatus'](0x194);}return _0x3c68b5;};}function handleError(_0x1b9e9d,_0x716c80){_0x716c80=_0x716c80||0x1f4;return function(_0x38daf3){logger[_0xbefb('0x24')](_0x38daf3[_0xbefb('0x25')]);if(_0x38daf3[_0xbefb('0x26')]){delete _0x38daf3[_0xbefb('0x26')];}_0x1b9e9d[_0xbefb('0x16')](_0x716c80)[_0xbefb('0x27')](_0x38daf3);};}exports[_0xbefb('0x28')]=function(_0x2c313b,_0x2539bc){var _0x5b4baf={},_0x338f72={},_0x5beee0={'count':0x0,'rows':[]};var _0x46d4f3=_['map'](db['VtigerConfiguration'][_0xbefb('0x29')],function(_0x264a18){return{'name':_0x264a18['fieldName'],'type':_0x264a18[_0xbefb('0x2a')][_0xbefb('0x2b')]};});_0x338f72[_0xbefb('0x2c')]=_[_0xbefb('0x2d')](_0x46d4f3,_0xbefb('0x26'));_0x338f72[_0xbefb('0x2e')]=_[_0xbefb('0x2f')](_0x2c313b[_0xbefb('0x2e')]);_0x338f72[_0xbefb('0x30')]=_['intersection'](_0x338f72[_0xbefb('0x2c')],_0x338f72[_0xbefb('0x2e')]);_0x5b4baf[_0xbefb('0x31')]=_[_0xbefb('0x32')](_0x338f72['model'],qs['fields'](_0x2c313b['query'][_0xbefb('0x33')]));_0x5b4baf[_0xbefb('0x31')]=_0x5b4baf[_0xbefb('0x31')]['length']?_0x5b4baf['attributes']:_0x338f72['model'];if(!_0x2c313b[_0xbefb('0x2e')][_0xbefb('0x34')](_0xbefb('0x35'))){_0x5b4baf[_0xbefb('0x1a')]=qs['limit'](_0x2c313b[_0xbefb('0x2e')][_0xbefb('0x1a')]);_0x5b4baf[_0xbefb('0x19')]=qs['offset'](_0x2c313b[_0xbefb('0x2e')]['offset']);}_0x5b4baf[_0xbefb('0x36')]=qs[_0xbefb('0x37')](_0x2c313b[_0xbefb('0x2e')][_0xbefb('0x37')]);_0x5b4baf[_0xbefb('0x38')]=qs['filters'](_[_0xbefb('0x39')](_0x2c313b[_0xbefb('0x2e')],_0x338f72[_0xbefb('0x30')]),_0x46d4f3);if(_0x2c313b['query'][_0xbefb('0x3a')]){_0x5b4baf[_0xbefb('0x38')]=_[_0xbefb('0x3b')](_0x5b4baf[_0xbefb('0x38')],{'$or':_[_0xbefb('0x2d')](_0x46d4f3,function(_0x3848f7){if(_0x3848f7[_0xbefb('0x2a')]!==_0xbefb('0x3c')){var _0x234118={};_0x234118[_0x3848f7['name']]={'$like':'%'+_0x2c313b[_0xbefb('0x2e')][_0xbefb('0x3a')]+'%'};return _0x234118;}})});}_0x5b4baf=_['merge']({},_0x5b4baf,_0x2c313b['options']);var _0x39929d={'where':_0x5b4baf[_0xbefb('0x38')]};return db[_0xbefb('0x3d')][_0xbefb('0x1c')](_0x39929d)[_0xbefb('0x22')](function(_0x1ef53a){_0x5beee0[_0xbefb('0x1c')]=_0x1ef53a;if(_0x2c313b[_0xbefb('0x2e')]['includeAll']){_0x5b4baf[_0xbefb('0x3e')]=[{'all':!![]}];}return db[_0xbefb('0x3d')][_0xbefb('0x3f')](_0x5b4baf);})[_0xbefb('0x22')](function(_0x5e2250){_0x5beee0[_0xbefb('0x40')]=_0x5e2250;return _0x5beee0;})['then'](respondWithFilteredResult(_0x2539bc,_0x5b4baf))[_0xbefb('0x41')](handleError(_0x2539bc,null));};exports['show']=function(_0x5ad55b,_0x480251){var _0xf13a71={'raw':![],'where':{'id':_0x5ad55b[_0xbefb('0x42')]['id']}},_0x10fbff={};_0x10fbff[_0xbefb('0x2c')]=_[_0xbefb('0x2f')](db[_0xbefb('0x3d')][_0xbefb('0x29')]);_0x10fbff[_0xbefb('0x2e')]=_[_0xbefb('0x2f')](_0x5ad55b[_0xbefb('0x2e')]);_0x10fbff[_0xbefb('0x30')]=_[_0xbefb('0x32')](_0x10fbff[_0xbefb('0x2c')],_0x10fbff[_0xbefb('0x2e')]);_0xf13a71['attributes']=_[_0xbefb('0x32')](_0x10fbff['model'],qs[_0xbefb('0x33')](_0x5ad55b[_0xbefb('0x2e')][_0xbefb('0x33')]));_0xf13a71['attributes']=_0xf13a71[_0xbefb('0x31')][_0xbefb('0x43')]?_0xf13a71[_0xbefb('0x31')]:_0x10fbff[_0xbefb('0x2c')];if(_0x5ad55b[_0xbefb('0x2e')]['includeAll']){_0xf13a71[_0xbefb('0x3e')]=[{'all':!![]}];}_0xf13a71=_[_0xbefb('0x3b')]({},_0xf13a71,_0x5ad55b['options']);return db['VtigerConfiguration'][_0xbefb('0x44')](_0xf13a71)['then'](handleEntityNotFound(_0x480251,null))['then'](respondWithResult(_0x480251,null))[_0xbefb('0x41')](handleError(_0x480251,null));};exports[_0xbefb('0x45')]=function(_0x5ca673,_0x1ecbe8){return db[_0xbefb('0x3d')][_0xbefb('0x45')](_0x5ca673[_0xbefb('0x46')],{})[_0xbefb('0x22')](respondWithResult(_0x1ecbe8,0xc9))[_0xbefb('0x41')](handleError(_0x1ecbe8,null));};exports[_0xbefb('0x21')]=function(_0x2cfbfa,_0x2a0c86){if(_0x2cfbfa[_0xbefb('0x46')]['id']){delete _0x2cfbfa['body']['id'];}return db[_0xbefb('0x3d')][_0xbefb('0x44')]({'where':{'id':_0x2cfbfa['params']['id']}})[_0xbefb('0x22')](handleEntityNotFound(_0x2a0c86,null))[_0xbefb('0x22')](saveUpdates(_0x2cfbfa[_0xbefb('0x46')],null))['then'](respondWithResult(_0x2a0c86,null))['catch'](handleError(_0x2a0c86,null));};exports[_0xbefb('0x23')]=function(_0x509377,_0x2d46dc){return db[_0xbefb('0x3d')]['find']({'where':{'id':_0x509377[_0xbefb('0x42')]['id']}})[_0xbefb('0x22')](handleEntityNotFound(_0x2d46dc,null))[_0xbefb('0x22')](removeEntity(_0x2d46dc,null))[_0xbefb('0x41')](handleError(_0x2d46dc,null));};exports['getFields']=function(_0x3c28a2,_0x27b65e,_0x323b23){var _0x2651b1={};var _0x55e73a={};var _0x3134f4;var _0x313ccc;return db[_0xbefb('0x3d')][_0xbefb('0x47')]({'where':{'id':_0x3c28a2[_0xbefb('0x42')]['id']}})[_0xbefb('0x22')](handleEntityNotFound(_0x27b65e,null))[_0xbefb('0x22')](function(_0x2cbd85){if(_0x2cbd85){_0x3134f4=_0x2cbd85;_0x55e73a[_0xbefb('0x2c')]=_[_0xbefb('0x2f')](db[_0xbefb('0x48')][_0xbefb('0x29')]);_0x55e73a[_0xbefb('0x2e')]=_[_0xbefb('0x2f')](_0x3c28a2['query']);_0x55e73a['filters']=_[_0xbefb('0x32')](_0x55e73a[_0xbefb('0x2c')],_0x55e73a[_0xbefb('0x2e')]);_0x2651b1[_0xbefb('0x31')]=_[_0xbefb('0x32')](_0x55e73a[_0xbefb('0x2c')],qs[_0xbefb('0x33')](_0x3c28a2[_0xbefb('0x2e')][_0xbefb('0x33')]));_0x2651b1['attributes']=_0x2651b1[_0xbefb('0x31')][_0xbefb('0x43')]?_0x2651b1[_0xbefb('0x31')]:_0x55e73a[_0xbefb('0x2c')];_0x2651b1[_0xbefb('0x36')]=qs[_0xbefb('0x37')](_0x3c28a2[_0xbefb('0x2e')][_0xbefb('0x37')]);_0x2651b1[_0xbefb('0x38')]=qs[_0xbefb('0x30')](_['pick'](_0x3c28a2['query'],_0x55e73a['filters']));if(_0x3c28a2[_0xbefb('0x2e')]['filter']){_0x2651b1[_0xbefb('0x38')]=_[_0xbefb('0x3b')](_0x2651b1['where'],{'$or':_[_0xbefb('0x2d')](_0x2651b1[_0xbefb('0x31')],function(_0x38dd34){var _0x551cf2={};_0x551cf2[_0x38dd34]={'$like':'%'+_0x3c28a2[_0xbefb('0x2e')][_0xbefb('0x3a')]+'%'};return _0x551cf2;})});}_0x2651b1=_[_0xbefb('0x3b')]({},_0x2651b1,_0x3c28a2[_0xbefb('0x49')]);return _0x3134f4[_0xbefb('0x4a')](_0x2651b1);}})[_0xbefb('0x22')](function(_0x3270fb){if(_0x3270fb){_0x313ccc=_0x3270fb[_0xbefb('0x43')];if(!_0x3c28a2[_0xbefb('0x2e')][_0xbefb('0x34')](_0xbefb('0x35'))){_0x2651b1[_0xbefb('0x1a')]=qs[_0xbefb('0x1a')](_0x3c28a2[_0xbefb('0x2e')][_0xbefb('0x1a')]);_0x2651b1[_0xbefb('0x19')]=qs[_0xbefb('0x19')](_0x3c28a2[_0xbefb('0x2e')]['offset']);}return _0x3134f4['getFields'](_0x2651b1);}})[_0xbefb('0x22')](function(_0x342f02){if(_0x342f02){return _0x342f02?{'count':_0x313ccc,'rows':_0x342f02}:null;}})[_0xbefb('0x22')](respondWithResult(_0x27b65e,null))[_0xbefb('0x41')](handleError(_0x27b65e,null));};exports[_0xbefb('0x4b')]=function(_0x2ad655,_0x560c98,_0x52d8e9){var _0x2a4c38={};var _0x14c0fb={};var _0x1fc89e;var _0x1265eb;return db['VtigerConfiguration'][_0xbefb('0x47')]({'where':{'id':_0x2ad655[_0xbefb('0x42')]['id']}})[_0xbefb('0x22')](handleEntityNotFound(_0x560c98,null))[_0xbefb('0x22')](function(_0x591dd7){if(_0x591dd7){_0x1fc89e=_0x591dd7;_0x14c0fb[_0xbefb('0x2c')]=_[_0xbefb('0x2f')](db[_0xbefb('0x48')][_0xbefb('0x29')]);_0x14c0fb['query']=_[_0xbefb('0x2f')](_0x2ad655['query']);_0x14c0fb[_0xbefb('0x30')]=_['intersection'](_0x14c0fb['model'],_0x14c0fb[_0xbefb('0x2e')]);_0x2a4c38['attributes']=_[_0xbefb('0x32')](_0x14c0fb[_0xbefb('0x2c')],qs[_0xbefb('0x33')](_0x2ad655['query']['fields']));_0x2a4c38[_0xbefb('0x31')]=_0x2a4c38[_0xbefb('0x31')]['length']?_0x2a4c38[_0xbefb('0x31')]:_0x14c0fb['model'];_0x2a4c38['order']=qs[_0xbefb('0x37')](_0x2ad655[_0xbefb('0x2e')][_0xbefb('0x37')]);_0x2a4c38[_0xbefb('0x38')]=qs[_0xbefb('0x30')](_['pick'](_0x2ad655[_0xbefb('0x2e')],_0x14c0fb[_0xbefb('0x30')]));if(_0x2ad655[_0xbefb('0x2e')][_0xbefb('0x3a')]){_0x2a4c38[_0xbefb('0x38')]=_[_0xbefb('0x3b')](_0x2a4c38[_0xbefb('0x38')],{'$or':_['map'](_0x2a4c38[_0xbefb('0x31')],function(_0x59a765){var _0x169fe9={};_0x169fe9[_0x59a765]={'$like':'%'+_0x2ad655[_0xbefb('0x2e')][_0xbefb('0x3a')]+'%'};return _0x169fe9;})});}_0x2a4c38=_[_0xbefb('0x3b')]({},_0x2a4c38,_0x2ad655[_0xbefb('0x49')]);return _0x1fc89e[_0xbefb('0x4b')](_0x2a4c38);}})[_0xbefb('0x22')](function(_0x1e17a3){if(_0x1e17a3){_0x1265eb=_0x1e17a3[_0xbefb('0x43')];if(!_0x2ad655[_0xbefb('0x2e')][_0xbefb('0x34')](_0xbefb('0x35'))){_0x2a4c38[_0xbefb('0x1a')]=qs[_0xbefb('0x1a')](_0x2ad655[_0xbefb('0x2e')][_0xbefb('0x1a')]);_0x2a4c38[_0xbefb('0x19')]=qs[_0xbefb('0x19')](_0x2ad655['query'][_0xbefb('0x19')]);}return _0x1fc89e[_0xbefb('0x4b')](_0x2a4c38);}})[_0xbefb('0x22')](function(_0x528124){if(_0x528124){return _0x528124?{'count':_0x1265eb,'rows':_0x528124}:null;}})[_0xbefb('0x22')](respondWithResult(_0x560c98,null))['catch'](handleError(_0x560c98,null));};exports[_0xbefb('0x4c')]=function(_0x24d1ea,_0x43f4ca,_0x4d9945){var _0x1a2bfe={};var _0x424e37={};var _0x101d4c;var _0x2a3f5e;return db[_0xbefb('0x3d')]['findOne']({'where':{'id':_0x24d1ea[_0xbefb('0x42')]['id']}})[_0xbefb('0x22')](handleEntityNotFound(_0x43f4ca,null))[_0xbefb('0x22')](function(_0x5294e8){if(_0x5294e8){_0x101d4c=_0x5294e8;_0x424e37[_0xbefb('0x2c')]=_[_0xbefb('0x2f')](db['VtigerField']['rawAttributes']);_0x424e37[_0xbefb('0x2e')]=_['keys'](_0x24d1ea[_0xbefb('0x2e')]);_0x424e37[_0xbefb('0x30')]=_[_0xbefb('0x32')](_0x424e37[_0xbefb('0x2c')],_0x424e37[_0xbefb('0x2e')]);_0x1a2bfe[_0xbefb('0x31')]=_[_0xbefb('0x32')](_0x424e37['model'],qs[_0xbefb('0x33')](_0x24d1ea[_0xbefb('0x2e')][_0xbefb('0x33')]));_0x1a2bfe['attributes']=_0x1a2bfe['attributes'][_0xbefb('0x43')]?_0x1a2bfe[_0xbefb('0x31')]:_0x424e37['model'];_0x1a2bfe[_0xbefb('0x36')]=qs[_0xbefb('0x37')](_0x24d1ea[_0xbefb('0x2e')][_0xbefb('0x37')]);_0x1a2bfe['where']=qs[_0xbefb('0x30')](_[_0xbefb('0x39')](_0x24d1ea[_0xbefb('0x2e')],_0x424e37[_0xbefb('0x30')]));if(_0x24d1ea['query'][_0xbefb('0x3a')]){_0x1a2bfe[_0xbefb('0x38')]=_[_0xbefb('0x3b')](_0x1a2bfe[_0xbefb('0x38')],{'$or':_[_0xbefb('0x2d')](_0x1a2bfe['attributes'],function(_0x514b6e){var _0x5c4c70={};_0x5c4c70[_0x514b6e]={'$like':'%'+_0x24d1ea[_0xbefb('0x2e')][_0xbefb('0x3a')]+'%'};return _0x5c4c70;})});}_0x1a2bfe=_[_0xbefb('0x3b')]({},_0x1a2bfe,_0x24d1ea[_0xbefb('0x49')]);return _0x101d4c[_0xbefb('0x4c')](_0x1a2bfe);}})[_0xbefb('0x22')](function(_0x3499e0){if(_0x3499e0){_0x2a3f5e=_0x3499e0[_0xbefb('0x43')];if(!_0x24d1ea[_0xbefb('0x2e')][_0xbefb('0x34')](_0xbefb('0x35'))){_0x1a2bfe[_0xbefb('0x1a')]=qs['limit'](_0x24d1ea[_0xbefb('0x2e')][_0xbefb('0x1a')]);_0x1a2bfe['offset']=qs[_0xbefb('0x19')](_0x24d1ea['query'][_0xbefb('0x19')]);}return _0x101d4c['getDescriptions'](_0x1a2bfe);}})['then'](function(_0x3def28){if(_0x3def28){return _0x3def28?{'count':_0x2a3f5e,'rows':_0x3def28}:null;}})[_0xbefb('0x22')](respondWithResult(_0x43f4ca,null))['catch'](handleError(_0x43f4ca,null));};
\ No newline at end of file
+var _0xfa1e=['rows','show','params','keys','include','create','body','catch','update','getFields','VtigerField','hasOwnProperty','findOne','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','then','destroy','sendStatus','error','stack','name','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','pick','filter','where','VIRTUAL','merge','options','VtigerConfiguration','includeAll','findAll'];(function(_0x187399,_0x40c56d){var _0x40fa92=function(_0x36058c){while(--_0x36058c){_0x187399['push'](_0x187399['shift']());}};_0x40fa92(++_0x40c56d);}(_0xfa1e,0x102));var _0xefa1=function(_0x53c4f8,_0x44ccaf){_0x53c4f8=_0x53c4f8-0x0;var _0x416458=_0xfa1e[_0x53c4f8];return _0x416458;};'use strict';var emlformat=require(_0xefa1('0x0'));var rimraf=require(_0xefa1('0x1'));var zipdir=require(_0xefa1('0x2'));var jsonpatch=require(_0xefa1('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xefa1('0x4'));var Mustache=require('mustache');var util=require(_0xefa1('0x5'));var path=require(_0xefa1('0x6'));var sox=require(_0xefa1('0x7'));var csv=require(_0xefa1('0x8'));var ejs=require(_0xefa1('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xefa1('0xa'));var crypto=require(_0xefa1('0xb'));var jsforce=require(_0xefa1('0xc'));var deskjs=require(_0xefa1('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xefa1('0xe'));var Redis=require(_0xefa1('0xf'));var authService=require(_0xefa1('0x10'));var qs=require(_0xefa1('0x11'));var as=require(_0xefa1('0x12'));var hardwareService=require(_0xefa1('0x13'));var logger=require(_0xefa1('0x14'))(_0xefa1('0x15'));var utils=require(_0xefa1('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xefa1('0x17'))['db'];function respondWithStatusCode(_0x2fa691,_0x25fc05){_0x25fc05=_0x25fc05||0xcc;return function(_0x3b1212){if(_0x3b1212){return _0x2fa691['sendStatus'](_0x25fc05);}return _0x2fa691[_0xefa1('0x18')](_0x25fc05)[_0xefa1('0x19')]();};}function respondWithResult(_0x906eb5,_0x68f189){_0x68f189=_0x68f189||0xc8;return function(_0x477b4a){if(_0x477b4a){return _0x906eb5[_0xefa1('0x18')](_0x68f189)['json'](_0x477b4a);}};}function respondWithFilteredResult(_0x109735,_0x15eb71){return function(_0x40867a){if(_0x40867a){var _0x53b033=typeof _0x15eb71[_0xefa1('0x1a')]===_0xefa1('0x1b')&&typeof _0x15eb71[_0xefa1('0x1c')]===_0xefa1('0x1b');var _0x299943=_0x40867a[_0xefa1('0x1d')];var _0x3d11fd=_0x53b033?0x0:_0x15eb71[_0xefa1('0x1a')];var _0x68c032=_0x53b033?_0x40867a[_0xefa1('0x1d')]:_0x15eb71[_0xefa1('0x1a')]+_0x15eb71[_0xefa1('0x1c')];var _0xa43af1;if(_0x68c032>=_0x299943){_0x68c032=_0x299943;_0xa43af1=0xc8;}else{_0xa43af1=0xce;}_0x109735[_0xefa1('0x18')](_0xa43af1);return _0x109735[_0xefa1('0x1e')](_0xefa1('0x1f'),_0x3d11fd+'-'+_0x68c032+'/'+_0x299943)[_0xefa1('0x20')](_0x40867a);}return null;};}function patchUpdates(_0x507e98){return function(_0x4b13ce){try{jsonpatch[_0xefa1('0x21')](_0x4b13ce,_0x507e98,!![]);}catch(_0x2be731){return BPromise[_0xefa1('0x22')](_0x2be731);}return _0x4b13ce[_0xefa1('0x23')]();};}function saveUpdates(_0x29ff37,_0x3bad0b){return function(_0x2182d5){if(_0x2182d5){return _0x2182d5['update'](_0x29ff37)[_0xefa1('0x24')](function(_0x584cb4){return _0x584cb4;});}return null;};}function removeEntity(_0x29d00f,_0x57b5fb){return function(_0x187c13){if(_0x187c13){return _0x187c13[_0xefa1('0x25')]()[_0xefa1('0x24')](function(){_0x29d00f[_0xefa1('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0xb95fbe,_0x4e4472){return function(_0x557c70){if(!_0x557c70){_0xb95fbe[_0xefa1('0x26')](0x194);}return _0x557c70;};}function handleError(_0x4ebaa4,_0x2a8045){_0x2a8045=_0x2a8045||0x1f4;return function(_0x1e642a){logger[_0xefa1('0x27')](_0x1e642a[_0xefa1('0x28')]);if(_0x1e642a[_0xefa1('0x29')]){delete _0x1e642a[_0xefa1('0x29')];}_0x4ebaa4[_0xefa1('0x18')](_0x2a8045)['send'](_0x1e642a);};}exports['index']=function(_0x1e400a,_0x18b2b2){var _0x512f9d={},_0x533c68={},_0x3d7052={'count':0x0,'rows':[]};var _0x484243=_[_0xefa1('0x2a')](db['VtigerConfiguration'][_0xefa1('0x2b')],function(_0x42fe98){return{'name':_0x42fe98[_0xefa1('0x2c')],'type':_0x42fe98[_0xefa1('0x2d')][_0xefa1('0x2e')]};});_0x533c68[_0xefa1('0x2f')]=_[_0xefa1('0x2a')](_0x484243,'name');_0x533c68[_0xefa1('0x30')]=_['keys'](_0x1e400a[_0xefa1('0x30')]);_0x533c68[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x533c68['model'],_0x533c68[_0xefa1('0x30')]);_0x512f9d['attributes']=_[_0xefa1('0x32')](_0x533c68[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x1e400a[_0xefa1('0x30')][_0xefa1('0x33')]));_0x512f9d['attributes']=_0x512f9d[_0xefa1('0x34')][_0xefa1('0x35')]?_0x512f9d['attributes']:_0x533c68['model'];if(!_0x1e400a['query']['hasOwnProperty'](_0xefa1('0x36'))){_0x512f9d[_0xefa1('0x1c')]=qs[_0xefa1('0x1c')](_0x1e400a[_0xefa1('0x30')]['limit']);_0x512f9d[_0xefa1('0x1a')]=qs['offset'](_0x1e400a[_0xefa1('0x30')][_0xefa1('0x1a')]);}_0x512f9d[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x1e400a[_0xefa1('0x30')]['sort']);_0x512f9d['where']=qs['filters'](_[_0xefa1('0x39')](_0x1e400a[_0xefa1('0x30')],_0x533c68[_0xefa1('0x31')]),_0x484243);if(_0x1e400a['query'][_0xefa1('0x3a')]){_0x512f9d[_0xefa1('0x3b')]=_['merge'](_0x512f9d[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x484243,function(_0xcd995){if(_0xcd995[_0xefa1('0x2d')]!==_0xefa1('0x3c')){var _0x5beb72={};_0x5beb72[_0xcd995[_0xefa1('0x29')]]={'$like':'%'+_0x1e400a[_0xefa1('0x30')][_0xefa1('0x3a')]+'%'};return _0x5beb72;}})});}_0x512f9d=_[_0xefa1('0x3d')]({},_0x512f9d,_0x1e400a[_0xefa1('0x3e')]);var _0x1db0c1={'where':_0x512f9d['where']};return db[_0xefa1('0x3f')][_0xefa1('0x1d')](_0x1db0c1)[_0xefa1('0x24')](function(_0x120094){_0x3d7052[_0xefa1('0x1d')]=_0x120094;if(_0x1e400a['query'][_0xefa1('0x40')]){_0x512f9d['include']=[{'all':!![]}];}return db[_0xefa1('0x3f')][_0xefa1('0x41')](_0x512f9d);})['then'](function(_0x208b83){_0x3d7052[_0xefa1('0x42')]=_0x208b83;return _0x3d7052;})[_0xefa1('0x24')](respondWithFilteredResult(_0x18b2b2,_0x512f9d))['catch'](handleError(_0x18b2b2,null));};exports[_0xefa1('0x43')]=function(_0x4bd962,_0x1eb4dc){var _0x4d59ac={'raw':![],'where':{'id':_0x4bd962[_0xefa1('0x44')]['id']}},_0x51a68c={};_0x51a68c['model']=_[_0xefa1('0x45')](db[_0xefa1('0x3f')][_0xefa1('0x2b')]);_0x51a68c[_0xefa1('0x30')]=_[_0xefa1('0x45')](_0x4bd962[_0xefa1('0x30')]);_0x51a68c[_0xefa1('0x31')]=_['intersection'](_0x51a68c['model'],_0x51a68c[_0xefa1('0x30')]);_0x4d59ac[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x51a68c[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x4bd962[_0xefa1('0x30')][_0xefa1('0x33')]));_0x4d59ac[_0xefa1('0x34')]=_0x4d59ac[_0xefa1('0x34')][_0xefa1('0x35')]?_0x4d59ac[_0xefa1('0x34')]:_0x51a68c[_0xefa1('0x2f')];if(_0x4bd962['query']['includeAll']){_0x4d59ac[_0xefa1('0x46')]=[{'all':!![]}];}_0x4d59ac=_[_0xefa1('0x3d')]({},_0x4d59ac,_0x4bd962[_0xefa1('0x3e')]);return db[_0xefa1('0x3f')]['find'](_0x4d59ac)[_0xefa1('0x24')](handleEntityNotFound(_0x1eb4dc,null))[_0xefa1('0x24')](respondWithResult(_0x1eb4dc,null))['catch'](handleError(_0x1eb4dc,null));};exports[_0xefa1('0x47')]=function(_0x5bb5b5,_0x48fc36){return db[_0xefa1('0x3f')][_0xefa1('0x47')](_0x5bb5b5[_0xefa1('0x48')],{})[_0xefa1('0x24')](respondWithResult(_0x48fc36,0xc9))[_0xefa1('0x49')](handleError(_0x48fc36,null));};exports[_0xefa1('0x4a')]=function(_0x33aa4f,_0x13d34d){if(_0x33aa4f[_0xefa1('0x48')]['id']){delete _0x33aa4f['body']['id'];}return db[_0xefa1('0x3f')]['find']({'where':{'id':_0x33aa4f['params']['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0x13d34d,null))[_0xefa1('0x24')](saveUpdates(_0x33aa4f[_0xefa1('0x48')],null))['then'](respondWithResult(_0x13d34d,null))[_0xefa1('0x49')](handleError(_0x13d34d,null));};exports['destroy']=function(_0x45c784,_0x2be606){return db[_0xefa1('0x3f')]['find']({'where':{'id':_0x45c784[_0xefa1('0x44')]['id']}})['then'](handleEntityNotFound(_0x2be606,null))[_0xefa1('0x24')](removeEntity(_0x2be606,null))['catch'](handleError(_0x2be606,null));};exports[_0xefa1('0x4b')]=function(_0x3d0324,_0xad4fc2,_0x187223){var _0x288965={};var _0x29fed4={};var _0x1c6584;var _0x19c9ec;return db[_0xefa1('0x3f')]['findOne']({'where':{'id':_0x3d0324[_0xefa1('0x44')]['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0xad4fc2,null))[_0xefa1('0x24')](function(_0x5d7e6c){if(_0x5d7e6c){_0x1c6584=_0x5d7e6c;_0x29fed4[_0xefa1('0x2f')]=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x29fed4[_0xefa1('0x30')]=_['keys'](_0x3d0324['query']);_0x29fed4[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x29fed4[_0xefa1('0x2f')],_0x29fed4[_0xefa1('0x30')]);_0x288965[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x29fed4['model'],qs['fields'](_0x3d0324[_0xefa1('0x30')]['fields']));_0x288965[_0xefa1('0x34')]=_0x288965[_0xefa1('0x34')][_0xefa1('0x35')]?_0x288965['attributes']:_0x29fed4[_0xefa1('0x2f')];_0x288965[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x3d0324[_0xefa1('0x30')][_0xefa1('0x38')]);_0x288965['where']=qs['filters'](_[_0xefa1('0x39')](_0x3d0324[_0xefa1('0x30')],_0x29fed4[_0xefa1('0x31')]));if(_0x3d0324['query']['filter']){_0x288965['where']=_[_0xefa1('0x3d')](_0x288965[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x288965[_0xefa1('0x34')],function(_0x572d7d){var _0x502127={};_0x502127[_0x572d7d]={'$like':'%'+_0x3d0324[_0xefa1('0x30')]['filter']+'%'};return _0x502127;})});}_0x288965=_['merge']({},_0x288965,_0x3d0324[_0xefa1('0x3e')]);return _0x1c6584['getFields'](_0x288965);}})['then'](function(_0x3e3277){if(_0x3e3277){_0x19c9ec=_0x3e3277[_0xefa1('0x35')];if(!_0x3d0324[_0xefa1('0x30')][_0xefa1('0x4d')]('nolimit')){_0x288965['limit']=qs[_0xefa1('0x1c')](_0x3d0324[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x288965[_0xefa1('0x1a')]=qs['offset'](_0x3d0324[_0xefa1('0x30')]['offset']);}return _0x1c6584[_0xefa1('0x4b')](_0x288965);}})['then'](function(_0x5bf047){if(_0x5bf047){return _0x5bf047?{'count':_0x19c9ec,'rows':_0x5bf047}:null;}})['then'](respondWithResult(_0xad4fc2,null))[_0xefa1('0x49')](handleError(_0xad4fc2,null));};exports['getSubjects']=function(_0x248a3d,_0x1a78bd,_0x25e5e0){var _0x4617b2={};var _0x170d32={};var _0x10d753;var _0x1fc608;return db['VtigerConfiguration'][_0xefa1('0x4e')]({'where':{'id':_0x248a3d[_0xefa1('0x44')]['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0x1a78bd,null))[_0xefa1('0x24')](function(_0x4677ef){if(_0x4677ef){_0x10d753=_0x4677ef;_0x170d32['model']=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x170d32['query']=_[_0xefa1('0x45')](_0x248a3d['query']);_0x170d32[_0xefa1('0x31')]=_['intersection'](_0x170d32[_0xefa1('0x2f')],_0x170d32[_0xefa1('0x30')]);_0x4617b2[_0xefa1('0x34')]=_['intersection'](_0x170d32[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x33')]));_0x4617b2[_0xefa1('0x34')]=_0x4617b2['attributes'][_0xefa1('0x35')]?_0x4617b2['attributes']:_0x170d32[_0xefa1('0x2f')];_0x4617b2[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x38')]);_0x4617b2['where']=qs[_0xefa1('0x31')](_['pick'](_0x248a3d[_0xefa1('0x30')],_0x170d32[_0xefa1('0x31')]));if(_0x248a3d['query'][_0xefa1('0x3a')]){_0x4617b2['where']=_[_0xefa1('0x3d')](_0x4617b2[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x4617b2[_0xefa1('0x34')],function(_0x162979){var _0xeb8194={};_0xeb8194[_0x162979]={'$like':'%'+_0x248a3d[_0xefa1('0x30')]['filter']+'%'};return _0xeb8194;})});}_0x4617b2=_[_0xefa1('0x3d')]({},_0x4617b2,_0x248a3d[_0xefa1('0x3e')]);return _0x10d753[_0xefa1('0x4f')](_0x4617b2);}})['then'](function(_0x5de3e3){if(_0x5de3e3){_0x1fc608=_0x5de3e3[_0xefa1('0x35')];if(!_0x248a3d[_0xefa1('0x30')][_0xefa1('0x4d')](_0xefa1('0x36'))){_0x4617b2['limit']=qs[_0xefa1('0x1c')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x4617b2[_0xefa1('0x1a')]=qs[_0xefa1('0x1a')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x1a')]);}return _0x10d753[_0xefa1('0x4f')](_0x4617b2);}})[_0xefa1('0x24')](function(_0x193be8){if(_0x193be8){return _0x193be8?{'count':_0x1fc608,'rows':_0x193be8}:null;}})['then'](respondWithResult(_0x1a78bd,null))['catch'](handleError(_0x1a78bd,null));};exports[_0xefa1('0x50')]=function(_0x7fddfd,_0x31141b,_0x3abd59){var _0x498dc4={};var _0x5732d0={};var _0x39da19;var _0xdb3e94;return db[_0xefa1('0x3f')][_0xefa1('0x4e')]({'where':{'id':_0x7fddfd[_0xefa1('0x44')]['id']}})['then'](handleEntityNotFound(_0x31141b,null))[_0xefa1('0x24')](function(_0xe45e9b){if(_0xe45e9b){_0x39da19=_0xe45e9b;_0x5732d0[_0xefa1('0x2f')]=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x5732d0[_0xefa1('0x30')]=_[_0xefa1('0x45')](_0x7fddfd[_0xefa1('0x30')]);_0x5732d0[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x5732d0['model'],_0x5732d0[_0xefa1('0x30')]);_0x498dc4[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x5732d0['model'],qs['fields'](_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x33')]));_0x498dc4[_0xefa1('0x34')]=_0x498dc4['attributes'][_0xefa1('0x35')]?_0x498dc4[_0xefa1('0x34')]:_0x5732d0[_0xefa1('0x2f')];_0x498dc4[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x7fddfd['query']['sort']);_0x498dc4[_0xefa1('0x3b')]=qs[_0xefa1('0x31')](_[_0xefa1('0x39')](_0x7fddfd[_0xefa1('0x30')],_0x5732d0[_0xefa1('0x31')]));if(_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x3a')]){_0x498dc4[_0xefa1('0x3b')]=_['merge'](_0x498dc4[_0xefa1('0x3b')],{'$or':_['map'](_0x498dc4[_0xefa1('0x34')],function(_0x2a2a00){var _0x53fd0b={};_0x53fd0b[_0x2a2a00]={'$like':'%'+_0x7fddfd[_0xefa1('0x30')]['filter']+'%'};return _0x53fd0b;})});}_0x498dc4=_[_0xefa1('0x3d')]({},_0x498dc4,_0x7fddfd[_0xefa1('0x3e')]);return _0x39da19[_0xefa1('0x50')](_0x498dc4);}})['then'](function(_0x45808){if(_0x45808){_0xdb3e94=_0x45808['length'];if(!_0x7fddfd['query']['hasOwnProperty'](_0xefa1('0x36'))){_0x498dc4[_0xefa1('0x1c')]=qs['limit'](_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x498dc4[_0xefa1('0x1a')]=qs['offset'](_0x7fddfd['query'][_0xefa1('0x1a')]);}return _0x39da19[_0xefa1('0x50')](_0x498dc4);}})[_0xefa1('0x24')](function(_0x14add8){if(_0x14add8){return _0x14add8?{'count':_0xdb3e94,'rows':_0x14add8}:null;}})[_0xefa1('0x24')](respondWithResult(_0x31141b,null))['catch'](handleError(_0x31141b,null));};
\ No newline at end of file