Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 5742739..7f837d1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfbf3=['findAll','rows','catch','show','params','keys','options','find','create','body','destroy','getFields','findOne','length','sort','pick','hasOwnProperty','nolimit','getSubjects','getDescriptions','ZohoField','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','stack','name','index','map','ZohoConfiguration','rawAttributes','fieldName','key','query','filters','intersection','model','fields','attributes','order','where','filter','merge','VIRTUAL','includeAll'];(function(_0x158d17,_0x46bc33){var _0x5a0ffd=function(_0x454345){while(--_0x454345){_0x158d17['push'](_0x158d17['shift']());}};_0x5a0ffd(++_0x46bc33);}(_0xfbf3,0x1ef));var _0x3fbf=function(_0x18d833,_0x554ddc){_0x18d833=_0x18d833-0x0;var _0xed0c80=_0xfbf3[_0x18d833];return _0xed0c80;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3fbf('0x0'));var zipdir=require(_0x3fbf('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x3fbf('0x2'));var moment=require('moment');var BPromise=require(_0x3fbf('0x3'));var Mustache=require(_0x3fbf('0x4'));var util=require(_0x3fbf('0x5'));var path=require(_0x3fbf('0x6'));var sox=require(_0x3fbf('0x7'));var csv=require(_0x3fbf('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3fbf('0x9'));var squel=require(_0x3fbf('0xa'));var crypto=require(_0x3fbf('0xb'));var jsforce=require(_0x3fbf('0xc'));var deskjs=require(_0x3fbf('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3fbf('0xe'));var Redis=require('ioredis');var authService=require(_0x3fbf('0xf'));var qs=require(_0x3fbf('0x10'));var as=require(_0x3fbf('0x11'));var hardwareService=require(_0x3fbf('0x12'));var logger=require(_0x3fbf('0x13'))(_0x3fbf('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x3fbf('0x15'));var db=require(_0x3fbf('0x16'))['db'];function respondWithStatusCode(_0x373e3a,_0x1fefa1){_0x1fefa1=_0x1fefa1||0xcc;return function(_0x5cdfdd){if(_0x5cdfdd){return _0x373e3a[_0x3fbf('0x17')](_0x1fefa1);}return _0x373e3a[_0x3fbf('0x18')](_0x1fefa1)[_0x3fbf('0x19')]();};}function respondWithResult(_0x5791b7,_0x57fe8a){_0x57fe8a=_0x57fe8a||0xc8;return function(_0xf8d092){if(_0xf8d092){return _0x5791b7[_0x3fbf('0x18')](_0x57fe8a)[_0x3fbf('0x1a')](_0xf8d092);}};}function respondWithFilteredResult(_0x1c7675,_0x1f1501){return function(_0x4a59ab){if(_0x4a59ab){var _0x3a577c=typeof _0x1f1501[_0x3fbf('0x1b')]===_0x3fbf('0x1c')&&typeof _0x1f1501[_0x3fbf('0x1d')]===_0x3fbf('0x1c');var _0x34cfdb=_0x4a59ab['count'];var _0x5d06f4=_0x3a577c?0x0:_0x1f1501[_0x3fbf('0x1b')];var _0x15b627=_0x3a577c?_0x4a59ab[_0x3fbf('0x1e')]:_0x1f1501['offset']+_0x1f1501[_0x3fbf('0x1d')];var _0x5f3221;if(_0x15b627>=_0x34cfdb){_0x15b627=_0x34cfdb;_0x5f3221=0xc8;}else{_0x5f3221=0xce;}_0x1c7675[_0x3fbf('0x18')](_0x5f3221);return _0x1c7675[_0x3fbf('0x1f')](_0x3fbf('0x20'),_0x5d06f4+'-'+_0x15b627+'/'+_0x34cfdb)[_0x3fbf('0x1a')](_0x4a59ab);}return null;};}function patchUpdates(_0x354b0d){return function(_0x26c0b1){try{jsonpatch[_0x3fbf('0x21')](_0x26c0b1,_0x354b0d,!![]);}catch(_0x4dc720){return BPromise[_0x3fbf('0x22')](_0x4dc720);}return _0x26c0b1[_0x3fbf('0x23')]();};}function saveUpdates(_0x58ca83,_0x622c97){return function(_0x2b4f03){if(_0x2b4f03){return _0x2b4f03[_0x3fbf('0x24')](_0x58ca83)[_0x3fbf('0x25')](function(_0x4369a0){return _0x4369a0;});}return null;};}function removeEntity(_0x1c4ee7,_0x28bec1){return function(_0x347148){if(_0x347148){return _0x347148['destroy']()[_0x3fbf('0x25')](function(){_0x1c4ee7['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x31ff72,_0x4f9fcc){return function(_0x33f89a){if(!_0x33f89a){_0x31ff72[_0x3fbf('0x17')](0x194);}return _0x33f89a;};}function handleError(_0x5d83d3,_0x30b3d2){_0x30b3d2=_0x30b3d2||0x1f4;return function(_0x1a00b1){logger['error'](_0x1a00b1[_0x3fbf('0x26')]);if(_0x1a00b1[_0x3fbf('0x27')]){delete _0x1a00b1['name'];}_0x5d83d3['status'](_0x30b3d2)['send'](_0x1a00b1);};}exports[_0x3fbf('0x28')]=function(_0x184b0c,_0x483089){var _0x2cb1b3={},_0xb36ca={},_0x25423b={'count':0x0,'rows':[]};var _0x2cae8=_[_0x3fbf('0x29')](db[_0x3fbf('0x2a')][_0x3fbf('0x2b')],function(_0x562d56){return{'name':_0x562d56[_0x3fbf('0x2c')],'type':_0x562d56['type'][_0x3fbf('0x2d')]};});_0xb36ca['model']=_['map'](_0x2cae8,_0x3fbf('0x27'));_0xb36ca[_0x3fbf('0x2e')]=_['keys'](_0x184b0c[_0x3fbf('0x2e')]);_0xb36ca[_0x3fbf('0x2f')]=_[_0x3fbf('0x30')](_0xb36ca[_0x3fbf('0x31')],_0xb36ca[_0x3fbf('0x2e')]);_0x2cb1b3['attributes']=_[_0x3fbf('0x30')](_0xb36ca['model'],qs['fields'](_0x184b0c[_0x3fbf('0x2e')][_0x3fbf('0x32')]));_0x2cb1b3[_0x3fbf('0x33')]=_0x2cb1b3[_0x3fbf('0x33')]['length']?_0x2cb1b3[_0x3fbf('0x33')]:_0xb36ca[_0x3fbf('0x31')];if(!_0x184b0c[_0x3fbf('0x2e')]['hasOwnProperty']('nolimit')){_0x2cb1b3[_0x3fbf('0x1d')]=qs[_0x3fbf('0x1d')](_0x184b0c['query'][_0x3fbf('0x1d')]);_0x2cb1b3['offset']=qs[_0x3fbf('0x1b')](_0x184b0c[_0x3fbf('0x2e')][_0x3fbf('0x1b')]);}_0x2cb1b3[_0x3fbf('0x34')]=qs['sort'](_0x184b0c[_0x3fbf('0x2e')]['sort']);_0x2cb1b3[_0x3fbf('0x35')]=qs[_0x3fbf('0x2f')](_['pick'](_0x184b0c['query'],_0xb36ca[_0x3fbf('0x2f')]),_0x2cae8);if(_0x184b0c[_0x3fbf('0x2e')][_0x3fbf('0x36')]){_0x2cb1b3['where']=_[_0x3fbf('0x37')](_0x2cb1b3[_0x3fbf('0x35')],{'$or':_[_0x3fbf('0x29')](_0x2cae8,function(_0x2f39e6){if(_0x2f39e6['type']!==_0x3fbf('0x38')){var _0x5cd28f={};_0x5cd28f[_0x2f39e6[_0x3fbf('0x27')]]={'$like':'%'+_0x184b0c['query'][_0x3fbf('0x36')]+'%'};return _0x5cd28f;}})});}_0x2cb1b3=_['merge']({},_0x2cb1b3,_0x184b0c['options']);var _0x52c80e={'where':_0x2cb1b3[_0x3fbf('0x35')]};return db[_0x3fbf('0x2a')][_0x3fbf('0x1e')](_0x52c80e)['then'](function(_0x46f5b4){_0x25423b[_0x3fbf('0x1e')]=_0x46f5b4;if(_0x184b0c[_0x3fbf('0x2e')][_0x3fbf('0x39')]){_0x2cb1b3['include']=[{'all':!![]}];}return db[_0x3fbf('0x2a')][_0x3fbf('0x3a')](_0x2cb1b3);})[_0x3fbf('0x25')](function(_0xaf6eb){_0x25423b[_0x3fbf('0x3b')]=_0xaf6eb;return _0x25423b;})[_0x3fbf('0x25')](respondWithFilteredResult(_0x483089,_0x2cb1b3))[_0x3fbf('0x3c')](handleError(_0x483089,null));};exports[_0x3fbf('0x3d')]=function(_0x21dc1f,_0x1408e7){var _0xd755f9={'raw':![],'where':{'id':_0x21dc1f[_0x3fbf('0x3e')]['id']}},_0x1dbe67={};_0x1dbe67[_0x3fbf('0x31')]=_[_0x3fbf('0x3f')](db[_0x3fbf('0x2a')][_0x3fbf('0x2b')]);_0x1dbe67['query']=_[_0x3fbf('0x3f')](_0x21dc1f[_0x3fbf('0x2e')]);_0x1dbe67[_0x3fbf('0x2f')]=_[_0x3fbf('0x30')](_0x1dbe67['model'],_0x1dbe67[_0x3fbf('0x2e')]);_0xd755f9['attributes']=_['intersection'](_0x1dbe67[_0x3fbf('0x31')],qs[_0x3fbf('0x32')](_0x21dc1f[_0x3fbf('0x2e')]['fields']));_0xd755f9[_0x3fbf('0x33')]=_0xd755f9[_0x3fbf('0x33')]['length']?_0xd755f9[_0x3fbf('0x33')]:_0x1dbe67[_0x3fbf('0x31')];if(_0x21dc1f[_0x3fbf('0x2e')][_0x3fbf('0x39')]){_0xd755f9['include']=[{'all':!![]}];}_0xd755f9=_[_0x3fbf('0x37')]({},_0xd755f9,_0x21dc1f[_0x3fbf('0x40')]);return db[_0x3fbf('0x2a')][_0x3fbf('0x41')](_0xd755f9)['then'](handleEntityNotFound(_0x1408e7,null))[_0x3fbf('0x25')](respondWithResult(_0x1408e7,null))[_0x3fbf('0x3c')](handleError(_0x1408e7,null));};exports['create']=function(_0x385866,_0x18644b){return db[_0x3fbf('0x2a')][_0x3fbf('0x42')](_0x385866[_0x3fbf('0x43')],{})[_0x3fbf('0x25')](respondWithResult(_0x18644b,0xc9))[_0x3fbf('0x3c')](handleError(_0x18644b,null));};exports[_0x3fbf('0x24')]=function(_0x1bc56c,_0x2a22a5){if(_0x1bc56c[_0x3fbf('0x43')]['id']){delete _0x1bc56c[_0x3fbf('0x43')]['id'];}return db[_0x3fbf('0x2a')]['find']({'where':{'id':_0x1bc56c[_0x3fbf('0x3e')]['id']}})[_0x3fbf('0x25')](handleEntityNotFound(_0x2a22a5,null))[_0x3fbf('0x25')](saveUpdates(_0x1bc56c[_0x3fbf('0x43')],null))[_0x3fbf('0x25')](respondWithResult(_0x2a22a5,null))[_0x3fbf('0x3c')](handleError(_0x2a22a5,null));};exports[_0x3fbf('0x44')]=function(_0x3dafe0,_0x5a4299){return db['ZohoConfiguration'][_0x3fbf('0x41')]({'where':{'id':_0x3dafe0[_0x3fbf('0x3e')]['id']}})[_0x3fbf('0x25')](handleEntityNotFound(_0x5a4299,null))[_0x3fbf('0x25')](removeEntity(_0x5a4299,null))[_0x3fbf('0x3c')](handleError(_0x5a4299,null));};exports[_0x3fbf('0x45')]=function(_0x194247,_0x1451c5,_0x3ad986){var _0x1f5df2={};var _0x3761e3={};var _0x4c6502;var _0x99f7b2;return db['ZohoConfiguration'][_0x3fbf('0x46')]({'where':{'id':_0x194247[_0x3fbf('0x3e')]['id']}})['then'](handleEntityNotFound(_0x1451c5,null))[_0x3fbf('0x25')](function(_0x1afbed){if(_0x1afbed){_0x4c6502=_0x1afbed;_0x3761e3[_0x3fbf('0x31')]=_['keys'](db['ZohoField']['rawAttributes']);_0x3761e3[_0x3fbf('0x2e')]=_['keys'](_0x194247[_0x3fbf('0x2e')]);_0x3761e3[_0x3fbf('0x2f')]=_[_0x3fbf('0x30')](_0x3761e3[_0x3fbf('0x31')],_0x3761e3[_0x3fbf('0x2e')]);_0x1f5df2[_0x3fbf('0x33')]=_[_0x3fbf('0x30')](_0x3761e3[_0x3fbf('0x31')],qs['fields'](_0x194247['query'][_0x3fbf('0x32')]));_0x1f5df2[_0x3fbf('0x33')]=_0x1f5df2[_0x3fbf('0x33')][_0x3fbf('0x47')]?_0x1f5df2[_0x3fbf('0x33')]:_0x3761e3['model'];_0x1f5df2[_0x3fbf('0x34')]=qs[_0x3fbf('0x48')](_0x194247[_0x3fbf('0x2e')][_0x3fbf('0x48')]);_0x1f5df2[_0x3fbf('0x35')]=qs[_0x3fbf('0x2f')](_[_0x3fbf('0x49')](_0x194247[_0x3fbf('0x2e')],_0x3761e3[_0x3fbf('0x2f')]));if(_0x194247[_0x3fbf('0x2e')]['filter']){_0x1f5df2[_0x3fbf('0x35')]=_[_0x3fbf('0x37')](_0x1f5df2['where'],{'$or':_[_0x3fbf('0x29')](_0x1f5df2[_0x3fbf('0x33')],function(_0x1d7a13){var _0x56399d={};_0x56399d[_0x1d7a13]={'$like':'%'+_0x194247['query'][_0x3fbf('0x36')]+'%'};return _0x56399d;})});}_0x1f5df2=_[_0x3fbf('0x37')]({},_0x1f5df2,_0x194247['options']);return _0x4c6502['getFields'](_0x1f5df2);}})[_0x3fbf('0x25')](function(_0x503b33){if(_0x503b33){_0x99f7b2=_0x503b33['length'];if(!_0x194247[_0x3fbf('0x2e')][_0x3fbf('0x4a')](_0x3fbf('0x4b'))){_0x1f5df2[_0x3fbf('0x1d')]=qs[_0x3fbf('0x1d')](_0x194247['query'][_0x3fbf('0x1d')]);_0x1f5df2[_0x3fbf('0x1b')]=qs[_0x3fbf('0x1b')](_0x194247[_0x3fbf('0x2e')][_0x3fbf('0x1b')]);}return _0x4c6502[_0x3fbf('0x45')](_0x1f5df2);}})[_0x3fbf('0x25')](function(_0x603e3a){if(_0x603e3a){return _0x603e3a?{'count':_0x99f7b2,'rows':_0x603e3a}:null;}})[_0x3fbf('0x25')](respondWithResult(_0x1451c5,null))[_0x3fbf('0x3c')](handleError(_0x1451c5,null));};exports[_0x3fbf('0x4c')]=function(_0x2d86e2,_0x1e8e11,_0x2e8e32){var _0x19a876={};var _0x49c3c4={};var _0x3d6528;var _0x2dfcce;return db[_0x3fbf('0x2a')][_0x3fbf('0x46')]({'where':{'id':_0x2d86e2['params']['id']}})[_0x3fbf('0x25')](handleEntityNotFound(_0x1e8e11,null))['then'](function(_0x9b5e4){if(_0x9b5e4){_0x3d6528=_0x9b5e4;_0x49c3c4[_0x3fbf('0x31')]=_[_0x3fbf('0x3f')](db['ZohoField']['rawAttributes']);_0x49c3c4[_0x3fbf('0x2e')]=_['keys'](_0x2d86e2[_0x3fbf('0x2e')]);_0x49c3c4['filters']=_['intersection'](_0x49c3c4['model'],_0x49c3c4[_0x3fbf('0x2e')]);_0x19a876[_0x3fbf('0x33')]=_[_0x3fbf('0x30')](_0x49c3c4['model'],qs['fields'](_0x2d86e2['query']['fields']));_0x19a876['attributes']=_0x19a876[_0x3fbf('0x33')][_0x3fbf('0x47')]?_0x19a876[_0x3fbf('0x33')]:_0x49c3c4[_0x3fbf('0x31')];_0x19a876[_0x3fbf('0x34')]=qs[_0x3fbf('0x48')](_0x2d86e2[_0x3fbf('0x2e')][_0x3fbf('0x48')]);_0x19a876[_0x3fbf('0x35')]=qs['filters'](_[_0x3fbf('0x49')](_0x2d86e2[_0x3fbf('0x2e')],_0x49c3c4[_0x3fbf('0x2f')]));if(_0x2d86e2[_0x3fbf('0x2e')][_0x3fbf('0x36')]){_0x19a876[_0x3fbf('0x35')]=_[_0x3fbf('0x37')](_0x19a876[_0x3fbf('0x35')],{'$or':_[_0x3fbf('0x29')](_0x19a876[_0x3fbf('0x33')],function(_0x20a26d){var _0x4ca7aa={};_0x4ca7aa[_0x20a26d]={'$like':'%'+_0x2d86e2[_0x3fbf('0x2e')][_0x3fbf('0x36')]+'%'};return _0x4ca7aa;})});}_0x19a876=_[_0x3fbf('0x37')]({},_0x19a876,_0x2d86e2[_0x3fbf('0x40')]);return _0x3d6528['getSubjects'](_0x19a876);}})[_0x3fbf('0x25')](function(_0x2bc4ac){if(_0x2bc4ac){_0x2dfcce=_0x2bc4ac[_0x3fbf('0x47')];if(!_0x2d86e2[_0x3fbf('0x2e')][_0x3fbf('0x4a')](_0x3fbf('0x4b'))){_0x19a876[_0x3fbf('0x1d')]=qs[_0x3fbf('0x1d')](_0x2d86e2[_0x3fbf('0x2e')]['limit']);_0x19a876[_0x3fbf('0x1b')]=qs[_0x3fbf('0x1b')](_0x2d86e2[_0x3fbf('0x2e')][_0x3fbf('0x1b')]);}return _0x3d6528[_0x3fbf('0x4c')](_0x19a876);}})[_0x3fbf('0x25')](function(_0x539809){if(_0x539809){return _0x539809?{'count':_0x2dfcce,'rows':_0x539809}:null;}})[_0x3fbf('0x25')](respondWithResult(_0x1e8e11,null))[_0x3fbf('0x3c')](handleError(_0x1e8e11,null));};exports[_0x3fbf('0x4d')]=function(_0x2b4954,_0x350e8e,_0x25cebe){var _0xb830c9={};var _0xeaf6ea={};var _0x29c93a;var _0x1076f5;return db[_0x3fbf('0x2a')][_0x3fbf('0x46')]({'where':{'id':_0x2b4954['params']['id']}})['then'](handleEntityNotFound(_0x350e8e,null))[_0x3fbf('0x25')](function(_0x3908bb){if(_0x3908bb){_0x29c93a=_0x3908bb;_0xeaf6ea['model']=_['keys'](db[_0x3fbf('0x4e')][_0x3fbf('0x2b')]);_0xeaf6ea[_0x3fbf('0x2e')]=_[_0x3fbf('0x3f')](_0x2b4954[_0x3fbf('0x2e')]);_0xeaf6ea[_0x3fbf('0x2f')]=_[_0x3fbf('0x30')](_0xeaf6ea[_0x3fbf('0x31')],_0xeaf6ea[_0x3fbf('0x2e')]);_0xb830c9['attributes']=_[_0x3fbf('0x30')](_0xeaf6ea[_0x3fbf('0x31')],qs['fields'](_0x2b4954[_0x3fbf('0x2e')][_0x3fbf('0x32')]));_0xb830c9[_0x3fbf('0x33')]=_0xb830c9[_0x3fbf('0x33')][_0x3fbf('0x47')]?_0xb830c9[_0x3fbf('0x33')]:_0xeaf6ea[_0x3fbf('0x31')];_0xb830c9[_0x3fbf('0x34')]=qs[_0x3fbf('0x48')](_0x2b4954[_0x3fbf('0x2e')]['sort']);_0xb830c9[_0x3fbf('0x35')]=qs['filters'](_['pick'](_0x2b4954['query'],_0xeaf6ea[_0x3fbf('0x2f')]));if(_0x2b4954[_0x3fbf('0x2e')][_0x3fbf('0x36')]){_0xb830c9['where']=_[_0x3fbf('0x37')](_0xb830c9[_0x3fbf('0x35')],{'$or':_[_0x3fbf('0x29')](_0xb830c9[_0x3fbf('0x33')],function(_0xe4c571){var _0x52234e={};_0x52234e[_0xe4c571]={'$like':'%'+_0x2b4954[_0x3fbf('0x2e')]['filter']+'%'};return _0x52234e;})});}_0xb830c9=_[_0x3fbf('0x37')]({},_0xb830c9,_0x2b4954['options']);return _0x29c93a[_0x3fbf('0x4d')](_0xb830c9);}})['then'](function(_0x4435c2){if(_0x4435c2){_0x1076f5=_0x4435c2[_0x3fbf('0x47')];if(!_0x2b4954[_0x3fbf('0x2e')][_0x3fbf('0x4a')]('nolimit')){_0xb830c9['limit']=qs[_0x3fbf('0x1d')](_0x2b4954['query'][_0x3fbf('0x1d')]);_0xb830c9['offset']=qs[_0x3fbf('0x1b')](_0x2b4954[_0x3fbf('0x2e')]['offset']);}return _0x29c93a[_0x3fbf('0x4d')](_0xb830c9);}})['then'](function(_0x528806){if(_0x528806){return _0x528806?{'count':_0x1076f5,'rows':_0x528806}:null;}})[_0x3fbf('0x25')](respondWithResult(_0x350e8e,null))['catch'](handleError(_0x350e8e,null));};
\ No newline at end of file
+var _0xf9d3=['jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','name','send','index','ZohoConfiguration','rawAttributes','fieldName','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','filters','filter','where','type','VIRTUAL','merge','options','includeAll','include','rows','catch','params','find','create','body','destroy','getFields','findOne','pick','nolimit','getSubjects','ZohoField','eml-format','rimraf','fast-json-patch','request-promise','mustache','path','to-csv','ejs','lodash','squel','crypto'];(function(_0x3bee2a,_0x534863){var _0x2dbdfb=function(_0x2d0d11){while(--_0x2d0d11){_0x3bee2a['push'](_0x3bee2a['shift']());}};_0x2dbdfb(++_0x534863);}(_0xf9d3,0x129));var _0x3f9d=function(_0x3149d2,_0x4a08f9){_0x3149d2=_0x3149d2-0x0;var _0x54e6a9=_0xf9d3[_0x3149d2];return _0x54e6a9;};'use strict';var emlformat=require(_0x3f9d('0x0'));var rimraf=require(_0x3f9d('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3f9d('0x2'));var rp=require(_0x3f9d('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x3f9d('0x4'));var util=require('util');var path=require(_0x3f9d('0x5'));var sox=require('sox');var csv=require(_0x3f9d('0x6'));var ejs=require(_0x3f9d('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3f9d('0x8'));var squel=require(_0x3f9d('0x9'));var crypto=require(_0x3f9d('0xa'));var jsforce=require(_0x3f9d('0xb'));var deskjs=require(_0x3f9d('0xc'));var toCsv=require('to-csv');var querystring=require(_0x3f9d('0xd'));var Papa=require(_0x3f9d('0xe'));var Redis=require('ioredis');var authService=require(_0x3f9d('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x3f9d('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x3f9d('0x11'))(_0x3f9d('0x12'));var utils=require(_0x3f9d('0x13'));var config=require(_0x3f9d('0x14'));var licenseUtil=require(_0x3f9d('0x15'));var db=require(_0x3f9d('0x16'))['db'];function respondWithStatusCode(_0x193eba,_0x2e0c72){_0x2e0c72=_0x2e0c72||0xcc;return function(_0x5d362a){if(_0x5d362a){return _0x193eba[_0x3f9d('0x17')](_0x2e0c72);}return _0x193eba['status'](_0x2e0c72)[_0x3f9d('0x18')]();};}function respondWithResult(_0xf680bf,_0x5e961e){_0x5e961e=_0x5e961e||0xc8;return function(_0x562f51){if(_0x562f51){return _0xf680bf[_0x3f9d('0x19')](_0x5e961e)[_0x3f9d('0x1a')](_0x562f51);}};}function respondWithFilteredResult(_0x190d1a,_0x59f5ae){return function(_0x1078d4){if(_0x1078d4){var _0x3a525c=typeof _0x59f5ae['offset']==='undefined'&&typeof _0x59f5ae['limit']==='undefined';var _0x4e425e=_0x1078d4[_0x3f9d('0x1b')];var _0x4eb940=_0x3a525c?0x0:_0x59f5ae[_0x3f9d('0x1c')];var _0x379c56=_0x3a525c?_0x1078d4[_0x3f9d('0x1b')]:_0x59f5ae['offset']+_0x59f5ae[_0x3f9d('0x1d')];var _0x4878e1;if(_0x379c56>=_0x4e425e){_0x379c56=_0x4e425e;_0x4878e1=0xc8;}else{_0x4878e1=0xce;}_0x190d1a['status'](_0x4878e1);return _0x190d1a[_0x3f9d('0x1e')](_0x3f9d('0x1f'),_0x4eb940+'-'+_0x379c56+'/'+_0x4e425e)[_0x3f9d('0x1a')](_0x1078d4);}return null;};}function patchUpdates(_0x57ac41){return function(_0x4f18b1){try{jsonpatch[_0x3f9d('0x20')](_0x4f18b1,_0x57ac41,!![]);}catch(_0x524c95){return BPromise[_0x3f9d('0x21')](_0x524c95);}return _0x4f18b1[_0x3f9d('0x22')]();};}function saveUpdates(_0xf3c9d9,_0x46deb2){return function(_0x2aef0c){if(_0x2aef0c){return _0x2aef0c[_0x3f9d('0x23')](_0xf3c9d9)[_0x3f9d('0x24')](function(_0x261602){return _0x261602;});}return null;};}function removeEntity(_0x3b9b5e,_0x47e89b){return function(_0x50bc8e){if(_0x50bc8e){return _0x50bc8e['destroy']()[_0x3f9d('0x24')](function(){_0x3b9b5e[_0x3f9d('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x575149,_0x312e62){return function(_0x33b249){if(!_0x33b249){_0x575149[_0x3f9d('0x17')](0x194);}return _0x33b249;};}function handleError(_0x2380de,_0x52063b){_0x52063b=_0x52063b||0x1f4;return function(_0x58a785){logger['error'](_0x58a785['stack']);if(_0x58a785[_0x3f9d('0x25')]){delete _0x58a785[_0x3f9d('0x25')];}_0x2380de[_0x3f9d('0x19')](_0x52063b)[_0x3f9d('0x26')](_0x58a785);};}exports[_0x3f9d('0x27')]=function(_0x1bf6ac,_0x30bf74){var _0x231dc7={},_0xdc8d5b={},_0x36f7c9={'count':0x0,'rows':[]};var _0x5244cf=_['map'](db[_0x3f9d('0x28')][_0x3f9d('0x29')],function(_0x2954e1){return{'name':_0x2954e1[_0x3f9d('0x2a')],'type':_0x2954e1['type'][_0x3f9d('0x2b')]};});_0xdc8d5b[_0x3f9d('0x2c')]=_[_0x3f9d('0x2d')](_0x5244cf,'name');_0xdc8d5b[_0x3f9d('0x2e')]=_[_0x3f9d('0x2f')](_0x1bf6ac['query']);_0xdc8d5b['filters']=_[_0x3f9d('0x30')](_0xdc8d5b[_0x3f9d('0x2c')],_0xdc8d5b[_0x3f9d('0x2e')]);_0x231dc7[_0x3f9d('0x31')]=_['intersection'](_0xdc8d5b[_0x3f9d('0x2c')],qs[_0x3f9d('0x32')](_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x32')]));_0x231dc7['attributes']=_0x231dc7[_0x3f9d('0x31')][_0x3f9d('0x33')]?_0x231dc7[_0x3f9d('0x31')]:_0xdc8d5b['model'];if(!_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x34')]('nolimit')){_0x231dc7[_0x3f9d('0x1d')]=qs[_0x3f9d('0x1d')](_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x1d')]);_0x231dc7[_0x3f9d('0x1c')]=qs['offset'](_0x1bf6ac[_0x3f9d('0x2e')]['offset']);}_0x231dc7[_0x3f9d('0x35')]=qs[_0x3f9d('0x36')](_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x36')]);_0x231dc7['where']=qs['filters'](_['pick'](_0x1bf6ac['query'],_0xdc8d5b[_0x3f9d('0x37')]),_0x5244cf);if(_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x38')]){_0x231dc7[_0x3f9d('0x39')]=_['merge'](_0x231dc7['where'],{'$or':_[_0x3f9d('0x2d')](_0x5244cf,function(_0x582122){if(_0x582122[_0x3f9d('0x3a')]!==_0x3f9d('0x3b')){var _0x12a643={};_0x12a643[_0x582122['name']]={'$like':'%'+_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x38')]+'%'};return _0x12a643;}})});}_0x231dc7=_[_0x3f9d('0x3c')]({},_0x231dc7,_0x1bf6ac[_0x3f9d('0x3d')]);var _0x4463a6={'where':_0x231dc7[_0x3f9d('0x39')]};return db[_0x3f9d('0x28')][_0x3f9d('0x1b')](_0x4463a6)['then'](function(_0x1e12bb){_0x36f7c9[_0x3f9d('0x1b')]=_0x1e12bb;if(_0x1bf6ac[_0x3f9d('0x2e')][_0x3f9d('0x3e')]){_0x231dc7[_0x3f9d('0x3f')]=[{'all':!![]}];}return db['ZohoConfiguration']['findAll'](_0x231dc7);})[_0x3f9d('0x24')](function(_0x31fdbb){_0x36f7c9[_0x3f9d('0x40')]=_0x31fdbb;return _0x36f7c9;})[_0x3f9d('0x24')](respondWithFilteredResult(_0x30bf74,_0x231dc7))[_0x3f9d('0x41')](handleError(_0x30bf74,null));};exports['show']=function(_0x463ae5,_0x2ff280){var _0x214e9d={'raw':![],'where':{'id':_0x463ae5[_0x3f9d('0x42')]['id']}},_0x4bf133={};_0x4bf133[_0x3f9d('0x2c')]=_[_0x3f9d('0x2f')](db[_0x3f9d('0x28')][_0x3f9d('0x29')]);_0x4bf133[_0x3f9d('0x2e')]=_['keys'](_0x463ae5[_0x3f9d('0x2e')]);_0x4bf133['filters']=_[_0x3f9d('0x30')](_0x4bf133[_0x3f9d('0x2c')],_0x4bf133[_0x3f9d('0x2e')]);_0x214e9d[_0x3f9d('0x31')]=_['intersection'](_0x4bf133['model'],qs[_0x3f9d('0x32')](_0x463ae5[_0x3f9d('0x2e')]['fields']));_0x214e9d[_0x3f9d('0x31')]=_0x214e9d[_0x3f9d('0x31')][_0x3f9d('0x33')]?_0x214e9d[_0x3f9d('0x31')]:_0x4bf133[_0x3f9d('0x2c')];if(_0x463ae5[_0x3f9d('0x2e')][_0x3f9d('0x3e')]){_0x214e9d[_0x3f9d('0x3f')]=[{'all':!![]}];}_0x214e9d=_[_0x3f9d('0x3c')]({},_0x214e9d,_0x463ae5[_0x3f9d('0x3d')]);return db[_0x3f9d('0x28')][_0x3f9d('0x43')](_0x214e9d)[_0x3f9d('0x24')](handleEntityNotFound(_0x2ff280,null))[_0x3f9d('0x24')](respondWithResult(_0x2ff280,null))[_0x3f9d('0x41')](handleError(_0x2ff280,null));};exports[_0x3f9d('0x44')]=function(_0x3374c6,_0xa818c7){return db['ZohoConfiguration'][_0x3f9d('0x44')](_0x3374c6[_0x3f9d('0x45')],{})[_0x3f9d('0x24')](respondWithResult(_0xa818c7,0xc9))[_0x3f9d('0x41')](handleError(_0xa818c7,null));};exports[_0x3f9d('0x23')]=function(_0x464ea3,_0xdbba3a){if(_0x464ea3['body']['id']){delete _0x464ea3['body']['id'];}return db['ZohoConfiguration'][_0x3f9d('0x43')]({'where':{'id':_0x464ea3[_0x3f9d('0x42')]['id']}})[_0x3f9d('0x24')](handleEntityNotFound(_0xdbba3a,null))[_0x3f9d('0x24')](saveUpdates(_0x464ea3[_0x3f9d('0x45')],null))['then'](respondWithResult(_0xdbba3a,null))[_0x3f9d('0x41')](handleError(_0xdbba3a,null));};exports[_0x3f9d('0x46')]=function(_0x66d548,_0x27b326){return db[_0x3f9d('0x28')][_0x3f9d('0x43')]({'where':{'id':_0x66d548[_0x3f9d('0x42')]['id']}})[_0x3f9d('0x24')](handleEntityNotFound(_0x27b326,null))['then'](removeEntity(_0x27b326,null))[_0x3f9d('0x41')](handleError(_0x27b326,null));};exports[_0x3f9d('0x47')]=function(_0x7ca046,_0x720184,_0x11247b){var _0x47dc22={};var _0x2602d4={};var _0x2b6fcb;var _0xa5e32b;return db['ZohoConfiguration'][_0x3f9d('0x48')]({'where':{'id':_0x7ca046[_0x3f9d('0x42')]['id']}})['then'](handleEntityNotFound(_0x720184,null))[_0x3f9d('0x24')](function(_0x26ed83){if(_0x26ed83){_0x2b6fcb=_0x26ed83;_0x2602d4[_0x3f9d('0x2c')]=_[_0x3f9d('0x2f')](db['ZohoField']['rawAttributes']);_0x2602d4[_0x3f9d('0x2e')]=_['keys'](_0x7ca046[_0x3f9d('0x2e')]);_0x2602d4[_0x3f9d('0x37')]=_[_0x3f9d('0x30')](_0x2602d4[_0x3f9d('0x2c')],_0x2602d4[_0x3f9d('0x2e')]);_0x47dc22[_0x3f9d('0x31')]=_['intersection'](_0x2602d4[_0x3f9d('0x2c')],qs[_0x3f9d('0x32')](_0x7ca046['query'][_0x3f9d('0x32')]));_0x47dc22['attributes']=_0x47dc22[_0x3f9d('0x31')][_0x3f9d('0x33')]?_0x47dc22['attributes']:_0x2602d4[_0x3f9d('0x2c')];_0x47dc22[_0x3f9d('0x35')]=qs[_0x3f9d('0x36')](_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x36')]);_0x47dc22[_0x3f9d('0x39')]=qs[_0x3f9d('0x37')](_[_0x3f9d('0x49')](_0x7ca046[_0x3f9d('0x2e')],_0x2602d4[_0x3f9d('0x37')]));if(_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x38')]){_0x47dc22[_0x3f9d('0x39')]=_[_0x3f9d('0x3c')](_0x47dc22['where'],{'$or':_[_0x3f9d('0x2d')](_0x47dc22[_0x3f9d('0x31')],function(_0x4a8ba4){var _0xf8a18b={};_0xf8a18b[_0x4a8ba4]={'$like':'%'+_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x38')]+'%'};return _0xf8a18b;})});}_0x47dc22=_[_0x3f9d('0x3c')]({},_0x47dc22,_0x7ca046[_0x3f9d('0x3d')]);return _0x2b6fcb[_0x3f9d('0x47')](_0x47dc22);}})['then'](function(_0x3a5ffa){if(_0x3a5ffa){_0xa5e32b=_0x3a5ffa[_0x3f9d('0x33')];if(!_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x34')](_0x3f9d('0x4a'))){_0x47dc22[_0x3f9d('0x1d')]=qs['limit'](_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x1d')]);_0x47dc22[_0x3f9d('0x1c')]=qs[_0x3f9d('0x1c')](_0x7ca046[_0x3f9d('0x2e')][_0x3f9d('0x1c')]);}return _0x2b6fcb[_0x3f9d('0x47')](_0x47dc22);}})['then'](function(_0x5184ab){if(_0x5184ab){return _0x5184ab?{'count':_0xa5e32b,'rows':_0x5184ab}:null;}})[_0x3f9d('0x24')](respondWithResult(_0x720184,null))[_0x3f9d('0x41')](handleError(_0x720184,null));};exports[_0x3f9d('0x4b')]=function(_0x4a87f4,_0x199169,_0xcb9797){var _0x17c0de={};var _0xb03317={};var _0x508cb0;var _0x5efd9c;return db['ZohoConfiguration'][_0x3f9d('0x48')]({'where':{'id':_0x4a87f4[_0x3f9d('0x42')]['id']}})['then'](handleEntityNotFound(_0x199169,null))[_0x3f9d('0x24')](function(_0x3ab1fa){if(_0x3ab1fa){_0x508cb0=_0x3ab1fa;_0xb03317[_0x3f9d('0x2c')]=_[_0x3f9d('0x2f')](db[_0x3f9d('0x4c')][_0x3f9d('0x29')]);_0xb03317[_0x3f9d('0x2e')]=_[_0x3f9d('0x2f')](_0x4a87f4[_0x3f9d('0x2e')]);_0xb03317[_0x3f9d('0x37')]=_[_0x3f9d('0x30')](_0xb03317['model'],_0xb03317[_0x3f9d('0x2e')]);_0x17c0de[_0x3f9d('0x31')]=_[_0x3f9d('0x30')](_0xb03317['model'],qs[_0x3f9d('0x32')](_0x4a87f4[_0x3f9d('0x2e')][_0x3f9d('0x32')]));_0x17c0de[_0x3f9d('0x31')]=_0x17c0de[_0x3f9d('0x31')]['length']?_0x17c0de[_0x3f9d('0x31')]:_0xb03317[_0x3f9d('0x2c')];_0x17c0de[_0x3f9d('0x35')]=qs[_0x3f9d('0x36')](_0x4a87f4[_0x3f9d('0x2e')]['sort']);_0x17c0de[_0x3f9d('0x39')]=qs[_0x3f9d('0x37')](_[_0x3f9d('0x49')](_0x4a87f4['query'],_0xb03317[_0x3f9d('0x37')]));if(_0x4a87f4[_0x3f9d('0x2e')][_0x3f9d('0x38')]){_0x17c0de['where']=_['merge'](_0x17c0de['where'],{'$or':_[_0x3f9d('0x2d')](_0x17c0de[_0x3f9d('0x31')],function(_0x259816){var _0x20b7f8={};_0x20b7f8[_0x259816]={'$like':'%'+_0x4a87f4[_0x3f9d('0x2e')]['filter']+'%'};return _0x20b7f8;})});}_0x17c0de=_['merge']({},_0x17c0de,_0x4a87f4[_0x3f9d('0x3d')]);return _0x508cb0[_0x3f9d('0x4b')](_0x17c0de);}})['then'](function(_0x437c16){if(_0x437c16){_0x5efd9c=_0x437c16['length'];if(!_0x4a87f4[_0x3f9d('0x2e')][_0x3f9d('0x34')]('nolimit')){_0x17c0de[_0x3f9d('0x1d')]=qs[_0x3f9d('0x1d')](_0x4a87f4[_0x3f9d('0x2e')][_0x3f9d('0x1d')]);_0x17c0de['offset']=qs[_0x3f9d('0x1c')](_0x4a87f4[_0x3f9d('0x2e')]['offset']);}return _0x508cb0['getSubjects'](_0x17c0de);}})['then'](function(_0x3ada2b){if(_0x3ada2b){return _0x3ada2b?{'count':_0x5efd9c,'rows':_0x3ada2b}:null;}})['then'](respondWithResult(_0x199169,null))[_0x3f9d('0x41')](handleError(_0x199169,null));};exports['getDescriptions']=function(_0x249274,_0x44462f,_0xd679c4){var _0x36e85={};var _0x394a80={};var _0x194cdc;var _0x4b2368;return db['ZohoConfiguration'][_0x3f9d('0x48')]({'where':{'id':_0x249274['params']['id']}})['then'](handleEntityNotFound(_0x44462f,null))[_0x3f9d('0x24')](function(_0x3d4949){if(_0x3d4949){_0x194cdc=_0x3d4949;_0x394a80['model']=_[_0x3f9d('0x2f')](db[_0x3f9d('0x4c')][_0x3f9d('0x29')]);_0x394a80[_0x3f9d('0x2e')]=_[_0x3f9d('0x2f')](_0x249274[_0x3f9d('0x2e')]);_0x394a80[_0x3f9d('0x37')]=_[_0x3f9d('0x30')](_0x394a80[_0x3f9d('0x2c')],_0x394a80[_0x3f9d('0x2e')]);_0x36e85[_0x3f9d('0x31')]=_[_0x3f9d('0x30')](_0x394a80[_0x3f9d('0x2c')],qs[_0x3f9d('0x32')](_0x249274[_0x3f9d('0x2e')]['fields']));_0x36e85[_0x3f9d('0x31')]=_0x36e85[_0x3f9d('0x31')][_0x3f9d('0x33')]?_0x36e85[_0x3f9d('0x31')]:_0x394a80[_0x3f9d('0x2c')];_0x36e85[_0x3f9d('0x35')]=qs[_0x3f9d('0x36')](_0x249274[_0x3f9d('0x2e')][_0x3f9d('0x36')]);_0x36e85[_0x3f9d('0x39')]=qs[_0x3f9d('0x37')](_[_0x3f9d('0x49')](_0x249274[_0x3f9d('0x2e')],_0x394a80[_0x3f9d('0x37')]));if(_0x249274[_0x3f9d('0x2e')]['filter']){_0x36e85[_0x3f9d('0x39')]=_[_0x3f9d('0x3c')](_0x36e85[_0x3f9d('0x39')],{'$or':_[_0x3f9d('0x2d')](_0x36e85[_0x3f9d('0x31')],function(_0x459922){var _0x46db39={};_0x46db39[_0x459922]={'$like':'%'+_0x249274[_0x3f9d('0x2e')][_0x3f9d('0x38')]+'%'};return _0x46db39;})});}_0x36e85=_[_0x3f9d('0x3c')]({},_0x36e85,_0x249274['options']);return _0x194cdc['getDescriptions'](_0x36e85);}})['then'](function(_0xaa770e){if(_0xaa770e){_0x4b2368=_0xaa770e['length'];if(!_0x249274['query']['hasOwnProperty'](_0x3f9d('0x4a'))){_0x36e85[_0x3f9d('0x1d')]=qs['limit'](_0x249274[_0x3f9d('0x2e')][_0x3f9d('0x1d')]);_0x36e85[_0x3f9d('0x1c')]=qs['offset'](_0x249274[_0x3f9d('0x2e')]['offset']);}return _0x194cdc['getDescriptions'](_0x36e85);}})[_0x3f9d('0x24')](function(_0x1d330d){if(_0x1d330d){return _0x1d330d?{'count':_0x4b2368,'rows':_0x1d330d}:null;}})[_0x3f9d('0x24')](respondWithResult(_0x44462f,null))['catch'](handleError(_0x44462f,null));};
\ No newline at end of file