Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 9e42831..1a100dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa9e0=['attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','ZohoConfiguration','count','includeAll','include','findAll','rows','params','intersection','find','body','findOne','ZohoField','order','getFields','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','ZohoConfiguration,\x20%s,\x20%s','debug','ZohoConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','catch','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','query','keys','filters','model'];(function(_0x47a40b,_0x443ecf){var _0x19610c=function(_0x4b8ce1){while(--_0x4b8ce1){_0x47a40b['push'](_0x47a40b['shift']());}};_0x19610c(++_0x443ecf);}(_0xa9e0,0x123));var _0x0a9e=function(_0x2160a9,_0x3cbd9e){_0x2160a9=_0x2160a9-0x0;var _0xa88cf7=_0xa9e0[_0x2160a9];return _0xa88cf7;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];var jayson=require(_0x0a9e('0x15'));var client=jayson[_0x0a9e('0x16')][_0x0a9e('0x17')]({'port':0x232a});function respondWithRpcPromise(_0x69aeb7,_0x5db4b0,_0x4283ce,_0x239b12){return new BPromise(function(_0x2b4227,_0x281129){var _0x44dcfd=_0x239b12||client;return _0x44dcfd[_0x0a9e('0x18')](_0x69aeb7,_0x4283ce)['then'](function(_0x22dccb){logger['info'](_0x0a9e('0x19'),_0x5db4b0,'request\x20sent');logger[_0x0a9e('0x1a')](_0x0a9e('0x1b'),_0x5db4b0,'request\x20sent',JSON[_0x0a9e('0x1c')](_0x22dccb));if(_0x22dccb['error']){if(_0x22dccb[_0x0a9e('0x1d')][_0x0a9e('0x1e')]===0x1f4){logger[_0x0a9e('0x1d')](_0x0a9e('0x19'),_0x5db4b0,_0x22dccb[_0x0a9e('0x1d')][_0x0a9e('0x1f')]);return _0x281129(_0x22dccb[_0x0a9e('0x1d')][_0x0a9e('0x1f')]);}logger[_0x0a9e('0x1d')](_0x0a9e('0x19'),_0x5db4b0,_0x22dccb[_0x0a9e('0x1d')][_0x0a9e('0x1f')]);return _0x2b4227(_0x22dccb['error'][_0x0a9e('0x1f')]);}else{logger[_0x0a9e('0x20')]('ZohoConfiguration,\x20%s,\x20%s',_0x5db4b0,_0x0a9e('0x21'));_0x2b4227(_0x22dccb['result']['message']);}})[_0x0a9e('0x22')](function(_0x432e56){logger[_0x0a9e('0x1d')](_0x0a9e('0x19'),_0x5db4b0,_0x432e56);_0x281129(_0x432e56);});});}function respondWithStatusCode(_0x4abc77,_0xfb6e48){_0xfb6e48=_0xfb6e48||0xcc;return function(_0x2fb0e4){if(_0x2fb0e4){return _0x4abc77[_0x0a9e('0x23')](_0xfb6e48);}return _0x4abc77[_0x0a9e('0x24')](_0xfb6e48)[_0x0a9e('0x25')]();};}function respondWithResult(_0x42ac8f,_0x16b1ca){_0x16b1ca=_0x16b1ca||0xc8;return function(_0x5ea472){if(_0x5ea472){return _0x42ac8f['status'](_0x16b1ca)[_0x0a9e('0x26')](_0x5ea472);}};}function respondWithFilteredResult(_0x3a8e58,_0x40c424){return function(_0x33161b){if(_0x33161b){var _0x526cf3=_0x33161b['count'],_0x384319=_0x40c424[_0x0a9e('0x27')],_0x479bc4=_0x40c424[_0x0a9e('0x27')]+_0x40c424[_0x0a9e('0x28')],_0x45a1e7;if(_0x479bc4>=_0x526cf3){_0x479bc4=_0x526cf3;_0x45a1e7=0xc8;}else{_0x45a1e7=0xce;}_0x3a8e58[_0x0a9e('0x24')](_0x45a1e7);return _0x3a8e58[_0x0a9e('0x29')](_0x0a9e('0x2a'),_0x384319+'-'+_0x479bc4+'/'+_0x526cf3)[_0x0a9e('0x26')](_0x33161b);}return null;};}function patchUpdates(_0x14de77){return function(_0x5a101a){try{jsonpatch[_0x0a9e('0x2b')](_0x5a101a,_0x14de77,!![]);}catch(_0x468813){return BPromise[_0x0a9e('0x2c')](_0x468813);}return _0x5a101a[_0x0a9e('0x2d')]();};}function saveUpdates(_0x5c877d,_0x15b200){return function(_0x40e7a3){if(_0x40e7a3){return _0x40e7a3[_0x0a9e('0x2e')](_0x5c877d)[_0x0a9e('0x2f')](function(_0x58b06f){return _0x58b06f;});}return null;};}function removeEntity(_0x563b45,_0x296f41){return function(_0x2e8759){if(_0x2e8759){return _0x2e8759[_0x0a9e('0x30')]()['then'](function(){_0x563b45[_0x0a9e('0x24')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2407f9,_0x3ae878){return function(_0x1122db){if(!_0x1122db){_0x2407f9[_0x0a9e('0x23')](0x194);}return _0x1122db;};}function handleError(_0x25ce3a,_0x5180f1){_0x5180f1=_0x5180f1||0x1f4;return function(_0x66c1d2){logger[_0x0a9e('0x1d')](_0x66c1d2[_0x0a9e('0x31')]);if(_0x66c1d2[_0x0a9e('0x32')]){delete _0x66c1d2[_0x0a9e('0x32')];}_0x25ce3a[_0x0a9e('0x24')](_0x5180f1)[_0x0a9e('0x33')](_0x66c1d2);};}exports[_0x0a9e('0x34')]=function(_0x5583a4,_0x44295a){var _0x5e7238={},_0x2cc7a0={},_0x14b13f={'count':0x0,'rows':[]};var _0x2b7e7f=_[_0x0a9e('0x35')](db['ZohoConfiguration'][_0x0a9e('0x36')],function(_0xd1836d){return{'name':_0xd1836d[_0x0a9e('0x37')],'type':_0xd1836d[_0x0a9e('0x38')]['key']};});_0x2cc7a0['model']=_[_0x0a9e('0x35')](_0x2b7e7f,'name');_0x2cc7a0[_0x0a9e('0x39')]=_[_0x0a9e('0x3a')](_0x5583a4[_0x0a9e('0x39')]);_0x2cc7a0[_0x0a9e('0x3b')]=_['intersection'](_0x2cc7a0[_0x0a9e('0x3c')],_0x2cc7a0[_0x0a9e('0x39')]);_0x5e7238[_0x0a9e('0x3d')]=_['intersection'](_0x2cc7a0[_0x0a9e('0x3c')],qs[_0x0a9e('0x3e')](_0x5583a4[_0x0a9e('0x39')]['fields']));_0x5e7238['attributes']=_0x5e7238[_0x0a9e('0x3d')][_0x0a9e('0x3f')]?_0x5e7238['attributes']:_0x2cc7a0[_0x0a9e('0x3c')];if(!_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x40')](_0x0a9e('0x41'))){_0x5e7238['limit']=qs['limit'](_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x28')]);_0x5e7238['offset']=qs[_0x0a9e('0x27')](_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x27')]);}_0x5e7238['order']=qs[_0x0a9e('0x42')](_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x42')]);_0x5e7238[_0x0a9e('0x43')]=qs[_0x0a9e('0x3b')](_[_0x0a9e('0x44')](_0x5583a4[_0x0a9e('0x39')],_0x2cc7a0[_0x0a9e('0x3b')]),_0x2b7e7f);if(_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x45')]){_0x5e7238[_0x0a9e('0x43')]=_[_0x0a9e('0x46')](_0x5e7238[_0x0a9e('0x43')],{'$or':_[_0x0a9e('0x35')](_0x2b7e7f,function(_0x37f6cc){if(_0x37f6cc['type']!=='VIRTUAL'){var _0x473fdc={};_0x473fdc[_0x37f6cc[_0x0a9e('0x32')]]={'$like':'%'+_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x45')]+'%'};return _0x473fdc;}})});}_0x5e7238=_[_0x0a9e('0x46')]({},_0x5e7238,_0x5583a4[_0x0a9e('0x47')]);var _0x10b040={'where':_0x5e7238[_0x0a9e('0x43')]};return db[_0x0a9e('0x48')][_0x0a9e('0x49')](_0x10b040)[_0x0a9e('0x2f')](function(_0x35ed4a){_0x14b13f['count']=_0x35ed4a;if(_0x5583a4[_0x0a9e('0x39')][_0x0a9e('0x4a')]){_0x5e7238[_0x0a9e('0x4b')]=[{'all':!![]}];}return db[_0x0a9e('0x48')][_0x0a9e('0x4c')](_0x5e7238);})[_0x0a9e('0x2f')](function(_0x21eb86){_0x14b13f[_0x0a9e('0x4d')]=_0x21eb86;return _0x14b13f;})['then'](respondWithFilteredResult(_0x44295a,_0x5e7238))[_0x0a9e('0x22')](handleError(_0x44295a,null));};exports['show']=function(_0x473dc8,_0x476688){var _0x8d6dd1={'raw':![],'where':{'id':_0x473dc8[_0x0a9e('0x4e')]['id']}},_0x562fb4={};_0x562fb4[_0x0a9e('0x3c')]=_[_0x0a9e('0x3a')](db[_0x0a9e('0x48')][_0x0a9e('0x36')]);_0x562fb4[_0x0a9e('0x39')]=_[_0x0a9e('0x3a')](_0x473dc8['query']);_0x562fb4[_0x0a9e('0x3b')]=_[_0x0a9e('0x4f')](_0x562fb4[_0x0a9e('0x3c')],_0x562fb4[_0x0a9e('0x39')]);_0x8d6dd1[_0x0a9e('0x3d')]=_[_0x0a9e('0x4f')](_0x562fb4[_0x0a9e('0x3c')],qs[_0x0a9e('0x3e')](_0x473dc8[_0x0a9e('0x39')]['fields']));_0x8d6dd1[_0x0a9e('0x3d')]=_0x8d6dd1[_0x0a9e('0x3d')]['length']?_0x8d6dd1['attributes']:_0x562fb4['model'];if(_0x473dc8[_0x0a9e('0x39')][_0x0a9e('0x4a')]){_0x8d6dd1[_0x0a9e('0x4b')]=[{'all':!![]}];}_0x8d6dd1=_[_0x0a9e('0x46')]({},_0x8d6dd1,_0x473dc8[_0x0a9e('0x47')]);return db[_0x0a9e('0x48')][_0x0a9e('0x50')](_0x8d6dd1)[_0x0a9e('0x2f')](handleEntityNotFound(_0x476688,null))['then'](respondWithResult(_0x476688,null))['catch'](handleError(_0x476688,null));};exports['create']=function(_0x39d77d,_0x204173){return db[_0x0a9e('0x48')]['create'](_0x39d77d[_0x0a9e('0x51')],{})[_0x0a9e('0x2f')](respondWithResult(_0x204173,0xc9))['catch'](handleError(_0x204173,null));};exports['update']=function(_0x2ef381,_0x59c6ff){if(_0x2ef381[_0x0a9e('0x51')]['id']){delete _0x2ef381['body']['id'];}return db[_0x0a9e('0x48')][_0x0a9e('0x50')]({'where':{'id':_0x2ef381[_0x0a9e('0x4e')]['id']}})['then'](handleEntityNotFound(_0x59c6ff,null))[_0x0a9e('0x2f')](saveUpdates(_0x2ef381[_0x0a9e('0x51')],null))['then'](respondWithResult(_0x59c6ff,null))['catch'](handleError(_0x59c6ff,null));};exports[_0x0a9e('0x30')]=function(_0x3aedd0,_0x49c095){return db[_0x0a9e('0x48')]['find']({'where':{'id':_0x3aedd0[_0x0a9e('0x4e')]['id']}})['then'](handleEntityNotFound(_0x49c095,null))[_0x0a9e('0x2f')](removeEntity(_0x49c095,null))['catch'](handleError(_0x49c095,null));};exports['getFields']=function(_0x5df0ad,_0x2da03c,_0x47de4c){var _0x2f7092={};var _0x65432={};var _0x3cfd00;var _0x19b4df;return db[_0x0a9e('0x48')][_0x0a9e('0x52')]({'where':{'id':_0x5df0ad[_0x0a9e('0x4e')]['id']}})[_0x0a9e('0x2f')](handleEntityNotFound(_0x2da03c,null))['then'](function(_0x1c693e){if(_0x1c693e){_0x3cfd00=_0x1c693e;_0x65432[_0x0a9e('0x3c')]=_[_0x0a9e('0x3a')](db[_0x0a9e('0x53')][_0x0a9e('0x36')]);_0x65432[_0x0a9e('0x39')]=_['keys'](_0x5df0ad[_0x0a9e('0x39')]);_0x65432[_0x0a9e('0x3b')]=_['intersection'](_0x65432[_0x0a9e('0x3c')],_0x65432['query']);_0x2f7092[_0x0a9e('0x3d')]=_['intersection'](_0x65432['model'],qs['fields'](_0x5df0ad[_0x0a9e('0x39')]['fields']));_0x2f7092[_0x0a9e('0x3d')]=_0x2f7092[_0x0a9e('0x3d')][_0x0a9e('0x3f')]?_0x2f7092[_0x0a9e('0x3d')]:_0x65432[_0x0a9e('0x3c')];_0x2f7092[_0x0a9e('0x54')]=qs['sort'](_0x5df0ad[_0x0a9e('0x39')]['sort']);_0x2f7092[_0x0a9e('0x43')]=qs[_0x0a9e('0x3b')](_[_0x0a9e('0x44')](_0x5df0ad['query'],_0x65432[_0x0a9e('0x3b')]));if(_0x5df0ad[_0x0a9e('0x39')][_0x0a9e('0x45')]){_0x2f7092[_0x0a9e('0x43')]=_['merge'](_0x2f7092[_0x0a9e('0x43')],{'$or':_[_0x0a9e('0x35')](_0x2f7092['attributes'],function(_0x797b45){var _0x17e88c={};_0x17e88c[_0x797b45]={'$like':'%'+_0x5df0ad[_0x0a9e('0x39')][_0x0a9e('0x45')]+'%'};return _0x17e88c;})});}_0x2f7092=_[_0x0a9e('0x46')]({},_0x2f7092,_0x5df0ad['options']);return _0x3cfd00[_0x0a9e('0x55')](_0x2f7092);}})[_0x0a9e('0x2f')](function(_0x281c7d){if(_0x281c7d){_0x19b4df=_0x281c7d['length'];if(!_0x5df0ad[_0x0a9e('0x39')]['hasOwnProperty']('nolimit')){_0x2f7092[_0x0a9e('0x28')]=qs[_0x0a9e('0x28')](_0x5df0ad[_0x0a9e('0x39')][_0x0a9e('0x28')]);_0x2f7092[_0x0a9e('0x27')]=qs[_0x0a9e('0x27')](_0x5df0ad[_0x0a9e('0x39')][_0x0a9e('0x27')]);}return _0x3cfd00[_0x0a9e('0x55')](_0x2f7092);}})[_0x0a9e('0x2f')](function(_0x2e89b7){if(_0x2e89b7){return _0x2e89b7?{'count':_0x19b4df,'rows':_0x2e89b7}:null;}})[_0x0a9e('0x2f')](respondWithResult(_0x2da03c,null))[_0x0a9e('0x22')](handleError(_0x2da03c,null));};exports[_0x0a9e('0x56')]=function(_0x320898,_0x412a72,_0x2a28c0){var _0x4257c9={};var _0x5150a4={};var _0x1b0b98;var _0x295763;return db[_0x0a9e('0x48')]['findOne']({'where':{'id':_0x320898[_0x0a9e('0x4e')]['id']}})[_0x0a9e('0x2f')](handleEntityNotFound(_0x412a72,null))['then'](function(_0x83f0b2){if(_0x83f0b2){_0x1b0b98=_0x83f0b2;_0x5150a4[_0x0a9e('0x3c')]=_[_0x0a9e('0x3a')](db[_0x0a9e('0x53')][_0x0a9e('0x36')]);_0x5150a4['query']=_['keys'](_0x320898['query']);_0x5150a4[_0x0a9e('0x3b')]=_[_0x0a9e('0x4f')](_0x5150a4[_0x0a9e('0x3c')],_0x5150a4[_0x0a9e('0x39')]);_0x4257c9[_0x0a9e('0x3d')]=_[_0x0a9e('0x4f')](_0x5150a4[_0x0a9e('0x3c')],qs[_0x0a9e('0x3e')](_0x320898['query'][_0x0a9e('0x3e')]));_0x4257c9[_0x0a9e('0x3d')]=_0x4257c9[_0x0a9e('0x3d')]['length']?_0x4257c9[_0x0a9e('0x3d')]:_0x5150a4['model'];_0x4257c9[_0x0a9e('0x54')]=qs[_0x0a9e('0x42')](_0x320898['query'][_0x0a9e('0x42')]);_0x4257c9[_0x0a9e('0x43')]=qs[_0x0a9e('0x3b')](_[_0x0a9e('0x44')](_0x320898['query'],_0x5150a4[_0x0a9e('0x3b')]));if(_0x320898[_0x0a9e('0x39')][_0x0a9e('0x45')]){_0x4257c9[_0x0a9e('0x43')]=_['merge'](_0x4257c9[_0x0a9e('0x43')],{'$or':_[_0x0a9e('0x35')](_0x4257c9[_0x0a9e('0x3d')],function(_0x361b21){var _0x4abc8f={};_0x4abc8f[_0x361b21]={'$like':'%'+_0x320898[_0x0a9e('0x39')][_0x0a9e('0x45')]+'%'};return _0x4abc8f;})});}_0x4257c9=_[_0x0a9e('0x46')]({},_0x4257c9,_0x320898[_0x0a9e('0x47')]);return _0x1b0b98[_0x0a9e('0x56')](_0x4257c9);}})[_0x0a9e('0x2f')](function(_0x40fc56){if(_0x40fc56){_0x295763=_0x40fc56[_0x0a9e('0x3f')];if(!_0x320898[_0x0a9e('0x39')][_0x0a9e('0x40')](_0x0a9e('0x41'))){_0x4257c9[_0x0a9e('0x28')]=qs[_0x0a9e('0x28')](_0x320898[_0x0a9e('0x39')]['limit']);_0x4257c9[_0x0a9e('0x27')]=qs[_0x0a9e('0x27')](_0x320898[_0x0a9e('0x39')]['offset']);}return _0x1b0b98[_0x0a9e('0x56')](_0x4257c9);}})[_0x0a9e('0x2f')](function(_0x8cea96){if(_0x8cea96){return _0x8cea96?{'count':_0x295763,'rows':_0x8cea96}:null;}})[_0x0a9e('0x2f')](respondWithResult(_0x412a72,null))['catch'](handleError(_0x412a72,null));};exports['getDescriptions']=function(_0x7ebea8,_0x2bbdb5,_0x4c54fa){var _0x45108c={};var _0x53a6a1={};var _0x260f4b;var _0x8ebf02;return db['ZohoConfiguration'][_0x0a9e('0x52')]({'where':{'id':_0x7ebea8[_0x0a9e('0x4e')]['id']}})[_0x0a9e('0x2f')](handleEntityNotFound(_0x2bbdb5,null))[_0x0a9e('0x2f')](function(_0x3755fe){if(_0x3755fe){_0x260f4b=_0x3755fe;_0x53a6a1[_0x0a9e('0x3c')]=_[_0x0a9e('0x3a')](db['ZohoField'][_0x0a9e('0x36')]);_0x53a6a1[_0x0a9e('0x39')]=_[_0x0a9e('0x3a')](_0x7ebea8[_0x0a9e('0x39')]);_0x53a6a1['filters']=_[_0x0a9e('0x4f')](_0x53a6a1[_0x0a9e('0x3c')],_0x53a6a1['query']);_0x45108c[_0x0a9e('0x3d')]=_['intersection'](_0x53a6a1[_0x0a9e('0x3c')],qs[_0x0a9e('0x3e')](_0x7ebea8[_0x0a9e('0x39')][_0x0a9e('0x3e')]));_0x45108c['attributes']=_0x45108c['attributes'][_0x0a9e('0x3f')]?_0x45108c[_0x0a9e('0x3d')]:_0x53a6a1[_0x0a9e('0x3c')];_0x45108c['order']=qs[_0x0a9e('0x42')](_0x7ebea8[_0x0a9e('0x39')]['sort']);_0x45108c['where']=qs[_0x0a9e('0x3b')](_['pick'](_0x7ebea8['query'],_0x53a6a1['filters']));if(_0x7ebea8[_0x0a9e('0x39')][_0x0a9e('0x45')]){_0x45108c[_0x0a9e('0x43')]=_[_0x0a9e('0x46')](_0x45108c[_0x0a9e('0x43')],{'$or':_[_0x0a9e('0x35')](_0x45108c['attributes'],function(_0x5fd5db){var _0x5955f1={};_0x5955f1[_0x5fd5db]={'$like':'%'+_0x7ebea8[_0x0a9e('0x39')][_0x0a9e('0x45')]+'%'};return _0x5955f1;})});}_0x45108c=_[_0x0a9e('0x46')]({},_0x45108c,_0x7ebea8[_0x0a9e('0x47')]);return _0x260f4b['getDescriptions'](_0x45108c);}})[_0x0a9e('0x2f')](function(_0x32f761){if(_0x32f761){_0x8ebf02=_0x32f761[_0x0a9e('0x3f')];if(!_0x7ebea8['query'][_0x0a9e('0x40')](_0x0a9e('0x41'))){_0x45108c[_0x0a9e('0x28')]=qs[_0x0a9e('0x28')](_0x7ebea8[_0x0a9e('0x39')][_0x0a9e('0x28')]);_0x45108c[_0x0a9e('0x27')]=qs[_0x0a9e('0x27')](_0x7ebea8['query'][_0x0a9e('0x27')]);}return _0x260f4b[_0x0a9e('0x57')](_0x45108c);}})['then'](function(_0x40e0f0){if(_0x40e0f0){return _0x40e0f0?{'count':_0x8ebf02,'rows':_0x40e0f0}:null;}})[_0x0a9e('0x2f')](respondWithResult(_0x2bbdb5,null))[_0x0a9e('0x22')](handleError(_0x2bbdb5,null));};
\ No newline at end of file
+var _0xbb3a=['path','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','set','Content-Range','apply','save','update','destroy','then','sendStatus','error','stack','name','send','index','ZohoConfiguration','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','count','include','findAll','rows','catch','includeAll','find','create','body','params','getFields','findOne','options','getSubjects','ZohoField','getDescriptions','eml-format','bluebird','mustache'];(function(_0x551b1c,_0x3584f9){var _0x131273=function(_0x553185){while(--_0x553185){_0x551b1c['push'](_0x551b1c['shift']());}};_0x131273(++_0x3584f9);}(_0xbb3a,0x93));var _0xabb3=function(_0xccbbdb,_0x264006){_0xccbbdb=_0xccbbdb-0x0;var _0x509328=_0xbb3a[_0xccbbdb];return _0x509328;};'use strict';var emlformat=require(_0xabb3('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xabb3('0x1'));var Mustache=require(_0xabb3('0x2'));var util=require('util');var path=require(_0xabb3('0x3'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xabb3('0x4'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xabb3('0x5'));var crypto=require(_0xabb3('0x6'));var jsforce=require(_0xabb3('0x7'));var deskjs=require(_0xabb3('0x8'));var toCsv=require('to-csv');var querystring=require(_0xabb3('0x9'));var Papa=require(_0xabb3('0xa'));var Redis=require(_0xabb3('0xb'));var authService=require('../../components/auth/service');var qs=require(_0xabb3('0xc'));var as=require(_0xabb3('0xd'));var hardwareService=require(_0xabb3('0xe'));var logger=require('../../config/logger')(_0xabb3('0xf'));var utils=require('../../config/utils');var config=require(_0xabb3('0x10'));var licenseUtil=require('../../config/license/util');var db=require(_0xabb3('0x11'))['db'];function respondWithStatusCode(_0x32eefb,_0x46df20){_0x46df20=_0x46df20||0xcc;return function(_0x36a26b){if(_0x36a26b){return _0x32eefb['sendStatus'](_0x46df20);}return _0x32eefb[_0xabb3('0x12')](_0x46df20)[_0xabb3('0x13')]();};}function respondWithResult(_0x58700b,_0x3b9cce){_0x3b9cce=_0x3b9cce||0xc8;return function(_0x3f4587){if(_0x3f4587){return _0x58700b[_0xabb3('0x12')](_0x3b9cce)[_0xabb3('0x14')](_0x3f4587);}};}function respondWithFilteredResult(_0x35b9e4,_0x207321){return function(_0x40dbf2){if(_0x40dbf2){var _0x540d56=typeof _0x207321[_0xabb3('0x15')]===_0xabb3('0x16')&&typeof _0x207321[_0xabb3('0x17')]===_0xabb3('0x16');var _0x46c5ce=_0x40dbf2['count'];var _0x38eff5=_0x540d56?0x0:_0x207321[_0xabb3('0x15')];var _0x459086=_0x540d56?_0x40dbf2['count']:_0x207321[_0xabb3('0x15')]+_0x207321[_0xabb3('0x17')];var _0x191f18;if(_0x459086>=_0x46c5ce){_0x459086=_0x46c5ce;_0x191f18=0xc8;}else{_0x191f18=0xce;}_0x35b9e4[_0xabb3('0x12')](_0x191f18);return _0x35b9e4[_0xabb3('0x18')](_0xabb3('0x19'),_0x38eff5+'-'+_0x459086+'/'+_0x46c5ce)['json'](_0x40dbf2);}return null;};}function patchUpdates(_0xe528b5){return function(_0x454a27){try{jsonpatch[_0xabb3('0x1a')](_0x454a27,_0xe528b5,!![]);}catch(_0xc9a602){return BPromise['reject'](_0xc9a602);}return _0x454a27[_0xabb3('0x1b')]();};}function saveUpdates(_0x5e6ef1,_0x226e6b){return function(_0x33573b){if(_0x33573b){return _0x33573b[_0xabb3('0x1c')](_0x5e6ef1)['then'](function(_0x222dab){return _0x222dab;});}return null;};}function removeEntity(_0x2b7ca6,_0x82059){return function(_0x41057a){if(_0x41057a){return _0x41057a[_0xabb3('0x1d')]()[_0xabb3('0x1e')](function(){_0x2b7ca6['status'](0xcc)[_0xabb3('0x13')]();});}};}function handleEntityNotFound(_0xeae8a4,_0x33ce84){return function(_0x5f20e1){if(!_0x5f20e1){_0xeae8a4[_0xabb3('0x1f')](0x194);}return _0x5f20e1;};}function handleError(_0x249f18,_0x17befa){_0x17befa=_0x17befa||0x1f4;return function(_0x36cde4){logger[_0xabb3('0x20')](_0x36cde4[_0xabb3('0x21')]);if(_0x36cde4[_0xabb3('0x22')]){delete _0x36cde4[_0xabb3('0x22')];}_0x249f18['status'](_0x17befa)[_0xabb3('0x23')](_0x36cde4);};}exports[_0xabb3('0x24')]=function(_0x52916d,_0x1e3a93){var _0x2db909={},_0x469400={},_0x1e48fd={'count':0x0,'rows':[]};var _0x10dad9=_['map'](db[_0xabb3('0x25')][_0xabb3('0x26')],function(_0x363a73){return{'name':_0x363a73[_0xabb3('0x27')],'type':_0x363a73[_0xabb3('0x28')]['key']};});_0x469400['model']=_[_0xabb3('0x29')](_0x10dad9,_0xabb3('0x22'));_0x469400[_0xabb3('0x2a')]=_[_0xabb3('0x2b')](_0x52916d[_0xabb3('0x2a')]);_0x469400[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x469400[_0xabb3('0x2e')],_0x469400[_0xabb3('0x2a')]);_0x2db909[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x469400[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x52916d[_0xabb3('0x2a')]['fields']));_0x2db909[_0xabb3('0x2f')]=_0x2db909['attributes'][_0xabb3('0x31')]?_0x2db909[_0xabb3('0x2f')]:_0x469400[_0xabb3('0x2e')];if(!_0x52916d[_0xabb3('0x2a')][_0xabb3('0x32')](_0xabb3('0x33'))){_0x2db909[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x52916d[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x2db909[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x52916d['query'][_0xabb3('0x15')]);}_0x2db909[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x52916d[_0xabb3('0x2a')][_0xabb3('0x35')]);_0x2db909['where']=qs[_0xabb3('0x2c')](_[_0xabb3('0x36')](_0x52916d[_0xabb3('0x2a')],_0x469400[_0xabb3('0x2c')]),_0x10dad9);if(_0x52916d[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x2db909[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x2db909[_0xabb3('0x38')],{'$or':_['map'](_0x10dad9,function(_0x5db34a){if(_0x5db34a[_0xabb3('0x28')]!==_0xabb3('0x3a')){var _0x1c7d0a={};_0x1c7d0a[_0x5db34a['name']]={'$like':'%'+_0x52916d[_0xabb3('0x2a')]['filter']+'%'};return _0x1c7d0a;}})});}_0x2db909=_[_0xabb3('0x39')]({},_0x2db909,_0x52916d['options']);var _0x5f1b30={'where':_0x2db909['where']};return db['ZohoConfiguration'][_0xabb3('0x3b')](_0x5f1b30)[_0xabb3('0x1e')](function(_0x2daff0){_0x1e48fd[_0xabb3('0x3b')]=_0x2daff0;if(_0x52916d[_0xabb3('0x2a')]['includeAll']){_0x2db909[_0xabb3('0x3c')]=[{'all':!![]}];}return db[_0xabb3('0x25')][_0xabb3('0x3d')](_0x2db909);})[_0xabb3('0x1e')](function(_0x13ca13){_0x1e48fd[_0xabb3('0x3e')]=_0x13ca13;return _0x1e48fd;})[_0xabb3('0x1e')](respondWithFilteredResult(_0x1e3a93,_0x2db909))[_0xabb3('0x3f')](handleError(_0x1e3a93,null));};exports['show']=function(_0x59ea37,_0x4af7a7){var _0x4583f8={'raw':![],'where':{'id':_0x59ea37['params']['id']}},_0x5d54c5={};_0x5d54c5[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db[_0xabb3('0x25')][_0xabb3('0x26')]);_0x5d54c5[_0xabb3('0x2a')]=_['keys'](_0x59ea37[_0xabb3('0x2a')]);_0x5d54c5[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x5d54c5[_0xabb3('0x2e')],_0x5d54c5[_0xabb3('0x2a')]);_0x4583f8[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x5d54c5[_0xabb3('0x2e')],qs['fields'](_0x59ea37[_0xabb3('0x2a')][_0xabb3('0x30')]));_0x4583f8['attributes']=_0x4583f8['attributes'][_0xabb3('0x31')]?_0x4583f8['attributes']:_0x5d54c5['model'];if(_0x59ea37[_0xabb3('0x2a')][_0xabb3('0x40')]){_0x4583f8[_0xabb3('0x3c')]=[{'all':!![]}];}_0x4583f8=_[_0xabb3('0x39')]({},_0x4583f8,_0x59ea37['options']);return db[_0xabb3('0x25')][_0xabb3('0x41')](_0x4583f8)[_0xabb3('0x1e')](handleEntityNotFound(_0x4af7a7,null))[_0xabb3('0x1e')](respondWithResult(_0x4af7a7,null))[_0xabb3('0x3f')](handleError(_0x4af7a7,null));};exports['create']=function(_0x465b04,_0x49a3da){return db[_0xabb3('0x25')][_0xabb3('0x42')](_0x465b04[_0xabb3('0x43')],{})[_0xabb3('0x1e')](respondWithResult(_0x49a3da,0xc9))[_0xabb3('0x3f')](handleError(_0x49a3da,null));};exports[_0xabb3('0x1c')]=function(_0x193340,_0x32a0f2){if(_0x193340[_0xabb3('0x43')]['id']){delete _0x193340['body']['id'];}return db[_0xabb3('0x25')][_0xabb3('0x41')]({'where':{'id':_0x193340[_0xabb3('0x44')]['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x32a0f2,null))[_0xabb3('0x1e')](saveUpdates(_0x193340['body'],null))[_0xabb3('0x1e')](respondWithResult(_0x32a0f2,null))[_0xabb3('0x3f')](handleError(_0x32a0f2,null));};exports[_0xabb3('0x1d')]=function(_0x6378a4,_0x1a68ea){return db[_0xabb3('0x25')]['find']({'where':{'id':_0x6378a4['params']['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x1a68ea,null))['then'](removeEntity(_0x1a68ea,null))[_0xabb3('0x3f')](handleError(_0x1a68ea,null));};exports[_0xabb3('0x45')]=function(_0x3dbd79,_0x24448c,_0x15b274){var _0x39906e={};var _0x551317={};var _0x32cbcb;var _0x37ddd2;return db[_0xabb3('0x25')][_0xabb3('0x46')]({'where':{'id':_0x3dbd79[_0xabb3('0x44')]['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x24448c,null))[_0xabb3('0x1e')](function(_0x52aeb4){if(_0x52aeb4){_0x32cbcb=_0x52aeb4;_0x551317[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db['ZohoField'][_0xabb3('0x26')]);_0x551317[_0xabb3('0x2a')]=_['keys'](_0x3dbd79[_0xabb3('0x2a')]);_0x551317['filters']=_[_0xabb3('0x2d')](_0x551317[_0xabb3('0x2e')],_0x551317['query']);_0x39906e[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x551317[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x3dbd79['query'][_0xabb3('0x30')]));_0x39906e['attributes']=_0x39906e['attributes'][_0xabb3('0x31')]?_0x39906e[_0xabb3('0x2f')]:_0x551317[_0xabb3('0x2e')];_0x39906e['order']=qs[_0xabb3('0x35')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x35')]);_0x39906e[_0xabb3('0x38')]=qs[_0xabb3('0x2c')](_[_0xabb3('0x36')](_0x3dbd79[_0xabb3('0x2a')],_0x551317[_0xabb3('0x2c')]));if(_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x39906e['where']=_[_0xabb3('0x39')](_0x39906e[_0xabb3('0x38')],{'$or':_[_0xabb3('0x29')](_0x39906e[_0xabb3('0x2f')],function(_0x77b8b){var _0x14089f={};_0x14089f[_0x77b8b]={'$like':'%'+_0x3dbd79[_0xabb3('0x2a')]['filter']+'%'};return _0x14089f;})});}_0x39906e=_[_0xabb3('0x39')]({},_0x39906e,_0x3dbd79[_0xabb3('0x47')]);return _0x32cbcb['getFields'](_0x39906e);}})['then'](function(_0x31202e){if(_0x31202e){_0x37ddd2=_0x31202e[_0xabb3('0x31')];if(!_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x32')](_0xabb3('0x33'))){_0x39906e[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x39906e[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x32cbcb[_0xabb3('0x45')](_0x39906e);}})[_0xabb3('0x1e')](function(_0x4c4ce7){if(_0x4c4ce7){return _0x4c4ce7?{'count':_0x37ddd2,'rows':_0x4c4ce7}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x24448c,null))['catch'](handleError(_0x24448c,null));};exports[_0xabb3('0x48')]=function(_0x2939a9,_0x334ff8,_0x541e29){var _0x45cc15={};var _0xeb5ecc={};var _0x4ae971;var _0x3b8190;return db['ZohoConfiguration'][_0xabb3('0x46')]({'where':{'id':_0x2939a9['params']['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x334ff8,null))[_0xabb3('0x1e')](function(_0xc08562){if(_0xc08562){_0x4ae971=_0xc08562;_0xeb5ecc['model']=_[_0xabb3('0x2b')](db[_0xabb3('0x49')]['rawAttributes']);_0xeb5ecc[_0xabb3('0x2a')]=_[_0xabb3('0x2b')](_0x2939a9[_0xabb3('0x2a')]);_0xeb5ecc[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0xeb5ecc[_0xabb3('0x2e')],_0xeb5ecc['query']);_0x45cc15[_0xabb3('0x2f')]=_['intersection'](_0xeb5ecc[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x2939a9['query']['fields']));_0x45cc15[_0xabb3('0x2f')]=_0x45cc15[_0xabb3('0x2f')][_0xabb3('0x31')]?_0x45cc15[_0xabb3('0x2f')]:_0xeb5ecc[_0xabb3('0x2e')];_0x45cc15[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x2939a9['query'][_0xabb3('0x35')]);_0x45cc15[_0xabb3('0x38')]=qs['filters'](_[_0xabb3('0x36')](_0x2939a9[_0xabb3('0x2a')],_0xeb5ecc[_0xabb3('0x2c')]));if(_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x45cc15[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x45cc15[_0xabb3('0x38')],{'$or':_[_0xabb3('0x29')](_0x45cc15[_0xabb3('0x2f')],function(_0x4c0caf){var _0x7fa87b={};_0x7fa87b[_0x4c0caf]={'$like':'%'+_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x37')]+'%'};return _0x7fa87b;})});}_0x45cc15=_[_0xabb3('0x39')]({},_0x45cc15,_0x2939a9[_0xabb3('0x47')]);return _0x4ae971[_0xabb3('0x48')](_0x45cc15);}})[_0xabb3('0x1e')](function(_0x521225){if(_0x521225){_0x3b8190=_0x521225['length'];if(!_0x2939a9['query'][_0xabb3('0x32')](_0xabb3('0x33'))){_0x45cc15['limit']=qs[_0xabb3('0x17')](_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x45cc15[_0xabb3('0x15')]=qs['offset'](_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x4ae971[_0xabb3('0x48')](_0x45cc15);}})[_0xabb3('0x1e')](function(_0x155bc1){if(_0x155bc1){return _0x155bc1?{'count':_0x3b8190,'rows':_0x155bc1}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x334ff8,null))[_0xabb3('0x3f')](handleError(_0x334ff8,null));};exports['getDescriptions']=function(_0x363594,_0x1ad5a4,_0x2af72e){var _0x34ab39={};var _0x2a58ba={};var _0x243423;var _0xfc8a31;return db[_0xabb3('0x25')]['findOne']({'where':{'id':_0x363594[_0xabb3('0x44')]['id']}})['then'](handleEntityNotFound(_0x1ad5a4,null))['then'](function(_0x4d67ef){if(_0x4d67ef){_0x243423=_0x4d67ef;_0x2a58ba[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db[_0xabb3('0x49')]['rawAttributes']);_0x2a58ba[_0xabb3('0x2a')]=_['keys'](_0x363594['query']);_0x2a58ba[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x2a58ba[_0xabb3('0x2e')],_0x2a58ba[_0xabb3('0x2a')]);_0x34ab39[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x2a58ba[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x30')]));_0x34ab39[_0xabb3('0x2f')]=_0x34ab39[_0xabb3('0x2f')]['length']?_0x34ab39['attributes']:_0x2a58ba[_0xabb3('0x2e')];_0x34ab39[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x363594['query'][_0xabb3('0x35')]);_0x34ab39[_0xabb3('0x38')]=qs['filters'](_[_0xabb3('0x36')](_0x363594[_0xabb3('0x2a')],_0x2a58ba[_0xabb3('0x2c')]));if(_0x363594[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x34ab39[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x34ab39['where'],{'$or':_[_0xabb3('0x29')](_0x34ab39['attributes'],function(_0x300611){var _0x47f898={};_0x47f898[_0x300611]={'$like':'%'+_0x363594[_0xabb3('0x2a')]['filter']+'%'};return _0x47f898;})});}_0x34ab39=_['merge']({},_0x34ab39,_0x363594[_0xabb3('0x47')]);return _0x243423['getDescriptions'](_0x34ab39);}})[_0xabb3('0x1e')](function(_0x30195b){if(_0x30195b){_0xfc8a31=_0x30195b['length'];if(!_0x363594['query'][_0xabb3('0x32')](_0xabb3('0x33'))){_0x34ab39[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x34ab39[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x243423[_0xabb3('0x4a')](_0x34ab39);}})[_0xabb3('0x1e')](function(_0x4adc53){if(_0x4adc53){return _0x4adc53?{'count':_0xfc8a31,'rows':_0x4adc53}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x1ad5a4,null))[_0xabb3('0x3f')](handleError(_0x1ad5a4,null));};
\ No newline at end of file