Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 420349f..67bf090 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7cca=['create','body','update','find','params','findOne','ZohoField','pick','hasOwnProperty','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','moment','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where','filter','merge','options','ZohoConfiguration','include','findAll','rows','includeAll','catch'];(function(_0x3f087d,_0x89cc1){var _0x248faa=function(_0x45997e){while(--_0x45997e){_0x3f087d['push'](_0x3f087d['shift']());}};_0x248faa(++_0x89cc1);}(_0x7cca,0x140));var _0xa7cc=function(_0x59547b,_0x332d58){_0x59547b=_0x59547b-0x0;var _0x5291b2=_0x7cca[_0x59547b];return _0x5291b2;};'use strict';var emlformat=require(_0xa7cc('0x0'));var rimraf=require(_0xa7cc('0x1'));var zipdir=require(_0xa7cc('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa7cc('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xa7cc('0x4'));var util=require('util');var path=require(_0xa7cc('0x5'));var sox=require(_0xa7cc('0x6'));var csv=require(_0xa7cc('0x7'));var ejs=require(_0xa7cc('0x8'));var fs=require('fs');var fs_extra=require(_0xa7cc('0x9'));var _=require('lodash');var squel=require(_0xa7cc('0xa'));var crypto=require(_0xa7cc('0xb'));var jsforce=require(_0xa7cc('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xa7cc('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xa7cc('0xe'));var as=require(_0xa7cc('0xf'));var hardwareService=require(_0xa7cc('0x10'));var logger=require(_0xa7cc('0x11'))(_0xa7cc('0x12'));var utils=require('../../config/utils');var config=require(_0xa7cc('0x13'));var licenseUtil=require(_0xa7cc('0x14'));var db=require(_0xa7cc('0x15'))['db'];function respondWithStatusCode(_0x4fe6d0,_0x1d07bd){_0x1d07bd=_0x1d07bd||0xcc;return function(_0x560a5d){if(_0x560a5d){return _0x4fe6d0['sendStatus'](_0x1d07bd);}return _0x4fe6d0[_0xa7cc('0x16')](_0x1d07bd)[_0xa7cc('0x17')]();};}function respondWithResult(_0x445a6e,_0xf69c5f){_0xf69c5f=_0xf69c5f||0xc8;return function(_0x497f51){if(_0x497f51){return _0x445a6e[_0xa7cc('0x16')](_0xf69c5f)[_0xa7cc('0x18')](_0x497f51);}};}function respondWithFilteredResult(_0x567e98,_0x495e7e){return function(_0x1736c9){if(_0x1736c9){var _0x45dde9=typeof _0x495e7e[_0xa7cc('0x19')]===_0xa7cc('0x1a')&&typeof _0x495e7e[_0xa7cc('0x1b')]==='undefined';var _0x1f5ca9=_0x1736c9[_0xa7cc('0x1c')];var _0x3cd820=_0x45dde9?0x0:_0x495e7e[_0xa7cc('0x19')];var _0x390249=_0x45dde9?_0x1736c9['count']:_0x495e7e[_0xa7cc('0x19')]+_0x495e7e[_0xa7cc('0x1b')];var _0x2f7673;if(_0x390249>=_0x1f5ca9){_0x390249=_0x1f5ca9;_0x2f7673=0xc8;}else{_0x2f7673=0xce;}_0x567e98[_0xa7cc('0x16')](_0x2f7673);return _0x567e98[_0xa7cc('0x1d')](_0xa7cc('0x1e'),_0x3cd820+'-'+_0x390249+'/'+_0x1f5ca9)['json'](_0x1736c9);}return null;};}function patchUpdates(_0x28f37f){return function(_0x18753e){try{jsonpatch[_0xa7cc('0x1f')](_0x18753e,_0x28f37f,!![]);}catch(_0x20849c){return BPromise[_0xa7cc('0x20')](_0x20849c);}return _0x18753e[_0xa7cc('0x21')]();};}function saveUpdates(_0x2e6a1f,_0x4f50f2){return function(_0x553b3d){if(_0x553b3d){return _0x553b3d['update'](_0x2e6a1f)[_0xa7cc('0x22')](function(_0x434132){return _0x434132;});}return null;};}function removeEntity(_0x534ae3,_0x215f5f){return function(_0x174196){if(_0x174196){return _0x174196[_0xa7cc('0x23')]()[_0xa7cc('0x22')](function(){_0x534ae3[_0xa7cc('0x16')](0xcc)[_0xa7cc('0x17')]();});}};}function handleEntityNotFound(_0x5b9d56,_0x3bbec7){return function(_0x1381b3){if(!_0x1381b3){_0x5b9d56['sendStatus'](0x194);}return _0x1381b3;};}function handleError(_0x8f1c61,_0x59b05e){_0x59b05e=_0x59b05e||0x1f4;return function(_0x8650d0){logger['error'](_0x8650d0[_0xa7cc('0x24')]);if(_0x8650d0[_0xa7cc('0x25')]){delete _0x8650d0[_0xa7cc('0x25')];}_0x8f1c61[_0xa7cc('0x16')](_0x59b05e)[_0xa7cc('0x26')](_0x8650d0);};}exports[_0xa7cc('0x27')]=function(_0xc4549d,_0x1e65b2){var _0x2942b5={},_0x4d3a80={},_0x456aaf={'count':0x0,'rows':[]};var _0x29641f=_[_0xa7cc('0x28')](db['ZohoConfiguration'][_0xa7cc('0x29')],function(_0x4d2813){return{'name':_0x4d2813[_0xa7cc('0x2a')],'type':_0x4d2813[_0xa7cc('0x2b')]['key']};});_0x4d3a80[_0xa7cc('0x2c')]=_[_0xa7cc('0x28')](_0x29641f,_0xa7cc('0x25'));_0x4d3a80[_0xa7cc('0x2d')]=_[_0xa7cc('0x2e')](_0xc4549d['query']);_0x4d3a80[_0xa7cc('0x2f')]=_[_0xa7cc('0x30')](_0x4d3a80[_0xa7cc('0x2c')],_0x4d3a80[_0xa7cc('0x2d')]);_0x2942b5['attributes']=_[_0xa7cc('0x30')](_0x4d3a80[_0xa7cc('0x2c')],qs[_0xa7cc('0x31')](_0xc4549d[_0xa7cc('0x2d')][_0xa7cc('0x31')]));_0x2942b5[_0xa7cc('0x32')]=_0x2942b5[_0xa7cc('0x32')][_0xa7cc('0x33')]?_0x2942b5[_0xa7cc('0x32')]:_0x4d3a80['model'];if(!_0xc4549d[_0xa7cc('0x2d')]['hasOwnProperty'](_0xa7cc('0x34'))){_0x2942b5[_0xa7cc('0x1b')]=qs[_0xa7cc('0x1b')](_0xc4549d[_0xa7cc('0x2d')]['limit']);_0x2942b5[_0xa7cc('0x19')]=qs[_0xa7cc('0x19')](_0xc4549d[_0xa7cc('0x2d')][_0xa7cc('0x19')]);}_0x2942b5[_0xa7cc('0x35')]=qs[_0xa7cc('0x36')](_0xc4549d[_0xa7cc('0x2d')][_0xa7cc('0x36')]);_0x2942b5[_0xa7cc('0x37')]=qs[_0xa7cc('0x2f')](_['pick'](_0xc4549d[_0xa7cc('0x2d')],_0x4d3a80[_0xa7cc('0x2f')]),_0x29641f);if(_0xc4549d[_0xa7cc('0x2d')][_0xa7cc('0x38')]){_0x2942b5['where']=_[_0xa7cc('0x39')](_0x2942b5[_0xa7cc('0x37')],{'$or':_[_0xa7cc('0x28')](_0x29641f,function(_0x2cd2b0){if(_0x2cd2b0[_0xa7cc('0x2b')]!=='VIRTUAL'){var _0xd7643c={};_0xd7643c[_0x2cd2b0[_0xa7cc('0x25')]]={'$like':'%'+_0xc4549d[_0xa7cc('0x2d')]['filter']+'%'};return _0xd7643c;}})});}_0x2942b5=_[_0xa7cc('0x39')]({},_0x2942b5,_0xc4549d[_0xa7cc('0x3a')]);var _0x2c1cb6={'where':_0x2942b5[_0xa7cc('0x37')]};return db[_0xa7cc('0x3b')][_0xa7cc('0x1c')](_0x2c1cb6)['then'](function(_0x3953f1){_0x456aaf[_0xa7cc('0x1c')]=_0x3953f1;if(_0xc4549d[_0xa7cc('0x2d')]['includeAll']){_0x2942b5[_0xa7cc('0x3c')]=[{'all':!![]}];}return db['ZohoConfiguration'][_0xa7cc('0x3d')](_0x2942b5);})[_0xa7cc('0x22')](function(_0x1441cc){_0x456aaf[_0xa7cc('0x3e')]=_0x1441cc;return _0x456aaf;})[_0xa7cc('0x22')](respondWithFilteredResult(_0x1e65b2,_0x2942b5))['catch'](handleError(_0x1e65b2,null));};exports['show']=function(_0x307a9f,_0xdbec89){var _0x134817={'raw':![],'where':{'id':_0x307a9f['params']['id']}},_0x23a25b={};_0x23a25b[_0xa7cc('0x2c')]=_[_0xa7cc('0x2e')](db[_0xa7cc('0x3b')]['rawAttributes']);_0x23a25b[_0xa7cc('0x2d')]=_[_0xa7cc('0x2e')](_0x307a9f[_0xa7cc('0x2d')]);_0x23a25b[_0xa7cc('0x2f')]=_[_0xa7cc('0x30')](_0x23a25b[_0xa7cc('0x2c')],_0x23a25b['query']);_0x134817[_0xa7cc('0x32')]=_[_0xa7cc('0x30')](_0x23a25b[_0xa7cc('0x2c')],qs[_0xa7cc('0x31')](_0x307a9f[_0xa7cc('0x2d')][_0xa7cc('0x31')]));_0x134817[_0xa7cc('0x32')]=_0x134817[_0xa7cc('0x32')][_0xa7cc('0x33')]?_0x134817[_0xa7cc('0x32')]:_0x23a25b['model'];if(_0x307a9f[_0xa7cc('0x2d')][_0xa7cc('0x3f')]){_0x134817[_0xa7cc('0x3c')]=[{'all':!![]}];}_0x134817=_['merge']({},_0x134817,_0x307a9f[_0xa7cc('0x3a')]);return db[_0xa7cc('0x3b')]['find'](_0x134817)[_0xa7cc('0x22')](handleEntityNotFound(_0xdbec89,null))['then'](respondWithResult(_0xdbec89,null))[_0xa7cc('0x40')](handleError(_0xdbec89,null));};exports[_0xa7cc('0x41')]=function(_0x7da8f7,_0x164047){return db[_0xa7cc('0x3b')][_0xa7cc('0x41')](_0x7da8f7[_0xa7cc('0x42')],{})[_0xa7cc('0x22')](respondWithResult(_0x164047,0xc9))['catch'](handleError(_0x164047,null));};exports[_0xa7cc('0x43')]=function(_0x516c5f,_0x19517d){if(_0x516c5f[_0xa7cc('0x42')]['id']){delete _0x516c5f[_0xa7cc('0x42')]['id'];}return db['ZohoConfiguration'][_0xa7cc('0x44')]({'where':{'id':_0x516c5f[_0xa7cc('0x45')]['id']}})[_0xa7cc('0x22')](handleEntityNotFound(_0x19517d,null))['then'](saveUpdates(_0x516c5f[_0xa7cc('0x42')],null))['then'](respondWithResult(_0x19517d,null))['catch'](handleError(_0x19517d,null));};exports[_0xa7cc('0x23')]=function(_0x16a3f2,_0x3b5cbd){return db[_0xa7cc('0x3b')][_0xa7cc('0x44')]({'where':{'id':_0x16a3f2[_0xa7cc('0x45')]['id']}})[_0xa7cc('0x22')](handleEntityNotFound(_0x3b5cbd,null))[_0xa7cc('0x22')](removeEntity(_0x3b5cbd,null))[_0xa7cc('0x40')](handleError(_0x3b5cbd,null));};exports['getFields']=function(_0x157e82,_0x8f69c4,_0x177c64){var _0x3ebe11={};var _0x36f3f1={};var _0x4baeff;var _0x122040;return db[_0xa7cc('0x3b')][_0xa7cc('0x46')]({'where':{'id':_0x157e82[_0xa7cc('0x45')]['id']}})['then'](handleEntityNotFound(_0x8f69c4,null))[_0xa7cc('0x22')](function(_0x86e3d1){if(_0x86e3d1){_0x4baeff=_0x86e3d1;_0x36f3f1['model']=_['keys'](db[_0xa7cc('0x47')][_0xa7cc('0x29')]);_0x36f3f1['query']=_[_0xa7cc('0x2e')](_0x157e82[_0xa7cc('0x2d')]);_0x36f3f1[_0xa7cc('0x2f')]=_[_0xa7cc('0x30')](_0x36f3f1[_0xa7cc('0x2c')],_0x36f3f1[_0xa7cc('0x2d')]);_0x3ebe11['attributes']=_['intersection'](_0x36f3f1['model'],qs[_0xa7cc('0x31')](_0x157e82['query'][_0xa7cc('0x31')]));_0x3ebe11[_0xa7cc('0x32')]=_0x3ebe11[_0xa7cc('0x32')][_0xa7cc('0x33')]?_0x3ebe11[_0xa7cc('0x32')]:_0x36f3f1['model'];_0x3ebe11[_0xa7cc('0x35')]=qs[_0xa7cc('0x36')](_0x157e82[_0xa7cc('0x2d')]['sort']);_0x3ebe11[_0xa7cc('0x37')]=qs[_0xa7cc('0x2f')](_[_0xa7cc('0x48')](_0x157e82['query'],_0x36f3f1['filters']));if(_0x157e82['query']['filter']){_0x3ebe11['where']=_[_0xa7cc('0x39')](_0x3ebe11[_0xa7cc('0x37')],{'$or':_[_0xa7cc('0x28')](_0x3ebe11[_0xa7cc('0x32')],function(_0x39513e){var _0x50ddca={};_0x50ddca[_0x39513e]={'$like':'%'+_0x157e82[_0xa7cc('0x2d')][_0xa7cc('0x38')]+'%'};return _0x50ddca;})});}_0x3ebe11=_[_0xa7cc('0x39')]({},_0x3ebe11,_0x157e82[_0xa7cc('0x3a')]);return _0x4baeff['getFields'](_0x3ebe11);}})[_0xa7cc('0x22')](function(_0x4d4ac5){if(_0x4d4ac5){_0x122040=_0x4d4ac5[_0xa7cc('0x33')];if(!_0x157e82[_0xa7cc('0x2d')][_0xa7cc('0x49')](_0xa7cc('0x34'))){_0x3ebe11[_0xa7cc('0x1b')]=qs[_0xa7cc('0x1b')](_0x157e82['query']['limit']);_0x3ebe11[_0xa7cc('0x19')]=qs[_0xa7cc('0x19')](_0x157e82[_0xa7cc('0x2d')][_0xa7cc('0x19')]);}return _0x4baeff[_0xa7cc('0x4a')](_0x3ebe11);}})[_0xa7cc('0x22')](function(_0x42ad6a){if(_0x42ad6a){return _0x42ad6a?{'count':_0x122040,'rows':_0x42ad6a}:null;}})['then'](respondWithResult(_0x8f69c4,null))[_0xa7cc('0x40')](handleError(_0x8f69c4,null));};exports[_0xa7cc('0x4b')]=function(_0x20b5e1,_0x11f45d,_0x2e6f65){var _0x2fbab3={};var _0x486e6b={};var _0x3d5e98;var _0x454d4b;return db[_0xa7cc('0x3b')][_0xa7cc('0x46')]({'where':{'id':_0x20b5e1[_0xa7cc('0x45')]['id']}})[_0xa7cc('0x22')](handleEntityNotFound(_0x11f45d,null))[_0xa7cc('0x22')](function(_0x1aba4b){if(_0x1aba4b){_0x3d5e98=_0x1aba4b;_0x486e6b['model']=_[_0xa7cc('0x2e')](db['ZohoField'][_0xa7cc('0x29')]);_0x486e6b[_0xa7cc('0x2d')]=_[_0xa7cc('0x2e')](_0x20b5e1['query']);_0x486e6b[_0xa7cc('0x2f')]=_[_0xa7cc('0x30')](_0x486e6b[_0xa7cc('0x2c')],_0x486e6b[_0xa7cc('0x2d')]);_0x2fbab3[_0xa7cc('0x32')]=_['intersection'](_0x486e6b[_0xa7cc('0x2c')],qs[_0xa7cc('0x31')](_0x20b5e1[_0xa7cc('0x2d')][_0xa7cc('0x31')]));_0x2fbab3[_0xa7cc('0x32')]=_0x2fbab3[_0xa7cc('0x32')][_0xa7cc('0x33')]?_0x2fbab3[_0xa7cc('0x32')]:_0x486e6b[_0xa7cc('0x2c')];_0x2fbab3[_0xa7cc('0x35')]=qs[_0xa7cc('0x36')](_0x20b5e1[_0xa7cc('0x2d')][_0xa7cc('0x36')]);_0x2fbab3['where']=qs[_0xa7cc('0x2f')](_[_0xa7cc('0x48')](_0x20b5e1['query'],_0x486e6b[_0xa7cc('0x2f')]));if(_0x20b5e1[_0xa7cc('0x2d')]['filter']){_0x2fbab3[_0xa7cc('0x37')]=_[_0xa7cc('0x39')](_0x2fbab3[_0xa7cc('0x37')],{'$or':_['map'](_0x2fbab3[_0xa7cc('0x32')],function(_0x1d7ef8){var _0x440208={};_0x440208[_0x1d7ef8]={'$like':'%'+_0x20b5e1[_0xa7cc('0x2d')][_0xa7cc('0x38')]+'%'};return _0x440208;})});}_0x2fbab3=_[_0xa7cc('0x39')]({},_0x2fbab3,_0x20b5e1[_0xa7cc('0x3a')]);return _0x3d5e98['getSubjects'](_0x2fbab3);}})[_0xa7cc('0x22')](function(_0x177e59){if(_0x177e59){_0x454d4b=_0x177e59[_0xa7cc('0x33')];if(!_0x20b5e1[_0xa7cc('0x2d')]['hasOwnProperty'](_0xa7cc('0x34'))){_0x2fbab3[_0xa7cc('0x1b')]=qs[_0xa7cc('0x1b')](_0x20b5e1[_0xa7cc('0x2d')][_0xa7cc('0x1b')]);_0x2fbab3[_0xa7cc('0x19')]=qs[_0xa7cc('0x19')](_0x20b5e1[_0xa7cc('0x2d')]['offset']);}return _0x3d5e98[_0xa7cc('0x4b')](_0x2fbab3);}})[_0xa7cc('0x22')](function(_0x2e052f){if(_0x2e052f){return _0x2e052f?{'count':_0x454d4b,'rows':_0x2e052f}:null;}})[_0xa7cc('0x22')](respondWithResult(_0x11f45d,null))[_0xa7cc('0x40')](handleError(_0x11f45d,null));};exports[_0xa7cc('0x4c')]=function(_0x34a488,_0x1fe67f,_0x11c837){var _0x368b65={};var _0x3d3a0e={};var _0x49a5a7;var _0x19cac4;return db[_0xa7cc('0x3b')][_0xa7cc('0x46')]({'where':{'id':_0x34a488[_0xa7cc('0x45')]['id']}})['then'](handleEntityNotFound(_0x1fe67f,null))[_0xa7cc('0x22')](function(_0xda47d4){if(_0xda47d4){_0x49a5a7=_0xda47d4;_0x3d3a0e[_0xa7cc('0x2c')]=_[_0xa7cc('0x2e')](db['ZohoField'][_0xa7cc('0x29')]);_0x3d3a0e['query']=_[_0xa7cc('0x2e')](_0x34a488['query']);_0x3d3a0e[_0xa7cc('0x2f')]=_[_0xa7cc('0x30')](_0x3d3a0e[_0xa7cc('0x2c')],_0x3d3a0e[_0xa7cc('0x2d')]);_0x368b65[_0xa7cc('0x32')]=_[_0xa7cc('0x30')](_0x3d3a0e[_0xa7cc('0x2c')],qs[_0xa7cc('0x31')](_0x34a488[_0xa7cc('0x2d')][_0xa7cc('0x31')]));_0x368b65[_0xa7cc('0x32')]=_0x368b65['attributes'][_0xa7cc('0x33')]?_0x368b65['attributes']:_0x3d3a0e[_0xa7cc('0x2c')];_0x368b65['order']=qs[_0xa7cc('0x36')](_0x34a488[_0xa7cc('0x2d')][_0xa7cc('0x36')]);_0x368b65[_0xa7cc('0x37')]=qs[_0xa7cc('0x2f')](_[_0xa7cc('0x48')](_0x34a488[_0xa7cc('0x2d')],_0x3d3a0e[_0xa7cc('0x2f')]));if(_0x34a488['query']['filter']){_0x368b65[_0xa7cc('0x37')]=_[_0xa7cc('0x39')](_0x368b65[_0xa7cc('0x37')],{'$or':_[_0xa7cc('0x28')](_0x368b65[_0xa7cc('0x32')],function(_0x1e0786){var _0x24946d={};_0x24946d[_0x1e0786]={'$like':'%'+_0x34a488[_0xa7cc('0x2d')][_0xa7cc('0x38')]+'%'};return _0x24946d;})});}_0x368b65=_[_0xa7cc('0x39')]({},_0x368b65,_0x34a488[_0xa7cc('0x3a')]);return _0x49a5a7[_0xa7cc('0x4c')](_0x368b65);}})[_0xa7cc('0x22')](function(_0x4be896){if(_0x4be896){_0x19cac4=_0x4be896[_0xa7cc('0x33')];if(!_0x34a488['query'][_0xa7cc('0x49')](_0xa7cc('0x34'))){_0x368b65[_0xa7cc('0x1b')]=qs[_0xa7cc('0x1b')](_0x34a488['query'][_0xa7cc('0x1b')]);_0x368b65[_0xa7cc('0x19')]=qs[_0xa7cc('0x19')](_0x34a488['query']['offset']);}return _0x49a5a7[_0xa7cc('0x4c')](_0x368b65);}})[_0xa7cc('0x22')](function(_0x47a28b){if(_0x47a28b){return _0x47a28b?{'count':_0x19cac4,'rows':_0x47a28b}:null;}})[_0xa7cc('0x22')](respondWithResult(_0x1fe67f,null))[_0xa7cc('0x40')](handleError(_0x1fe67f,null));};
\ No newline at end of file
+var _0xf009=['util','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','error','ZohoConfiguration','rawAttributes','fieldName','type','key','map','name','keys','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','include','findAll','rows','show','includeAll','find','create','body','catch','params','getFields','findOne','ZohoField','pick','getSubjects','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf009,0x136));var _0x9f00=function(_0x239eaf,_0x1968b4){_0x239eaf=_0x239eaf-0x0;var _0x8863f7=_0xf009[_0x239eaf];return _0x8863f7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9f00('0x0'));var zipdir=require(_0x9f00('0x1'));var jsonpatch=require(_0x9f00('0x2'));var rp=require(_0x9f00('0x3'));var moment=require('moment');var BPromise=require(_0x9f00('0x4'));var Mustache=require(_0x9f00('0x5'));var util=require(_0x9f00('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0x9f00('0x7'));var ejs=require(_0x9f00('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9f00('0x9'));var squel=require('squel');var crypto=require(_0x9f00('0xa'));var jsforce=require(_0x9f00('0xb'));var deskjs=require(_0x9f00('0xc'));var toCsv=require(_0x9f00('0x7'));var querystring=require(_0x9f00('0xd'));var Papa=require(_0x9f00('0xe'));var Redis=require(_0x9f00('0xf'));var authService=require(_0x9f00('0x10'));var qs=require(_0x9f00('0x11'));var as=require(_0x9f00('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9f00('0x13'))(_0x9f00('0x14'));var utils=require(_0x9f00('0x15'));var config=require(_0x9f00('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x48758c,_0x3b3212){_0x3b3212=_0x3b3212||0xcc;return function(_0x3f0cf0){if(_0x3f0cf0){return _0x48758c[_0x9f00('0x17')](_0x3b3212);}return _0x48758c['status'](_0x3b3212)[_0x9f00('0x18')]();};}function respondWithResult(_0x2d4639,_0x1d75ed){_0x1d75ed=_0x1d75ed||0xc8;return function(_0x54a869){if(_0x54a869){return _0x2d4639[_0x9f00('0x19')](_0x1d75ed)[_0x9f00('0x1a')](_0x54a869);}};}function respondWithFilteredResult(_0x4e19ec,_0x1a90f8){return function(_0x74ddea){if(_0x74ddea){var _0xdcc093=typeof _0x1a90f8[_0x9f00('0x1b')]===_0x9f00('0x1c')&&typeof _0x1a90f8[_0x9f00('0x1d')]===_0x9f00('0x1c');var _0x4a657f=_0x74ddea[_0x9f00('0x1e')];var _0x530f8e=_0xdcc093?0x0:_0x1a90f8[_0x9f00('0x1b')];var _0x4d468f=_0xdcc093?_0x74ddea[_0x9f00('0x1e')]:_0x1a90f8[_0x9f00('0x1b')]+_0x1a90f8[_0x9f00('0x1d')];var _0x52a5d3;if(_0x4d468f>=_0x4a657f){_0x4d468f=_0x4a657f;_0x52a5d3=0xc8;}else{_0x52a5d3=0xce;}_0x4e19ec[_0x9f00('0x19')](_0x52a5d3);return _0x4e19ec[_0x9f00('0x1f')](_0x9f00('0x20'),_0x530f8e+'-'+_0x4d468f+'/'+_0x4a657f)[_0x9f00('0x1a')](_0x74ddea);}return null;};}function patchUpdates(_0x12d199){return function(_0x385d38){try{jsonpatch['apply'](_0x385d38,_0x12d199,!![]);}catch(_0xabbfb3){return BPromise[_0x9f00('0x21')](_0xabbfb3);}return _0x385d38[_0x9f00('0x22')]();};}function saveUpdates(_0x58af36,_0x47b545){return function(_0x2e39f3){if(_0x2e39f3){return _0x2e39f3[_0x9f00('0x23')](_0x58af36)[_0x9f00('0x24')](function(_0x66b956){return _0x66b956;});}return null;};}function removeEntity(_0x4d8059,_0x2c4bd1){return function(_0x32668e){if(_0x32668e){return _0x32668e[_0x9f00('0x25')]()['then'](function(){_0x4d8059[_0x9f00('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5de97f,_0x5b97fa){return function(_0x2f12bc){if(!_0x2f12bc){_0x5de97f[_0x9f00('0x17')](0x194);}return _0x2f12bc;};}function handleError(_0x23936b,_0x1e9151){_0x1e9151=_0x1e9151||0x1f4;return function(_0x4e5a0b){logger[_0x9f00('0x26')](_0x4e5a0b['stack']);if(_0x4e5a0b['name']){delete _0x4e5a0b['name'];}_0x23936b[_0x9f00('0x19')](_0x1e9151)['send'](_0x4e5a0b);};}exports['index']=function(_0x361c5a,_0x2b4631){var _0x26e2be={},_0x5ef013={},_0x35abbc={'count':0x0,'rows':[]};var _0x2ccce3=_['map'](db[_0x9f00('0x27')][_0x9f00('0x28')],function(_0x49e06f){return{'name':_0x49e06f[_0x9f00('0x29')],'type':_0x49e06f[_0x9f00('0x2a')][_0x9f00('0x2b')]};});_0x5ef013['model']=_[_0x9f00('0x2c')](_0x2ccce3,_0x9f00('0x2d'));_0x5ef013['query']=_[_0x9f00('0x2e')](_0x361c5a[_0x9f00('0x2f')]);_0x5ef013[_0x9f00('0x30')]=_[_0x9f00('0x31')](_0x5ef013[_0x9f00('0x32')],_0x5ef013[_0x9f00('0x2f')]);_0x26e2be['attributes']=_[_0x9f00('0x31')](_0x5ef013[_0x9f00('0x32')],qs['fields'](_0x361c5a[_0x9f00('0x2f')][_0x9f00('0x33')]));_0x26e2be[_0x9f00('0x34')]=_0x26e2be['attributes'][_0x9f00('0x35')]?_0x26e2be[_0x9f00('0x34')]:_0x5ef013[_0x9f00('0x32')];if(!_0x361c5a[_0x9f00('0x2f')][_0x9f00('0x36')](_0x9f00('0x37'))){_0x26e2be[_0x9f00('0x1d')]=qs['limit'](_0x361c5a['query'][_0x9f00('0x1d')]);_0x26e2be[_0x9f00('0x1b')]=qs[_0x9f00('0x1b')](_0x361c5a[_0x9f00('0x2f')][_0x9f00('0x1b')]);}_0x26e2be[_0x9f00('0x38')]=qs[_0x9f00('0x39')](_0x361c5a['query']['sort']);_0x26e2be[_0x9f00('0x3a')]=qs[_0x9f00('0x30')](_['pick'](_0x361c5a[_0x9f00('0x2f')],_0x5ef013[_0x9f00('0x30')]),_0x2ccce3);if(_0x361c5a[_0x9f00('0x2f')][_0x9f00('0x3b')]){_0x26e2be[_0x9f00('0x3a')]=_[_0x9f00('0x3c')](_0x26e2be[_0x9f00('0x3a')],{'$or':_[_0x9f00('0x2c')](_0x2ccce3,function(_0x220584){if(_0x220584['type']!==_0x9f00('0x3d')){var _0x30f169={};_0x30f169[_0x220584[_0x9f00('0x2d')]]={'$like':'%'+_0x361c5a[_0x9f00('0x2f')]['filter']+'%'};return _0x30f169;}})});}_0x26e2be=_['merge']({},_0x26e2be,_0x361c5a[_0x9f00('0x3e')]);var _0x2f1f8d={'where':_0x26e2be[_0x9f00('0x3a')]};return db[_0x9f00('0x27')][_0x9f00('0x1e')](_0x2f1f8d)[_0x9f00('0x24')](function(_0x2ea4a9){_0x35abbc[_0x9f00('0x1e')]=_0x2ea4a9;if(_0x361c5a['query']['includeAll']){_0x26e2be[_0x9f00('0x3f')]=[{'all':!![]}];}return db[_0x9f00('0x27')][_0x9f00('0x40')](_0x26e2be);})['then'](function(_0x4d889d){_0x35abbc[_0x9f00('0x41')]=_0x4d889d;return _0x35abbc;})['then'](respondWithFilteredResult(_0x2b4631,_0x26e2be))['catch'](handleError(_0x2b4631,null));};exports[_0x9f00('0x42')]=function(_0x3b568f,_0x14294a){var _0x261783={'raw':![],'where':{'id':_0x3b568f['params']['id']}},_0xc7168e={};_0xc7168e[_0x9f00('0x32')]=_[_0x9f00('0x2e')](db[_0x9f00('0x27')][_0x9f00('0x28')]);_0xc7168e['query']=_['keys'](_0x3b568f[_0x9f00('0x2f')]);_0xc7168e[_0x9f00('0x30')]=_[_0x9f00('0x31')](_0xc7168e[_0x9f00('0x32')],_0xc7168e[_0x9f00('0x2f')]);_0x261783['attributes']=_[_0x9f00('0x31')](_0xc7168e[_0x9f00('0x32')],qs[_0x9f00('0x33')](_0x3b568f[_0x9f00('0x2f')][_0x9f00('0x33')]));_0x261783['attributes']=_0x261783[_0x9f00('0x34')][_0x9f00('0x35')]?_0x261783[_0x9f00('0x34')]:_0xc7168e[_0x9f00('0x32')];if(_0x3b568f[_0x9f00('0x2f')][_0x9f00('0x43')]){_0x261783[_0x9f00('0x3f')]=[{'all':!![]}];}_0x261783=_['merge']({},_0x261783,_0x3b568f['options']);return db[_0x9f00('0x27')][_0x9f00('0x44')](_0x261783)['then'](handleEntityNotFound(_0x14294a,null))[_0x9f00('0x24')](respondWithResult(_0x14294a,null))['catch'](handleError(_0x14294a,null));};exports[_0x9f00('0x45')]=function(_0x363320,_0x5d5a26){return db[_0x9f00('0x27')][_0x9f00('0x45')](_0x363320[_0x9f00('0x46')],{})[_0x9f00('0x24')](respondWithResult(_0x5d5a26,0xc9))[_0x9f00('0x47')](handleError(_0x5d5a26,null));};exports[_0x9f00('0x23')]=function(_0x3d17e4,_0x10ac9c){if(_0x3d17e4[_0x9f00('0x46')]['id']){delete _0x3d17e4[_0x9f00('0x46')]['id'];}return db[_0x9f00('0x27')][_0x9f00('0x44')]({'where':{'id':_0x3d17e4['params']['id']}})['then'](handleEntityNotFound(_0x10ac9c,null))[_0x9f00('0x24')](saveUpdates(_0x3d17e4[_0x9f00('0x46')],null))[_0x9f00('0x24')](respondWithResult(_0x10ac9c,null))[_0x9f00('0x47')](handleError(_0x10ac9c,null));};exports[_0x9f00('0x25')]=function(_0x12a245,_0x521bb2){return db[_0x9f00('0x27')][_0x9f00('0x44')]({'where':{'id':_0x12a245[_0x9f00('0x48')]['id']}})['then'](handleEntityNotFound(_0x521bb2,null))[_0x9f00('0x24')](removeEntity(_0x521bb2,null))[_0x9f00('0x47')](handleError(_0x521bb2,null));};exports[_0x9f00('0x49')]=function(_0xf3c904,_0x595259,_0x502737){var _0x4294a7={};var _0x20cdef={};var _0x582216;var _0x422522;return db[_0x9f00('0x27')][_0x9f00('0x4a')]({'where':{'id':_0xf3c904[_0x9f00('0x48')]['id']}})[_0x9f00('0x24')](handleEntityNotFound(_0x595259,null))['then'](function(_0x5cd844){if(_0x5cd844){_0x582216=_0x5cd844;_0x20cdef[_0x9f00('0x32')]=_[_0x9f00('0x2e')](db['ZohoField'][_0x9f00('0x28')]);_0x20cdef['query']=_[_0x9f00('0x2e')](_0xf3c904[_0x9f00('0x2f')]);_0x20cdef[_0x9f00('0x30')]=_['intersection'](_0x20cdef[_0x9f00('0x32')],_0x20cdef['query']);_0x4294a7[_0x9f00('0x34')]=_[_0x9f00('0x31')](_0x20cdef[_0x9f00('0x32')],qs[_0x9f00('0x33')](_0xf3c904[_0x9f00('0x2f')][_0x9f00('0x33')]));_0x4294a7['attributes']=_0x4294a7[_0x9f00('0x34')][_0x9f00('0x35')]?_0x4294a7['attributes']:_0x20cdef[_0x9f00('0x32')];_0x4294a7[_0x9f00('0x38')]=qs[_0x9f00('0x39')](_0xf3c904[_0x9f00('0x2f')][_0x9f00('0x39')]);_0x4294a7[_0x9f00('0x3a')]=qs[_0x9f00('0x30')](_['pick'](_0xf3c904[_0x9f00('0x2f')],_0x20cdef[_0x9f00('0x30')]));if(_0xf3c904['query']['filter']){_0x4294a7[_0x9f00('0x3a')]=_[_0x9f00('0x3c')](_0x4294a7['where'],{'$or':_['map'](_0x4294a7[_0x9f00('0x34')],function(_0x40838c){var _0x33ad8a={};_0x33ad8a[_0x40838c]={'$like':'%'+_0xf3c904['query']['filter']+'%'};return _0x33ad8a;})});}_0x4294a7=_[_0x9f00('0x3c')]({},_0x4294a7,_0xf3c904[_0x9f00('0x3e')]);return _0x582216['getFields'](_0x4294a7);}})[_0x9f00('0x24')](function(_0x2bcd59){if(_0x2bcd59){_0x422522=_0x2bcd59[_0x9f00('0x35')];if(!_0xf3c904[_0x9f00('0x2f')]['hasOwnProperty'](_0x9f00('0x37'))){_0x4294a7[_0x9f00('0x1d')]=qs[_0x9f00('0x1d')](_0xf3c904[_0x9f00('0x2f')]['limit']);_0x4294a7[_0x9f00('0x1b')]=qs['offset'](_0xf3c904[_0x9f00('0x2f')][_0x9f00('0x1b')]);}return _0x582216['getFields'](_0x4294a7);}})[_0x9f00('0x24')](function(_0x5f3b2e){if(_0x5f3b2e){return _0x5f3b2e?{'count':_0x422522,'rows':_0x5f3b2e}:null;}})[_0x9f00('0x24')](respondWithResult(_0x595259,null))['catch'](handleError(_0x595259,null));};exports['getSubjects']=function(_0x4684db,_0x39f06a,_0x19dc23){var _0x174e24={};var _0x23c60f={};var _0xb94313;var _0x43dfaa;return db[_0x9f00('0x27')][_0x9f00('0x4a')]({'where':{'id':_0x4684db['params']['id']}})['then'](handleEntityNotFound(_0x39f06a,null))['then'](function(_0x49247c){if(_0x49247c){_0xb94313=_0x49247c;_0x23c60f[_0x9f00('0x32')]=_[_0x9f00('0x2e')](db[_0x9f00('0x4b')][_0x9f00('0x28')]);_0x23c60f[_0x9f00('0x2f')]=_[_0x9f00('0x2e')](_0x4684db[_0x9f00('0x2f')]);_0x23c60f[_0x9f00('0x30')]=_[_0x9f00('0x31')](_0x23c60f['model'],_0x23c60f[_0x9f00('0x2f')]);_0x174e24[_0x9f00('0x34')]=_['intersection'](_0x23c60f['model'],qs[_0x9f00('0x33')](_0x4684db[_0x9f00('0x2f')][_0x9f00('0x33')]));_0x174e24['attributes']=_0x174e24[_0x9f00('0x34')]['length']?_0x174e24[_0x9f00('0x34')]:_0x23c60f[_0x9f00('0x32')];_0x174e24[_0x9f00('0x38')]=qs[_0x9f00('0x39')](_0x4684db['query']['sort']);_0x174e24[_0x9f00('0x3a')]=qs['filters'](_[_0x9f00('0x4c')](_0x4684db[_0x9f00('0x2f')],_0x23c60f[_0x9f00('0x30')]));if(_0x4684db[_0x9f00('0x2f')]['filter']){_0x174e24[_0x9f00('0x3a')]=_[_0x9f00('0x3c')](_0x174e24[_0x9f00('0x3a')],{'$or':_['map'](_0x174e24['attributes'],function(_0x2d9ba5){var _0x55557f={};_0x55557f[_0x2d9ba5]={'$like':'%'+_0x4684db['query'][_0x9f00('0x3b')]+'%'};return _0x55557f;})});}_0x174e24=_[_0x9f00('0x3c')]({},_0x174e24,_0x4684db[_0x9f00('0x3e')]);return _0xb94313[_0x9f00('0x4d')](_0x174e24);}})[_0x9f00('0x24')](function(_0x4fdffd){if(_0x4fdffd){_0x43dfaa=_0x4fdffd[_0x9f00('0x35')];if(!_0x4684db[_0x9f00('0x2f')][_0x9f00('0x36')](_0x9f00('0x37'))){_0x174e24[_0x9f00('0x1d')]=qs['limit'](_0x4684db['query']['limit']);_0x174e24[_0x9f00('0x1b')]=qs[_0x9f00('0x1b')](_0x4684db['query'][_0x9f00('0x1b')]);}return _0xb94313[_0x9f00('0x4d')](_0x174e24);}})[_0x9f00('0x24')](function(_0x40cbca){if(_0x40cbca){return _0x40cbca?{'count':_0x43dfaa,'rows':_0x40cbca}:null;}})[_0x9f00('0x24')](respondWithResult(_0x39f06a,null))[_0x9f00('0x47')](handleError(_0x39f06a,null));};exports[_0x9f00('0x4e')]=function(_0x3c0b62,_0x1e3dce,_0x44f969){var _0x8037fb={};var _0x3dc4d0={};var _0xecb919;var _0x59bc84;return db[_0x9f00('0x27')][_0x9f00('0x4a')]({'where':{'id':_0x3c0b62['params']['id']}})['then'](handleEntityNotFound(_0x1e3dce,null))['then'](function(_0xc40047){if(_0xc40047){_0xecb919=_0xc40047;_0x3dc4d0['model']=_[_0x9f00('0x2e')](db[_0x9f00('0x4b')][_0x9f00('0x28')]);_0x3dc4d0[_0x9f00('0x2f')]=_[_0x9f00('0x2e')](_0x3c0b62['query']);_0x3dc4d0['filters']=_[_0x9f00('0x31')](_0x3dc4d0[_0x9f00('0x32')],_0x3dc4d0['query']);_0x8037fb['attributes']=_[_0x9f00('0x31')](_0x3dc4d0[_0x9f00('0x32')],qs['fields'](_0x3c0b62[_0x9f00('0x2f')][_0x9f00('0x33')]));_0x8037fb[_0x9f00('0x34')]=_0x8037fb[_0x9f00('0x34')][_0x9f00('0x35')]?_0x8037fb['attributes']:_0x3dc4d0[_0x9f00('0x32')];_0x8037fb[_0x9f00('0x38')]=qs[_0x9f00('0x39')](_0x3c0b62['query']['sort']);_0x8037fb['where']=qs['filters'](_[_0x9f00('0x4c')](_0x3c0b62[_0x9f00('0x2f')],_0x3dc4d0[_0x9f00('0x30')]));if(_0x3c0b62[_0x9f00('0x2f')]['filter']){_0x8037fb['where']=_['merge'](_0x8037fb[_0x9f00('0x3a')],{'$or':_[_0x9f00('0x2c')](_0x8037fb[_0x9f00('0x34')],function(_0x2e899a){var _0x5daef2={};_0x5daef2[_0x2e899a]={'$like':'%'+_0x3c0b62[_0x9f00('0x2f')]['filter']+'%'};return _0x5daef2;})});}_0x8037fb=_[_0x9f00('0x3c')]({},_0x8037fb,_0x3c0b62[_0x9f00('0x3e')]);return _0xecb919[_0x9f00('0x4e')](_0x8037fb);}})[_0x9f00('0x24')](function(_0x4acc27){if(_0x4acc27){_0x59bc84=_0x4acc27[_0x9f00('0x35')];if(!_0x3c0b62['query']['hasOwnProperty'](_0x9f00('0x37'))){_0x8037fb[_0x9f00('0x1d')]=qs['limit'](_0x3c0b62[_0x9f00('0x2f')][_0x9f00('0x1d')]);_0x8037fb[_0x9f00('0x1b')]=qs[_0x9f00('0x1b')](_0x3c0b62[_0x9f00('0x2f')][_0x9f00('0x1b')]);}return _0xecb919[_0x9f00('0x4e')](_0x8037fb);}})[_0x9f00('0x24')](function(_0x515d32){if(_0x515d32){return _0x515d32?{'count':_0x59bc84,'rows':_0x515d32}:null;}})['then'](respondWithResult(_0x1e3dce,null))[_0x9f00('0x47')](handleError(_0x1e3dce,null));};
\ No newline at end of file