Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 55ddc58..1a100dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdf9b=['fs-extra','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','limit','set','Content-Range','then','destroy','end','error','name','send','ZohoConfiguration','rawAttributes','fieldName','type','model','map','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','count','includeAll','findAll','rows','catch','show','params','include','create','update','body','find','getFields','findOne','getSubjects','ZohoField','getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','ejs'];(function(_0x4baae2,_0x487ab6){var _0x1a2285=function(_0x1cea47){while(--_0x1cea47){_0x4baae2['push'](_0x4baae2['shift']());}};_0x1a2285(++_0x487ab6);}(_0xdf9b,0xdd));var _0xbdf9=function(_0x1cc8fe,_0x105328){_0x1cc8fe=_0x1cc8fe-0x0;var _0x230054=_0xdf9b[_0x1cc8fe];return _0x230054;};'use strict';var emlformat=require(_0xbdf9('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbdf9('0x1'));var jsonpatch=require(_0xbdf9('0x2'));var rp=require(_0xbdf9('0x3'));var moment=require(_0xbdf9('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbdf9('0x5'));var util=require(_0xbdf9('0x6'));var path=require('path');var sox=require(_0xbdf9('0x7'));var csv=require(_0xbdf9('0x8'));var ejs=require(_0xbdf9('0x9'));var fs=require('fs');var fs_extra=require(_0xbdf9('0xa'));var _=require(_0xbdf9('0xb'));var squel=require('squel');var crypto=require(_0xbdf9('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xbdf9('0x8'));var querystring=require(_0xbdf9('0xd'));var Papa=require(_0xbdf9('0xe'));var Redis=require(_0xbdf9('0xf'));var authService=require(_0xbdf9('0x10'));var qs=require(_0xbdf9('0x11'));var as=require(_0xbdf9('0x12'));var hardwareService=require(_0xbdf9('0x13'));var logger=require(_0xbdf9('0x14'))('api');var utils=require(_0xbdf9('0x15'));var config=require(_0xbdf9('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xbdf9('0x17'))['db'];function respondWithStatusCode(_0x2a47ce,_0x4477cb){_0x4477cb=_0x4477cb||0xcc;return function(_0x332acf){if(_0x332acf){return _0x2a47ce[_0xbdf9('0x18')](_0x4477cb);}return _0x2a47ce[_0xbdf9('0x19')](_0x4477cb)['end']();};}function respondWithResult(_0x5a2ae7,_0x3fbd97){_0x3fbd97=_0x3fbd97||0xc8;return function(_0x77c9b4){if(_0x77c9b4){return _0x5a2ae7['status'](_0x3fbd97)[_0xbdf9('0x1a')](_0x77c9b4);}};}function respondWithFilteredResult(_0x3071a1,_0x5f206e){return function(_0x5a5921){if(_0x5a5921){var _0x2b5690=typeof _0x5f206e[_0xbdf9('0x1b')]===_0xbdf9('0x1c')&&typeof _0x5f206e[_0xbdf9('0x1d')]===_0xbdf9('0x1c');var _0x39b9df=_0x5a5921['count'];var _0x485eb9=_0x2b5690?0x0:_0x5f206e[_0xbdf9('0x1b')];var _0x394d47=_0x2b5690?_0x5a5921['count']:_0x5f206e[_0xbdf9('0x1b')]+_0x5f206e[_0xbdf9('0x1d')];var _0x40ed03;if(_0x394d47>=_0x39b9df){_0x394d47=_0x39b9df;_0x40ed03=0xc8;}else{_0x40ed03=0xce;}_0x3071a1[_0xbdf9('0x19')](_0x40ed03);return _0x3071a1[_0xbdf9('0x1e')](_0xbdf9('0x1f'),_0x485eb9+'-'+_0x394d47+'/'+_0x39b9df)[_0xbdf9('0x1a')](_0x5a5921);}return null;};}function patchUpdates(_0x2dee46){return function(_0x233188){try{jsonpatch['apply'](_0x233188,_0x2dee46,!![]);}catch(_0x27d06f){return BPromise['reject'](_0x27d06f);}return _0x233188['save']();};}function saveUpdates(_0x405912,_0x3276ff){return function(_0x15dba3){if(_0x15dba3){return _0x15dba3['update'](_0x405912)[_0xbdf9('0x20')](function(_0x23e4d9){return _0x23e4d9;});}return null;};}function removeEntity(_0x173c31,_0x4adfc1){return function(_0x1d41e8){if(_0x1d41e8){return _0x1d41e8[_0xbdf9('0x21')]()['then'](function(){_0x173c31['status'](0xcc)[_0xbdf9('0x22')]();});}};}function handleEntityNotFound(_0x52c967,_0x10d69a){return function(_0x31bac8){if(!_0x31bac8){_0x52c967[_0xbdf9('0x18')](0x194);}return _0x31bac8;};}function handleError(_0x528b0a,_0x3b56dc){_0x3b56dc=_0x3b56dc||0x1f4;return function(_0x2f16ca){logger[_0xbdf9('0x23')](_0x2f16ca['stack']);if(_0x2f16ca[_0xbdf9('0x24')]){delete _0x2f16ca[_0xbdf9('0x24')];}_0x528b0a['status'](_0x3b56dc)[_0xbdf9('0x25')](_0x2f16ca);};}exports['index']=function(_0x2182dc,_0x1ca88b){var _0xdbe187={},_0x189e65={},_0x407866={'count':0x0,'rows':[]};var _0x3e2f6a=_['map'](db[_0xbdf9('0x26')][_0xbdf9('0x27')],function(_0x7a1193){return{'name':_0x7a1193[_0xbdf9('0x28')],'type':_0x7a1193[_0xbdf9('0x29')]['key']};});_0x189e65[_0xbdf9('0x2a')]=_[_0xbdf9('0x2b')](_0x3e2f6a,_0xbdf9('0x24'));_0x189e65['query']=_[_0xbdf9('0x2c')](_0x2182dc['query']);_0x189e65[_0xbdf9('0x2d')]=_[_0xbdf9('0x2e')](_0x189e65[_0xbdf9('0x2a')],_0x189e65[_0xbdf9('0x2f')]);_0xdbe187[_0xbdf9('0x30')]=_['intersection'](_0x189e65[_0xbdf9('0x2a')],qs[_0xbdf9('0x31')](_0x2182dc[_0xbdf9('0x2f')][_0xbdf9('0x31')]));_0xdbe187[_0xbdf9('0x30')]=_0xdbe187[_0xbdf9('0x30')][_0xbdf9('0x32')]?_0xdbe187['attributes']:_0x189e65[_0xbdf9('0x2a')];if(!_0x2182dc[_0xbdf9('0x2f')][_0xbdf9('0x33')](_0xbdf9('0x34'))){_0xdbe187[_0xbdf9('0x1d')]=qs['limit'](_0x2182dc['query'][_0xbdf9('0x1d')]);_0xdbe187[_0xbdf9('0x1b')]=qs[_0xbdf9('0x1b')](_0x2182dc[_0xbdf9('0x2f')][_0xbdf9('0x1b')]);}_0xdbe187[_0xbdf9('0x35')]=qs[_0xbdf9('0x36')](_0x2182dc[_0xbdf9('0x2f')][_0xbdf9('0x36')]);_0xdbe187[_0xbdf9('0x37')]=qs[_0xbdf9('0x2d')](_[_0xbdf9('0x38')](_0x2182dc[_0xbdf9('0x2f')],_0x189e65['filters']),_0x3e2f6a);if(_0x2182dc['query'][_0xbdf9('0x39')]){_0xdbe187[_0xbdf9('0x37')]=_[_0xbdf9('0x3a')](_0xdbe187[_0xbdf9('0x37')],{'$or':_[_0xbdf9('0x2b')](_0x3e2f6a,function(_0x340cd7){if(_0x340cd7[_0xbdf9('0x29')]!=='VIRTUAL'){var _0x303688={};_0x303688[_0x340cd7['name']]={'$like':'%'+_0x2182dc['query'][_0xbdf9('0x39')]+'%'};return _0x303688;}})});}_0xdbe187=_[_0xbdf9('0x3a')]({},_0xdbe187,_0x2182dc[_0xbdf9('0x3b')]);var _0x31b1d6={'where':_0xdbe187[_0xbdf9('0x37')]};return db[_0xbdf9('0x26')][_0xbdf9('0x3c')](_0x31b1d6)['then'](function(_0x4d51ca){_0x407866['count']=_0x4d51ca;if(_0x2182dc['query'][_0xbdf9('0x3d')]){_0xdbe187['include']=[{'all':!![]}];}return db[_0xbdf9('0x26')][_0xbdf9('0x3e')](_0xdbe187);})[_0xbdf9('0x20')](function(_0x5972b4){_0x407866[_0xbdf9('0x3f')]=_0x5972b4;return _0x407866;})[_0xbdf9('0x20')](respondWithFilteredResult(_0x1ca88b,_0xdbe187))[_0xbdf9('0x40')](handleError(_0x1ca88b,null));};exports[_0xbdf9('0x41')]=function(_0x506207,_0x28901d){var _0x3a10e1={'raw':![],'where':{'id':_0x506207[_0xbdf9('0x42')]['id']}},_0x3064d2={};_0x3064d2['model']=_['keys'](db[_0xbdf9('0x26')][_0xbdf9('0x27')]);_0x3064d2['query']=_[_0xbdf9('0x2c')](_0x506207[_0xbdf9('0x2f')]);_0x3064d2[_0xbdf9('0x2d')]=_['intersection'](_0x3064d2['model'],_0x3064d2[_0xbdf9('0x2f')]);_0x3a10e1['attributes']=_[_0xbdf9('0x2e')](_0x3064d2[_0xbdf9('0x2a')],qs[_0xbdf9('0x31')](_0x506207[_0xbdf9('0x2f')][_0xbdf9('0x31')]));_0x3a10e1[_0xbdf9('0x30')]=_0x3a10e1[_0xbdf9('0x30')][_0xbdf9('0x32')]?_0x3a10e1[_0xbdf9('0x30')]:_0x3064d2['model'];if(_0x506207['query'][_0xbdf9('0x3d')]){_0x3a10e1[_0xbdf9('0x43')]=[{'all':!![]}];}_0x3a10e1=_['merge']({},_0x3a10e1,_0x506207[_0xbdf9('0x3b')]);return db[_0xbdf9('0x26')]['find'](_0x3a10e1)[_0xbdf9('0x20')](handleEntityNotFound(_0x28901d,null))[_0xbdf9('0x20')](respondWithResult(_0x28901d,null))['catch'](handleError(_0x28901d,null));};exports[_0xbdf9('0x44')]=function(_0x47aff0,_0xc9b1c9){return db['ZohoConfiguration'][_0xbdf9('0x44')](_0x47aff0['body'],{})[_0xbdf9('0x20')](respondWithResult(_0xc9b1c9,0xc9))[_0xbdf9('0x40')](handleError(_0xc9b1c9,null));};exports[_0xbdf9('0x45')]=function(_0x3837d9,_0x4974b3){if(_0x3837d9[_0xbdf9('0x46')]['id']){delete _0x3837d9[_0xbdf9('0x46')]['id'];}return db[_0xbdf9('0x26')][_0xbdf9('0x47')]({'where':{'id':_0x3837d9[_0xbdf9('0x42')]['id']}})['then'](handleEntityNotFound(_0x4974b3,null))[_0xbdf9('0x20')](saveUpdates(_0x3837d9[_0xbdf9('0x46')],null))[_0xbdf9('0x20')](respondWithResult(_0x4974b3,null))['catch'](handleError(_0x4974b3,null));};exports[_0xbdf9('0x21')]=function(_0x6f4933,_0x5999f1){return db[_0xbdf9('0x26')][_0xbdf9('0x47')]({'where':{'id':_0x6f4933['params']['id']}})[_0xbdf9('0x20')](handleEntityNotFound(_0x5999f1,null))[_0xbdf9('0x20')](removeEntity(_0x5999f1,null))[_0xbdf9('0x40')](handleError(_0x5999f1,null));};exports[_0xbdf9('0x48')]=function(_0x176490,_0x38d5ea,_0xfebb31){var _0x2fabc5={};var _0x2b0614={};var _0x2b4e7d;var _0x35b63f;return db['ZohoConfiguration'][_0xbdf9('0x49')]({'where':{'id':_0x176490[_0xbdf9('0x42')]['id']}})['then'](handleEntityNotFound(_0x38d5ea,null))[_0xbdf9('0x20')](function(_0xa4d5ee){if(_0xa4d5ee){_0x2b4e7d=_0xa4d5ee;_0x2b0614[_0xbdf9('0x2a')]=_[_0xbdf9('0x2c')](db['ZohoField'][_0xbdf9('0x27')]);_0x2b0614['query']=_[_0xbdf9('0x2c')](_0x176490[_0xbdf9('0x2f')]);_0x2b0614[_0xbdf9('0x2d')]=_[_0xbdf9('0x2e')](_0x2b0614[_0xbdf9('0x2a')],_0x2b0614[_0xbdf9('0x2f')]);_0x2fabc5[_0xbdf9('0x30')]=_[_0xbdf9('0x2e')](_0x2b0614[_0xbdf9('0x2a')],qs[_0xbdf9('0x31')](_0x176490[_0xbdf9('0x2f')]['fields']));_0x2fabc5['attributes']=_0x2fabc5[_0xbdf9('0x30')][_0xbdf9('0x32')]?_0x2fabc5[_0xbdf9('0x30')]:_0x2b0614['model'];_0x2fabc5['order']=qs['sort'](_0x176490[_0xbdf9('0x2f')][_0xbdf9('0x36')]);_0x2fabc5[_0xbdf9('0x37')]=qs[_0xbdf9('0x2d')](_[_0xbdf9('0x38')](_0x176490[_0xbdf9('0x2f')],_0x2b0614['filters']));if(_0x176490[_0xbdf9('0x2f')]['filter']){_0x2fabc5[_0xbdf9('0x37')]=_['merge'](_0x2fabc5[_0xbdf9('0x37')],{'$or':_['map'](_0x2fabc5[_0xbdf9('0x30')],function(_0x294fc2){var _0x30d522={};_0x30d522[_0x294fc2]={'$like':'%'+_0x176490['query'][_0xbdf9('0x39')]+'%'};return _0x30d522;})});}_0x2fabc5=_['merge']({},_0x2fabc5,_0x176490[_0xbdf9('0x3b')]);return _0x2b4e7d[_0xbdf9('0x48')](_0x2fabc5);}})['then'](function(_0x32d467){if(_0x32d467){_0x35b63f=_0x32d467[_0xbdf9('0x32')];if(!_0x176490[_0xbdf9('0x2f')]['hasOwnProperty'](_0xbdf9('0x34'))){_0x2fabc5[_0xbdf9('0x1d')]=qs[_0xbdf9('0x1d')](_0x176490[_0xbdf9('0x2f')][_0xbdf9('0x1d')]);_0x2fabc5[_0xbdf9('0x1b')]=qs['offset'](_0x176490[_0xbdf9('0x2f')][_0xbdf9('0x1b')]);}return _0x2b4e7d[_0xbdf9('0x48')](_0x2fabc5);}})[_0xbdf9('0x20')](function(_0xf6577e){if(_0xf6577e){return _0xf6577e?{'count':_0x35b63f,'rows':_0xf6577e}:null;}})[_0xbdf9('0x20')](respondWithResult(_0x38d5ea,null))[_0xbdf9('0x40')](handleError(_0x38d5ea,null));};exports[_0xbdf9('0x4a')]=function(_0x3b44fd,_0x2088c3,_0x501468){var _0x43bd09={};var _0x52c55d={};var _0x5397bb;var _0x3cf90c;return db[_0xbdf9('0x26')][_0xbdf9('0x49')]({'where':{'id':_0x3b44fd['params']['id']}})[_0xbdf9('0x20')](handleEntityNotFound(_0x2088c3,null))[_0xbdf9('0x20')](function(_0x1ff356){if(_0x1ff356){_0x5397bb=_0x1ff356;_0x52c55d[_0xbdf9('0x2a')]=_['keys'](db[_0xbdf9('0x4b')]['rawAttributes']);_0x52c55d['query']=_[_0xbdf9('0x2c')](_0x3b44fd[_0xbdf9('0x2f')]);_0x52c55d['filters']=_['intersection'](_0x52c55d['model'],_0x52c55d['query']);_0x43bd09[_0xbdf9('0x30')]=_[_0xbdf9('0x2e')](_0x52c55d[_0xbdf9('0x2a')],qs['fields'](_0x3b44fd['query'][_0xbdf9('0x31')]));_0x43bd09[_0xbdf9('0x30')]=_0x43bd09[_0xbdf9('0x30')][_0xbdf9('0x32')]?_0x43bd09[_0xbdf9('0x30')]:_0x52c55d[_0xbdf9('0x2a')];_0x43bd09[_0xbdf9('0x35')]=qs[_0xbdf9('0x36')](_0x3b44fd[_0xbdf9('0x2f')]['sort']);_0x43bd09[_0xbdf9('0x37')]=qs['filters'](_['pick'](_0x3b44fd[_0xbdf9('0x2f')],_0x52c55d['filters']));if(_0x3b44fd['query'][_0xbdf9('0x39')]){_0x43bd09[_0xbdf9('0x37')]=_[_0xbdf9('0x3a')](_0x43bd09[_0xbdf9('0x37')],{'$or':_[_0xbdf9('0x2b')](_0x43bd09[_0xbdf9('0x30')],function(_0x4f96bb){var _0xe74ffc={};_0xe74ffc[_0x4f96bb]={'$like':'%'+_0x3b44fd[_0xbdf9('0x2f')][_0xbdf9('0x39')]+'%'};return _0xe74ffc;})});}_0x43bd09=_[_0xbdf9('0x3a')]({},_0x43bd09,_0x3b44fd[_0xbdf9('0x3b')]);return _0x5397bb[_0xbdf9('0x4a')](_0x43bd09);}})[_0xbdf9('0x20')](function(_0xea3ba7){if(_0xea3ba7){_0x3cf90c=_0xea3ba7[_0xbdf9('0x32')];if(!_0x3b44fd[_0xbdf9('0x2f')]['hasOwnProperty'](_0xbdf9('0x34'))){_0x43bd09['limit']=qs[_0xbdf9('0x1d')](_0x3b44fd[_0xbdf9('0x2f')][_0xbdf9('0x1d')]);_0x43bd09[_0xbdf9('0x1b')]=qs['offset'](_0x3b44fd['query']['offset']);}return _0x5397bb[_0xbdf9('0x4a')](_0x43bd09);}})[_0xbdf9('0x20')](function(_0x1779d1){if(_0x1779d1){return _0x1779d1?{'count':_0x3cf90c,'rows':_0x1779d1}:null;}})[_0xbdf9('0x20')](respondWithResult(_0x2088c3,null))[_0xbdf9('0x40')](handleError(_0x2088c3,null));};exports[_0xbdf9('0x4c')]=function(_0x1bfaf5,_0x4ee5bc,_0x9691d7){var _0x4b234c={};var _0x13239b={};var _0x1fa821;var _0xe5ef9d;return db[_0xbdf9('0x26')][_0xbdf9('0x49')]({'where':{'id':_0x1bfaf5[_0xbdf9('0x42')]['id']}})[_0xbdf9('0x20')](handleEntityNotFound(_0x4ee5bc,null))[_0xbdf9('0x20')](function(_0x57d05b){if(_0x57d05b){_0x1fa821=_0x57d05b;_0x13239b[_0xbdf9('0x2a')]=_[_0xbdf9('0x2c')](db[_0xbdf9('0x4b')][_0xbdf9('0x27')]);_0x13239b['query']=_['keys'](_0x1bfaf5[_0xbdf9('0x2f')]);_0x13239b[_0xbdf9('0x2d')]=_['intersection'](_0x13239b[_0xbdf9('0x2a')],_0x13239b[_0xbdf9('0x2f')]);_0x4b234c[_0xbdf9('0x30')]=_[_0xbdf9('0x2e')](_0x13239b[_0xbdf9('0x2a')],qs[_0xbdf9('0x31')](_0x1bfaf5['query']['fields']));_0x4b234c[_0xbdf9('0x30')]=_0x4b234c['attributes'][_0xbdf9('0x32')]?_0x4b234c[_0xbdf9('0x30')]:_0x13239b['model'];_0x4b234c[_0xbdf9('0x35')]=qs[_0xbdf9('0x36')](_0x1bfaf5[_0xbdf9('0x2f')][_0xbdf9('0x36')]);_0x4b234c[_0xbdf9('0x37')]=qs[_0xbdf9('0x2d')](_[_0xbdf9('0x38')](_0x1bfaf5[_0xbdf9('0x2f')],_0x13239b[_0xbdf9('0x2d')]));if(_0x1bfaf5[_0xbdf9('0x2f')]['filter']){_0x4b234c[_0xbdf9('0x37')]=_[_0xbdf9('0x3a')](_0x4b234c[_0xbdf9('0x37')],{'$or':_['map'](_0x4b234c[_0xbdf9('0x30')],function(_0x4eda60){var _0x2b41bc={};_0x2b41bc[_0x4eda60]={'$like':'%'+_0x1bfaf5[_0xbdf9('0x2f')]['filter']+'%'};return _0x2b41bc;})});}_0x4b234c=_['merge']({},_0x4b234c,_0x1bfaf5['options']);return _0x1fa821[_0xbdf9('0x4c')](_0x4b234c);}})[_0xbdf9('0x20')](function(_0x15f38e){if(_0x15f38e){_0xe5ef9d=_0x15f38e[_0xbdf9('0x32')];if(!_0x1bfaf5['query'][_0xbdf9('0x33')](_0xbdf9('0x34'))){_0x4b234c[_0xbdf9('0x1d')]=qs[_0xbdf9('0x1d')](_0x1bfaf5[_0xbdf9('0x2f')][_0xbdf9('0x1d')]);_0x4b234c['offset']=qs[_0xbdf9('0x1b')](_0x1bfaf5[_0xbdf9('0x2f')][_0xbdf9('0x1b')]);}return _0x1fa821[_0xbdf9('0x4c')](_0x4b234c);}})['then'](function(_0x2c0b7a){if(_0x2c0b7a){return _0x2c0b7a?{'count':_0xe5ef9d,'rows':_0x2c0b7a}:null;}})[_0xbdf9('0x20')](respondWithResult(_0x4ee5bc,null))[_0xbdf9('0x40')](handleError(_0x4ee5bc,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