Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 8ed09e1..1a100dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe7b6=['rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','save','then','destroy','stack','name','index','map','ZohoConfiguration','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','show','params','length','create','update','body','find','keys','ZohoField','getFields','hasOwnProperty','getSubjects','findOne','getDescriptions'];(function(_0x2c98db,_0x19a9e6){var _0x1b2142=function(_0xbea8d7){while(--_0xbea8d7){_0x2c98db['push'](_0x2c98db['shift']());}};_0x1b2142(++_0x19a9e6);}(_0xe7b6,0x13c));var _0x6e7b=function(_0x39848b,_0xe50afc){_0x39848b=_0x39848b-0x0;var _0x660163=_0xe7b6[_0x39848b];return _0x660163;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6e7b('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6e7b('0x1'));var rp=require(_0x6e7b('0x2'));var moment=require(_0x6e7b('0x3'));var BPromise=require(_0x6e7b('0x4'));var Mustache=require(_0x6e7b('0x5'));var util=require(_0x6e7b('0x6'));var path=require('path');var sox=require(_0x6e7b('0x7'));var csv=require(_0x6e7b('0x8'));var ejs=require(_0x6e7b('0x9'));var fs=require('fs');var fs_extra=require(_0x6e7b('0xa'));var _=require(_0x6e7b('0xb'));var squel=require(_0x6e7b('0xc'));var crypto=require(_0x6e7b('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6e7b('0xe'));var toCsv=require(_0x6e7b('0x8'));var querystring=require(_0x6e7b('0xf'));var Papa=require(_0x6e7b('0x10'));var Redis=require(_0x6e7b('0x11'));var authService=require(_0x6e7b('0x12'));var qs=require(_0x6e7b('0x13'));var as=require(_0x6e7b('0x14'));var hardwareService=require(_0x6e7b('0x15'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x6e7b('0x16'));var licenseUtil=require(_0x6e7b('0x17'));var db=require(_0x6e7b('0x18'))['db'];function respondWithStatusCode(_0x52230b,_0x22b733){_0x22b733=_0x22b733||0xcc;return function(_0x246404){if(_0x246404){return _0x52230b[_0x6e7b('0x19')](_0x22b733);}return _0x52230b[_0x6e7b('0x1a')](_0x22b733)[_0x6e7b('0x1b')]();};}function respondWithResult(_0x12c662,_0x4b0aad){_0x4b0aad=_0x4b0aad||0xc8;return function(_0x724593){if(_0x724593){return _0x12c662[_0x6e7b('0x1a')](_0x4b0aad)[_0x6e7b('0x1c')](_0x724593);}};}function respondWithFilteredResult(_0x179572,_0x8b2c1c){return function(_0x8c5571){if(_0x8c5571){var _0x2c7d13=typeof _0x8b2c1c[_0x6e7b('0x1d')]===_0x6e7b('0x1e')&&typeof _0x8b2c1c[_0x6e7b('0x1f')]===_0x6e7b('0x1e');var _0x228f75=_0x8c5571[_0x6e7b('0x20')];var _0x30985d=_0x2c7d13?0x0:_0x8b2c1c[_0x6e7b('0x1d')];var _0x2600ad=_0x2c7d13?_0x8c5571['count']:_0x8b2c1c[_0x6e7b('0x1d')]+_0x8b2c1c[_0x6e7b('0x1f')];var _0xbeedd2;if(_0x2600ad>=_0x228f75){_0x2600ad=_0x228f75;_0xbeedd2=0xc8;}else{_0xbeedd2=0xce;}_0x179572['status'](_0xbeedd2);return _0x179572[_0x6e7b('0x21')](_0x6e7b('0x22'),_0x30985d+'-'+_0x2600ad+'/'+_0x228f75)['json'](_0x8c5571);}return null;};}function patchUpdates(_0x5707cf){return function(_0x59f71d){try{jsonpatch[_0x6e7b('0x23')](_0x59f71d,_0x5707cf,!![]);}catch(_0x527698){return BPromise['reject'](_0x527698);}return _0x59f71d[_0x6e7b('0x24')]();};}function saveUpdates(_0xc4395,_0x3bebc7){return function(_0x15fa31){if(_0x15fa31){return _0x15fa31['update'](_0xc4395)[_0x6e7b('0x25')](function(_0x3b20fa){return _0x3b20fa;});}return null;};}function removeEntity(_0x4ec5be,_0x2497d0){return function(_0x35024e){if(_0x35024e){return _0x35024e[_0x6e7b('0x26')]()[_0x6e7b('0x25')](function(){_0x4ec5be[_0x6e7b('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x47fb31,_0x1bb8ad){return function(_0x598086){if(!_0x598086){_0x47fb31['sendStatus'](0x194);}return _0x598086;};}function handleError(_0x426dfa,_0x50c5c6){_0x50c5c6=_0x50c5c6||0x1f4;return function(_0x5aac73){logger['error'](_0x5aac73[_0x6e7b('0x27')]);if(_0x5aac73[_0x6e7b('0x28')]){delete _0x5aac73['name'];}_0x426dfa[_0x6e7b('0x1a')](_0x50c5c6)['send'](_0x5aac73);};}exports[_0x6e7b('0x29')]=function(_0x5788e8,_0x4a7174){var _0x5b6d21={},_0x128702={},_0xe00cc3={'count':0x0,'rows':[]};var _0x18c0fc=_[_0x6e7b('0x2a')](db[_0x6e7b('0x2b')][_0x6e7b('0x2c')],function(_0x443a20){return{'name':_0x443a20['fieldName'],'type':_0x443a20[_0x6e7b('0x2d')][_0x6e7b('0x2e')]};});_0x128702[_0x6e7b('0x2f')]=_[_0x6e7b('0x2a')](_0x18c0fc,_0x6e7b('0x28'));_0x128702[_0x6e7b('0x30')]=_['keys'](_0x5788e8['query']);_0x128702[_0x6e7b('0x31')]=_[_0x6e7b('0x32')](_0x128702['model'],_0x128702[_0x6e7b('0x30')]);_0x5b6d21[_0x6e7b('0x33')]=_[_0x6e7b('0x32')](_0x128702[_0x6e7b('0x2f')],qs[_0x6e7b('0x34')](_0x5788e8[_0x6e7b('0x30')][_0x6e7b('0x34')]));_0x5b6d21['attributes']=_0x5b6d21['attributes']['length']?_0x5b6d21[_0x6e7b('0x33')]:_0x128702['model'];if(!_0x5788e8['query']['hasOwnProperty'](_0x6e7b('0x35'))){_0x5b6d21[_0x6e7b('0x1f')]=qs[_0x6e7b('0x1f')](_0x5788e8[_0x6e7b('0x30')][_0x6e7b('0x1f')]);_0x5b6d21[_0x6e7b('0x1d')]=qs[_0x6e7b('0x1d')](_0x5788e8['query']['offset']);}_0x5b6d21[_0x6e7b('0x36')]=qs[_0x6e7b('0x37')](_0x5788e8[_0x6e7b('0x30')][_0x6e7b('0x37')]);_0x5b6d21[_0x6e7b('0x38')]=qs['filters'](_[_0x6e7b('0x39')](_0x5788e8[_0x6e7b('0x30')],_0x128702[_0x6e7b('0x31')]),_0x18c0fc);if(_0x5788e8[_0x6e7b('0x30')][_0x6e7b('0x3a')]){_0x5b6d21[_0x6e7b('0x38')]=_[_0x6e7b('0x3b')](_0x5b6d21[_0x6e7b('0x38')],{'$or':_[_0x6e7b('0x2a')](_0x18c0fc,function(_0x296dd4){if(_0x296dd4[_0x6e7b('0x2d')]!==_0x6e7b('0x3c')){var _0x1d1d17={};_0x1d1d17[_0x296dd4['name']]={'$like':'%'+_0x5788e8[_0x6e7b('0x30')][_0x6e7b('0x3a')]+'%'};return _0x1d1d17;}})});}_0x5b6d21=_['merge']({},_0x5b6d21,_0x5788e8[_0x6e7b('0x3d')]);var _0x19bcc1={'where':_0x5b6d21[_0x6e7b('0x38')]};return db[_0x6e7b('0x2b')][_0x6e7b('0x20')](_0x19bcc1)[_0x6e7b('0x25')](function(_0x5f05fb){_0xe00cc3[_0x6e7b('0x20')]=_0x5f05fb;if(_0x5788e8[_0x6e7b('0x30')]['includeAll']){_0x5b6d21[_0x6e7b('0x3e')]=[{'all':!![]}];}return db['ZohoConfiguration']['findAll'](_0x5b6d21);})[_0x6e7b('0x25')](function(_0x472ec4){_0xe00cc3[_0x6e7b('0x3f')]=_0x472ec4;return _0xe00cc3;})[_0x6e7b('0x25')](respondWithFilteredResult(_0x4a7174,_0x5b6d21))[_0x6e7b('0x40')](handleError(_0x4a7174,null));};exports[_0x6e7b('0x41')]=function(_0x2dad51,_0x1d9dca){var _0x29d9d2={'raw':![],'where':{'id':_0x2dad51[_0x6e7b('0x42')]['id']}},_0xfb2557={};_0xfb2557[_0x6e7b('0x2f')]=_['keys'](db[_0x6e7b('0x2b')][_0x6e7b('0x2c')]);_0xfb2557[_0x6e7b('0x30')]=_['keys'](_0x2dad51['query']);_0xfb2557[_0x6e7b('0x31')]=_['intersection'](_0xfb2557[_0x6e7b('0x2f')],_0xfb2557[_0x6e7b('0x30')]);_0x29d9d2[_0x6e7b('0x33')]=_[_0x6e7b('0x32')](_0xfb2557[_0x6e7b('0x2f')],qs['fields'](_0x2dad51[_0x6e7b('0x30')][_0x6e7b('0x34')]));_0x29d9d2[_0x6e7b('0x33')]=_0x29d9d2[_0x6e7b('0x33')][_0x6e7b('0x43')]?_0x29d9d2['attributes']:_0xfb2557['model'];if(_0x2dad51[_0x6e7b('0x30')]['includeAll']){_0x29d9d2[_0x6e7b('0x3e')]=[{'all':!![]}];}_0x29d9d2=_[_0x6e7b('0x3b')]({},_0x29d9d2,_0x2dad51['options']);return db[_0x6e7b('0x2b')]['find'](_0x29d9d2)[_0x6e7b('0x25')](handleEntityNotFound(_0x1d9dca,null))[_0x6e7b('0x25')](respondWithResult(_0x1d9dca,null))[_0x6e7b('0x40')](handleError(_0x1d9dca,null));};exports[_0x6e7b('0x44')]=function(_0x1a97ad,_0x290599){return db[_0x6e7b('0x2b')][_0x6e7b('0x44')](_0x1a97ad['body'],{})[_0x6e7b('0x25')](respondWithResult(_0x290599,0xc9))[_0x6e7b('0x40')](handleError(_0x290599,null));};exports[_0x6e7b('0x45')]=function(_0x219cf7,_0x2ab8f5){if(_0x219cf7[_0x6e7b('0x46')]['id']){delete _0x219cf7[_0x6e7b('0x46')]['id'];}return db[_0x6e7b('0x2b')]['find']({'where':{'id':_0x219cf7['params']['id']}})[_0x6e7b('0x25')](handleEntityNotFound(_0x2ab8f5,null))['then'](saveUpdates(_0x219cf7['body'],null))[_0x6e7b('0x25')](respondWithResult(_0x2ab8f5,null))[_0x6e7b('0x40')](handleError(_0x2ab8f5,null));};exports[_0x6e7b('0x26')]=function(_0x2c2f07,_0x3b52c0){return db[_0x6e7b('0x2b')][_0x6e7b('0x47')]({'where':{'id':_0x2c2f07[_0x6e7b('0x42')]['id']}})[_0x6e7b('0x25')](handleEntityNotFound(_0x3b52c0,null))[_0x6e7b('0x25')](removeEntity(_0x3b52c0,null))[_0x6e7b('0x40')](handleError(_0x3b52c0,null));};exports['getFields']=function(_0x218fd9,_0x22a1b6,_0x7d397f){var _0x14eb7a={};var _0x483236={};var _0x308aca;var _0x5db388;return db[_0x6e7b('0x2b')]['findOne']({'where':{'id':_0x218fd9[_0x6e7b('0x42')]['id']}})[_0x6e7b('0x25')](handleEntityNotFound(_0x22a1b6,null))[_0x6e7b('0x25')](function(_0x211adf){if(_0x211adf){_0x308aca=_0x211adf;_0x483236[_0x6e7b('0x2f')]=_[_0x6e7b('0x48')](db[_0x6e7b('0x49')][_0x6e7b('0x2c')]);_0x483236[_0x6e7b('0x30')]=_[_0x6e7b('0x48')](_0x218fd9[_0x6e7b('0x30')]);_0x483236[_0x6e7b('0x31')]=_[_0x6e7b('0x32')](_0x483236[_0x6e7b('0x2f')],_0x483236[_0x6e7b('0x30')]);_0x14eb7a[_0x6e7b('0x33')]=_[_0x6e7b('0x32')](_0x483236[_0x6e7b('0x2f')],qs[_0x6e7b('0x34')](_0x218fd9[_0x6e7b('0x30')]['fields']));_0x14eb7a[_0x6e7b('0x33')]=_0x14eb7a[_0x6e7b('0x33')][_0x6e7b('0x43')]?_0x14eb7a['attributes']:_0x483236['model'];_0x14eb7a[_0x6e7b('0x36')]=qs['sort'](_0x218fd9['query'][_0x6e7b('0x37')]);_0x14eb7a[_0x6e7b('0x38')]=qs[_0x6e7b('0x31')](_[_0x6e7b('0x39')](_0x218fd9[_0x6e7b('0x30')],_0x483236['filters']));if(_0x218fd9[_0x6e7b('0x30')]['filter']){_0x14eb7a[_0x6e7b('0x38')]=_[_0x6e7b('0x3b')](_0x14eb7a[_0x6e7b('0x38')],{'$or':_['map'](_0x14eb7a['attributes'],function(_0x1b98f0){var _0x76d7bb={};_0x76d7bb[_0x1b98f0]={'$like':'%'+_0x218fd9[_0x6e7b('0x30')][_0x6e7b('0x3a')]+'%'};return _0x76d7bb;})});}_0x14eb7a=_['merge']({},_0x14eb7a,_0x218fd9[_0x6e7b('0x3d')]);return _0x308aca[_0x6e7b('0x4a')](_0x14eb7a);}})[_0x6e7b('0x25')](function(_0x1e5018){if(_0x1e5018){_0x5db388=_0x1e5018[_0x6e7b('0x43')];if(!_0x218fd9[_0x6e7b('0x30')][_0x6e7b('0x4b')](_0x6e7b('0x35'))){_0x14eb7a[_0x6e7b('0x1f')]=qs['limit'](_0x218fd9['query'][_0x6e7b('0x1f')]);_0x14eb7a[_0x6e7b('0x1d')]=qs[_0x6e7b('0x1d')](_0x218fd9[_0x6e7b('0x30')][_0x6e7b('0x1d')]);}return _0x308aca['getFields'](_0x14eb7a);}})['then'](function(_0x233524){if(_0x233524){return _0x233524?{'count':_0x5db388,'rows':_0x233524}:null;}})[_0x6e7b('0x25')](respondWithResult(_0x22a1b6,null))[_0x6e7b('0x40')](handleError(_0x22a1b6,null));};exports[_0x6e7b('0x4c')]=function(_0x1f2b6d,_0x561f40,_0x40eac1){var _0x3451fa={};var _0x27e806={};var _0x3a4236;var _0x23aa7f;return db[_0x6e7b('0x2b')][_0x6e7b('0x4d')]({'where':{'id':_0x1f2b6d[_0x6e7b('0x42')]['id']}})[_0x6e7b('0x25')](handleEntityNotFound(_0x561f40,null))[_0x6e7b('0x25')](function(_0x437991){if(_0x437991){_0x3a4236=_0x437991;_0x27e806[_0x6e7b('0x2f')]=_['keys'](db[_0x6e7b('0x49')][_0x6e7b('0x2c')]);_0x27e806['query']=_[_0x6e7b('0x48')](_0x1f2b6d[_0x6e7b('0x30')]);_0x27e806[_0x6e7b('0x31')]=_[_0x6e7b('0x32')](_0x27e806['model'],_0x27e806[_0x6e7b('0x30')]);_0x3451fa[_0x6e7b('0x33')]=_[_0x6e7b('0x32')](_0x27e806[_0x6e7b('0x2f')],qs[_0x6e7b('0x34')](_0x1f2b6d[_0x6e7b('0x30')][_0x6e7b('0x34')]));_0x3451fa[_0x6e7b('0x33')]=_0x3451fa[_0x6e7b('0x33')][_0x6e7b('0x43')]?_0x3451fa[_0x6e7b('0x33')]:_0x27e806[_0x6e7b('0x2f')];_0x3451fa['order']=qs[_0x6e7b('0x37')](_0x1f2b6d[_0x6e7b('0x30')]['sort']);_0x3451fa[_0x6e7b('0x38')]=qs[_0x6e7b('0x31')](_[_0x6e7b('0x39')](_0x1f2b6d[_0x6e7b('0x30')],_0x27e806[_0x6e7b('0x31')]));if(_0x1f2b6d[_0x6e7b('0x30')][_0x6e7b('0x3a')]){_0x3451fa[_0x6e7b('0x38')]=_[_0x6e7b('0x3b')](_0x3451fa[_0x6e7b('0x38')],{'$or':_[_0x6e7b('0x2a')](_0x3451fa[_0x6e7b('0x33')],function(_0x29822a){var _0x151bd6={};_0x151bd6[_0x29822a]={'$like':'%'+_0x1f2b6d[_0x6e7b('0x30')]['filter']+'%'};return _0x151bd6;})});}_0x3451fa=_['merge']({},_0x3451fa,_0x1f2b6d[_0x6e7b('0x3d')]);return _0x3a4236['getSubjects'](_0x3451fa);}})[_0x6e7b('0x25')](function(_0x347474){if(_0x347474){_0x23aa7f=_0x347474[_0x6e7b('0x43')];if(!_0x1f2b6d[_0x6e7b('0x30')][_0x6e7b('0x4b')](_0x6e7b('0x35'))){_0x3451fa[_0x6e7b('0x1f')]=qs[_0x6e7b('0x1f')](_0x1f2b6d['query'][_0x6e7b('0x1f')]);_0x3451fa[_0x6e7b('0x1d')]=qs[_0x6e7b('0x1d')](_0x1f2b6d[_0x6e7b('0x30')][_0x6e7b('0x1d')]);}return _0x3a4236[_0x6e7b('0x4c')](_0x3451fa);}})[_0x6e7b('0x25')](function(_0x5ba25f){if(_0x5ba25f){return _0x5ba25f?{'count':_0x23aa7f,'rows':_0x5ba25f}:null;}})[_0x6e7b('0x25')](respondWithResult(_0x561f40,null))[_0x6e7b('0x40')](handleError(_0x561f40,null));};exports['getDescriptions']=function(_0x510fe9,_0x4fa767,_0x137de6){var _0x425910={};var _0x5f4286={};var _0x29efd8;var _0x3a806d;return db[_0x6e7b('0x2b')][_0x6e7b('0x4d')]({'where':{'id':_0x510fe9['params']['id']}})['then'](handleEntityNotFound(_0x4fa767,null))[_0x6e7b('0x25')](function(_0x34968e){if(_0x34968e){_0x29efd8=_0x34968e;_0x5f4286[_0x6e7b('0x2f')]=_[_0x6e7b('0x48')](db[_0x6e7b('0x49')]['rawAttributes']);_0x5f4286[_0x6e7b('0x30')]=_[_0x6e7b('0x48')](_0x510fe9[_0x6e7b('0x30')]);_0x5f4286[_0x6e7b('0x31')]=_[_0x6e7b('0x32')](_0x5f4286['model'],_0x5f4286[_0x6e7b('0x30')]);_0x425910[_0x6e7b('0x33')]=_[_0x6e7b('0x32')](_0x5f4286[_0x6e7b('0x2f')],qs[_0x6e7b('0x34')](_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x34')]));_0x425910[_0x6e7b('0x33')]=_0x425910[_0x6e7b('0x33')][_0x6e7b('0x43')]?_0x425910['attributes']:_0x5f4286['model'];_0x425910['order']=qs[_0x6e7b('0x37')](_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x37')]);_0x425910[_0x6e7b('0x38')]=qs[_0x6e7b('0x31')](_['pick'](_0x510fe9[_0x6e7b('0x30')],_0x5f4286[_0x6e7b('0x31')]));if(_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x3a')]){_0x425910[_0x6e7b('0x38')]=_['merge'](_0x425910[_0x6e7b('0x38')],{'$or':_['map'](_0x425910[_0x6e7b('0x33')],function(_0x4041c4){var _0x2f1fb4={};_0x2f1fb4[_0x4041c4]={'$like':'%'+_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x3a')]+'%'};return _0x2f1fb4;})});}_0x425910=_[_0x6e7b('0x3b')]({},_0x425910,_0x510fe9[_0x6e7b('0x3d')]);return _0x29efd8[_0x6e7b('0x4e')](_0x425910);}})[_0x6e7b('0x25')](function(_0x4e235d){if(_0x4e235d){_0x3a806d=_0x4e235d['length'];if(!_0x510fe9['query'][_0x6e7b('0x4b')](_0x6e7b('0x35'))){_0x425910[_0x6e7b('0x1f')]=qs[_0x6e7b('0x1f')](_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x1f')]);_0x425910[_0x6e7b('0x1d')]=qs[_0x6e7b('0x1d')](_0x510fe9[_0x6e7b('0x30')][_0x6e7b('0x1d')]);}return _0x29efd8[_0x6e7b('0x4e')](_0x425910);}})['then'](function(_0x5d9aeb){if(_0x5d9aeb){return _0x5d9aeb?{'count':_0x3a806d,'rows':_0x5d9aeb}:null;}})['then'](respondWithResult(_0x4fa767,null))[_0x6e7b('0x40')](handleError(_0x4fa767,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