Built motion from commit (unavailable).|2.3.1
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 0bb6b63..86a95dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfaf2=['findAll','rows','show','params','includeAll','find','body','getFields','findOne','VtigerField','pick','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../mysqldb','jayson/promise','http','then','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','destroy','stack','name','index','VtigerConfiguration','rawAttributes','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','map','type','key','VIRTUAL','field','merge','options','include'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xfaf2,0x169));var _0x2faf=function(_0x22feb1,_0x32f0cd){_0x22feb1=_0x22feb1-0x0;var _0x38f8de=_0xfaf2[_0x22feb1];return _0x38f8de;};'use strict';var pdf=require(_0x2faf('0x0'));var emlformat=require(_0x2faf('0x1'));var rimraf=require(_0x2faf('0x2'));var zipdir=require(_0x2faf('0x3'));var jsonpatch=require(_0x2faf('0x4'));var rp=require('request-promise');var moment=require(_0x2faf('0x5'));var BPromise=require(_0x2faf('0x6'));var Mustache=require(_0x2faf('0x7'));var util=require(_0x2faf('0x8'));var path=require(_0x2faf('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x2faf('0xa'));var squel=require(_0x2faf('0xb'));var crypto=require(_0x2faf('0xc'));var jsforce=require(_0x2faf('0xd'));var deskjs=require(_0x2faf('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x2faf('0xf'));var authService=require(_0x2faf('0x10'));var hardwareService=require('../../config/license/hardware');var Redis=require('ioredis');var qs=require(_0x2faf('0x11'));var logger=require(_0x2faf('0x12'))(_0x2faf('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0x2faf('0x14'))['db'];var jayson=require(_0x2faf('0x15'));var client=jayson['client'][_0x2faf('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x509157,_0x1945fe,_0x8c74bf,_0x400a19){return new BPromise(function(_0x3b7751,_0x1be421){var _0x27d2c1=_0x400a19||client;return _0x27d2c1['request'](_0x509157,_0x8c74bf)[_0x2faf('0x17')](function(_0x3910c3){logger['info'](_0x2faf('0x18'),_0x1945fe,_0x2faf('0x19'));logger[_0x2faf('0x1a')](_0x2faf('0x1b'),_0x1945fe,'request\x20sent',JSON[_0x2faf('0x1c')](_0x3910c3));if(_0x3910c3[_0x2faf('0x1d')]){if(_0x3910c3[_0x2faf('0x1d')][_0x2faf('0x1e')]===0x1f4){logger['error'](_0x2faf('0x18'),_0x1945fe,_0x3910c3[_0x2faf('0x1d')][_0x2faf('0x1f')]);return _0x1be421(_0x3910c3[_0x2faf('0x1d')][_0x2faf('0x1f')]);}logger[_0x2faf('0x1d')](_0x2faf('0x18'),_0x1945fe,_0x3910c3['error']['message']);return _0x3b7751(_0x3910c3['error'][_0x2faf('0x1f')]);}else{logger[_0x2faf('0x20')]('VtigerConfiguration,\x20%s,\x20%s',_0x1945fe,_0x2faf('0x19'));_0x3b7751(_0x3910c3['result']['message']);}})[_0x2faf('0x21')](function(_0x2cb862){logger['error'](_0x2faf('0x18'),_0x1945fe,_0x2cb862);_0x1be421(_0x2cb862);});});}function respondWithStatusCode(_0x3c1e49,_0x3545cf){_0x3545cf=_0x3545cf||0xcc;return function(_0x3f598c){if(_0x3f598c){return _0x3c1e49[_0x2faf('0x22')](_0x3545cf);}return _0x3c1e49[_0x2faf('0x23')](_0x3545cf)[_0x2faf('0x24')]();};}function respondWithResult(_0x1ee5a7,_0x107cd4){_0x107cd4=_0x107cd4||0xc8;return function(_0x2dd82b){if(_0x2dd82b){return _0x1ee5a7[_0x2faf('0x23')](_0x107cd4)[_0x2faf('0x25')](_0x2dd82b);}};}function respondWithFilteredResult(_0x5f1359,_0x404f67){return function(_0x13b655){if(_0x13b655){var _0xa092f6=_0x13b655[_0x2faf('0x26')],_0x53f72c=_0x404f67[_0x2faf('0x27')],_0x2553fc=_0x404f67[_0x2faf('0x27')]+_0x404f67[_0x2faf('0x28')],_0x24f6c2;if(_0x2553fc>=_0xa092f6){_0x2553fc=_0xa092f6;_0x24f6c2=0xc8;}else{_0x24f6c2=0xce;}_0x5f1359['status'](_0x24f6c2);return _0x5f1359[_0x2faf('0x29')]('Content-Range',_0x53f72c+'-'+_0x2553fc+'/'+_0xa092f6)[_0x2faf('0x25')](_0x13b655);}return null;};}function patchUpdates(_0x1133a0){return function(_0x147730){try{jsonpatch[_0x2faf('0x2a')](_0x147730,_0x1133a0,!![]);}catch(_0x462d9b){return BPromise[_0x2faf('0x2b')](_0x462d9b);}return _0x147730[_0x2faf('0x2c')]();};}function saveUpdates(_0x266dce,_0x3b504c){return function(_0x48f6a5){if(_0x48f6a5){return _0x48f6a5[_0x2faf('0x2d')](_0x266dce)[_0x2faf('0x17')](function(_0xfa4391){return _0xfa4391;});}return null;};}function removeEntity(_0x404366,_0x2d86a4){return function(_0x5a0c5e){if(_0x5a0c5e){return _0x5a0c5e[_0x2faf('0x2e')]()[_0x2faf('0x17')](function(){_0x404366['status'](0xcc)[_0x2faf('0x24')]();});}};}function handleEntityNotFound(_0xcb2caf,_0x129878){return function(_0xf57453){if(!_0xf57453){_0xcb2caf['sendStatus'](0x194);}return _0xf57453;};}function handleError(_0x201695,_0x56c8b0){_0x56c8b0=_0x56c8b0||0x1f4;return function(_0x4d1b94){logger[_0x2faf('0x1d')](_0x4d1b94[_0x2faf('0x2f')]);if(_0x4d1b94[_0x2faf('0x30')]){delete _0x4d1b94[_0x2faf('0x30')];}_0x201695['status'](_0x56c8b0)['send'](_0x4d1b94);};}exports[_0x2faf('0x31')]=function(_0x1aa654,_0xa8bb28){var _0x1a34ac={},_0x1a5dbf={},_0x23ccb6={'count':0x0,'rows':[]};var _0x5c5d57=db[_0x2faf('0x32')][_0x2faf('0x33')];_0x1a5dbf[_0x2faf('0x34')]=_[_0x2faf('0x35')](_0x5c5d57);_0x1a5dbf[_0x2faf('0x36')]=_[_0x2faf('0x35')](_0x1aa654[_0x2faf('0x36')]);_0x1a5dbf[_0x2faf('0x37')]=_[_0x2faf('0x38')](_0x1a5dbf[_0x2faf('0x34')],_0x1a5dbf[_0x2faf('0x36')]);_0x1a34ac[_0x2faf('0x39')]=_[_0x2faf('0x38')](_0x1a5dbf['model'],qs['fields'](_0x1aa654[_0x2faf('0x36')][_0x2faf('0x3a')]));_0x1a34ac['attributes']=_0x1a34ac['attributes'][_0x2faf('0x3b')]?_0x1a34ac[_0x2faf('0x39')]:_0x1a5dbf[_0x2faf('0x34')];if(!_0x1aa654[_0x2faf('0x36')][_0x2faf('0x3c')](_0x2faf('0x3d'))){_0x1a34ac[_0x2faf('0x28')]=qs['limit'](_0x1aa654['query'][_0x2faf('0x28')]);_0x1a34ac['offset']=qs['offset'](_0x1aa654['query']['offset']);}_0x1a34ac[_0x2faf('0x3e')]=qs[_0x2faf('0x3f')](_0x1aa654[_0x2faf('0x36')]['sort']);_0x1a34ac[_0x2faf('0x40')]=qs['filters'](_['pick'](_0x1aa654[_0x2faf('0x36')],_0x1a5dbf[_0x2faf('0x37')]));if(_0x1aa654[_0x2faf('0x36')][_0x2faf('0x41')]){_0x1a34ac[_0x2faf('0x40')]=_['merge'](_0x1a34ac[_0x2faf('0x40')],{'$or':_[_0x2faf('0x42')](_0x5c5d57,function(_0x294e5c){if(_0x294e5c[_0x2faf('0x43')][_0x2faf('0x44')]!==_0x2faf('0x45')){var _0x1f8f93={};_0x1f8f93[_0x294e5c[_0x2faf('0x46')]]={'$like':'%'+_0x1aa654[_0x2faf('0x36')][_0x2faf('0x41')]+'%'};return _0x1f8f93;}})});}_0x1a34ac=_[_0x2faf('0x47')]({},_0x1a34ac,_0x1aa654[_0x2faf('0x48')]);var _0x4f98e9={'where':_0x1a34ac[_0x2faf('0x40')]};return db[_0x2faf('0x32')][_0x2faf('0x26')](_0x4f98e9)[_0x2faf('0x17')](function(_0x42c0fb){_0x23ccb6[_0x2faf('0x26')]=_0x42c0fb;if(_0x1aa654[_0x2faf('0x36')]['includeAll']){_0x1a34ac[_0x2faf('0x49')]=[{'all':!![]}];}return db[_0x2faf('0x32')][_0x2faf('0x4a')](_0x1a34ac);})[_0x2faf('0x17')](function(_0x2bf5b8){_0x23ccb6[_0x2faf('0x4b')]=_0x2bf5b8;return _0x23ccb6;})[_0x2faf('0x17')](respondWithFilteredResult(_0xa8bb28,_0x1a34ac))['catch'](handleError(_0xa8bb28,null));};exports[_0x2faf('0x4c')]=function(_0x5c6a9f,_0x44e939){var _0x23d802={'raw':![],'where':{'id':_0x5c6a9f[_0x2faf('0x4d')]['id']}},_0xfb260a={};_0xfb260a[_0x2faf('0x34')]=_[_0x2faf('0x35')](db['VtigerConfiguration'][_0x2faf('0x33')]);_0xfb260a[_0x2faf('0x36')]=_[_0x2faf('0x35')](_0x5c6a9f[_0x2faf('0x36')]);_0xfb260a[_0x2faf('0x37')]=_[_0x2faf('0x38')](_0xfb260a[_0x2faf('0x34')],_0xfb260a[_0x2faf('0x36')]);_0x23d802[_0x2faf('0x39')]=_[_0x2faf('0x38')](_0xfb260a['model'],qs['fields'](_0x5c6a9f['query'][_0x2faf('0x3a')]));_0x23d802[_0x2faf('0x39')]=_0x23d802['attributes'][_0x2faf('0x3b')]?_0x23d802['attributes']:_0xfb260a[_0x2faf('0x34')];if(_0x5c6a9f['query'][_0x2faf('0x4e')]){_0x23d802[_0x2faf('0x49')]=[{'all':!![]}];}_0x23d802=_[_0x2faf('0x47')]({},_0x23d802,_0x5c6a9f['options']);return db['VtigerConfiguration'][_0x2faf('0x4f')](_0x23d802)[_0x2faf('0x17')](handleEntityNotFound(_0x44e939,null))['then'](respondWithResult(_0x44e939,null))[_0x2faf('0x21')](handleError(_0x44e939,null));};exports['create']=function(_0x575f31,_0x4495ca){return db[_0x2faf('0x32')]['create'](_0x575f31[_0x2faf('0x50')],{})[_0x2faf('0x17')](respondWithResult(_0x4495ca,0xc9))[_0x2faf('0x21')](handleError(_0x4495ca,null));};exports[_0x2faf('0x2d')]=function(_0x194946,_0x28d2c8){if(_0x194946[_0x2faf('0x50')]['id']){delete _0x194946[_0x2faf('0x50')]['id'];}return db[_0x2faf('0x32')][_0x2faf('0x4f')]({'where':{'id':_0x194946['params']['id']}})[_0x2faf('0x17')](handleEntityNotFound(_0x28d2c8,null))['then'](saveUpdates(_0x194946[_0x2faf('0x50')],null))[_0x2faf('0x17')](respondWithResult(_0x28d2c8,null))[_0x2faf('0x21')](handleError(_0x28d2c8,null));};exports[_0x2faf('0x2e')]=function(_0x351d7d,_0x230669){return db[_0x2faf('0x32')][_0x2faf('0x4f')]({'where':{'id':_0x351d7d['params']['id']}})[_0x2faf('0x17')](handleEntityNotFound(_0x230669,null))['then'](removeEntity(_0x230669,null))[_0x2faf('0x21')](handleError(_0x230669,null));};exports[_0x2faf('0x51')]=function(_0x45d652,_0x53c15d,_0x3992cc){var _0x5f529c={};var _0x2d7167={};var _0x18beb0;var _0x5d7e05;return db[_0x2faf('0x32')][_0x2faf('0x52')]({'where':{'id':_0x45d652['params']['id']}})[_0x2faf('0x17')](handleEntityNotFound(_0x53c15d,null))[_0x2faf('0x17')](function(_0x3efacc){if(_0x3efacc){_0x18beb0=_0x3efacc;_0x2d7167['model']=_[_0x2faf('0x35')](db[_0x2faf('0x53')]['rawAttributes']);_0x2d7167[_0x2faf('0x36')]=_[_0x2faf('0x35')](_0x45d652[_0x2faf('0x36')]);_0x2d7167[_0x2faf('0x37')]=_['intersection'](_0x2d7167[_0x2faf('0x34')],_0x2d7167[_0x2faf('0x36')]);_0x5f529c[_0x2faf('0x39')]=_['intersection'](_0x2d7167[_0x2faf('0x34')],qs[_0x2faf('0x3a')](_0x45d652['query'][_0x2faf('0x3a')]));_0x5f529c[_0x2faf('0x39')]=_0x5f529c[_0x2faf('0x39')]['length']?_0x5f529c[_0x2faf('0x39')]:_0x2d7167[_0x2faf('0x34')];_0x5f529c[_0x2faf('0x3e')]=qs[_0x2faf('0x3f')](_0x45d652[_0x2faf('0x36')][_0x2faf('0x3f')]);_0x5f529c[_0x2faf('0x40')]=qs[_0x2faf('0x37')](_[_0x2faf('0x54')](_0x45d652[_0x2faf('0x36')],_0x2d7167['filters']));if(_0x45d652[_0x2faf('0x36')]['filter']){_0x5f529c[_0x2faf('0x40')]=_[_0x2faf('0x47')](_0x5f529c['where'],{'$or':_[_0x2faf('0x42')](_0x5f529c['attributes'],function(_0x5a3e44){var _0x37b56d={};_0x37b56d[_0x5a3e44]={'$like':'%'+_0x45d652[_0x2faf('0x36')][_0x2faf('0x41')]+'%'};return _0x37b56d;})});}_0x5f529c=_[_0x2faf('0x47')]({},_0x5f529c,_0x45d652[_0x2faf('0x48')]);return _0x18beb0['getFields'](_0x5f529c);}})['then'](function(_0x31a718){if(_0x31a718){_0x5d7e05=_0x31a718[_0x2faf('0x3b')];if(!_0x45d652[_0x2faf('0x36')]['hasOwnProperty'](_0x2faf('0x3d'))){_0x5f529c[_0x2faf('0x28')]=qs[_0x2faf('0x28')](_0x45d652[_0x2faf('0x36')][_0x2faf('0x28')]);_0x5f529c[_0x2faf('0x27')]=qs[_0x2faf('0x27')](_0x45d652[_0x2faf('0x36')][_0x2faf('0x27')]);}return _0x18beb0['getFields'](_0x5f529c);}})[_0x2faf('0x17')](function(_0x3200d5){if(_0x3200d5){return _0x3200d5?{'count':_0x5d7e05,'rows':_0x3200d5}:null;}})[_0x2faf('0x17')](respondWithResult(_0x53c15d,null))[_0x2faf('0x21')](handleError(_0x53c15d,null));};exports['getSubjects']=function(_0x19e368,_0x3d869a,_0x422d84){var _0x233f21={};var _0x57eda2={};var _0x4be783;var _0x280adb;return db[_0x2faf('0x32')][_0x2faf('0x52')]({'where':{'id':_0x19e368[_0x2faf('0x4d')]['id']}})[_0x2faf('0x17')](handleEntityNotFound(_0x3d869a,null))[_0x2faf('0x17')](function(_0x5d1f3a){if(_0x5d1f3a){_0x4be783=_0x5d1f3a;_0x57eda2[_0x2faf('0x34')]=_[_0x2faf('0x35')](db[_0x2faf('0x53')][_0x2faf('0x33')]);_0x57eda2[_0x2faf('0x36')]=_[_0x2faf('0x35')](_0x19e368[_0x2faf('0x36')]);_0x57eda2[_0x2faf('0x37')]=_['intersection'](_0x57eda2['model'],_0x57eda2[_0x2faf('0x36')]);_0x233f21[_0x2faf('0x39')]=_[_0x2faf('0x38')](_0x57eda2['model'],qs[_0x2faf('0x3a')](_0x19e368[_0x2faf('0x36')][_0x2faf('0x3a')]));_0x233f21[_0x2faf('0x39')]=_0x233f21['attributes']['length']?_0x233f21[_0x2faf('0x39')]:_0x57eda2[_0x2faf('0x34')];_0x233f21[_0x2faf('0x3e')]=qs[_0x2faf('0x3f')](_0x19e368[_0x2faf('0x36')][_0x2faf('0x3f')]);_0x233f21[_0x2faf('0x40')]=qs[_0x2faf('0x37')](_[_0x2faf('0x54')](_0x19e368[_0x2faf('0x36')],_0x57eda2[_0x2faf('0x37')]));if(_0x19e368[_0x2faf('0x36')][_0x2faf('0x41')]){_0x233f21[_0x2faf('0x40')]=_[_0x2faf('0x47')](_0x233f21[_0x2faf('0x40')],{'$or':_['map'](_0x233f21[_0x2faf('0x39')],function(_0xcfef00){var _0x19a5a3={};_0x19a5a3[_0xcfef00]={'$like':'%'+_0x19e368['query'][_0x2faf('0x41')]+'%'};return _0x19a5a3;})});}_0x233f21=_[_0x2faf('0x47')]({},_0x233f21,_0x19e368[_0x2faf('0x48')]);return _0x4be783[_0x2faf('0x55')](_0x233f21);}})['then'](function(_0x29bc73){if(_0x29bc73){_0x280adb=_0x29bc73[_0x2faf('0x3b')];if(!_0x19e368[_0x2faf('0x36')][_0x2faf('0x3c')]('nolimit')){_0x233f21[_0x2faf('0x28')]=qs[_0x2faf('0x28')](_0x19e368['query'][_0x2faf('0x28')]);_0x233f21[_0x2faf('0x27')]=qs[_0x2faf('0x27')](_0x19e368['query'][_0x2faf('0x27')]);}return _0x4be783[_0x2faf('0x55')](_0x233f21);}})[_0x2faf('0x17')](function(_0x44a676){if(_0x44a676){return _0x44a676?{'count':_0x280adb,'rows':_0x44a676}:null;}})['then'](respondWithResult(_0x3d869a,null))[_0x2faf('0x21')](handleError(_0x3d869a,null));};exports[_0x2faf('0x56')]=function(_0x2e6fe7,_0x314d58,_0x2a90ff){var _0x100ce0={};var _0x5f5140={};var _0x57be52;var _0x51bb3c;return db[_0x2faf('0x32')]['findOne']({'where':{'id':_0x2e6fe7[_0x2faf('0x4d')]['id']}})[_0x2faf('0x17')](handleEntityNotFound(_0x314d58,null))[_0x2faf('0x17')](function(_0x3e9b0b){if(_0x3e9b0b){_0x57be52=_0x3e9b0b;_0x5f5140[_0x2faf('0x34')]=_[_0x2faf('0x35')](db['VtigerField'][_0x2faf('0x33')]);_0x5f5140[_0x2faf('0x36')]=_[_0x2faf('0x35')](_0x2e6fe7[_0x2faf('0x36')]);_0x5f5140[_0x2faf('0x37')]=_['intersection'](_0x5f5140['model'],_0x5f5140['query']);_0x100ce0[_0x2faf('0x39')]=_[_0x2faf('0x38')](_0x5f5140['model'],qs[_0x2faf('0x3a')](_0x2e6fe7[_0x2faf('0x36')]['fields']));_0x100ce0[_0x2faf('0x39')]=_0x100ce0[_0x2faf('0x39')][_0x2faf('0x3b')]?_0x100ce0[_0x2faf('0x39')]:_0x5f5140[_0x2faf('0x34')];_0x100ce0[_0x2faf('0x3e')]=qs[_0x2faf('0x3f')](_0x2e6fe7[_0x2faf('0x36')][_0x2faf('0x3f')]);_0x100ce0[_0x2faf('0x40')]=qs[_0x2faf('0x37')](_[_0x2faf('0x54')](_0x2e6fe7[_0x2faf('0x36')],_0x5f5140['filters']));if(_0x2e6fe7[_0x2faf('0x36')][_0x2faf('0x41')]){_0x100ce0[_0x2faf('0x40')]=_[_0x2faf('0x47')](_0x100ce0[_0x2faf('0x40')],{'$or':_['map'](_0x100ce0[_0x2faf('0x39')],function(_0x414f9a){var _0x3cacc6={};_0x3cacc6[_0x414f9a]={'$like':'%'+_0x2e6fe7[_0x2faf('0x36')][_0x2faf('0x41')]+'%'};return _0x3cacc6;})});}_0x100ce0=_[_0x2faf('0x47')]({},_0x100ce0,_0x2e6fe7[_0x2faf('0x48')]);return _0x57be52[_0x2faf('0x56')](_0x100ce0);}})[_0x2faf('0x17')](function(_0x453818){if(_0x453818){_0x51bb3c=_0x453818[_0x2faf('0x3b')];if(!_0x2e6fe7['query'][_0x2faf('0x3c')](_0x2faf('0x3d'))){_0x100ce0[_0x2faf('0x28')]=qs[_0x2faf('0x28')](_0x2e6fe7[_0x2faf('0x36')]['limit']);_0x100ce0[_0x2faf('0x27')]=qs[_0x2faf('0x27')](_0x2e6fe7[_0x2faf('0x36')][_0x2faf('0x27')]);}return _0x57be52[_0x2faf('0x56')](_0x100ce0);}})[_0x2faf('0x17')](function(_0x258d9b){if(_0x258d9b){return _0x258d9b?{'count':_0x51bb3c,'rows':_0x258d9b}:null;}})[_0x2faf('0x17')](respondWithResult(_0x314d58,null))[_0x2faf('0x21')](handleError(_0x314d58,null));};
\ No newline at end of file
+var _0xffc0=['getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../config/license/hardware','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../mysqldb','jayson/promise','http','request','then','info','request\x20sent','VtigerConfiguration,\x20%s,\x20%s,\x20%s','error','message','VtigerConfiguration,\x20%s,\x20%s','result','catch','sendStatus','json','offset','set','apply','reject','save','update','destroy','status','stack','name','send','index','VtigerConfiguration','rawAttributes','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','merge','type','VIRTUAL','filter','options','count','include','findAll','rows','params','filters','create','body','getFields','findOne','VtigerField','map','pick'];(function(_0x55abd9,_0x1148af){var _0x3e5669=function(_0x6f2105){while(--_0x6f2105){_0x55abd9['push'](_0x55abd9['shift']());}};_0x3e5669(++_0x1148af);}(_0xffc0,0x1a0));var _0x0ffc=function(_0x3304ba,_0x5df355){_0x3304ba=_0x3304ba-0x0;var _0x44dd4c=_0xffc0[_0x3304ba];return _0x44dd4c;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x0ffc('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0ffc('0x1'));var jsonpatch=require(_0x0ffc('0x2'));var rp=require(_0x0ffc('0x3'));var moment=require(_0x0ffc('0x4'));var BPromise=require(_0x0ffc('0x5'));var Mustache=require(_0x0ffc('0x6'));var util=require(_0x0ffc('0x7'));var path=require('path');var sox=require(_0x0ffc('0x8'));var csv=require(_0x0ffc('0x9'));var ejs=require(_0x0ffc('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x0ffc('0xb'));var jsforce=require(_0x0ffc('0xc'));var deskjs=require(_0x0ffc('0xd'));var toCsv=require(_0x0ffc('0x9'));var querystring=require('querystring');var Papa=require(_0x0ffc('0xe'));var authService=require(_0x0ffc('0xf'));var hardwareService=require(_0x0ffc('0x10'));var Redis=require(_0x0ffc('0x11'));var qs=require(_0x0ffc('0x12'));var logger=require(_0x0ffc('0x13'))(_0x0ffc('0x14'));var utils=require(_0x0ffc('0x15'));var config=require('../../config/environment');var db=require(_0x0ffc('0x16'))['db'];var jayson=require(_0x0ffc('0x17'));var client=jayson['client'][_0x0ffc('0x18')]({'port':0x232a});function respondWithRpcPromise(_0xbf12d1,_0x9622fe,_0x59d73e,_0x15f5f8){return new BPromise(function(_0x232345,_0x47a80b){var _0x2095df=_0x15f5f8||client;return _0x2095df[_0x0ffc('0x19')](_0xbf12d1,_0x59d73e)[_0x0ffc('0x1a')](function(_0x11a5ee){logger[_0x0ffc('0x1b')]('VtigerConfiguration,\x20%s,\x20%s',_0x9622fe,_0x0ffc('0x1c'));logger['debug'](_0x0ffc('0x1d'),_0x9622fe,_0x0ffc('0x1c'),JSON['stringify'](_0x11a5ee));if(_0x11a5ee[_0x0ffc('0x1e')]){if(_0x11a5ee['error']['code']===0x1f4){logger['error']('VtigerConfiguration,\x20%s,\x20%s',_0x9622fe,_0x11a5ee[_0x0ffc('0x1e')][_0x0ffc('0x1f')]);return _0x47a80b(_0x11a5ee[_0x0ffc('0x1e')][_0x0ffc('0x1f')]);}logger[_0x0ffc('0x1e')]('VtigerConfiguration,\x20%s,\x20%s',_0x9622fe,_0x11a5ee['error'][_0x0ffc('0x1f')]);return _0x232345(_0x11a5ee['error']['message']);}else{logger[_0x0ffc('0x1b')](_0x0ffc('0x20'),_0x9622fe,'request\x20sent');_0x232345(_0x11a5ee[_0x0ffc('0x21')][_0x0ffc('0x1f')]);}})[_0x0ffc('0x22')](function(_0x527fd4){logger['error'](_0x0ffc('0x20'),_0x9622fe,_0x527fd4);_0x47a80b(_0x527fd4);});});}function respondWithStatusCode(_0x2721b6,_0x418150){_0x418150=_0x418150||0xcc;return function(_0x948451){if(_0x948451){return _0x2721b6[_0x0ffc('0x23')](_0x418150);}return _0x2721b6['status'](_0x418150)['end']();};}function respondWithResult(_0x3e1180,_0x529415){_0x529415=_0x529415||0xc8;return function(_0x154ffe){if(_0x154ffe){return _0x3e1180['status'](_0x529415)[_0x0ffc('0x24')](_0x154ffe);}};}function respondWithFilteredResult(_0x136b0a,_0x23b14e){return function(_0x1265f5){if(_0x1265f5){var _0x3968cc=_0x1265f5['count'],_0x34bce1=_0x23b14e[_0x0ffc('0x25')],_0x20db15=_0x23b14e[_0x0ffc('0x25')]+_0x23b14e['limit'],_0x4a2794;if(_0x20db15>=_0x3968cc){_0x20db15=_0x3968cc;_0x4a2794=0xc8;}else{_0x4a2794=0xce;}_0x136b0a['status'](_0x4a2794);return _0x136b0a[_0x0ffc('0x26')]('Content-Range',_0x34bce1+'-'+_0x20db15+'/'+_0x3968cc)[_0x0ffc('0x24')](_0x1265f5);}return null;};}function patchUpdates(_0x5d3cff){return function(_0x4ece4f){try{jsonpatch[_0x0ffc('0x27')](_0x4ece4f,_0x5d3cff,!![]);}catch(_0x4f9cae){return BPromise[_0x0ffc('0x28')](_0x4f9cae);}return _0x4ece4f[_0x0ffc('0x29')]();};}function saveUpdates(_0x28c608,_0x4e813f){return function(_0x29f0cf){if(_0x29f0cf){return _0x29f0cf[_0x0ffc('0x2a')](_0x28c608)[_0x0ffc('0x1a')](function(_0x10e86d){return _0x10e86d;});}return null;};}function removeEntity(_0x51c673,_0x170390){return function(_0x557f1f){if(_0x557f1f){return _0x557f1f[_0x0ffc('0x2b')]()['then'](function(){_0x51c673[_0x0ffc('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x321fa9,_0x47a923){return function(_0x214faf){if(!_0x214faf){_0x321fa9[_0x0ffc('0x23')](0x194);}return _0x214faf;};}function handleError(_0x48fdca,_0x473d6c){_0x473d6c=_0x473d6c||0x1f4;return function(_0x313d57){logger[_0x0ffc('0x1e')](_0x313d57[_0x0ffc('0x2d')]);if(_0x313d57['name']){delete _0x313d57[_0x0ffc('0x2e')];}_0x48fdca[_0x0ffc('0x2c')](_0x473d6c)[_0x0ffc('0x2f')](_0x313d57);};}exports[_0x0ffc('0x30')]=function(_0x1edd2c,_0x6f3091){var _0x1ba0b6={},_0x597d9a={},_0x482372={'count':0x0,'rows':[]};var _0x3e3c5f=db[_0x0ffc('0x31')][_0x0ffc('0x32')];_0x597d9a['model']=_[_0x0ffc('0x33')](_0x3e3c5f);_0x597d9a[_0x0ffc('0x34')]=_[_0x0ffc('0x33')](_0x1edd2c[_0x0ffc('0x34')]);_0x597d9a['filters']=_[_0x0ffc('0x35')](_0x597d9a[_0x0ffc('0x36')],_0x597d9a[_0x0ffc('0x34')]);_0x1ba0b6[_0x0ffc('0x37')]=_[_0x0ffc('0x35')](_0x597d9a[_0x0ffc('0x36')],qs[_0x0ffc('0x38')](_0x1edd2c[_0x0ffc('0x34')][_0x0ffc('0x38')]));_0x1ba0b6['attributes']=_0x1ba0b6[_0x0ffc('0x37')][_0x0ffc('0x39')]?_0x1ba0b6[_0x0ffc('0x37')]:_0x597d9a[_0x0ffc('0x36')];if(!_0x1edd2c['query'][_0x0ffc('0x3a')](_0x0ffc('0x3b'))){_0x1ba0b6[_0x0ffc('0x3c')]=qs[_0x0ffc('0x3c')](_0x1edd2c[_0x0ffc('0x34')][_0x0ffc('0x3c')]);_0x1ba0b6[_0x0ffc('0x25')]=qs[_0x0ffc('0x25')](_0x1edd2c[_0x0ffc('0x34')]['offset']);}_0x1ba0b6[_0x0ffc('0x3d')]=qs[_0x0ffc('0x3e')](_0x1edd2c[_0x0ffc('0x34')][_0x0ffc('0x3e')]);_0x1ba0b6['where']=qs['filters'](_['pick'](_0x1edd2c[_0x0ffc('0x34')],_0x597d9a['filters']));if(_0x1edd2c[_0x0ffc('0x34')]['filter']){_0x1ba0b6[_0x0ffc('0x3f')]=_[_0x0ffc('0x40')](_0x1ba0b6['where'],{'$or':_['map'](_0x3e3c5f,function(_0x1bf431){if(_0x1bf431[_0x0ffc('0x41')]['key']!==_0x0ffc('0x42')){var _0x153a04={};_0x153a04[_0x1bf431['field']]={'$like':'%'+_0x1edd2c['query'][_0x0ffc('0x43')]+'%'};return _0x153a04;}})});}_0x1ba0b6=_['merge']({},_0x1ba0b6,_0x1edd2c[_0x0ffc('0x44')]);var _0x4928ef={'where':_0x1ba0b6['where']};return db['VtigerConfiguration'][_0x0ffc('0x45')](_0x4928ef)['then'](function(_0x1683d8){_0x482372[_0x0ffc('0x45')]=_0x1683d8;if(_0x1edd2c[_0x0ffc('0x34')]['includeAll']){_0x1ba0b6[_0x0ffc('0x46')]=[{'all':!![]}];}return db[_0x0ffc('0x31')][_0x0ffc('0x47')](_0x1ba0b6);})[_0x0ffc('0x1a')](function(_0x3ed692){_0x482372[_0x0ffc('0x48')]=_0x3ed692;return _0x482372;})[_0x0ffc('0x1a')](respondWithFilteredResult(_0x6f3091,_0x1ba0b6))[_0x0ffc('0x22')](handleError(_0x6f3091,null));};exports['show']=function(_0xd7aa22,_0x200b10){var _0x3c4b87={'raw':![],'where':{'id':_0xd7aa22[_0x0ffc('0x49')]['id']}},_0x5c5093={};_0x5c5093[_0x0ffc('0x36')]=_[_0x0ffc('0x33')](db[_0x0ffc('0x31')]['rawAttributes']);_0x5c5093[_0x0ffc('0x34')]=_[_0x0ffc('0x33')](_0xd7aa22['query']);_0x5c5093[_0x0ffc('0x4a')]=_[_0x0ffc('0x35')](_0x5c5093['model'],_0x5c5093['query']);_0x3c4b87[_0x0ffc('0x37')]=_[_0x0ffc('0x35')](_0x5c5093[_0x0ffc('0x36')],qs['fields'](_0xd7aa22['query'][_0x0ffc('0x38')]));_0x3c4b87['attributes']=_0x3c4b87[_0x0ffc('0x37')][_0x0ffc('0x39')]?_0x3c4b87[_0x0ffc('0x37')]:_0x5c5093[_0x0ffc('0x36')];if(_0xd7aa22[_0x0ffc('0x34')]['includeAll']){_0x3c4b87[_0x0ffc('0x46')]=[{'all':!![]}];}_0x3c4b87=_[_0x0ffc('0x40')]({},_0x3c4b87,_0xd7aa22[_0x0ffc('0x44')]);return db[_0x0ffc('0x31')]['find'](_0x3c4b87)['then'](handleEntityNotFound(_0x200b10,null))[_0x0ffc('0x1a')](respondWithResult(_0x200b10,null))['catch'](handleError(_0x200b10,null));};exports[_0x0ffc('0x4b')]=function(_0x4456f5,_0x52cc45){return db['VtigerConfiguration'][_0x0ffc('0x4b')](_0x4456f5[_0x0ffc('0x4c')],{})['then'](respondWithResult(_0x52cc45,0xc9))[_0x0ffc('0x22')](handleError(_0x52cc45,null));};exports[_0x0ffc('0x2a')]=function(_0x265b8d,_0x38aa4b){if(_0x265b8d[_0x0ffc('0x4c')]['id']){delete _0x265b8d[_0x0ffc('0x4c')]['id'];}return db[_0x0ffc('0x31')]['find']({'where':{'id':_0x265b8d['params']['id']}})[_0x0ffc('0x1a')](handleEntityNotFound(_0x38aa4b,null))[_0x0ffc('0x1a')](saveUpdates(_0x265b8d['body'],null))[_0x0ffc('0x1a')](respondWithResult(_0x38aa4b,null))[_0x0ffc('0x22')](handleError(_0x38aa4b,null));};exports[_0x0ffc('0x2b')]=function(_0x49fa0a,_0x14e012){return db['VtigerConfiguration']['find']({'where':{'id':_0x49fa0a[_0x0ffc('0x49')]['id']}})['then'](handleEntityNotFound(_0x14e012,null))['then'](removeEntity(_0x14e012,null))[_0x0ffc('0x22')](handleError(_0x14e012,null));};exports[_0x0ffc('0x4d')]=function(_0xd5e2cf,_0x5847c4,_0x252aa0){var _0x3320e9={};var _0x53d060={};var _0x51d53d;var _0x2a4b66;return db[_0x0ffc('0x31')][_0x0ffc('0x4e')]({'where':{'id':_0xd5e2cf[_0x0ffc('0x49')]['id']}})[_0x0ffc('0x1a')](handleEntityNotFound(_0x5847c4,null))['then'](function(_0x348874){if(_0x348874){_0x51d53d=_0x348874;_0x53d060['model']=_['keys'](db[_0x0ffc('0x4f')][_0x0ffc('0x32')]);_0x53d060[_0x0ffc('0x34')]=_['keys'](_0xd5e2cf['query']);_0x53d060['filters']=_[_0x0ffc('0x35')](_0x53d060[_0x0ffc('0x36')],_0x53d060['query']);_0x3320e9[_0x0ffc('0x37')]=_[_0x0ffc('0x35')](_0x53d060['model'],qs[_0x0ffc('0x38')](_0xd5e2cf[_0x0ffc('0x34')][_0x0ffc('0x38')]));_0x3320e9['attributes']=_0x3320e9[_0x0ffc('0x37')][_0x0ffc('0x39')]?_0x3320e9[_0x0ffc('0x37')]:_0x53d060[_0x0ffc('0x36')];_0x3320e9['order']=qs['sort'](_0xd5e2cf[_0x0ffc('0x34')]['sort']);_0x3320e9[_0x0ffc('0x3f')]=qs[_0x0ffc('0x4a')](_['pick'](_0xd5e2cf[_0x0ffc('0x34')],_0x53d060['filters']));if(_0xd5e2cf[_0x0ffc('0x34')][_0x0ffc('0x43')]){_0x3320e9['where']=_['merge'](_0x3320e9[_0x0ffc('0x3f')],{'$or':_[_0x0ffc('0x50')](_0x3320e9[_0x0ffc('0x37')],function(_0x26f3d8){var _0x21bb09={};_0x21bb09[_0x26f3d8]={'$like':'%'+_0xd5e2cf[_0x0ffc('0x34')]['filter']+'%'};return _0x21bb09;})});}_0x3320e9=_['merge']({},_0x3320e9,_0xd5e2cf[_0x0ffc('0x44')]);return _0x51d53d[_0x0ffc('0x4d')](_0x3320e9);}})[_0x0ffc('0x1a')](function(_0x18dc97){if(_0x18dc97){_0x2a4b66=_0x18dc97[_0x0ffc('0x39')];if(!_0xd5e2cf['query']['hasOwnProperty'](_0x0ffc('0x3b'))){_0x3320e9[_0x0ffc('0x3c')]=qs[_0x0ffc('0x3c')](_0xd5e2cf['query'][_0x0ffc('0x3c')]);_0x3320e9[_0x0ffc('0x25')]=qs[_0x0ffc('0x25')](_0xd5e2cf[_0x0ffc('0x34')][_0x0ffc('0x25')]);}return _0x51d53d['getFields'](_0x3320e9);}})[_0x0ffc('0x1a')](function(_0x435ea9){if(_0x435ea9){return _0x435ea9?{'count':_0x2a4b66,'rows':_0x435ea9}:null;}})[_0x0ffc('0x1a')](respondWithResult(_0x5847c4,null))[_0x0ffc('0x22')](handleError(_0x5847c4,null));};exports['getSubjects']=function(_0x228e23,_0x463132,_0x5db7ba){var _0x24dd64={};var _0x589e42={};var _0xc8e26d;var _0x416aad;return db[_0x0ffc('0x31')][_0x0ffc('0x4e')]({'where':{'id':_0x228e23[_0x0ffc('0x49')]['id']}})[_0x0ffc('0x1a')](handleEntityNotFound(_0x463132,null))[_0x0ffc('0x1a')](function(_0x53ee34){if(_0x53ee34){_0xc8e26d=_0x53ee34;_0x589e42[_0x0ffc('0x36')]=_['keys'](db[_0x0ffc('0x4f')][_0x0ffc('0x32')]);_0x589e42['query']=_[_0x0ffc('0x33')](_0x228e23[_0x0ffc('0x34')]);_0x589e42[_0x0ffc('0x4a')]=_[_0x0ffc('0x35')](_0x589e42[_0x0ffc('0x36')],_0x589e42[_0x0ffc('0x34')]);_0x24dd64[_0x0ffc('0x37')]=_[_0x0ffc('0x35')](_0x589e42['model'],qs[_0x0ffc('0x38')](_0x228e23[_0x0ffc('0x34')][_0x0ffc('0x38')]));_0x24dd64[_0x0ffc('0x37')]=_0x24dd64[_0x0ffc('0x37')][_0x0ffc('0x39')]?_0x24dd64[_0x0ffc('0x37')]:_0x589e42[_0x0ffc('0x36')];_0x24dd64['order']=qs[_0x0ffc('0x3e')](_0x228e23[_0x0ffc('0x34')]['sort']);_0x24dd64[_0x0ffc('0x3f')]=qs['filters'](_[_0x0ffc('0x51')](_0x228e23['query'],_0x589e42[_0x0ffc('0x4a')]));if(_0x228e23['query'][_0x0ffc('0x43')]){_0x24dd64[_0x0ffc('0x3f')]=_[_0x0ffc('0x40')](_0x24dd64['where'],{'$or':_['map'](_0x24dd64[_0x0ffc('0x37')],function(_0x512dde){var _0x56a68b={};_0x56a68b[_0x512dde]={'$like':'%'+_0x228e23[_0x0ffc('0x34')][_0x0ffc('0x43')]+'%'};return _0x56a68b;})});}_0x24dd64=_['merge']({},_0x24dd64,_0x228e23[_0x0ffc('0x44')]);return _0xc8e26d['getSubjects'](_0x24dd64);}})[_0x0ffc('0x1a')](function(_0x396992){if(_0x396992){_0x416aad=_0x396992[_0x0ffc('0x39')];if(!_0x228e23['query'][_0x0ffc('0x3a')](_0x0ffc('0x3b'))){_0x24dd64[_0x0ffc('0x3c')]=qs[_0x0ffc('0x3c')](_0x228e23[_0x0ffc('0x34')]['limit']);_0x24dd64[_0x0ffc('0x25')]=qs[_0x0ffc('0x25')](_0x228e23['query'][_0x0ffc('0x25')]);}return _0xc8e26d['getSubjects'](_0x24dd64);}})[_0x0ffc('0x1a')](function(_0x100d6c){if(_0x100d6c){return _0x100d6c?{'count':_0x416aad,'rows':_0x100d6c}:null;}})[_0x0ffc('0x1a')](respondWithResult(_0x463132,null))[_0x0ffc('0x22')](handleError(_0x463132,null));};exports[_0x0ffc('0x52')]=function(_0x3314be,_0x5956a0,_0x355a70){var _0x1034db={};var _0x52dd03={};var _0x7789d4;var _0x418de1;return db[_0x0ffc('0x31')][_0x0ffc('0x4e')]({'where':{'id':_0x3314be[_0x0ffc('0x49')]['id']}})[_0x0ffc('0x1a')](handleEntityNotFound(_0x5956a0,null))[_0x0ffc('0x1a')](function(_0x2fbe10){if(_0x2fbe10){_0x7789d4=_0x2fbe10;_0x52dd03[_0x0ffc('0x36')]=_[_0x0ffc('0x33')](db['VtigerField']['rawAttributes']);_0x52dd03['query']=_[_0x0ffc('0x33')](_0x3314be[_0x0ffc('0x34')]);_0x52dd03[_0x0ffc('0x4a')]=_[_0x0ffc('0x35')](_0x52dd03[_0x0ffc('0x36')],_0x52dd03['query']);_0x1034db[_0x0ffc('0x37')]=_[_0x0ffc('0x35')](_0x52dd03[_0x0ffc('0x36')],qs[_0x0ffc('0x38')](_0x3314be['query'][_0x0ffc('0x38')]));_0x1034db[_0x0ffc('0x37')]=_0x1034db[_0x0ffc('0x37')][_0x0ffc('0x39')]?_0x1034db[_0x0ffc('0x37')]:_0x52dd03[_0x0ffc('0x36')];_0x1034db[_0x0ffc('0x3d')]=qs[_0x0ffc('0x3e')](_0x3314be[_0x0ffc('0x34')]['sort']);_0x1034db[_0x0ffc('0x3f')]=qs[_0x0ffc('0x4a')](_['pick'](_0x3314be[_0x0ffc('0x34')],_0x52dd03[_0x0ffc('0x4a')]));if(_0x3314be[_0x0ffc('0x34')][_0x0ffc('0x43')]){_0x1034db[_0x0ffc('0x3f')]=_['merge'](_0x1034db[_0x0ffc('0x3f')],{'$or':_[_0x0ffc('0x50')](_0x1034db['attributes'],function(_0x5e62ea){var _0xe3c7e1={};_0xe3c7e1[_0x5e62ea]={'$like':'%'+_0x3314be[_0x0ffc('0x34')]['filter']+'%'};return _0xe3c7e1;})});}_0x1034db=_['merge']({},_0x1034db,_0x3314be[_0x0ffc('0x44')]);return _0x7789d4[_0x0ffc('0x52')](_0x1034db);}})[_0x0ffc('0x1a')](function(_0x365ca7){if(_0x365ca7){_0x418de1=_0x365ca7['length'];if(!_0x3314be[_0x0ffc('0x34')][_0x0ffc('0x3a')](_0x0ffc('0x3b'))){_0x1034db['limit']=qs[_0x0ffc('0x3c')](_0x3314be['query'][_0x0ffc('0x3c')]);_0x1034db[_0x0ffc('0x25')]=qs[_0x0ffc('0x25')](_0x3314be[_0x0ffc('0x34')][_0x0ffc('0x25')]);}return _0x7789d4['getDescriptions'](_0x1034db);}})[_0x0ffc('0x1a')](function(_0xed11c7){if(_0xed11c7){return _0xed11c7?{'count':_0x418de1,'rows':_0xed11c7}:null;}})[_0x0ffc('0x1a')](respondWithResult(_0x5956a0,null))[_0x0ffc('0x22')](handleError(_0x5956a0,null));};
\ No newline at end of file