Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / intServicenowConfiguration / intServicenowConfiguration.controller.js
index 783355f..1a3846c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x21f6=['rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','ejs','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','client','http','request','then','info','ServicenowConfiguration,\x20%s,\x20%s','debug','error','code','message','request\x20sent','result','catch','sendStatus','end','status','json','count','offset','set','Content-Range','apply','destroy','name','index','ServicenowConfiguration','fieldName','type','key','model','map','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','filters','pick','filter','where','merge','options','include','show','keys','rawAttributes','includeAll','find','create','body','update','params','findOne','order','getFields','getSubjects','ServicenowField','getDescriptions','eml-format'];(function(_0x54a964,_0x23c311){var _0x1d2a5d=function(_0x7070b0){while(--_0x7070b0){_0x54a964['push'](_0x54a964['shift']());}};_0x1d2a5d(++_0x23c311);}(_0x21f6,0xad));var _0x621f=function(_0x49bf14,_0x7d72a9){_0x49bf14=_0x49bf14-0x0;var _0x413809=_0x21f6[_0x49bf14];return _0x413809;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x621f('0x0'));var rimraf=require(_0x621f('0x1'));var zipdir=require(_0x621f('0x2'));var jsonpatch=require(_0x621f('0x3'));var rp=require(_0x621f('0x4'));var moment=require('moment');var BPromise=require(_0x621f('0x5'));var Mustache=require('mustache');var util=require(_0x621f('0x6'));var path=require(_0x621f('0x7'));var sox=require(_0x621f('0x8'));var csv=require(_0x621f('0x9'));var ejs=require(_0x621f('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x621f('0xb'));var crypto=require(_0x621f('0xc'));var jsforce=require(_0x621f('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x621f('0x9'));var querystring=require(_0x621f('0xe'));var Papa=require(_0x621f('0xf'));var Redis=require(_0x621f('0x10'));var authService=require(_0x621f('0x11'));var qs=require(_0x621f('0x12'));var as=require(_0x621f('0x13'));var hardwareService=require(_0x621f('0x14'));var logger=require('../../config/logger')(_0x621f('0x15'));var utils=require('../../config/utils');var config=require(_0x621f('0x16'));var licenseUtil=require(_0x621f('0x17'));var db=require(_0x621f('0x18'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x621f('0x19')][_0x621f('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x3e0afe,_0x338be8,_0xf81131,_0x3922fe){return new BPromise(function(_0x29cf84,_0x23da71){var _0x55feea=_0x3922fe||client;return _0x55feea[_0x621f('0x1b')](_0x3e0afe,_0xf81131)[_0x621f('0x1c')](function(_0x27507c){logger[_0x621f('0x1d')](_0x621f('0x1e'),_0x338be8,'request\x20sent');logger[_0x621f('0x1f')]('ServicenowConfiguration,\x20%s,\x20%s,\x20%s',_0x338be8,'request\x20sent',JSON['stringify'](_0x27507c));if(_0x27507c[_0x621f('0x20')]){if(_0x27507c[_0x621f('0x20')][_0x621f('0x21')]===0x1f4){logger[_0x621f('0x20')](_0x621f('0x1e'),_0x338be8,_0x27507c[_0x621f('0x20')]['message']);return _0x23da71(_0x27507c[_0x621f('0x20')][_0x621f('0x22')]);}logger['error']('ServicenowConfiguration,\x20%s,\x20%s',_0x338be8,_0x27507c[_0x621f('0x20')][_0x621f('0x22')]);return _0x29cf84(_0x27507c['error'][_0x621f('0x22')]);}else{logger[_0x621f('0x1d')](_0x621f('0x1e'),_0x338be8,_0x621f('0x23'));_0x29cf84(_0x27507c[_0x621f('0x24')][_0x621f('0x22')]);}})[_0x621f('0x25')](function(_0x5b7134){logger[_0x621f('0x20')](_0x621f('0x1e'),_0x338be8,_0x5b7134);_0x23da71(_0x5b7134);});});}function respondWithStatusCode(_0x3d499e,_0x1bac83){_0x1bac83=_0x1bac83||0xcc;return function(_0x3960fd){if(_0x3960fd){return _0x3d499e[_0x621f('0x26')](_0x1bac83);}return _0x3d499e['status'](_0x1bac83)[_0x621f('0x27')]();};}function respondWithResult(_0x2ba9b3,_0x11ce41){_0x11ce41=_0x11ce41||0xc8;return function(_0x590857){if(_0x590857){return _0x2ba9b3[_0x621f('0x28')](_0x11ce41)[_0x621f('0x29')](_0x590857);}};}function respondWithFilteredResult(_0x398dfd,_0x1f6148){return function(_0x2538db){if(_0x2538db){var _0x2c2e7c=_0x2538db[_0x621f('0x2a')],_0x445b49=_0x1f6148['offset'],_0x4ba445=_0x1f6148[_0x621f('0x2b')]+_0x1f6148['limit'],_0x488e96;if(_0x4ba445>=_0x2c2e7c){_0x4ba445=_0x2c2e7c;_0x488e96=0xc8;}else{_0x488e96=0xce;}_0x398dfd[_0x621f('0x28')](_0x488e96);return _0x398dfd[_0x621f('0x2c')](_0x621f('0x2d'),_0x445b49+'-'+_0x4ba445+'/'+_0x2c2e7c)[_0x621f('0x29')](_0x2538db);}return null;};}function patchUpdates(_0x14096d){return function(_0xf01437){try{jsonpatch[_0x621f('0x2e')](_0xf01437,_0x14096d,!![]);}catch(_0x275f0b){return BPromise['reject'](_0x275f0b);}return _0xf01437['save']();};}function saveUpdates(_0x66a6dd,_0x199988){return function(_0x39676c){if(_0x39676c){return _0x39676c['update'](_0x66a6dd)[_0x621f('0x1c')](function(_0x3e652f){return _0x3e652f;});}return null;};}function removeEntity(_0x301018,_0x4dea2a){return function(_0x1e4d83){if(_0x1e4d83){return _0x1e4d83[_0x621f('0x2f')]()[_0x621f('0x1c')](function(){_0x301018[_0x621f('0x28')](0xcc)[_0x621f('0x27')]();});}};}function handleEntityNotFound(_0x46d7f8,_0x9794fb){return function(_0x3efc92){if(!_0x3efc92){_0x46d7f8[_0x621f('0x26')](0x194);}return _0x3efc92;};}function handleError(_0x288456,_0xa6e63f){_0xa6e63f=_0xa6e63f||0x1f4;return function(_0x339078){logger[_0x621f('0x20')](_0x339078['stack']);if(_0x339078[_0x621f('0x30')]){delete _0x339078[_0x621f('0x30')];}_0x288456[_0x621f('0x28')](_0xa6e63f)['send'](_0x339078);};}exports[_0x621f('0x31')]=function(_0x132398,_0x1f21b8){var _0x22603a={},_0x3b2ac8={},_0x3d0a8c={'count':0x0,'rows':[]};var _0x2cda07=_['map'](db[_0x621f('0x32')]['rawAttributes'],function(_0x1b4ad8){return{'name':_0x1b4ad8[_0x621f('0x33')],'type':_0x1b4ad8[_0x621f('0x34')][_0x621f('0x35')]};});_0x3b2ac8[_0x621f('0x36')]=_[_0x621f('0x37')](_0x2cda07,_0x621f('0x30'));_0x3b2ac8[_0x621f('0x38')]=_['keys'](_0x132398[_0x621f('0x38')]);_0x3b2ac8['filters']=_[_0x621f('0x39')](_0x3b2ac8[_0x621f('0x36')],_0x3b2ac8[_0x621f('0x38')]);_0x22603a[_0x621f('0x3a')]=_[_0x621f('0x39')](_0x3b2ac8[_0x621f('0x36')],qs[_0x621f('0x3b')](_0x132398[_0x621f('0x38')][_0x621f('0x3b')]));_0x22603a['attributes']=_0x22603a[_0x621f('0x3a')][_0x621f('0x3c')]?_0x22603a['attributes']:_0x3b2ac8[_0x621f('0x36')];if(!_0x132398['query'][_0x621f('0x3d')](_0x621f('0x3e'))){_0x22603a['limit']=qs[_0x621f('0x3f')](_0x132398['query'][_0x621f('0x3f')]);_0x22603a[_0x621f('0x2b')]=qs['offset'](_0x132398['query']['offset']);}_0x22603a['order']=qs[_0x621f('0x40')](_0x132398[_0x621f('0x38')][_0x621f('0x40')]);_0x22603a['where']=qs[_0x621f('0x41')](_[_0x621f('0x42')](_0x132398['query'],_0x3b2ac8[_0x621f('0x41')]),_0x2cda07);if(_0x132398[_0x621f('0x38')][_0x621f('0x43')]){_0x22603a[_0x621f('0x44')]=_['merge'](_0x22603a[_0x621f('0x44')],{'$or':_[_0x621f('0x37')](_0x2cda07,function(_0x2c03ab){if(_0x2c03ab[_0x621f('0x34')]!=='VIRTUAL'){var _0x2824dc={};_0x2824dc[_0x2c03ab[_0x621f('0x30')]]={'$like':'%'+_0x132398[_0x621f('0x38')]['filter']+'%'};return _0x2824dc;}})});}_0x22603a=_[_0x621f('0x45')]({},_0x22603a,_0x132398[_0x621f('0x46')]);var _0x7050cb={'where':_0x22603a[_0x621f('0x44')]};return db[_0x621f('0x32')]['count'](_0x7050cb)[_0x621f('0x1c')](function(_0x59eb02){_0x3d0a8c[_0x621f('0x2a')]=_0x59eb02;if(_0x132398[_0x621f('0x38')]['includeAll']){_0x22603a[_0x621f('0x47')]=[{'all':!![]}];}return db[_0x621f('0x32')]['findAll'](_0x22603a);})[_0x621f('0x1c')](function(_0x1a8966){_0x3d0a8c['rows']=_0x1a8966;return _0x3d0a8c;})['then'](respondWithFilteredResult(_0x1f21b8,_0x22603a))[_0x621f('0x25')](handleError(_0x1f21b8,null));};exports[_0x621f('0x48')]=function(_0x5b1a3e,_0x3383b7){var _0x2a37c9={'raw':![],'where':{'id':_0x5b1a3e['params']['id']}},_0x5ea342={};_0x5ea342[_0x621f('0x36')]=_[_0x621f('0x49')](db[_0x621f('0x32')][_0x621f('0x4a')]);_0x5ea342['query']=_['keys'](_0x5b1a3e[_0x621f('0x38')]);_0x5ea342[_0x621f('0x41')]=_[_0x621f('0x39')](_0x5ea342[_0x621f('0x36')],_0x5ea342['query']);_0x2a37c9[_0x621f('0x3a')]=_[_0x621f('0x39')](_0x5ea342[_0x621f('0x36')],qs[_0x621f('0x3b')](_0x5b1a3e['query']['fields']));_0x2a37c9['attributes']=_0x2a37c9[_0x621f('0x3a')][_0x621f('0x3c')]?_0x2a37c9['attributes']:_0x5ea342[_0x621f('0x36')];if(_0x5b1a3e['query'][_0x621f('0x4b')]){_0x2a37c9[_0x621f('0x47')]=[{'all':!![]}];}_0x2a37c9=_[_0x621f('0x45')]({},_0x2a37c9,_0x5b1a3e[_0x621f('0x46')]);return db['ServicenowConfiguration'][_0x621f('0x4c')](_0x2a37c9)[_0x621f('0x1c')](handleEntityNotFound(_0x3383b7,null))[_0x621f('0x1c')](respondWithResult(_0x3383b7,null))[_0x621f('0x25')](handleError(_0x3383b7,null));};exports[_0x621f('0x4d')]=function(_0x6a2d72,_0x100fdb){return db['ServicenowConfiguration'][_0x621f('0x4d')](_0x6a2d72[_0x621f('0x4e')],{})[_0x621f('0x1c')](respondWithResult(_0x100fdb,0xc9))[_0x621f('0x25')](handleError(_0x100fdb,null));};exports[_0x621f('0x4f')]=function(_0x133d7e,_0x8ed00b){if(_0x133d7e[_0x621f('0x4e')]['id']){delete _0x133d7e[_0x621f('0x4e')]['id'];}return db[_0x621f('0x32')][_0x621f('0x4c')]({'where':{'id':_0x133d7e[_0x621f('0x50')]['id']}})[_0x621f('0x1c')](handleEntityNotFound(_0x8ed00b,null))[_0x621f('0x1c')](saveUpdates(_0x133d7e[_0x621f('0x4e')],null))['then'](respondWithResult(_0x8ed00b,null))[_0x621f('0x25')](handleError(_0x8ed00b,null));};exports[_0x621f('0x2f')]=function(_0x102852,_0x11888a){return db[_0x621f('0x32')][_0x621f('0x4c')]({'where':{'id':_0x102852[_0x621f('0x50')]['id']}})[_0x621f('0x1c')](handleEntityNotFound(_0x11888a,null))[_0x621f('0x1c')](removeEntity(_0x11888a,null))['catch'](handleError(_0x11888a,null));};exports['getFields']=function(_0x25ffb9,_0x219fac,_0x51bed0){var _0x14b91a={};var _0x570f69={};var _0x57d250;var _0x265a84;return db[_0x621f('0x32')][_0x621f('0x51')]({'where':{'id':_0x25ffb9[_0x621f('0x50')]['id']}})[_0x621f('0x1c')](handleEntityNotFound(_0x219fac,null))[_0x621f('0x1c')](function(_0x5f17b3){if(_0x5f17b3){_0x57d250=_0x5f17b3;_0x570f69[_0x621f('0x36')]=_[_0x621f('0x49')](db['ServicenowField']['rawAttributes']);_0x570f69[_0x621f('0x38')]=_[_0x621f('0x49')](_0x25ffb9[_0x621f('0x38')]);_0x570f69[_0x621f('0x41')]=_[_0x621f('0x39')](_0x570f69[_0x621f('0x36')],_0x570f69[_0x621f('0x38')]);_0x14b91a[_0x621f('0x3a')]=_[_0x621f('0x39')](_0x570f69['model'],qs['fields'](_0x25ffb9['query'][_0x621f('0x3b')]));_0x14b91a[_0x621f('0x3a')]=_0x14b91a['attributes'][_0x621f('0x3c')]?_0x14b91a[_0x621f('0x3a')]:_0x570f69[_0x621f('0x36')];_0x14b91a[_0x621f('0x52')]=qs[_0x621f('0x40')](_0x25ffb9[_0x621f('0x38')][_0x621f('0x40')]);_0x14b91a[_0x621f('0x44')]=qs[_0x621f('0x41')](_[_0x621f('0x42')](_0x25ffb9[_0x621f('0x38')],_0x570f69[_0x621f('0x41')]));if(_0x25ffb9[_0x621f('0x38')][_0x621f('0x43')]){_0x14b91a[_0x621f('0x44')]=_['merge'](_0x14b91a['where'],{'$or':_['map'](_0x14b91a[_0x621f('0x3a')],function(_0x203c21){var _0x37b726={};_0x37b726[_0x203c21]={'$like':'%'+_0x25ffb9[_0x621f('0x38')][_0x621f('0x43')]+'%'};return _0x37b726;})});}_0x14b91a=_['merge']({},_0x14b91a,_0x25ffb9[_0x621f('0x46')]);return _0x57d250[_0x621f('0x53')](_0x14b91a);}})['then'](function(_0x15a7e8){if(_0x15a7e8){_0x265a84=_0x15a7e8[_0x621f('0x3c')];if(!_0x25ffb9['query'][_0x621f('0x3d')](_0x621f('0x3e'))){_0x14b91a[_0x621f('0x3f')]=qs[_0x621f('0x3f')](_0x25ffb9[_0x621f('0x38')][_0x621f('0x3f')]);_0x14b91a[_0x621f('0x2b')]=qs['offset'](_0x25ffb9[_0x621f('0x38')][_0x621f('0x2b')]);}return _0x57d250[_0x621f('0x53')](_0x14b91a);}})[_0x621f('0x1c')](function(_0x8ae665){if(_0x8ae665){return _0x8ae665?{'count':_0x265a84,'rows':_0x8ae665}:null;}})[_0x621f('0x1c')](respondWithResult(_0x219fac,null))[_0x621f('0x25')](handleError(_0x219fac,null));};exports[_0x621f('0x54')]=function(_0xdc491c,_0xf263d7,_0x3aac40){var _0x11d80b={};var _0x192120={};var _0x2e5036;var _0x25f41c;return db[_0x621f('0x32')]['findOne']({'where':{'id':_0xdc491c[_0x621f('0x50')]['id']}})[_0x621f('0x1c')](handleEntityNotFound(_0xf263d7,null))[_0x621f('0x1c')](function(_0x165861){if(_0x165861){_0x2e5036=_0x165861;_0x192120[_0x621f('0x36')]=_[_0x621f('0x49')](db['ServicenowField'][_0x621f('0x4a')]);_0x192120[_0x621f('0x38')]=_[_0x621f('0x49')](_0xdc491c[_0x621f('0x38')]);_0x192120['filters']=_['intersection'](_0x192120[_0x621f('0x36')],_0x192120['query']);_0x11d80b[_0x621f('0x3a')]=_[_0x621f('0x39')](_0x192120[_0x621f('0x36')],qs['fields'](_0xdc491c[_0x621f('0x38')][_0x621f('0x3b')]));_0x11d80b['attributes']=_0x11d80b['attributes']['length']?_0x11d80b[_0x621f('0x3a')]:_0x192120[_0x621f('0x36')];_0x11d80b[_0x621f('0x52')]=qs[_0x621f('0x40')](_0xdc491c['query'][_0x621f('0x40')]);_0x11d80b[_0x621f('0x44')]=qs[_0x621f('0x41')](_[_0x621f('0x42')](_0xdc491c[_0x621f('0x38')],_0x192120[_0x621f('0x41')]));if(_0xdc491c[_0x621f('0x38')][_0x621f('0x43')]){_0x11d80b[_0x621f('0x44')]=_[_0x621f('0x45')](_0x11d80b['where'],{'$or':_[_0x621f('0x37')](_0x11d80b[_0x621f('0x3a')],function(_0x5830ad){var _0xfcd1d={};_0xfcd1d[_0x5830ad]={'$like':'%'+_0xdc491c[_0x621f('0x38')][_0x621f('0x43')]+'%'};return _0xfcd1d;})});}_0x11d80b=_[_0x621f('0x45')]({},_0x11d80b,_0xdc491c[_0x621f('0x46')]);return _0x2e5036[_0x621f('0x54')](_0x11d80b);}})[_0x621f('0x1c')](function(_0x225692){if(_0x225692){_0x25f41c=_0x225692[_0x621f('0x3c')];if(!_0xdc491c[_0x621f('0x38')][_0x621f('0x3d')]('nolimit')){_0x11d80b[_0x621f('0x3f')]=qs[_0x621f('0x3f')](_0xdc491c[_0x621f('0x38')][_0x621f('0x3f')]);_0x11d80b['offset']=qs[_0x621f('0x2b')](_0xdc491c[_0x621f('0x38')][_0x621f('0x2b')]);}return _0x2e5036['getSubjects'](_0x11d80b);}})[_0x621f('0x1c')](function(_0x1ae015){if(_0x1ae015){return _0x1ae015?{'count':_0x25f41c,'rows':_0x1ae015}:null;}})[_0x621f('0x1c')](respondWithResult(_0xf263d7,null))[_0x621f('0x25')](handleError(_0xf263d7,null));};exports['getDescriptions']=function(_0x25ac9c,_0x39cd8c,_0x4af23a){var _0x195693={};var _0xfec494={};var _0x1e64b0;var _0x171dfd;return db[_0x621f('0x32')]['findOne']({'where':{'id':_0x25ac9c['params']['id']}})[_0x621f('0x1c')](handleEntityNotFound(_0x39cd8c,null))[_0x621f('0x1c')](function(_0x518831){if(_0x518831){_0x1e64b0=_0x518831;_0xfec494['model']=_['keys'](db[_0x621f('0x55')][_0x621f('0x4a')]);_0xfec494[_0x621f('0x38')]=_[_0x621f('0x49')](_0x25ac9c[_0x621f('0x38')]);_0xfec494[_0x621f('0x41')]=_[_0x621f('0x39')](_0xfec494['model'],_0xfec494['query']);_0x195693[_0x621f('0x3a')]=_['intersection'](_0xfec494[_0x621f('0x36')],qs[_0x621f('0x3b')](_0x25ac9c[_0x621f('0x38')][_0x621f('0x3b')]));_0x195693[_0x621f('0x3a')]=_0x195693[_0x621f('0x3a')]['length']?_0x195693[_0x621f('0x3a')]:_0xfec494[_0x621f('0x36')];_0x195693[_0x621f('0x52')]=qs[_0x621f('0x40')](_0x25ac9c[_0x621f('0x38')][_0x621f('0x40')]);_0x195693[_0x621f('0x44')]=qs['filters'](_[_0x621f('0x42')](_0x25ac9c['query'],_0xfec494['filters']));if(_0x25ac9c[_0x621f('0x38')][_0x621f('0x43')]){_0x195693['where']=_[_0x621f('0x45')](_0x195693['where'],{'$or':_[_0x621f('0x37')](_0x195693[_0x621f('0x3a')],function(_0x39465c){var _0x473a56={};_0x473a56[_0x39465c]={'$like':'%'+_0x25ac9c[_0x621f('0x38')]['filter']+'%'};return _0x473a56;})});}_0x195693=_['merge']({},_0x195693,_0x25ac9c[_0x621f('0x46')]);return _0x1e64b0[_0x621f('0x56')](_0x195693);}})[_0x621f('0x1c')](function(_0x16f2dd){if(_0x16f2dd){_0x171dfd=_0x16f2dd[_0x621f('0x3c')];if(!_0x25ac9c[_0x621f('0x38')][_0x621f('0x3d')](_0x621f('0x3e'))){_0x195693[_0x621f('0x3f')]=qs[_0x621f('0x3f')](_0x25ac9c['query'][_0x621f('0x3f')]);_0x195693[_0x621f('0x2b')]=qs[_0x621f('0x2b')](_0x25ac9c[_0x621f('0x38')]['offset']);}return _0x1e64b0['getDescriptions'](_0x195693);}})['then'](function(_0x496a25){if(_0x496a25){return _0x496a25?{'count':_0x171dfd,'rows':_0x496a25}:null;}})[_0x621f('0x1c')](respondWithResult(_0x39cd8c,null))[_0x621f('0x25')](handleError(_0x39cd8c,null));};
\ No newline at end of file
+var _0xd62b=['result','catch','sendStatus','status','count','offset','limit','Content-Range','json','reject','destroy','end','stack','name','index','ServicenowConfiguration','type','key','map','query','keys','intersection','attributes','model','fields','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','length','find','create','body','getFields','findOne','rawAttributes','getSubjects','getDescriptions','ServicenowField','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','ServicenowConfiguration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info'];(function(_0x4bc4c4,_0x5d6c2c){var _0x2b5b13=function(_0x991e28){while(--_0x991e28){_0x4bc4c4['push'](_0x4bc4c4['shift']());}};_0x2b5b13(++_0x5d6c2c);}(_0xd62b,0x8c));var _0xbd62=function(_0x53b594,_0x559767){_0x53b594=_0x53b594-0x0;var _0x1e616f=_0xd62b[_0x53b594];return _0x1e616f;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xbd62('0x0'));var zipdir=require(_0xbd62('0x1'));var jsonpatch=require(_0xbd62('0x2'));var rp=require('request-promise');var moment=require(_0xbd62('0x3'));var BPromise=require(_0xbd62('0x4'));var Mustache=require(_0xbd62('0x5'));var util=require(_0xbd62('0x6'));var path=require(_0xbd62('0x7'));var sox=require(_0xbd62('0x8'));var csv=require(_0xbd62('0x9'));var ejs=require(_0xbd62('0xa'));var fs=require('fs');var _=require(_0xbd62('0xb'));var squel=require('squel');var crypto=require(_0xbd62('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xbd62('0x9'));var querystring=require(_0xbd62('0xd'));var Papa=require(_0xbd62('0xe'));var Redis=require(_0xbd62('0xf'));var authService=require(_0xbd62('0x10'));var qs=require(_0xbd62('0x11'));var as=require(_0xbd62('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xbd62('0x13'));var utils=require(_0xbd62('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xbd62('0x15'));var db=require(_0xbd62('0x16'))['db'];var jayson=require(_0xbd62('0x17'));var client=jayson[_0xbd62('0x18')][_0xbd62('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x3d74b6,_0x5968df,_0x42997e,_0x351594){return new BPromise(function(_0x17146f,_0x54527b){var _0x10d00c=_0x351594||client;return _0x10d00c[_0xbd62('0x1a')](_0x3d74b6,_0x42997e)[_0xbd62('0x1b')](function(_0x5cd7e0){logger['info'](_0xbd62('0x1c'),_0x5968df,_0xbd62('0x1d'));logger[_0xbd62('0x1e')]('ServicenowConfiguration,\x20%s,\x20%s,\x20%s',_0x5968df,'request\x20sent',JSON[_0xbd62('0x1f')](_0x5cd7e0));if(_0x5cd7e0[_0xbd62('0x20')]){if(_0x5cd7e0[_0xbd62('0x20')][_0xbd62('0x21')]===0x1f4){logger[_0xbd62('0x20')](_0xbd62('0x1c'),_0x5968df,_0x5cd7e0['error'][_0xbd62('0x22')]);return _0x54527b(_0x5cd7e0['error']['message']);}logger[_0xbd62('0x20')](_0xbd62('0x1c'),_0x5968df,_0x5cd7e0[_0xbd62('0x20')]['message']);return _0x17146f(_0x5cd7e0[_0xbd62('0x20')][_0xbd62('0x22')]);}else{logger[_0xbd62('0x23')]('ServicenowConfiguration,\x20%s,\x20%s',_0x5968df,_0xbd62('0x1d'));_0x17146f(_0x5cd7e0[_0xbd62('0x24')][_0xbd62('0x22')]);}})[_0xbd62('0x25')](function(_0x35238a){logger[_0xbd62('0x20')](_0xbd62('0x1c'),_0x5968df,_0x35238a);_0x54527b(_0x35238a);});});}function respondWithStatusCode(_0x1bca75,_0x328868){_0x328868=_0x328868||0xcc;return function(_0x1b8fbe){if(_0x1b8fbe){return _0x1bca75[_0xbd62('0x26')](_0x328868);}return _0x1bca75[_0xbd62('0x27')](_0x328868)['end']();};}function respondWithResult(_0x28fabc,_0x3e1222){_0x3e1222=_0x3e1222||0xc8;return function(_0x5c512b){if(_0x5c512b){return _0x28fabc['status'](_0x3e1222)['json'](_0x5c512b);}};}function respondWithFilteredResult(_0x568f6e,_0xdf69aa){return function(_0x55359a){if(_0x55359a){var _0x582a0e=_0x55359a[_0xbd62('0x28')],_0x34bcc3=_0xdf69aa[_0xbd62('0x29')],_0x2077a9=_0xdf69aa[_0xbd62('0x29')]+_0xdf69aa[_0xbd62('0x2a')],_0x361089;if(_0x2077a9>=_0x582a0e){_0x2077a9=_0x582a0e;_0x361089=0xc8;}else{_0x361089=0xce;}_0x568f6e[_0xbd62('0x27')](_0x361089);return _0x568f6e['set'](_0xbd62('0x2b'),_0x34bcc3+'-'+_0x2077a9+'/'+_0x582a0e)[_0xbd62('0x2c')](_0x55359a);}return null;};}function patchUpdates(_0x2340eb){return function(_0x1a58d5){try{jsonpatch['apply'](_0x1a58d5,_0x2340eb,!![]);}catch(_0x2e500a){return BPromise[_0xbd62('0x2d')](_0x2e500a);}return _0x1a58d5['save']();};}function saveUpdates(_0x404342,_0x2f300e){return function(_0x4878c3){if(_0x4878c3){return _0x4878c3['update'](_0x404342)[_0xbd62('0x1b')](function(_0x117952){return _0x117952;});}return null;};}function removeEntity(_0x50d01c,_0x3a326b){return function(_0x230b82){if(_0x230b82){return _0x230b82[_0xbd62('0x2e')]()[_0xbd62('0x1b')](function(){_0x50d01c[_0xbd62('0x27')](0xcc)[_0xbd62('0x2f')]();});}};}function handleEntityNotFound(_0xd9871a,_0x15ff71){return function(_0x1e0b19){if(!_0x1e0b19){_0xd9871a[_0xbd62('0x26')](0x194);}return _0x1e0b19;};}function handleError(_0x4f57d2,_0x3d8465){_0x3d8465=_0x3d8465||0x1f4;return function(_0x389f3a){logger['error'](_0x389f3a[_0xbd62('0x30')]);if(_0x389f3a[_0xbd62('0x31')]){delete _0x389f3a[_0xbd62('0x31')];}_0x4f57d2[_0xbd62('0x27')](_0x3d8465)['send'](_0x389f3a);};}exports[_0xbd62('0x32')]=function(_0x4b7346,_0x2d9acc){var _0x2f9e9d={},_0x1086bd={},_0x1a27e3={'count':0x0,'rows':[]};var _0x33ce37=_['map'](db[_0xbd62('0x33')]['rawAttributes'],function(_0xec8aa1){return{'name':_0xec8aa1['fieldName'],'type':_0xec8aa1[_0xbd62('0x34')][_0xbd62('0x35')]};});_0x1086bd['model']=_[_0xbd62('0x36')](_0x33ce37,_0xbd62('0x31'));_0x1086bd[_0xbd62('0x37')]=_[_0xbd62('0x38')](_0x4b7346['query']);_0x1086bd['filters']=_[_0xbd62('0x39')](_0x1086bd['model'],_0x1086bd[_0xbd62('0x37')]);_0x2f9e9d[_0xbd62('0x3a')]=_[_0xbd62('0x39')](_0x1086bd[_0xbd62('0x3b')],qs['fields'](_0x4b7346[_0xbd62('0x37')][_0xbd62('0x3c')]));_0x2f9e9d['attributes']=_0x2f9e9d['attributes']['length']?_0x2f9e9d['attributes']:_0x1086bd[_0xbd62('0x3b')];if(!_0x4b7346[_0xbd62('0x37')][_0xbd62('0x3d')](_0xbd62('0x3e'))){_0x2f9e9d[_0xbd62('0x2a')]=qs[_0xbd62('0x2a')](_0x4b7346[_0xbd62('0x37')][_0xbd62('0x2a')]);_0x2f9e9d[_0xbd62('0x29')]=qs['offset'](_0x4b7346[_0xbd62('0x37')]['offset']);}_0x2f9e9d[_0xbd62('0x3f')]=qs[_0xbd62('0x40')](_0x4b7346['query'][_0xbd62('0x40')]);_0x2f9e9d['where']=qs[_0xbd62('0x41')](_[_0xbd62('0x42')](_0x4b7346['query'],_0x1086bd['filters']),_0x33ce37);if(_0x4b7346['query'][_0xbd62('0x43')]){_0x2f9e9d[_0xbd62('0x44')]=_[_0xbd62('0x45')](_0x2f9e9d[_0xbd62('0x44')],{'$or':_[_0xbd62('0x36')](_0x33ce37,function(_0xa90dd){if(_0xa90dd[_0xbd62('0x34')]!==_0xbd62('0x46')){var _0x5406f8={};_0x5406f8[_0xa90dd[_0xbd62('0x31')]]={'$like':'%'+_0x4b7346[_0xbd62('0x37')][_0xbd62('0x43')]+'%'};return _0x5406f8;}})});}_0x2f9e9d=_[_0xbd62('0x45')]({},_0x2f9e9d,_0x4b7346[_0xbd62('0x47')]);var _0x1474a3={'where':_0x2f9e9d[_0xbd62('0x44')]};return db[_0xbd62('0x33')][_0xbd62('0x28')](_0x1474a3)[_0xbd62('0x1b')](function(_0x4f0986){_0x1a27e3['count']=_0x4f0986;if(_0x4b7346[_0xbd62('0x37')][_0xbd62('0x48')]){_0x2f9e9d[_0xbd62('0x49')]=[{'all':!![]}];}return db[_0xbd62('0x33')][_0xbd62('0x4a')](_0x2f9e9d);})[_0xbd62('0x1b')](function(_0x506d3d){_0x1a27e3[_0xbd62('0x4b')]=_0x506d3d;return _0x1a27e3;})[_0xbd62('0x1b')](respondWithFilteredResult(_0x2d9acc,_0x2f9e9d))[_0xbd62('0x25')](handleError(_0x2d9acc,null));};exports[_0xbd62('0x4c')]=function(_0x31a116,_0x45c35f){var _0x248699={'raw':![],'where':{'id':_0x31a116[_0xbd62('0x4d')]['id']}},_0x28b201={};_0x28b201[_0xbd62('0x3b')]=_[_0xbd62('0x38')](db[_0xbd62('0x33')]['rawAttributes']);_0x28b201[_0xbd62('0x37')]=_[_0xbd62('0x38')](_0x31a116[_0xbd62('0x37')]);_0x28b201[_0xbd62('0x41')]=_[_0xbd62('0x39')](_0x28b201['model'],_0x28b201[_0xbd62('0x37')]);_0x248699['attributes']=_[_0xbd62('0x39')](_0x28b201[_0xbd62('0x3b')],qs['fields'](_0x31a116[_0xbd62('0x37')][_0xbd62('0x3c')]));_0x248699[_0xbd62('0x3a')]=_0x248699[_0xbd62('0x3a')][_0xbd62('0x4e')]?_0x248699['attributes']:_0x28b201['model'];if(_0x31a116[_0xbd62('0x37')]['includeAll']){_0x248699[_0xbd62('0x49')]=[{'all':!![]}];}_0x248699=_[_0xbd62('0x45')]({},_0x248699,_0x31a116[_0xbd62('0x47')]);return db[_0xbd62('0x33')][_0xbd62('0x4f')](_0x248699)[_0xbd62('0x1b')](handleEntityNotFound(_0x45c35f,null))[_0xbd62('0x1b')](respondWithResult(_0x45c35f,null))[_0xbd62('0x25')](handleError(_0x45c35f,null));};exports[_0xbd62('0x50')]=function(_0x776195,_0xb3f4b6){return db['ServicenowConfiguration'][_0xbd62('0x50')](_0x776195[_0xbd62('0x51')],{})[_0xbd62('0x1b')](respondWithResult(_0xb3f4b6,0xc9))[_0xbd62('0x25')](handleError(_0xb3f4b6,null));};exports['update']=function(_0x37f364,_0x1bc630){if(_0x37f364['body']['id']){delete _0x37f364['body']['id'];}return db[_0xbd62('0x33')][_0xbd62('0x4f')]({'where':{'id':_0x37f364[_0xbd62('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1bc630,null))[_0xbd62('0x1b')](saveUpdates(_0x37f364['body'],null))[_0xbd62('0x1b')](respondWithResult(_0x1bc630,null))[_0xbd62('0x25')](handleError(_0x1bc630,null));};exports['destroy']=function(_0x187fb4,_0x4fdbc4){return db[_0xbd62('0x33')][_0xbd62('0x4f')]({'where':{'id':_0x187fb4[_0xbd62('0x4d')]['id']}})[_0xbd62('0x1b')](handleEntityNotFound(_0x4fdbc4,null))['then'](removeEntity(_0x4fdbc4,null))[_0xbd62('0x25')](handleError(_0x4fdbc4,null));};exports[_0xbd62('0x52')]=function(_0x312080,_0x1ec2c9,_0x5763c9){var _0x2b3898={};var _0x17eae5={};var _0x3d42ce;var _0x5501ee;return db[_0xbd62('0x33')][_0xbd62('0x53')]({'where':{'id':_0x312080['params']['id']}})[_0xbd62('0x1b')](handleEntityNotFound(_0x1ec2c9,null))['then'](function(_0x39d74f){if(_0x39d74f){_0x3d42ce=_0x39d74f;_0x17eae5['model']=_[_0xbd62('0x38')](db['ServicenowField'][_0xbd62('0x54')]);_0x17eae5['query']=_[_0xbd62('0x38')](_0x312080['query']);_0x17eae5[_0xbd62('0x41')]=_['intersection'](_0x17eae5['model'],_0x17eae5[_0xbd62('0x37')]);_0x2b3898[_0xbd62('0x3a')]=_['intersection'](_0x17eae5[_0xbd62('0x3b')],qs['fields'](_0x312080[_0xbd62('0x37')][_0xbd62('0x3c')]));_0x2b3898[_0xbd62('0x3a')]=_0x2b3898[_0xbd62('0x3a')]['length']?_0x2b3898[_0xbd62('0x3a')]:_0x17eae5[_0xbd62('0x3b')];_0x2b3898['order']=qs[_0xbd62('0x40')](_0x312080[_0xbd62('0x37')][_0xbd62('0x40')]);_0x2b3898[_0xbd62('0x44')]=qs[_0xbd62('0x41')](_[_0xbd62('0x42')](_0x312080[_0xbd62('0x37')],_0x17eae5[_0xbd62('0x41')]));if(_0x312080[_0xbd62('0x37')]['filter']){_0x2b3898[_0xbd62('0x44')]=_[_0xbd62('0x45')](_0x2b3898[_0xbd62('0x44')],{'$or':_[_0xbd62('0x36')](_0x2b3898['attributes'],function(_0x2d5a66){var _0x2948ac={};_0x2948ac[_0x2d5a66]={'$like':'%'+_0x312080[_0xbd62('0x37')][_0xbd62('0x43')]+'%'};return _0x2948ac;})});}_0x2b3898=_[_0xbd62('0x45')]({},_0x2b3898,_0x312080[_0xbd62('0x47')]);return _0x3d42ce[_0xbd62('0x52')](_0x2b3898);}})[_0xbd62('0x1b')](function(_0xb58b51){if(_0xb58b51){_0x5501ee=_0xb58b51[_0xbd62('0x4e')];if(!_0x312080[_0xbd62('0x37')]['hasOwnProperty']('nolimit')){_0x2b3898[_0xbd62('0x2a')]=qs[_0xbd62('0x2a')](_0x312080[_0xbd62('0x37')]['limit']);_0x2b3898['offset']=qs['offset'](_0x312080[_0xbd62('0x37')][_0xbd62('0x29')]);}return _0x3d42ce[_0xbd62('0x52')](_0x2b3898);}})['then'](function(_0x5b2d21){if(_0x5b2d21){return _0x5b2d21?{'count':_0x5501ee,'rows':_0x5b2d21}:null;}})[_0xbd62('0x1b')](respondWithResult(_0x1ec2c9,null))[_0xbd62('0x25')](handleError(_0x1ec2c9,null));};exports['getSubjects']=function(_0x31bb06,_0x5ebdf3,_0x5d9efc){var _0xc95b36={};var _0x549170={};var _0x27a24b;var _0x1058fa;return db[_0xbd62('0x33')][_0xbd62('0x53')]({'where':{'id':_0x31bb06[_0xbd62('0x4d')]['id']}})[_0xbd62('0x1b')](handleEntityNotFound(_0x5ebdf3,null))['then'](function(_0x5f2111){if(_0x5f2111){_0x27a24b=_0x5f2111;_0x549170[_0xbd62('0x3b')]=_['keys'](db['ServicenowField'][_0xbd62('0x54')]);_0x549170['query']=_['keys'](_0x31bb06[_0xbd62('0x37')]);_0x549170['filters']=_[_0xbd62('0x39')](_0x549170[_0xbd62('0x3b')],_0x549170[_0xbd62('0x37')]);_0xc95b36[_0xbd62('0x3a')]=_['intersection'](_0x549170['model'],qs['fields'](_0x31bb06[_0xbd62('0x37')]['fields']));_0xc95b36[_0xbd62('0x3a')]=_0xc95b36[_0xbd62('0x3a')][_0xbd62('0x4e')]?_0xc95b36[_0xbd62('0x3a')]:_0x549170[_0xbd62('0x3b')];_0xc95b36['order']=qs[_0xbd62('0x40')](_0x31bb06[_0xbd62('0x37')][_0xbd62('0x40')]);_0xc95b36[_0xbd62('0x44')]=qs[_0xbd62('0x41')](_[_0xbd62('0x42')](_0x31bb06[_0xbd62('0x37')],_0x549170[_0xbd62('0x41')]));if(_0x31bb06[_0xbd62('0x37')][_0xbd62('0x43')]){_0xc95b36[_0xbd62('0x44')]=_[_0xbd62('0x45')](_0xc95b36[_0xbd62('0x44')],{'$or':_[_0xbd62('0x36')](_0xc95b36['attributes'],function(_0x1138ac){var _0x5eaa8a={};_0x5eaa8a[_0x1138ac]={'$like':'%'+_0x31bb06[_0xbd62('0x37')][_0xbd62('0x43')]+'%'};return _0x5eaa8a;})});}_0xc95b36=_['merge']({},_0xc95b36,_0x31bb06[_0xbd62('0x47')]);return _0x27a24b['getSubjects'](_0xc95b36);}})[_0xbd62('0x1b')](function(_0x1553ef){if(_0x1553ef){_0x1058fa=_0x1553ef['length'];if(!_0x31bb06[_0xbd62('0x37')]['hasOwnProperty'](_0xbd62('0x3e'))){_0xc95b36['limit']=qs[_0xbd62('0x2a')](_0x31bb06[_0xbd62('0x37')][_0xbd62('0x2a')]);_0xc95b36['offset']=qs[_0xbd62('0x29')](_0x31bb06[_0xbd62('0x37')][_0xbd62('0x29')]);}return _0x27a24b[_0xbd62('0x55')](_0xc95b36);}})[_0xbd62('0x1b')](function(_0x2881a8){if(_0x2881a8){return _0x2881a8?{'count':_0x1058fa,'rows':_0x2881a8}:null;}})[_0xbd62('0x1b')](respondWithResult(_0x5ebdf3,null))[_0xbd62('0x25')](handleError(_0x5ebdf3,null));};exports[_0xbd62('0x56')]=function(_0x48127f,_0x5b947a,_0x52b020){var _0xe6fe52={};var _0x3df30b={};var _0xcfd590;var _0x522be7;return db[_0xbd62('0x33')][_0xbd62('0x53')]({'where':{'id':_0x48127f[_0xbd62('0x4d')]['id']}})[_0xbd62('0x1b')](handleEntityNotFound(_0x5b947a,null))[_0xbd62('0x1b')](function(_0x19a0eb){if(_0x19a0eb){_0xcfd590=_0x19a0eb;_0x3df30b['model']=_[_0xbd62('0x38')](db[_0xbd62('0x57')][_0xbd62('0x54')]);_0x3df30b[_0xbd62('0x37')]=_[_0xbd62('0x38')](_0x48127f[_0xbd62('0x37')]);_0x3df30b['filters']=_[_0xbd62('0x39')](_0x3df30b[_0xbd62('0x3b')],_0x3df30b[_0xbd62('0x37')]);_0xe6fe52[_0xbd62('0x3a')]=_[_0xbd62('0x39')](_0x3df30b[_0xbd62('0x3b')],qs[_0xbd62('0x3c')](_0x48127f['query'][_0xbd62('0x3c')]));_0xe6fe52[_0xbd62('0x3a')]=_0xe6fe52[_0xbd62('0x3a')][_0xbd62('0x4e')]?_0xe6fe52[_0xbd62('0x3a')]:_0x3df30b['model'];_0xe6fe52[_0xbd62('0x3f')]=qs['sort'](_0x48127f['query'][_0xbd62('0x40')]);_0xe6fe52['where']=qs[_0xbd62('0x41')](_['pick'](_0x48127f[_0xbd62('0x37')],_0x3df30b['filters']));if(_0x48127f[_0xbd62('0x37')][_0xbd62('0x43')]){_0xe6fe52[_0xbd62('0x44')]=_['merge'](_0xe6fe52[_0xbd62('0x44')],{'$or':_[_0xbd62('0x36')](_0xe6fe52[_0xbd62('0x3a')],function(_0x33ad65){var _0x39f0db={};_0x39f0db[_0x33ad65]={'$like':'%'+_0x48127f['query'][_0xbd62('0x43')]+'%'};return _0x39f0db;})});}_0xe6fe52=_[_0xbd62('0x45')]({},_0xe6fe52,_0x48127f[_0xbd62('0x47')]);return _0xcfd590[_0xbd62('0x56')](_0xe6fe52);}})[_0xbd62('0x1b')](function(_0x2c3fc5){if(_0x2c3fc5){_0x522be7=_0x2c3fc5['length'];if(!_0x48127f['query']['hasOwnProperty'](_0xbd62('0x3e'))){_0xe6fe52[_0xbd62('0x2a')]=qs[_0xbd62('0x2a')](_0x48127f['query'][_0xbd62('0x2a')]);_0xe6fe52[_0xbd62('0x29')]=qs[_0xbd62('0x29')](_0x48127f[_0xbd62('0x37')][_0xbd62('0x29')]);}return _0xcfd590[_0xbd62('0x56')](_0xe6fe52);}})['then'](function(_0x58e827){if(_0x58e827){return _0x58e827?{'count':_0x522be7,'rows':_0x58e827}:null;}})[_0xbd62('0x1b')](respondWithResult(_0x5b947a,null))['catch'](handleError(_0x5b947a,null));};
\ No newline at end of file