Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / intServicenowField / intServicenowField.controller.js
index 0d8040e..96967ef 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x13e7=['set','Content-Range','apply','save','update','then','destroy','error','stack','name','index','map','ServicenowField','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','includeAll','include','findAll','rows','catch','show','params','keys','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset'];(function(_0x542211,_0x27fc4f){var _0xcf249f=function(_0x3bdcc1){while(--_0x3bdcc1){_0x542211['push'](_0x542211['shift']());}};_0xcf249f(++_0x27fc4f);}(_0x13e7,0x1e6));var _0x713e=function(_0x299784,_0xb0918f){_0x299784=_0x299784-0x0;var _0x5ab008=_0x13e7[_0x299784];return _0x5ab008;};'use strict';var emlformat=require(_0x713e('0x0'));var rimraf=require(_0x713e('0x1'));var zipdir=require(_0x713e('0x2'));var jsonpatch=require(_0x713e('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x713e('0x4'));var Mustache=require(_0x713e('0x5'));var util=require(_0x713e('0x6'));var path=require('path');var sox=require(_0x713e('0x7'));var csv=require('to-csv');var ejs=require(_0x713e('0x8'));var fs=require('fs');var fs_extra=require(_0x713e('0x9'));var _=require(_0x713e('0xa'));var squel=require(_0x713e('0xb'));var crypto=require(_0x713e('0xc'));var jsforce=require(_0x713e('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x713e('0xe'));var querystring=require(_0x713e('0xf'));var Papa=require(_0x713e('0x10'));var Redis=require(_0x713e('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x713e('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x713e('0x13'));var utils=require(_0x713e('0x14'));var config=require(_0x713e('0x15'));var licenseUtil=require(_0x713e('0x16'));var db=require(_0x713e('0x17'))['db'];function respondWithStatusCode(_0x1b2cb7,_0x5962db){_0x5962db=_0x5962db||0xcc;return function(_0x4a78b2){if(_0x4a78b2){return _0x1b2cb7[_0x713e('0x18')](_0x5962db);}return _0x1b2cb7[_0x713e('0x19')](_0x5962db)[_0x713e('0x1a')]();};}function respondWithResult(_0x4e7ec2,_0x30e47d){_0x30e47d=_0x30e47d||0xc8;return function(_0x3cd743){if(_0x3cd743){return _0x4e7ec2[_0x713e('0x19')](_0x30e47d)[_0x713e('0x1b')](_0x3cd743);}};}function respondWithFilteredResult(_0x13a333,_0x1db9c7){return function(_0x2b9d53){if(_0x2b9d53){var _0x286cd0=typeof _0x1db9c7['offset']===_0x713e('0x1c')&&typeof _0x1db9c7[_0x713e('0x1d')]==='undefined';var _0xa166fe=_0x2b9d53[_0x713e('0x1e')];var _0x56fce0=_0x286cd0?0x0:_0x1db9c7[_0x713e('0x1f')];var _0x903124=_0x286cd0?_0x2b9d53[_0x713e('0x1e')]:_0x1db9c7[_0x713e('0x1f')]+_0x1db9c7[_0x713e('0x1d')];var _0x25aa75;if(_0x903124>=_0xa166fe){_0x903124=_0xa166fe;_0x25aa75=0xc8;}else{_0x25aa75=0xce;}_0x13a333[_0x713e('0x19')](_0x25aa75);return _0x13a333[_0x713e('0x20')](_0x713e('0x21'),_0x56fce0+'-'+_0x903124+'/'+_0xa166fe)[_0x713e('0x1b')](_0x2b9d53);}return null;};}function patchUpdates(_0x100989){return function(_0x486af6){try{jsonpatch[_0x713e('0x22')](_0x486af6,_0x100989,!![]);}catch(_0x147d2b){return BPromise['reject'](_0x147d2b);}return _0x486af6[_0x713e('0x23')]();};}function saveUpdates(_0x304d5e,_0x5518b6){return function(_0x209a53){if(_0x209a53){return _0x209a53[_0x713e('0x24')](_0x304d5e)[_0x713e('0x25')](function(_0x37411e){return _0x37411e;});}return null;};}function removeEntity(_0x57eb9c,_0x6f6d46){return function(_0x5b0436){if(_0x5b0436){return _0x5b0436[_0x713e('0x26')]()['then'](function(){_0x57eb9c[_0x713e('0x19')](0xcc)[_0x713e('0x1a')]();});}};}function handleEntityNotFound(_0x29b9f0,_0x4271c4){return function(_0x772ca6){if(!_0x772ca6){_0x29b9f0[_0x713e('0x18')](0x194);}return _0x772ca6;};}function handleError(_0x3e6968,_0x330e80){_0x330e80=_0x330e80||0x1f4;return function(_0x48f705){logger[_0x713e('0x27')](_0x48f705[_0x713e('0x28')]);if(_0x48f705[_0x713e('0x29')]){delete _0x48f705[_0x713e('0x29')];}_0x3e6968[_0x713e('0x19')](_0x330e80)['send'](_0x48f705);};}exports[_0x713e('0x2a')]=function(_0x14c24e,_0x218699){var _0x11e643={},_0x25c85b={},_0x24245c={'count':0x0,'rows':[]};var _0x3ce42a=_[_0x713e('0x2b')](db[_0x713e('0x2c')][_0x713e('0x2d')],function(_0x40757b){return{'name':_0x40757b['fieldName'],'type':_0x40757b[_0x713e('0x2e')][_0x713e('0x2f')]};});_0x25c85b[_0x713e('0x30')]=_[_0x713e('0x2b')](_0x3ce42a,_0x713e('0x29'));_0x25c85b['query']=_['keys'](_0x14c24e[_0x713e('0x31')]);_0x25c85b[_0x713e('0x32')]=_[_0x713e('0x33')](_0x25c85b[_0x713e('0x30')],_0x25c85b[_0x713e('0x31')]);_0x11e643[_0x713e('0x34')]=_[_0x713e('0x33')](_0x25c85b[_0x713e('0x30')],qs['fields'](_0x14c24e[_0x713e('0x31')][_0x713e('0x35')]));_0x11e643[_0x713e('0x34')]=_0x11e643[_0x713e('0x34')][_0x713e('0x36')]?_0x11e643[_0x713e('0x34')]:_0x25c85b['model'];if(!_0x14c24e[_0x713e('0x31')]['hasOwnProperty'](_0x713e('0x37'))){_0x11e643[_0x713e('0x1d')]=qs[_0x713e('0x1d')](_0x14c24e[_0x713e('0x31')][_0x713e('0x1d')]);_0x11e643[_0x713e('0x1f')]=qs['offset'](_0x14c24e[_0x713e('0x31')][_0x713e('0x1f')]);}_0x11e643[_0x713e('0x38')]=qs[_0x713e('0x39')](_0x14c24e[_0x713e('0x31')]['sort']);_0x11e643[_0x713e('0x3a')]=qs[_0x713e('0x32')](_[_0x713e('0x3b')](_0x14c24e['query'],_0x25c85b[_0x713e('0x32')]),_0x3ce42a);if(_0x14c24e[_0x713e('0x31')][_0x713e('0x3c')]){_0x11e643['where']=_['merge'](_0x11e643[_0x713e('0x3a')],{'$or':_[_0x713e('0x2b')](_0x3ce42a,function(_0x20cba5){if(_0x20cba5['type']!==_0x713e('0x3d')){var _0x3b202d={};_0x3b202d[_0x20cba5[_0x713e('0x29')]]={'$like':'%'+_0x14c24e[_0x713e('0x31')][_0x713e('0x3c')]+'%'};return _0x3b202d;}})});}_0x11e643=_[_0x713e('0x3e')]({},_0x11e643,_0x14c24e['options']);var _0x654176={'where':_0x11e643[_0x713e('0x3a')]};return db['ServicenowField']['count'](_0x654176)[_0x713e('0x25')](function(_0x40fb8a){_0x24245c['count']=_0x40fb8a;if(_0x14c24e['query'][_0x713e('0x3f')]){_0x11e643[_0x713e('0x40')]=[{'all':!![]}];}return db[_0x713e('0x2c')][_0x713e('0x41')](_0x11e643);})['then'](function(_0x31e270){_0x24245c[_0x713e('0x42')]=_0x31e270;return _0x24245c;})['then'](respondWithFilteredResult(_0x218699,_0x11e643))[_0x713e('0x43')](handleError(_0x218699,null));};exports[_0x713e('0x44')]=function(_0x35e861,_0x3d2998){var _0xe67c11={'raw':!![],'where':{'id':_0x35e861[_0x713e('0x45')]['id']}},_0x32ef1d={};_0x32ef1d[_0x713e('0x30')]=_[_0x713e('0x46')](db[_0x713e('0x2c')]['rawAttributes']);_0x32ef1d['query']=_[_0x713e('0x46')](_0x35e861[_0x713e('0x31')]);_0x32ef1d[_0x713e('0x32')]=_['intersection'](_0x32ef1d[_0x713e('0x30')],_0x32ef1d[_0x713e('0x31')]);_0xe67c11[_0x713e('0x34')]=_[_0x713e('0x33')](_0x32ef1d[_0x713e('0x30')],qs[_0x713e('0x35')](_0x35e861[_0x713e('0x31')]['fields']));_0xe67c11[_0x713e('0x34')]=_0xe67c11['attributes'][_0x713e('0x36')]?_0xe67c11[_0x713e('0x34')]:_0x32ef1d[_0x713e('0x30')];if(_0x35e861['query']['includeAll']){_0xe67c11['include']=[{'all':!![]}];}_0xe67c11=_['merge']({},_0xe67c11,_0x35e861['options']);return db[_0x713e('0x2c')][_0x713e('0x47')](_0xe67c11)[_0x713e('0x25')](handleEntityNotFound(_0x3d2998,null))[_0x713e('0x25')](respondWithResult(_0x3d2998,null))[_0x713e('0x43')](handleError(_0x3d2998,null));};exports[_0x713e('0x48')]=function(_0x1b554d,_0x90f604){return db[_0x713e('0x2c')]['create'](_0x1b554d[_0x713e('0x49')],{})[_0x713e('0x25')](respondWithResult(_0x90f604,0xc9))[_0x713e('0x43')](handleError(_0x90f604,null));};exports[_0x713e('0x24')]=function(_0x4ca790,_0x4236f3){if(_0x4ca790['body']['id']){delete _0x4ca790['body']['id'];}return db[_0x713e('0x2c')]['find']({'where':{'id':_0x4ca790['params']['id']}})[_0x713e('0x25')](handleEntityNotFound(_0x4236f3,null))[_0x713e('0x25')](saveUpdates(_0x4ca790[_0x713e('0x49')],null))[_0x713e('0x25')](respondWithResult(_0x4236f3,null))[_0x713e('0x43')](handleError(_0x4236f3,null));};exports[_0x713e('0x26')]=function(_0x435996,_0x16c5b5){return db['ServicenowField'][_0x713e('0x47')]({'where':{'id':_0x435996[_0x713e('0x45')]['id']}})['then'](handleEntityNotFound(_0x16c5b5,null))[_0x713e('0x25')](removeEntity(_0x16c5b5,null))[_0x713e('0x43')](handleError(_0x16c5b5,null));};
\ No newline at end of file
+var _0x901e=['lodash','crypto','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','then','destroy','name','send','index','map','ServicenowField','rawAttributes','type','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','include','findAll','show','params','fields','includeAll','find','catch','update','body','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','sox','fs-extra'];(function(_0x47408e,_0x481428){var _0x1636bc=function(_0x2fe7a6){while(--_0x2fe7a6){_0x47408e['push'](_0x47408e['shift']());}};_0x1636bc(++_0x481428);}(_0x901e,0x100));var _0xe901=function(_0x110c54,_0xa3cfcb){_0x110c54=_0x110c54-0x0;var _0x58a348=_0x901e[_0x110c54];return _0x58a348;};'use strict';var emlformat=require(_0xe901('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xe901('0x1'));var rp=require(_0xe901('0x2'));var moment=require('moment');var BPromise=require(_0xe901('0x3'));var Mustache=require(_0xe901('0x4'));var util=require(_0xe901('0x5'));var path=require('path');var sox=require(_0xe901('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe901('0x7'));var _=require(_0xe901('0x8'));var squel=require('squel');var crypto=require(_0xe901('0x9'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xe901('0xa'));var querystring=require(_0xe901('0xb'));var Papa=require(_0xe901('0xc'));var Redis=require('ioredis');var authService=require(_0xe901('0xd'));var qs=require('../../components/parsers/qs');var as=require(_0xe901('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xe901('0xf'));var utils=require(_0xe901('0x10'));var config=require(_0xe901('0x11'));var licenseUtil=require(_0xe901('0x12'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x33b0c7,_0x198b0c){_0x198b0c=_0x198b0c||0xcc;return function(_0x4166b1){if(_0x4166b1){return _0x33b0c7['sendStatus'](_0x198b0c);}return _0x33b0c7[_0xe901('0x13')](_0x198b0c)[_0xe901('0x14')]();};}function respondWithResult(_0x23056c,_0x38503d){_0x38503d=_0x38503d||0xc8;return function(_0x4a06cd){if(_0x4a06cd){return _0x23056c[_0xe901('0x13')](_0x38503d)[_0xe901('0x15')](_0x4a06cd);}};}function respondWithFilteredResult(_0xd98ba8,_0x51a89f){return function(_0x8d4a6){if(_0x8d4a6){var _0x27e294=typeof _0x51a89f[_0xe901('0x16')]==='undefined'&&typeof _0x51a89f[_0xe901('0x17')]===_0xe901('0x18');var _0x23551c=_0x8d4a6[_0xe901('0x19')];var _0x4ac743=_0x27e294?0x0:_0x51a89f['offset'];var _0x3903f8=_0x27e294?_0x8d4a6['count']:_0x51a89f[_0xe901('0x16')]+_0x51a89f['limit'];var _0x59e97f;if(_0x3903f8>=_0x23551c){_0x3903f8=_0x23551c;_0x59e97f=0xc8;}else{_0x59e97f=0xce;}_0xd98ba8['status'](_0x59e97f);return _0xd98ba8[_0xe901('0x1a')](_0xe901('0x1b'),_0x4ac743+'-'+_0x3903f8+'/'+_0x23551c)['json'](_0x8d4a6);}return null;};}function patchUpdates(_0x2a49d8){return function(_0xf91109){try{jsonpatch[_0xe901('0x1c')](_0xf91109,_0x2a49d8,!![]);}catch(_0x4c9a49){return BPromise[_0xe901('0x1d')](_0x4c9a49);}return _0xf91109['save']();};}function saveUpdates(_0x1db253,_0x5a2514){return function(_0x3212b5){if(_0x3212b5){return _0x3212b5['update'](_0x1db253)[_0xe901('0x1e')](function(_0x143a0d){return _0x143a0d;});}return null;};}function removeEntity(_0x410518,_0x492dae){return function(_0x51e3c3){if(_0x51e3c3){return _0x51e3c3[_0xe901('0x1f')]()[_0xe901('0x1e')](function(){_0x410518[_0xe901('0x13')](0xcc)[_0xe901('0x14')]();});}};}function handleEntityNotFound(_0x332e82,_0x12268f){return function(_0x45f4ab){if(!_0x45f4ab){_0x332e82['sendStatus'](0x194);}return _0x45f4ab;};}function handleError(_0x3c87f8,_0x4edeb4){_0x4edeb4=_0x4edeb4||0x1f4;return function(_0xd33e87){logger['error'](_0xd33e87['stack']);if(_0xd33e87[_0xe901('0x20')]){delete _0xd33e87[_0xe901('0x20')];}_0x3c87f8[_0xe901('0x13')](_0x4edeb4)[_0xe901('0x21')](_0xd33e87);};}exports[_0xe901('0x22')]=function(_0x47899b,_0x55af81){var _0x40a6cf={},_0x214cec={},_0x1d50b2={'count':0x0,'rows':[]};var _0x4d8589=_[_0xe901('0x23')](db[_0xe901('0x24')][_0xe901('0x25')],function(_0x10566){return{'name':_0x10566['fieldName'],'type':_0x10566[_0xe901('0x26')]['key']};});_0x214cec[_0xe901('0x27')]=_[_0xe901('0x23')](_0x4d8589,_0xe901('0x20'));_0x214cec[_0xe901('0x28')]=_[_0xe901('0x29')](_0x47899b['query']);_0x214cec[_0xe901('0x2a')]=_[_0xe901('0x2b')](_0x214cec['model'],_0x214cec[_0xe901('0x28')]);_0x40a6cf[_0xe901('0x2c')]=_[_0xe901('0x2b')](_0x214cec['model'],qs['fields'](_0x47899b['query']['fields']));_0x40a6cf[_0xe901('0x2c')]=_0x40a6cf[_0xe901('0x2c')][_0xe901('0x2d')]?_0x40a6cf['attributes']:_0x214cec['model'];if(!_0x47899b[_0xe901('0x28')][_0xe901('0x2e')](_0xe901('0x2f'))){_0x40a6cf[_0xe901('0x17')]=qs[_0xe901('0x17')](_0x47899b[_0xe901('0x28')][_0xe901('0x17')]);_0x40a6cf['offset']=qs[_0xe901('0x16')](_0x47899b[_0xe901('0x28')]['offset']);}_0x40a6cf[_0xe901('0x30')]=qs[_0xe901('0x31')](_0x47899b[_0xe901('0x28')][_0xe901('0x31')]);_0x40a6cf[_0xe901('0x32')]=qs[_0xe901('0x2a')](_[_0xe901('0x33')](_0x47899b['query'],_0x214cec['filters']),_0x4d8589);if(_0x47899b[_0xe901('0x28')]['filter']){_0x40a6cf[_0xe901('0x32')]=_[_0xe901('0x34')](_0x40a6cf[_0xe901('0x32')],{'$or':_[_0xe901('0x23')](_0x4d8589,function(_0x2c9637){if(_0x2c9637[_0xe901('0x26')]!==_0xe901('0x35')){var _0x5657d7={};_0x5657d7[_0x2c9637[_0xe901('0x20')]]={'$like':'%'+_0x47899b['query'][_0xe901('0x36')]+'%'};return _0x5657d7;}})});}_0x40a6cf=_[_0xe901('0x34')]({},_0x40a6cf,_0x47899b[_0xe901('0x37')]);var _0x317f38={'where':_0x40a6cf[_0xe901('0x32')]};return db[_0xe901('0x24')][_0xe901('0x19')](_0x317f38)[_0xe901('0x1e')](function(_0x34680a){_0x1d50b2['count']=_0x34680a;if(_0x47899b[_0xe901('0x28')]['includeAll']){_0x40a6cf[_0xe901('0x38')]=[{'all':!![]}];}return db[_0xe901('0x24')][_0xe901('0x39')](_0x40a6cf);})[_0xe901('0x1e')](function(_0x10881f){_0x1d50b2['rows']=_0x10881f;return _0x1d50b2;})[_0xe901('0x1e')](respondWithFilteredResult(_0x55af81,_0x40a6cf))['catch'](handleError(_0x55af81,null));};exports[_0xe901('0x3a')]=function(_0x4116c1,_0x4e8756){var _0x1d0356={'raw':!![],'where':{'id':_0x4116c1[_0xe901('0x3b')]['id']}},_0x4c4cfe={};_0x4c4cfe[_0xe901('0x27')]=_[_0xe901('0x29')](db[_0xe901('0x24')][_0xe901('0x25')]);_0x4c4cfe[_0xe901('0x28')]=_[_0xe901('0x29')](_0x4116c1[_0xe901('0x28')]);_0x4c4cfe['filters']=_[_0xe901('0x2b')](_0x4c4cfe[_0xe901('0x27')],_0x4c4cfe[_0xe901('0x28')]);_0x1d0356['attributes']=_['intersection'](_0x4c4cfe[_0xe901('0x27')],qs[_0xe901('0x3c')](_0x4116c1[_0xe901('0x28')][_0xe901('0x3c')]));_0x1d0356[_0xe901('0x2c')]=_0x1d0356[_0xe901('0x2c')][_0xe901('0x2d')]?_0x1d0356[_0xe901('0x2c')]:_0x4c4cfe[_0xe901('0x27')];if(_0x4116c1[_0xe901('0x28')][_0xe901('0x3d')]){_0x1d0356['include']=[{'all':!![]}];}_0x1d0356=_['merge']({},_0x1d0356,_0x4116c1['options']);return db[_0xe901('0x24')][_0xe901('0x3e')](_0x1d0356)[_0xe901('0x1e')](handleEntityNotFound(_0x4e8756,null))['then'](respondWithResult(_0x4e8756,null))[_0xe901('0x3f')](handleError(_0x4e8756,null));};exports['create']=function(_0x1f0bf9,_0x7f5450){return db[_0xe901('0x24')]['create'](_0x1f0bf9['body'],{})['then'](respondWithResult(_0x7f5450,0xc9))[_0xe901('0x3f')](handleError(_0x7f5450,null));};exports[_0xe901('0x40')]=function(_0x45ea5c,_0x55ae97){if(_0x45ea5c[_0xe901('0x41')]['id']){delete _0x45ea5c[_0xe901('0x41')]['id'];}return db[_0xe901('0x24')]['find']({'where':{'id':_0x45ea5c[_0xe901('0x3b')]['id']}})[_0xe901('0x1e')](handleEntityNotFound(_0x55ae97,null))['then'](saveUpdates(_0x45ea5c[_0xe901('0x41')],null))['then'](respondWithResult(_0x55ae97,null))['catch'](handleError(_0x55ae97,null));};exports['destroy']=function(_0x2acb77,_0x529010){return db[_0xe901('0x24')][_0xe901('0x3e')]({'where':{'id':_0x2acb77[_0xe901('0x3b')]['id']}})['then'](handleEntityNotFound(_0x529010,null))['then'](removeEntity(_0x529010,null))[_0xe901('0x3f')](handleError(_0x529010,null));};
\ No newline at end of file