18 var _0x1626=['create','body','getFields','findOne','nolimit','getSubjects','ServicenowField','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','error','name','send','index','rawAttributes','type','key','model','keys','query','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','map','VIRTUAL','options','ServicenowConfiguration','includeAll','include','rows','catch','show','params','find'];(function(_0xef8146,_0x459c34){var _0x5a6cb0=function(_0x2f84ec){while(--_0x2f84ec){_0xef8146['push'](_0xef8146['shift']());}};_0x5a6cb0(++_0x459c34);}(_0x1626,0xfe));var _0x6162=function(_0x329664,_0x130748){_0x329664=_0x329664-0x0;var _0x4e346e=_0x1626[_0x329664];return _0x4e346e;};'use strict';var emlformat=require(_0x6162('0x0'));var rimraf=require(_0x6162('0x1'));var zipdir=require(_0x6162('0x2'));var jsonpatch=require(_0x6162('0x3'));var rp=require(_0x6162('0x4'));var moment=require('moment');var BPromise=require(_0x6162('0x5'));var Mustache=require('mustache');var util=require(_0x6162('0x6'));var path=require(_0x6162('0x7'));var sox=require(_0x6162('0x8'));var csv=require(_0x6162('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6162('0xa'));var _=require(_0x6162('0xb'));var squel=require(_0x6162('0xc'));var crypto=require(_0x6162('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6162('0xe'));var toCsv=require(_0x6162('0x9'));var querystring=require(_0x6162('0xf'));var Papa=require(_0x6162('0x10'));var Redis=require('ioredis');var authService=require(_0x6162('0x11'));var qs=require(_0x6162('0x12'));var as=require(_0x6162('0x13'));var hardwareService=require(_0x6162('0x14'));var logger=require(_0x6162('0x15'))(_0x6162('0x16'));var utils=require(_0x6162('0x17'));var config=require(_0x6162('0x18'));var licenseUtil=require(_0x6162('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x10bac2,_0x3f1235){_0x3f1235=_0x3f1235||0xcc;return function(_0x46b999){if(_0x46b999){return _0x10bac2[_0x6162('0x1a')](_0x3f1235);}return _0x10bac2[_0x6162('0x1b')](_0x3f1235)[_0x6162('0x1c')]();};}function respondWithResult(_0x4d87fc,_0xb56ab7){_0xb56ab7=_0xb56ab7||0xc8;return function(_0x3792a5){if(_0x3792a5){return _0x4d87fc[_0x6162('0x1b')](_0xb56ab7)[_0x6162('0x1d')](_0x3792a5);}};}function respondWithFilteredResult(_0x194d65,_0xa7e774){return function(_0xebc22c){if(_0xebc22c){var _0x3ddfce=typeof _0xa7e774['offset']==='undefined'&&typeof _0xa7e774[_0x6162('0x1e')]==='undefined';var _0x169d89=_0xebc22c[_0x6162('0x1f')];var _0x2f663d=_0x3ddfce?0x0:_0xa7e774['offset'];var _0x19fc63=_0x3ddfce?_0xebc22c['count']:_0xa7e774[_0x6162('0x20')]+_0xa7e774['limit'];var _0x3bffb3;if(_0x19fc63>=_0x169d89){_0x19fc63=_0x169d89;_0x3bffb3=0xc8;}else{_0x3bffb3=0xce;}_0x194d65[_0x6162('0x1b')](_0x3bffb3);return _0x194d65[_0x6162('0x21')](_0x6162('0x22'),_0x2f663d+'-'+_0x19fc63+'/'+_0x169d89)[_0x6162('0x1d')](_0xebc22c);}return null;};}function patchUpdates(_0x52628e){return function(_0x21b20b){try{jsonpatch[_0x6162('0x23')](_0x21b20b,_0x52628e,!![]);}catch(_0x421d64){return BPromise[_0x6162('0x24')](_0x421d64);}return _0x21b20b[_0x6162('0x25')]();};}function saveUpdates(_0x3def3c,_0x5241a8){return function(_0x525b35){if(_0x525b35){return _0x525b35[_0x6162('0x26')](_0x3def3c)[_0x6162('0x27')](function(_0x299c5f){return _0x299c5f;});}return null;};}function removeEntity(_0x4ed74b,_0x9211ca){return function(_0x174917){if(_0x174917){return _0x174917[_0x6162('0x28')]()[_0x6162('0x27')](function(){_0x4ed74b[_0x6162('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4eb541,_0x26f60f){return function(_0xabad03){if(!_0xabad03){_0x4eb541[_0x6162('0x1a')](0x194);}return _0xabad03;};}function handleError(_0xc6c418,_0x5dc867){_0x5dc867=_0x5dc867||0x1f4;return function(_0x2ae235){logger[_0x6162('0x29')](_0x2ae235['stack']);if(_0x2ae235[_0x6162('0x2a')]){delete _0x2ae235[_0x6162('0x2a')];}_0xc6c418[_0x6162('0x1b')](_0x5dc867)[_0x6162('0x2b')](_0x2ae235);};}exports[_0x6162('0x2c')]=function(_0x5c6f9e,_0x314e09){var _0x3531d7={},_0x5343ab={},_0x1117c1={'count':0x0,'rows':[]};var _0x5930e5=_['map'](db['ServicenowConfiguration'][_0x6162('0x2d')],function(_0x1dd27c){return{'name':_0x1dd27c['fieldName'],'type':_0x1dd27c[_0x6162('0x2e')][_0x6162('0x2f')]};});_0x5343ab[_0x6162('0x30')]=_['map'](_0x5930e5,_0x6162('0x2a'));_0x5343ab['query']=_[_0x6162('0x31')](_0x5c6f9e[_0x6162('0x32')]);_0x5343ab['filters']=_[_0x6162('0x33')](_0x5343ab['model'],_0x5343ab[_0x6162('0x32')]);_0x3531d7['attributes']=_[_0x6162('0x33')](_0x5343ab[_0x6162('0x30')],qs['fields'](_0x5c6f9e['query'][_0x6162('0x34')]));_0x3531d7[_0x6162('0x35')]=_0x3531d7['attributes'][_0x6162('0x36')]?_0x3531d7[_0x6162('0x35')]:_0x5343ab[_0x6162('0x30')];if(!_0x5c6f9e[_0x6162('0x32')][_0x6162('0x37')]('nolimit')){_0x3531d7['limit']=qs[_0x6162('0x1e')](_0x5c6f9e[_0x6162('0x32')][_0x6162('0x1e')]);_0x3531d7[_0x6162('0x20')]=qs[_0x6162('0x20')](_0x5c6f9e['query'][_0x6162('0x20')]);}_0x3531d7[_0x6162('0x38')]=qs[_0x6162('0x39')](_0x5c6f9e['query'][_0x6162('0x39')]);_0x3531d7[_0x6162('0x3a')]=qs[_0x6162('0x3b')](_[_0x6162('0x3c')](_0x5c6f9e[_0x6162('0x32')],_0x5343ab[_0x6162('0x3b')]),_0x5930e5);if(_0x5c6f9e[_0x6162('0x32')][_0x6162('0x3d')]){_0x3531d7['where']=_[_0x6162('0x3e')](_0x3531d7[_0x6162('0x3a')],{'$or':_[_0x6162('0x3f')](_0x5930e5,function(_0x5ead44){if(_0x5ead44[_0x6162('0x2e')]!==_0x6162('0x40')){var _0x12f3bb={};_0x12f3bb[_0x5ead44[_0x6162('0x2a')]]={'$like':'%'+_0x5c6f9e[_0x6162('0x32')]['filter']+'%'};return _0x12f3bb;}})});}_0x3531d7=_['merge']({},_0x3531d7,_0x5c6f9e[_0x6162('0x41')]);var _0x5a1048={'where':_0x3531d7[_0x6162('0x3a')]};return db[_0x6162('0x42')][_0x6162('0x1f')](_0x5a1048)[_0x6162('0x27')](function(_0x15f342){_0x1117c1['count']=_0x15f342;if(_0x5c6f9e[_0x6162('0x32')][_0x6162('0x43')]){_0x3531d7[_0x6162('0x44')]=[{'all':!![]}];}return db['ServicenowConfiguration']['findAll'](_0x3531d7);})[_0x6162('0x27')](function(_0x19e926){_0x1117c1[_0x6162('0x45')]=_0x19e926;return _0x1117c1;})[_0x6162('0x27')](respondWithFilteredResult(_0x314e09,_0x3531d7))[_0x6162('0x46')](handleError(_0x314e09,null));};exports[_0x6162('0x47')]=function(_0x1880fc,_0x3f12f0){var _0x5a75ba={'raw':![],'where':{'id':_0x1880fc[_0x6162('0x48')]['id']}},_0x53f626={};_0x53f626['model']=_[_0x6162('0x31')](db[_0x6162('0x42')]['rawAttributes']);_0x53f626['query']=_['keys'](_0x1880fc[_0x6162('0x32')]);_0x53f626[_0x6162('0x3b')]=_[_0x6162('0x33')](_0x53f626[_0x6162('0x30')],_0x53f626[_0x6162('0x32')]);_0x5a75ba['attributes']=_['intersection'](_0x53f626[_0x6162('0x30')],qs[_0x6162('0x34')](_0x1880fc[_0x6162('0x32')][_0x6162('0x34')]));_0x5a75ba[_0x6162('0x35')]=_0x5a75ba[_0x6162('0x35')]['length']?_0x5a75ba['attributes']:_0x53f626['model'];if(_0x1880fc[_0x6162('0x32')][_0x6162('0x43')]){_0x5a75ba[_0x6162('0x44')]=[{'all':!![]}];}_0x5a75ba=_[_0x6162('0x3e')]({},_0x5a75ba,_0x1880fc['options']);return db[_0x6162('0x42')][_0x6162('0x49')](_0x5a75ba)['then'](handleEntityNotFound(_0x3f12f0,null))[_0x6162('0x27')](respondWithResult(_0x3f12f0,null))[_0x6162('0x46')](handleError(_0x3f12f0,null));};exports['create']=function(_0x126f6a,_0xf30df2){return db[_0x6162('0x42')][_0x6162('0x4a')](_0x126f6a['body'],{})['then'](respondWithResult(_0xf30df2,0xc9))[_0x6162('0x46')](handleError(_0xf30df2,null));};exports[_0x6162('0x26')]=function(_0x460f04,_0x547d99){if(_0x460f04[_0x6162('0x4b')]['id']){delete _0x460f04['body']['id'];}return db[_0x6162('0x42')][_0x6162('0x49')]({'where':{'id':_0x460f04[_0x6162('0x48')]['id']}})['then'](handleEntityNotFound(_0x547d99,null))['then'](saveUpdates(_0x460f04['body'],null))['then'](respondWithResult(_0x547d99,null))[_0x6162('0x46')](handleError(_0x547d99,null));};exports['destroy']=function(_0x1828b2,_0x2e7398){return db['ServicenowConfiguration'][_0x6162('0x49')]({'where':{'id':_0x1828b2['params']['id']}})[_0x6162('0x27')](handleEntityNotFound(_0x2e7398,null))['then'](removeEntity(_0x2e7398,null))[_0x6162('0x46')](handleError(_0x2e7398,null));};exports[_0x6162('0x4c')]=function(_0x257af9,_0x465d0f,_0x107f09){var _0x1f8148={};var _0x4e33bc={};var _0x1025de;var _0x2bce63;return db[_0x6162('0x42')][_0x6162('0x4d')]({'where':{'id':_0x257af9[_0x6162('0x48')]['id']}})[_0x6162('0x27')](handleEntityNotFound(_0x465d0f,null))['then'](function(_0x4fdf3c){if(_0x4fdf3c){_0x1025de=_0x4fdf3c;_0x4e33bc[_0x6162('0x30')]=_['keys'](db['ServicenowField']['rawAttributes']);_0x4e33bc['query']=_[_0x6162('0x31')](_0x257af9[_0x6162('0x32')]);_0x4e33bc['filters']=_['intersection'](_0x4e33bc[_0x6162('0x30')],_0x4e33bc[_0x6162('0x32')]);_0x1f8148[_0x6162('0x35')]=_[_0x6162('0x33')](_0x4e33bc[_0x6162('0x30')],qs[_0x6162('0x34')](_0x257af9[_0x6162('0x32')][_0x6162('0x34')]));_0x1f8148['attributes']=_0x1f8148[_0x6162('0x35')][_0x6162('0x36')]?_0x1f8148['attributes']:_0x4e33bc[_0x6162('0x30')];_0x1f8148['order']=qs[_0x6162('0x39')](_0x257af9['query'][_0x6162('0x39')]);_0x1f8148[_0x6162('0x3a')]=qs['filters'](_['pick'](_0x257af9['query'],_0x4e33bc['filters']));if(_0x257af9[_0x6162('0x32')][_0x6162('0x3d')]){_0x1f8148[_0x6162('0x3a')]=_[_0x6162('0x3e')](_0x1f8148[_0x6162('0x3a')],{'$or':_[_0x6162('0x3f')](_0x1f8148[_0x6162('0x35')],function(_0x2a56a0){var _0xa655ed={};_0xa655ed[_0x2a56a0]={'$like':'%'+_0x257af9[_0x6162('0x32')][_0x6162('0x3d')]+'%'};return _0xa655ed;})});}_0x1f8148=_[_0x6162('0x3e')]({},_0x1f8148,_0x257af9[_0x6162('0x41')]);return _0x1025de[_0x6162('0x4c')](_0x1f8148);}})[_0x6162('0x27')](function(_0x2ee6de){if(_0x2ee6de){_0x2bce63=_0x2ee6de[_0x6162('0x36')];if(!_0x257af9['query'][_0x6162('0x37')](_0x6162('0x4e'))){_0x1f8148[_0x6162('0x1e')]=qs['limit'](_0x257af9[_0x6162('0x32')][_0x6162('0x1e')]);_0x1f8148[_0x6162('0x20')]=qs[_0x6162('0x20')](_0x257af9[_0x6162('0x32')][_0x6162('0x20')]);}return _0x1025de[_0x6162('0x4c')](_0x1f8148);}})[_0x6162('0x27')](function(_0x235d80){if(_0x235d80){return _0x235d80?{'count':_0x2bce63,'rows':_0x235d80}:null;}})['then'](respondWithResult(_0x465d0f,null))['catch'](handleError(_0x465d0f,null));};exports[_0x6162('0x4f')]=function(_0x4bd4d6,_0xff1ba8,_0x11c289){var _0x223c15={};var _0x2eebae={};var _0x5b951a;var _0xc97d68;return db['ServicenowConfiguration'][_0x6162('0x4d')]({'where':{'id':_0x4bd4d6[_0x6162('0x48')]['id']}})['then'](handleEntityNotFound(_0xff1ba8,null))[_0x6162('0x27')](function(_0x47e5b4){if(_0x47e5b4){_0x5b951a=_0x47e5b4;_0x2eebae[_0x6162('0x30')]=_['keys'](db[_0x6162('0x50')][_0x6162('0x2d')]);_0x2eebae[_0x6162('0x32')]=_[_0x6162('0x31')](_0x4bd4d6['query']);_0x2eebae['filters']=_[_0x6162('0x33')](_0x2eebae['model'],_0x2eebae[_0x6162('0x32')]);_0x223c15['attributes']=_[_0x6162('0x33')](_0x2eebae[_0x6162('0x30')],qs[_0x6162('0x34')](_0x4bd4d6['query']['fields']));_0x223c15['attributes']=_0x223c15['attributes'][_0x6162('0x36')]?_0x223c15[_0x6162('0x35')]:_0x2eebae['model'];_0x223c15[_0x6162('0x38')]=qs[_0x6162('0x39')](_0x4bd4d6[_0x6162('0x32')][_0x6162('0x39')]);_0x223c15['where']=qs['filters'](_['pick'](_0x4bd4d6[_0x6162('0x32')],_0x2eebae[_0x6162('0x3b')]));if(_0x4bd4d6[_0x6162('0x32')][_0x6162('0x3d')]){_0x223c15['where']=_[_0x6162('0x3e')](_0x223c15['where'],{'$or':_['map'](_0x223c15[_0x6162('0x35')],function(_0x5dbb82){var _0x3e51e7={};_0x3e51e7[_0x5dbb82]={'$like':'%'+_0x4bd4d6[_0x6162('0x32')]['filter']+'%'};return _0x3e51e7;})});}_0x223c15=_[_0x6162('0x3e')]({},_0x223c15,_0x4bd4d6[_0x6162('0x41')]);return _0x5b951a[_0x6162('0x4f')](_0x223c15);}})['then'](function(_0x4cc4c4){if(_0x4cc4c4){_0xc97d68=_0x4cc4c4['length'];if(!_0x4bd4d6['query'][_0x6162('0x37')]('nolimit')){_0x223c15[_0x6162('0x1e')]=qs[_0x6162('0x1e')](_0x4bd4d6[_0x6162('0x32')]['limit']);_0x223c15[_0x6162('0x20')]=qs[_0x6162('0x20')](_0x4bd4d6[_0x6162('0x32')][_0x6162('0x20')]);}return _0x5b951a[_0x6162('0x4f')](_0x223c15);}})[_0x6162('0x27')](function(_0xd36ca2){if(_0xd36ca2){return _0xd36ca2?{'count':_0xc97d68,'rows':_0xd36ca2}:null;}})['then'](respondWithResult(_0xff1ba8,null))['catch'](handleError(_0xff1ba8,null));};exports[_0x6162('0x51')]=function(_0x188f0e,_0xc9fa0f,_0xda0cb){var _0x229369={};var _0x418bd5={};var _0x4b8cd8;var _0x69f30b;return db['ServicenowConfiguration']['findOne']({'where':{'id':_0x188f0e[_0x6162('0x48')]['id']}})[_0x6162('0x27')](handleEntityNotFound(_0xc9fa0f,null))['then'](function(_0x443566){if(_0x443566){_0x4b8cd8=_0x443566;_0x418bd5[_0x6162('0x30')]=_['keys'](db[_0x6162('0x50')]['rawAttributes']);_0x418bd5[_0x6162('0x32')]=_[_0x6162('0x31')](_0x188f0e[_0x6162('0x32')]);_0x418bd5[_0x6162('0x3b')]=_['intersection'](_0x418bd5['model'],_0x418bd5['query']);_0x229369[_0x6162('0x35')]=_[_0x6162('0x33')](_0x418bd5[_0x6162('0x30')],qs[_0x6162('0x34')](_0x188f0e[_0x6162('0x32')][_0x6162('0x34')]));_0x229369['attributes']=_0x229369[_0x6162('0x35')][_0x6162('0x36')]?_0x229369[_0x6162('0x35')]:_0x418bd5[_0x6162('0x30')];_0x229369[_0x6162('0x38')]=qs['sort'](_0x188f0e[_0x6162('0x32')][_0x6162('0x39')]);_0x229369[_0x6162('0x3a')]=qs[_0x6162('0x3b')](_[_0x6162('0x3c')](_0x188f0e[_0x6162('0x32')],_0x418bd5[_0x6162('0x3b')]));if(_0x188f0e[_0x6162('0x32')][_0x6162('0x3d')]){_0x229369['where']=_['merge'](_0x229369['where'],{'$or':_[_0x6162('0x3f')](_0x229369['attributes'],function(_0x5c81ab){var _0x4bfa7b={};_0x4bfa7b[_0x5c81ab]={'$like':'%'+_0x188f0e[_0x6162('0x32')][_0x6162('0x3d')]+'%'};return _0x4bfa7b;})});}_0x229369=_[_0x6162('0x3e')]({},_0x229369,_0x188f0e[_0x6162('0x41')]);return _0x4b8cd8[_0x6162('0x51')](_0x229369);}})['then'](function(_0x2f79d9){if(_0x2f79d9){_0x69f30b=_0x2f79d9[_0x6162('0x36')];if(!_0x188f0e[_0x6162('0x32')][_0x6162('0x37')](_0x6162('0x4e'))){_0x229369[_0x6162('0x1e')]=qs[_0x6162('0x1e')](_0x188f0e[_0x6162('0x32')][_0x6162('0x1e')]);_0x229369[_0x6162('0x20')]=qs[_0x6162('0x20')](_0x188f0e[_0x6162('0x32')]['offset']);}return _0x4b8cd8[_0x6162('0x51')](_0x229369);}})[_0x6162('0x27')](function(_0x1e039d){if(_0x1e039d){return _0x1e039d?{'count':_0x69f30b,'rows':_0x1e039d}:null;}})[_0x6162('0x27')](respondWithResult(_0xc9fa0f,null))[_0x6162('0x46')](handleError(_0xc9fa0f,null));};