Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / intServicenowConfiguration / intServicenowConfiguration.controller.js
index d4830ba..420045f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbced=['rawAttributes','fieldName','key','model','map','name','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','then','includeAll','include','rows','catch','show','params','ServicenowConfiguration','find','body','getFields','findOne','ServicenowField','length','getSubjects','getDescriptions','eml-format','rimraf','bluebird','path','to-csv','ejs','fs-extra','lodash','crypto','desk.js','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','save','update','index'];(function(_0x3c2b91,_0x5dd910){var _0x519192=function(_0x1a5f9a){while(--_0x1a5f9a){_0x3c2b91['push'](_0x3c2b91['shift']());}};_0x519192(++_0x5dd910);}(_0xbced,0x185));var _0xdbce=function(_0x5c5d9b,_0x2fbfb1){_0x5c5d9b=_0x5c5d9b-0x0;var _0x40ca79=_0xbced[_0x5c5d9b];return _0x40ca79;};'use strict';var emlformat=require(_0xdbce('0x0'));var rimraf=require(_0xdbce('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xdbce('0x2'));var Mustache=require('mustache');var util=require('util');var path=require(_0xdbce('0x3'));var sox=require('sox');var csv=require(_0xdbce('0x4'));var ejs=require(_0xdbce('0x5'));var fs=require('fs');var fs_extra=require(_0xdbce('0x6'));var _=require(_0xdbce('0x7'));var squel=require('squel');var crypto=require(_0xdbce('0x8'));var jsforce=require('jsforce');var deskjs=require(_0xdbce('0x9'));var toCsv=require(_0xdbce('0x4'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xdbce('0xa'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xdbce('0xb'));var logger=require(_0xdbce('0xc'))('api');var utils=require(_0xdbce('0xd'));var config=require(_0xdbce('0xe'));var licenseUtil=require(_0xdbce('0xf'));var db=require(_0xdbce('0x10'))['db'];function respondWithStatusCode(_0x192370,_0x25a895){_0x25a895=_0x25a895||0xcc;return function(_0x5cdce0){if(_0x5cdce0){return _0x192370[_0xdbce('0x11')](_0x25a895);}return _0x192370[_0xdbce('0x12')](_0x25a895)[_0xdbce('0x13')]();};}function respondWithResult(_0x2dbb42,_0x293fe8){_0x293fe8=_0x293fe8||0xc8;return function(_0x46342b){if(_0x46342b){return _0x2dbb42['status'](_0x293fe8)[_0xdbce('0x14')](_0x46342b);}};}function respondWithFilteredResult(_0x1bf427,_0x2ca6f0){return function(_0x56a716){if(_0x56a716){var _0x1302ca=typeof _0x2ca6f0['offset']===_0xdbce('0x15')&&typeof _0x2ca6f0[_0xdbce('0x16')]===_0xdbce('0x15');var _0x2eb063=_0x56a716[_0xdbce('0x17')];var _0x913359=_0x1302ca?0x0:_0x2ca6f0[_0xdbce('0x18')];var _0x26f44b=_0x1302ca?_0x56a716[_0xdbce('0x17')]:_0x2ca6f0[_0xdbce('0x18')]+_0x2ca6f0[_0xdbce('0x16')];var _0x5cee36;if(_0x26f44b>=_0x2eb063){_0x26f44b=_0x2eb063;_0x5cee36=0xc8;}else{_0x5cee36=0xce;}_0x1bf427['status'](_0x5cee36);return _0x1bf427[_0xdbce('0x19')](_0xdbce('0x1a'),_0x913359+'-'+_0x26f44b+'/'+_0x2eb063)[_0xdbce('0x14')](_0x56a716);}return null;};}function patchUpdates(_0x3361ea){return function(_0x4da8e4){try{jsonpatch[_0xdbce('0x1b')](_0x4da8e4,_0x3361ea,!![]);}catch(_0x56c3d7){return BPromise['reject'](_0x56c3d7);}return _0x4da8e4[_0xdbce('0x1c')]();};}function saveUpdates(_0x26d4e5,_0x2349fb){return function(_0x1b2bc5){if(_0x1b2bc5){return _0x1b2bc5[_0xdbce('0x1d')](_0x26d4e5)['then'](function(_0x151b84){return _0x151b84;});}return null;};}function removeEntity(_0x5ace02,_0x309fd4){return function(_0x2a69d8){if(_0x2a69d8){return _0x2a69d8['destroy']()['then'](function(){_0x5ace02['status'](0xcc)[_0xdbce('0x13')]();});}};}function handleEntityNotFound(_0x5bc57e,_0x24564a){return function(_0x348e99){if(!_0x348e99){_0x5bc57e[_0xdbce('0x11')](0x194);}return _0x348e99;};}function handleError(_0x464413,_0x33fcfe){_0x33fcfe=_0x33fcfe||0x1f4;return function(_0x39f864){logger['error'](_0x39f864['stack']);if(_0x39f864['name']){delete _0x39f864['name'];}_0x464413[_0xdbce('0x12')](_0x33fcfe)['send'](_0x39f864);};}exports[_0xdbce('0x1e')]=function(_0x40c3fb,_0x30a766){var _0xcc6bef={},_0x27ce51={},_0x5b83e8={'count':0x0,'rows':[]};var _0x4ce881=_['map'](db['ServicenowConfiguration'][_0xdbce('0x1f')],function(_0x407e75){return{'name':_0x407e75[_0xdbce('0x20')],'type':_0x407e75['type'][_0xdbce('0x21')]};});_0x27ce51[_0xdbce('0x22')]=_[_0xdbce('0x23')](_0x4ce881,_0xdbce('0x24'));_0x27ce51['query']=_[_0xdbce('0x25')](_0x40c3fb[_0xdbce('0x26')]);_0x27ce51[_0xdbce('0x27')]=_[_0xdbce('0x28')](_0x27ce51[_0xdbce('0x22')],_0x27ce51[_0xdbce('0x26')]);_0xcc6bef[_0xdbce('0x29')]=_[_0xdbce('0x28')](_0x27ce51[_0xdbce('0x22')],qs[_0xdbce('0x2a')](_0x40c3fb[_0xdbce('0x26')][_0xdbce('0x2a')]));_0xcc6bef[_0xdbce('0x29')]=_0xcc6bef[_0xdbce('0x29')]['length']?_0xcc6bef[_0xdbce('0x29')]:_0x27ce51[_0xdbce('0x22')];if(!_0x40c3fb['query'][_0xdbce('0x2b')](_0xdbce('0x2c'))){_0xcc6bef[_0xdbce('0x16')]=qs[_0xdbce('0x16')](_0x40c3fb[_0xdbce('0x26')]['limit']);_0xcc6bef[_0xdbce('0x18')]=qs[_0xdbce('0x18')](_0x40c3fb[_0xdbce('0x26')]['offset']);}_0xcc6bef[_0xdbce('0x2d')]=qs[_0xdbce('0x2e')](_0x40c3fb[_0xdbce('0x26')]['sort']);_0xcc6bef[_0xdbce('0x2f')]=qs[_0xdbce('0x27')](_[_0xdbce('0x30')](_0x40c3fb['query'],_0x27ce51[_0xdbce('0x27')]),_0x4ce881);if(_0x40c3fb[_0xdbce('0x26')][_0xdbce('0x31')]){_0xcc6bef[_0xdbce('0x2f')]=_[_0xdbce('0x32')](_0xcc6bef['where'],{'$or':_[_0xdbce('0x23')](_0x4ce881,function(_0x3dad68){if(_0x3dad68[_0xdbce('0x33')]!==_0xdbce('0x34')){var _0x3998f5={};_0x3998f5[_0x3dad68[_0xdbce('0x24')]]={'$like':'%'+_0x40c3fb[_0xdbce('0x26')][_0xdbce('0x31')]+'%'};return _0x3998f5;}})});}_0xcc6bef=_[_0xdbce('0x32')]({},_0xcc6bef,_0x40c3fb[_0xdbce('0x35')]);var _0x229db6={'where':_0xcc6bef[_0xdbce('0x2f')]};return db['ServicenowConfiguration'][_0xdbce('0x17')](_0x229db6)[_0xdbce('0x36')](function(_0x7b478b){_0x5b83e8['count']=_0x7b478b;if(_0x40c3fb[_0xdbce('0x26')][_0xdbce('0x37')]){_0xcc6bef[_0xdbce('0x38')]=[{'all':!![]}];}return db['ServicenowConfiguration']['findAll'](_0xcc6bef);})[_0xdbce('0x36')](function(_0x4d7fca){_0x5b83e8[_0xdbce('0x39')]=_0x4d7fca;return _0x5b83e8;})[_0xdbce('0x36')](respondWithFilteredResult(_0x30a766,_0xcc6bef))[_0xdbce('0x3a')](handleError(_0x30a766,null));};exports[_0xdbce('0x3b')]=function(_0x2aef7b,_0x4a76f8){var _0x3ba60d={'raw':![],'where':{'id':_0x2aef7b[_0xdbce('0x3c')]['id']}},_0x568303={};_0x568303[_0xdbce('0x22')]=_[_0xdbce('0x25')](db['ServicenowConfiguration'][_0xdbce('0x1f')]);_0x568303[_0xdbce('0x26')]=_[_0xdbce('0x25')](_0x2aef7b[_0xdbce('0x26')]);_0x568303[_0xdbce('0x27')]=_[_0xdbce('0x28')](_0x568303[_0xdbce('0x22')],_0x568303[_0xdbce('0x26')]);_0x3ba60d[_0xdbce('0x29')]=_[_0xdbce('0x28')](_0x568303[_0xdbce('0x22')],qs[_0xdbce('0x2a')](_0x2aef7b[_0xdbce('0x26')]['fields']));_0x3ba60d[_0xdbce('0x29')]=_0x3ba60d[_0xdbce('0x29')]['length']?_0x3ba60d['attributes']:_0x568303[_0xdbce('0x22')];if(_0x2aef7b[_0xdbce('0x26')][_0xdbce('0x37')]){_0x3ba60d['include']=[{'all':!![]}];}_0x3ba60d=_[_0xdbce('0x32')]({},_0x3ba60d,_0x2aef7b[_0xdbce('0x35')]);return db[_0xdbce('0x3d')][_0xdbce('0x3e')](_0x3ba60d)[_0xdbce('0x36')](handleEntityNotFound(_0x4a76f8,null))['then'](respondWithResult(_0x4a76f8,null))[_0xdbce('0x3a')](handleError(_0x4a76f8,null));};exports['create']=function(_0x2f0d40,_0x170049){return db[_0xdbce('0x3d')]['create'](_0x2f0d40[_0xdbce('0x3f')],{})[_0xdbce('0x36')](respondWithResult(_0x170049,0xc9))['catch'](handleError(_0x170049,null));};exports['update']=function(_0x25abaa,_0x1019ec){if(_0x25abaa[_0xdbce('0x3f')]['id']){delete _0x25abaa[_0xdbce('0x3f')]['id'];}return db['ServicenowConfiguration']['find']({'where':{'id':_0x25abaa['params']['id']}})[_0xdbce('0x36')](handleEntityNotFound(_0x1019ec,null))[_0xdbce('0x36')](saveUpdates(_0x25abaa[_0xdbce('0x3f')],null))[_0xdbce('0x36')](respondWithResult(_0x1019ec,null))[_0xdbce('0x3a')](handleError(_0x1019ec,null));};exports['destroy']=function(_0x3a3eb3,_0x3213be){return db[_0xdbce('0x3d')][_0xdbce('0x3e')]({'where':{'id':_0x3a3eb3['params']['id']}})['then'](handleEntityNotFound(_0x3213be,null))[_0xdbce('0x36')](removeEntity(_0x3213be,null))[_0xdbce('0x3a')](handleError(_0x3213be,null));};exports[_0xdbce('0x40')]=function(_0x407ab7,_0x57f1d0,_0x395243){var _0x316d3a={};var _0xf89ce={};var _0x3462fd;var _0x2f66c9;return db[_0xdbce('0x3d')][_0xdbce('0x41')]({'where':{'id':_0x407ab7['params']['id']}})[_0xdbce('0x36')](handleEntityNotFound(_0x57f1d0,null))[_0xdbce('0x36')](function(_0x26d2ca){if(_0x26d2ca){_0x3462fd=_0x26d2ca;_0xf89ce[_0xdbce('0x22')]=_[_0xdbce('0x25')](db[_0xdbce('0x42')]['rawAttributes']);_0xf89ce[_0xdbce('0x26')]=_[_0xdbce('0x25')](_0x407ab7[_0xdbce('0x26')]);_0xf89ce[_0xdbce('0x27')]=_['intersection'](_0xf89ce[_0xdbce('0x22')],_0xf89ce[_0xdbce('0x26')]);_0x316d3a[_0xdbce('0x29')]=_['intersection'](_0xf89ce[_0xdbce('0x22')],qs[_0xdbce('0x2a')](_0x407ab7[_0xdbce('0x26')][_0xdbce('0x2a')]));_0x316d3a[_0xdbce('0x29')]=_0x316d3a[_0xdbce('0x29')][_0xdbce('0x43')]?_0x316d3a[_0xdbce('0x29')]:_0xf89ce[_0xdbce('0x22')];_0x316d3a['order']=qs[_0xdbce('0x2e')](_0x407ab7['query'][_0xdbce('0x2e')]);_0x316d3a[_0xdbce('0x2f')]=qs[_0xdbce('0x27')](_[_0xdbce('0x30')](_0x407ab7[_0xdbce('0x26')],_0xf89ce['filters']));if(_0x407ab7['query']['filter']){_0x316d3a[_0xdbce('0x2f')]=_[_0xdbce('0x32')](_0x316d3a['where'],{'$or':_['map'](_0x316d3a[_0xdbce('0x29')],function(_0x1a8953){var _0x46420f={};_0x46420f[_0x1a8953]={'$like':'%'+_0x407ab7[_0xdbce('0x26')][_0xdbce('0x31')]+'%'};return _0x46420f;})});}_0x316d3a=_[_0xdbce('0x32')]({},_0x316d3a,_0x407ab7[_0xdbce('0x35')]);return _0x3462fd['getFields'](_0x316d3a);}})[_0xdbce('0x36')](function(_0x475843){if(_0x475843){_0x2f66c9=_0x475843[_0xdbce('0x43')];if(!_0x407ab7['query']['hasOwnProperty'](_0xdbce('0x2c'))){_0x316d3a['limit']=qs['limit'](_0x407ab7[_0xdbce('0x26')]['limit']);_0x316d3a[_0xdbce('0x18')]=qs[_0xdbce('0x18')](_0x407ab7[_0xdbce('0x26')]['offset']);}return _0x3462fd[_0xdbce('0x40')](_0x316d3a);}})['then'](function(_0x134614){if(_0x134614){return _0x134614?{'count':_0x2f66c9,'rows':_0x134614}:null;}})[_0xdbce('0x36')](respondWithResult(_0x57f1d0,null))[_0xdbce('0x3a')](handleError(_0x57f1d0,null));};exports[_0xdbce('0x44')]=function(_0x59d467,_0x565ef3,_0x2d22ac){var _0x5b6ed2={};var _0xd5edac={};var _0x1e041a;var _0x5bfd07;return db[_0xdbce('0x3d')]['findOne']({'where':{'id':_0x59d467[_0xdbce('0x3c')]['id']}})['then'](handleEntityNotFound(_0x565ef3,null))[_0xdbce('0x36')](function(_0x18a79a){if(_0x18a79a){_0x1e041a=_0x18a79a;_0xd5edac[_0xdbce('0x22')]=_[_0xdbce('0x25')](db[_0xdbce('0x42')][_0xdbce('0x1f')]);_0xd5edac['query']=_['keys'](_0x59d467[_0xdbce('0x26')]);_0xd5edac[_0xdbce('0x27')]=_[_0xdbce('0x28')](_0xd5edac[_0xdbce('0x22')],_0xd5edac[_0xdbce('0x26')]);_0x5b6ed2[_0xdbce('0x29')]=_[_0xdbce('0x28')](_0xd5edac[_0xdbce('0x22')],qs['fields'](_0x59d467['query']['fields']));_0x5b6ed2[_0xdbce('0x29')]=_0x5b6ed2[_0xdbce('0x29')][_0xdbce('0x43')]?_0x5b6ed2[_0xdbce('0x29')]:_0xd5edac['model'];_0x5b6ed2[_0xdbce('0x2d')]=qs[_0xdbce('0x2e')](_0x59d467[_0xdbce('0x26')][_0xdbce('0x2e')]);_0x5b6ed2[_0xdbce('0x2f')]=qs[_0xdbce('0x27')](_[_0xdbce('0x30')](_0x59d467[_0xdbce('0x26')],_0xd5edac[_0xdbce('0x27')]));if(_0x59d467[_0xdbce('0x26')][_0xdbce('0x31')]){_0x5b6ed2['where']=_[_0xdbce('0x32')](_0x5b6ed2[_0xdbce('0x2f')],{'$or':_['map'](_0x5b6ed2[_0xdbce('0x29')],function(_0x1fa1ba){var _0x19d7a7={};_0x19d7a7[_0x1fa1ba]={'$like':'%'+_0x59d467['query'][_0xdbce('0x31')]+'%'};return _0x19d7a7;})});}_0x5b6ed2=_['merge']({},_0x5b6ed2,_0x59d467[_0xdbce('0x35')]);return _0x1e041a[_0xdbce('0x44')](_0x5b6ed2);}})[_0xdbce('0x36')](function(_0x2887ec){if(_0x2887ec){_0x5bfd07=_0x2887ec[_0xdbce('0x43')];if(!_0x59d467['query'][_0xdbce('0x2b')](_0xdbce('0x2c'))){_0x5b6ed2[_0xdbce('0x16')]=qs['limit'](_0x59d467[_0xdbce('0x26')]['limit']);_0x5b6ed2[_0xdbce('0x18')]=qs[_0xdbce('0x18')](_0x59d467[_0xdbce('0x26')][_0xdbce('0x18')]);}return _0x1e041a['getSubjects'](_0x5b6ed2);}})[_0xdbce('0x36')](function(_0xcb7e39){if(_0xcb7e39){return _0xcb7e39?{'count':_0x5bfd07,'rows':_0xcb7e39}:null;}})[_0xdbce('0x36')](respondWithResult(_0x565ef3,null))['catch'](handleError(_0x565ef3,null));};exports['getDescriptions']=function(_0x30b48e,_0x469d21,_0x176a30){var _0x54c768={};var _0x343a52={};var _0x5f09af;var _0x24ce94;return db['ServicenowConfiguration'][_0xdbce('0x41')]({'where':{'id':_0x30b48e['params']['id']}})[_0xdbce('0x36')](handleEntityNotFound(_0x469d21,null))[_0xdbce('0x36')](function(_0x2e5d1f){if(_0x2e5d1f){_0x5f09af=_0x2e5d1f;_0x343a52[_0xdbce('0x22')]=_[_0xdbce('0x25')](db['ServicenowField'][_0xdbce('0x1f')]);_0x343a52[_0xdbce('0x26')]=_[_0xdbce('0x25')](_0x30b48e[_0xdbce('0x26')]);_0x343a52['filters']=_[_0xdbce('0x28')](_0x343a52[_0xdbce('0x22')],_0x343a52[_0xdbce('0x26')]);_0x54c768['attributes']=_[_0xdbce('0x28')](_0x343a52['model'],qs['fields'](_0x30b48e[_0xdbce('0x26')][_0xdbce('0x2a')]));_0x54c768[_0xdbce('0x29')]=_0x54c768[_0xdbce('0x29')][_0xdbce('0x43')]?_0x54c768['attributes']:_0x343a52['model'];_0x54c768[_0xdbce('0x2d')]=qs['sort'](_0x30b48e['query'][_0xdbce('0x2e')]);_0x54c768[_0xdbce('0x2f')]=qs['filters'](_[_0xdbce('0x30')](_0x30b48e['query'],_0x343a52['filters']));if(_0x30b48e[_0xdbce('0x26')][_0xdbce('0x31')]){_0x54c768['where']=_[_0xdbce('0x32')](_0x54c768[_0xdbce('0x2f')],{'$or':_[_0xdbce('0x23')](_0x54c768[_0xdbce('0x29')],function(_0x4a5c3e){var _0x57ab5b={};_0x57ab5b[_0x4a5c3e]={'$like':'%'+_0x30b48e[_0xdbce('0x26')]['filter']+'%'};return _0x57ab5b;})});}_0x54c768=_[_0xdbce('0x32')]({},_0x54c768,_0x30b48e['options']);return _0x5f09af[_0xdbce('0x45')](_0x54c768);}})[_0xdbce('0x36')](function(_0x417536){if(_0x417536){_0x24ce94=_0x417536['length'];if(!_0x30b48e[_0xdbce('0x26')]['hasOwnProperty'](_0xdbce('0x2c'))){_0x54c768[_0xdbce('0x16')]=qs['limit'](_0x30b48e[_0xdbce('0x26')][_0xdbce('0x16')]);_0x54c768[_0xdbce('0x18')]=qs[_0xdbce('0x18')](_0x30b48e[_0xdbce('0x26')]['offset']);}return _0x5f09af['getDescriptions'](_0x54c768);}})['then'](function(_0x25b45f){if(_0x25b45f){return _0x25b45f?{'count':_0x24ce94,'rows':_0x25b45f}:null;}})[_0xdbce('0x36')](respondWithResult(_0x469d21,null))[_0xdbce('0x3a')](handleError(_0x469d21,null));};
\ No newline at end of file
+var _0x24aa=['getSubjects','getDescriptions','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','limit','offset','count','apply','reject','update','then','stack','name','send','index','map','ServicenowConfiguration','fieldName','type','key','model','query','keys','filters','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','rows','catch','show','params','rawAttributes','intersection','fields','length','includeAll','find','create','body','destroy','getFields','findOne','ServicenowField','hasOwnProperty'];(function(_0x2bcf24,_0x69755c){var _0x2d823d=function(_0x539d8a){while(--_0x539d8a){_0x2bcf24['push'](_0x2bcf24['shift']());}};_0x2d823d(++_0x69755c);}(_0x24aa,0x146));var _0xa24a=function(_0x566d27,_0x56fc58){_0x566d27=_0x566d27-0x0;var _0x3c6acb=_0x24aa[_0x566d27];return _0x3c6acb;};'use strict';var emlformat=require(_0xa24a('0x0'));var rimraf=require(_0xa24a('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa24a('0x2'));var rp=require('request-promise');var moment=require(_0xa24a('0x3'));var BPromise=require(_0xa24a('0x4'));var Mustache=require(_0xa24a('0x5'));var util=require(_0xa24a('0x6'));var path=require(_0xa24a('0x7'));var sox=require(_0xa24a('0x8'));var csv=require(_0xa24a('0x9'));var ejs=require(_0xa24a('0xa'));var fs=require('fs');var fs_extra=require(_0xa24a('0xb'));var _=require(_0xa24a('0xc'));var squel=require(_0xa24a('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xa24a('0xe'));var toCsv=require(_0xa24a('0x9'));var querystring=require(_0xa24a('0xf'));var Papa=require(_0xa24a('0x10'));var Redis=require(_0xa24a('0x11'));var authService=require(_0xa24a('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xa24a('0x13'));var hardwareService=require(_0xa24a('0x14'));var logger=require(_0xa24a('0x15'))(_0xa24a('0x16'));var utils=require(_0xa24a('0x17'));var config=require(_0xa24a('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xa24a('0x19'))['db'];function respondWithStatusCode(_0x4a5814,_0x255001){_0x255001=_0x255001||0xcc;return function(_0x3060ed){if(_0x3060ed){return _0x4a5814[_0xa24a('0x1a')](_0x255001);}return _0x4a5814[_0xa24a('0x1b')](_0x255001)[_0xa24a('0x1c')]();};}function respondWithResult(_0x1cd9a0,_0x33716a){_0x33716a=_0x33716a||0xc8;return function(_0x4f6145){if(_0x4f6145){return _0x1cd9a0['status'](_0x33716a)[_0xa24a('0x1d')](_0x4f6145);}};}function respondWithFilteredResult(_0x50a54b,_0x385e4b){return function(_0x2a9080){if(_0x2a9080){var _0x27852c=typeof _0x385e4b['offset']==='undefined'&&typeof _0x385e4b[_0xa24a('0x1e')]==='undefined';var _0x4e1477=_0x2a9080['count'];var _0x29709a=_0x27852c?0x0:_0x385e4b[_0xa24a('0x1f')];var _0x350867=_0x27852c?_0x2a9080[_0xa24a('0x20')]:_0x385e4b[_0xa24a('0x1f')]+_0x385e4b[_0xa24a('0x1e')];var _0x36075a;if(_0x350867>=_0x4e1477){_0x350867=_0x4e1477;_0x36075a=0xc8;}else{_0x36075a=0xce;}_0x50a54b[_0xa24a('0x1b')](_0x36075a);return _0x50a54b['set']('Content-Range',_0x29709a+'-'+_0x350867+'/'+_0x4e1477)[_0xa24a('0x1d')](_0x2a9080);}return null;};}function patchUpdates(_0x3b5488){return function(_0x4c8bdf){try{jsonpatch[_0xa24a('0x21')](_0x4c8bdf,_0x3b5488,!![]);}catch(_0xd29180){return BPromise[_0xa24a('0x22')](_0xd29180);}return _0x4c8bdf['save']();};}function saveUpdates(_0x1f486b,_0xd613f9){return function(_0x15872e){if(_0x15872e){return _0x15872e[_0xa24a('0x23')](_0x1f486b)[_0xa24a('0x24')](function(_0x56750d){return _0x56750d;});}return null;};}function removeEntity(_0x5b0689,_0x5d0b13){return function(_0x417d49){if(_0x417d49){return _0x417d49['destroy']()[_0xa24a('0x24')](function(){_0x5b0689[_0xa24a('0x1b')](0xcc)[_0xa24a('0x1c')]();});}};}function handleEntityNotFound(_0xb0ab42,_0x3ba282){return function(_0x3197ce){if(!_0x3197ce){_0xb0ab42['sendStatus'](0x194);}return _0x3197ce;};}function handleError(_0x479078,_0x3e4802){_0x3e4802=_0x3e4802||0x1f4;return function(_0x5eab36){logger['error'](_0x5eab36[_0xa24a('0x25')]);if(_0x5eab36[_0xa24a('0x26')]){delete _0x5eab36[_0xa24a('0x26')];}_0x479078[_0xa24a('0x1b')](_0x3e4802)[_0xa24a('0x27')](_0x5eab36);};}exports[_0xa24a('0x28')]=function(_0x52bfac,_0x108c1f){var _0x5ad512={},_0x5a4f54={},_0x1ae59a={'count':0x0,'rows':[]};var _0x284af8=_[_0xa24a('0x29')](db[_0xa24a('0x2a')]['rawAttributes'],function(_0x333393){return{'name':_0x333393[_0xa24a('0x2b')],'type':_0x333393[_0xa24a('0x2c')][_0xa24a('0x2d')]};});_0x5a4f54[_0xa24a('0x2e')]=_['map'](_0x284af8,'name');_0x5a4f54[_0xa24a('0x2f')]=_[_0xa24a('0x30')](_0x52bfac['query']);_0x5a4f54[_0xa24a('0x31')]=_['intersection'](_0x5a4f54[_0xa24a('0x2e')],_0x5a4f54[_0xa24a('0x2f')]);_0x5ad512['attributes']=_['intersection'](_0x5a4f54[_0xa24a('0x2e')],qs['fields'](_0x52bfac[_0xa24a('0x2f')]['fields']));_0x5ad512[_0xa24a('0x32')]=_0x5ad512['attributes']['length']?_0x5ad512[_0xa24a('0x32')]:_0x5a4f54[_0xa24a('0x2e')];if(!_0x52bfac[_0xa24a('0x2f')]['hasOwnProperty'](_0xa24a('0x33'))){_0x5ad512[_0xa24a('0x1e')]=qs[_0xa24a('0x1e')](_0x52bfac[_0xa24a('0x2f')][_0xa24a('0x1e')]);_0x5ad512[_0xa24a('0x1f')]=qs[_0xa24a('0x1f')](_0x52bfac[_0xa24a('0x2f')][_0xa24a('0x1f')]);}_0x5ad512[_0xa24a('0x34')]=qs[_0xa24a('0x35')](_0x52bfac[_0xa24a('0x2f')][_0xa24a('0x35')]);_0x5ad512[_0xa24a('0x36')]=qs[_0xa24a('0x31')](_[_0xa24a('0x37')](_0x52bfac[_0xa24a('0x2f')],_0x5a4f54[_0xa24a('0x31')]),_0x284af8);if(_0x52bfac[_0xa24a('0x2f')][_0xa24a('0x38')]){_0x5ad512[_0xa24a('0x36')]=_[_0xa24a('0x39')](_0x5ad512[_0xa24a('0x36')],{'$or':_['map'](_0x284af8,function(_0x20549c){if(_0x20549c[_0xa24a('0x2c')]!==_0xa24a('0x3a')){var _0x54c25d={};_0x54c25d[_0x20549c[_0xa24a('0x26')]]={'$like':'%'+_0x52bfac[_0xa24a('0x2f')]['filter']+'%'};return _0x54c25d;}})});}_0x5ad512=_[_0xa24a('0x39')]({},_0x5ad512,_0x52bfac[_0xa24a('0x3b')]);var _0x53fe51={'where':_0x5ad512['where']};return db[_0xa24a('0x2a')][_0xa24a('0x20')](_0x53fe51)['then'](function(_0x51f3fd){_0x1ae59a[_0xa24a('0x20')]=_0x51f3fd;if(_0x52bfac[_0xa24a('0x2f')]['includeAll']){_0x5ad512[_0xa24a('0x3c')]=[{'all':!![]}];}return db[_0xa24a('0x2a')][_0xa24a('0x3d')](_0x5ad512);})[_0xa24a('0x24')](function(_0x31dcb4){_0x1ae59a[_0xa24a('0x3e')]=_0x31dcb4;return _0x1ae59a;})[_0xa24a('0x24')](respondWithFilteredResult(_0x108c1f,_0x5ad512))[_0xa24a('0x3f')](handleError(_0x108c1f,null));};exports[_0xa24a('0x40')]=function(_0x436f7a,_0x2a0a2b){var _0x30be4a={'raw':![],'where':{'id':_0x436f7a[_0xa24a('0x41')]['id']}},_0x4f5e38={};_0x4f5e38[_0xa24a('0x2e')]=_[_0xa24a('0x30')](db[_0xa24a('0x2a')][_0xa24a('0x42')]);_0x4f5e38[_0xa24a('0x2f')]=_[_0xa24a('0x30')](_0x436f7a[_0xa24a('0x2f')]);_0x4f5e38[_0xa24a('0x31')]=_[_0xa24a('0x43')](_0x4f5e38[_0xa24a('0x2e')],_0x4f5e38[_0xa24a('0x2f')]);_0x30be4a['attributes']=_[_0xa24a('0x43')](_0x4f5e38[_0xa24a('0x2e')],qs[_0xa24a('0x44')](_0x436f7a[_0xa24a('0x2f')][_0xa24a('0x44')]));_0x30be4a[_0xa24a('0x32')]=_0x30be4a[_0xa24a('0x32')][_0xa24a('0x45')]?_0x30be4a[_0xa24a('0x32')]:_0x4f5e38[_0xa24a('0x2e')];if(_0x436f7a[_0xa24a('0x2f')][_0xa24a('0x46')]){_0x30be4a[_0xa24a('0x3c')]=[{'all':!![]}];}_0x30be4a=_['merge']({},_0x30be4a,_0x436f7a[_0xa24a('0x3b')]);return db[_0xa24a('0x2a')][_0xa24a('0x47')](_0x30be4a)[_0xa24a('0x24')](handleEntityNotFound(_0x2a0a2b,null))[_0xa24a('0x24')](respondWithResult(_0x2a0a2b,null))[_0xa24a('0x3f')](handleError(_0x2a0a2b,null));};exports['create']=function(_0x2612b5,_0x112a4d){return db[_0xa24a('0x2a')][_0xa24a('0x48')](_0x2612b5[_0xa24a('0x49')],{})[_0xa24a('0x24')](respondWithResult(_0x112a4d,0xc9))[_0xa24a('0x3f')](handleError(_0x112a4d,null));};exports[_0xa24a('0x23')]=function(_0x127ae5,_0x42c6d6){if(_0x127ae5[_0xa24a('0x49')]['id']){delete _0x127ae5[_0xa24a('0x49')]['id'];}return db[_0xa24a('0x2a')][_0xa24a('0x47')]({'where':{'id':_0x127ae5[_0xa24a('0x41')]['id']}})[_0xa24a('0x24')](handleEntityNotFound(_0x42c6d6,null))[_0xa24a('0x24')](saveUpdates(_0x127ae5[_0xa24a('0x49')],null))[_0xa24a('0x24')](respondWithResult(_0x42c6d6,null))[_0xa24a('0x3f')](handleError(_0x42c6d6,null));};exports[_0xa24a('0x4a')]=function(_0x1d0eb5,_0x3fecf5){return db[_0xa24a('0x2a')][_0xa24a('0x47')]({'where':{'id':_0x1d0eb5[_0xa24a('0x41')]['id']}})[_0xa24a('0x24')](handleEntityNotFound(_0x3fecf5,null))['then'](removeEntity(_0x3fecf5,null))['catch'](handleError(_0x3fecf5,null));};exports[_0xa24a('0x4b')]=function(_0x21d9b9,_0x1cf837,_0x29b8cd){var _0xa2e212={};var _0x31dcdb={};var _0x3d9720;var _0x5d7277;return db['ServicenowConfiguration'][_0xa24a('0x4c')]({'where':{'id':_0x21d9b9[_0xa24a('0x41')]['id']}})['then'](handleEntityNotFound(_0x1cf837,null))[_0xa24a('0x24')](function(_0x3f6c1e){if(_0x3f6c1e){_0x3d9720=_0x3f6c1e;_0x31dcdb[_0xa24a('0x2e')]=_[_0xa24a('0x30')](db[_0xa24a('0x4d')][_0xa24a('0x42')]);_0x31dcdb['query']=_[_0xa24a('0x30')](_0x21d9b9[_0xa24a('0x2f')]);_0x31dcdb['filters']=_[_0xa24a('0x43')](_0x31dcdb[_0xa24a('0x2e')],_0x31dcdb['query']);_0xa2e212['attributes']=_[_0xa24a('0x43')](_0x31dcdb[_0xa24a('0x2e')],qs[_0xa24a('0x44')](_0x21d9b9[_0xa24a('0x2f')][_0xa24a('0x44')]));_0xa2e212[_0xa24a('0x32')]=_0xa2e212[_0xa24a('0x32')]['length']?_0xa2e212[_0xa24a('0x32')]:_0x31dcdb[_0xa24a('0x2e')];_0xa2e212[_0xa24a('0x34')]=qs[_0xa24a('0x35')](_0x21d9b9['query'][_0xa24a('0x35')]);_0xa2e212[_0xa24a('0x36')]=qs[_0xa24a('0x31')](_['pick'](_0x21d9b9[_0xa24a('0x2f')],_0x31dcdb[_0xa24a('0x31')]));if(_0x21d9b9[_0xa24a('0x2f')]['filter']){_0xa2e212[_0xa24a('0x36')]=_[_0xa24a('0x39')](_0xa2e212[_0xa24a('0x36')],{'$or':_[_0xa24a('0x29')](_0xa2e212[_0xa24a('0x32')],function(_0x4cf6c1){var _0x4d1143={};_0x4d1143[_0x4cf6c1]={'$like':'%'+_0x21d9b9[_0xa24a('0x2f')][_0xa24a('0x38')]+'%'};return _0x4d1143;})});}_0xa2e212=_[_0xa24a('0x39')]({},_0xa2e212,_0x21d9b9['options']);return _0x3d9720[_0xa24a('0x4b')](_0xa2e212);}})['then'](function(_0x345b3a){if(_0x345b3a){_0x5d7277=_0x345b3a[_0xa24a('0x45')];if(!_0x21d9b9[_0xa24a('0x2f')][_0xa24a('0x4e')](_0xa24a('0x33'))){_0xa2e212['limit']=qs[_0xa24a('0x1e')](_0x21d9b9[_0xa24a('0x2f')][_0xa24a('0x1e')]);_0xa2e212[_0xa24a('0x1f')]=qs[_0xa24a('0x1f')](_0x21d9b9[_0xa24a('0x2f')][_0xa24a('0x1f')]);}return _0x3d9720[_0xa24a('0x4b')](_0xa2e212);}})[_0xa24a('0x24')](function(_0x2de02f){if(_0x2de02f){return _0x2de02f?{'count':_0x5d7277,'rows':_0x2de02f}:null;}})[_0xa24a('0x24')](respondWithResult(_0x1cf837,null))[_0xa24a('0x3f')](handleError(_0x1cf837,null));};exports[_0xa24a('0x4f')]=function(_0x2d70cf,_0x4c624d,_0x11e53c){var _0x5452a5={};var _0x16f820={};var _0x34a5e1;var _0x7bff5c;return db[_0xa24a('0x2a')][_0xa24a('0x4c')]({'where':{'id':_0x2d70cf[_0xa24a('0x41')]['id']}})[_0xa24a('0x24')](handleEntityNotFound(_0x4c624d,null))[_0xa24a('0x24')](function(_0x547eaf){if(_0x547eaf){_0x34a5e1=_0x547eaf;_0x16f820[_0xa24a('0x2e')]=_['keys'](db[_0xa24a('0x4d')]['rawAttributes']);_0x16f820[_0xa24a('0x2f')]=_[_0xa24a('0x30')](_0x2d70cf[_0xa24a('0x2f')]);_0x16f820[_0xa24a('0x31')]=_[_0xa24a('0x43')](_0x16f820[_0xa24a('0x2e')],_0x16f820[_0xa24a('0x2f')]);_0x5452a5[_0xa24a('0x32')]=_[_0xa24a('0x43')](_0x16f820['model'],qs[_0xa24a('0x44')](_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x44')]));_0x5452a5[_0xa24a('0x32')]=_0x5452a5[_0xa24a('0x32')]['length']?_0x5452a5[_0xa24a('0x32')]:_0x16f820['model'];_0x5452a5['order']=qs[_0xa24a('0x35')](_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x35')]);_0x5452a5['where']=qs[_0xa24a('0x31')](_[_0xa24a('0x37')](_0x2d70cf[_0xa24a('0x2f')],_0x16f820[_0xa24a('0x31')]));if(_0x2d70cf['query'][_0xa24a('0x38')]){_0x5452a5['where']=_['merge'](_0x5452a5[_0xa24a('0x36')],{'$or':_['map'](_0x5452a5[_0xa24a('0x32')],function(_0x524a8e){var _0x1fae95={};_0x1fae95[_0x524a8e]={'$like':'%'+_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x38')]+'%'};return _0x1fae95;})});}_0x5452a5=_[_0xa24a('0x39')]({},_0x5452a5,_0x2d70cf[_0xa24a('0x3b')]);return _0x34a5e1[_0xa24a('0x4f')](_0x5452a5);}})[_0xa24a('0x24')](function(_0x378b37){if(_0x378b37){_0x7bff5c=_0x378b37[_0xa24a('0x45')];if(!_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x4e')]('nolimit')){_0x5452a5['limit']=qs[_0xa24a('0x1e')](_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x1e')]);_0x5452a5[_0xa24a('0x1f')]=qs[_0xa24a('0x1f')](_0x2d70cf[_0xa24a('0x2f')][_0xa24a('0x1f')]);}return _0x34a5e1['getSubjects'](_0x5452a5);}})['then'](function(_0xba3197){if(_0xba3197){return _0xba3197?{'count':_0x7bff5c,'rows':_0xba3197}:null;}})[_0xa24a('0x24')](respondWithResult(_0x4c624d,null))[_0xa24a('0x3f')](handleError(_0x4c624d,null));};exports[_0xa24a('0x50')]=function(_0x30b6a7,_0x18faff,_0x3e9f56){var _0x33614d={};var _0x5baeae={};var _0x34e05e;var _0x362359;return db[_0xa24a('0x2a')][_0xa24a('0x4c')]({'where':{'id':_0x30b6a7[_0xa24a('0x41')]['id']}})[_0xa24a('0x24')](handleEntityNotFound(_0x18faff,null))[_0xa24a('0x24')](function(_0x27772a){if(_0x27772a){_0x34e05e=_0x27772a;_0x5baeae[_0xa24a('0x2e')]=_[_0xa24a('0x30')](db[_0xa24a('0x4d')][_0xa24a('0x42')]);_0x5baeae[_0xa24a('0x2f')]=_[_0xa24a('0x30')](_0x30b6a7[_0xa24a('0x2f')]);_0x5baeae[_0xa24a('0x31')]=_[_0xa24a('0x43')](_0x5baeae[_0xa24a('0x2e')],_0x5baeae[_0xa24a('0x2f')]);_0x33614d['attributes']=_[_0xa24a('0x43')](_0x5baeae['model'],qs[_0xa24a('0x44')](_0x30b6a7[_0xa24a('0x2f')][_0xa24a('0x44')]));_0x33614d[_0xa24a('0x32')]=_0x33614d['attributes'][_0xa24a('0x45')]?_0x33614d['attributes']:_0x5baeae['model'];_0x33614d[_0xa24a('0x34')]=qs[_0xa24a('0x35')](_0x30b6a7[_0xa24a('0x2f')][_0xa24a('0x35')]);_0x33614d[_0xa24a('0x36')]=qs['filters'](_['pick'](_0x30b6a7[_0xa24a('0x2f')],_0x5baeae['filters']));if(_0x30b6a7[_0xa24a('0x2f')]['filter']){_0x33614d[_0xa24a('0x36')]=_[_0xa24a('0x39')](_0x33614d[_0xa24a('0x36')],{'$or':_[_0xa24a('0x29')](_0x33614d[_0xa24a('0x32')],function(_0x52808a){var _0x5372cb={};_0x5372cb[_0x52808a]={'$like':'%'+_0x30b6a7[_0xa24a('0x2f')]['filter']+'%'};return _0x5372cb;})});}_0x33614d=_[_0xa24a('0x39')]({},_0x33614d,_0x30b6a7[_0xa24a('0x3b')]);return _0x34e05e[_0xa24a('0x50')](_0x33614d);}})[_0xa24a('0x24')](function(_0x43af47){if(_0x43af47){_0x362359=_0x43af47['length'];if(!_0x30b6a7[_0xa24a('0x2f')][_0xa24a('0x4e')]('nolimit')){_0x33614d[_0xa24a('0x1e')]=qs[_0xa24a('0x1e')](_0x30b6a7['query'][_0xa24a('0x1e')]);_0x33614d[_0xa24a('0x1f')]=qs[_0xa24a('0x1f')](_0x30b6a7[_0xa24a('0x2f')][_0xa24a('0x1f')]);}return _0x34e05e[_0xa24a('0x50')](_0x33614d);}})['then'](function(_0x3334b5){if(_0x3334b5){return _0x3334b5?{'count':_0x362359,'rows':_0x3334b5}:null;}})[_0xa24a('0x24')](respondWithResult(_0x18faff,null))[_0xa24a('0x3f')](handleError(_0x18faff,null));};
\ No newline at end of file