Built motion from commit 936e8062.|2.5.33
[motion2.git] / server / api / intServicenowField / intServicenowField.controller.js
index ccdd952..0d8040e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9a86=['request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','count','offset','limit','set','save','update','then','destroy','error','stack','name','send','index','map','ServicenowField','rawAttributes','type','key','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','filters','filter','where','merge','VIRTUAL','options','includeAll','rows','catch','show','params','find','create','body','html-pdf','eml-format','zip-dir','fast-json-patch'];(function(_0x5c584b,_0x5b17e6){var _0x4d43da=function(_0x3712a4){while(--_0x3712a4){_0x5c584b['push'](_0x5c584b['shift']());}};_0x4d43da(++_0x5b17e6);}(_0x9a86,0x1ed));var _0x69a8=function(_0x484c03,_0x13c1d2){_0x484c03=_0x484c03-0x0;var _0x294127=_0x9a86[_0x484c03];return _0x294127;};'use strict';var pdf=require(_0x69a8('0x0'));var emlformat=require(_0x69a8('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x69a8('0x2'));var jsonpatch=require(_0x69a8('0x3'));var rp=require(_0x69a8('0x4'));var moment=require(_0x69a8('0x5'));var BPromise=require(_0x69a8('0x6'));var Mustache=require(_0x69a8('0x7'));var util=require(_0x69a8('0x8'));var path=require(_0x69a8('0x9'));var sox=require(_0x69a8('0xa'));var csv=require(_0x69a8('0xb'));var ejs=require(_0x69a8('0xc'));var fs=require('fs');var _=require(_0x69a8('0xd'));var squel=require(_0x69a8('0xe'));var crypto=require(_0x69a8('0xf'));var jsforce=require(_0x69a8('0x10'));var deskjs=require(_0x69a8('0x11'));var toCsv=require('to-csv');var querystring=require(_0x69a8('0x12'));var Papa=require(_0x69a8('0x13'));var Redis=require('ioredis');var authService=require(_0x69a8('0x14'));var qs=require(_0x69a8('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x69a8('0x16'))(_0x69a8('0x17'));var utils=require(_0x69a8('0x18'));var config=require(_0x69a8('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x12bc21,_0x4eb43a){_0x4eb43a=_0x4eb43a||0xcc;return function(_0x18f782){if(_0x18f782){return _0x12bc21[_0x69a8('0x1a')](_0x4eb43a);}return _0x12bc21[_0x69a8('0x1b')](_0x4eb43a)[_0x69a8('0x1c')]();};}function respondWithResult(_0x272100,_0x524b28){_0x524b28=_0x524b28||0xc8;return function(_0x463937){if(_0x463937){return _0x272100['status'](_0x524b28)[_0x69a8('0x1d')](_0x463937);}};}function respondWithFilteredResult(_0x10c6c8,_0x5edd76){return function(_0x33b701){if(_0x33b701){var _0x264347=_0x33b701[_0x69a8('0x1e')],_0x275a8f=_0x5edd76[_0x69a8('0x1f')],_0x35906f=_0x5edd76[_0x69a8('0x1f')]+_0x5edd76[_0x69a8('0x20')],_0x1d3ebf;if(_0x35906f>=_0x264347){_0x35906f=_0x264347;_0x1d3ebf=0xc8;}else{_0x1d3ebf=0xce;}_0x10c6c8[_0x69a8('0x1b')](_0x1d3ebf);return _0x10c6c8[_0x69a8('0x21')]('Content-Range',_0x275a8f+'-'+_0x35906f+'/'+_0x264347)[_0x69a8('0x1d')](_0x33b701);}return null;};}function patchUpdates(_0x18ce82){return function(_0x237232){try{jsonpatch['apply'](_0x237232,_0x18ce82,!![]);}catch(_0x15c709){return BPromise['reject'](_0x15c709);}return _0x237232[_0x69a8('0x22')]();};}function saveUpdates(_0x2db796,_0x12cb53){return function(_0x35e0c8){if(_0x35e0c8){return _0x35e0c8[_0x69a8('0x23')](_0x2db796)[_0x69a8('0x24')](function(_0x22cf03){return _0x22cf03;});}return null;};}function removeEntity(_0x40a35d,_0x363fc0){return function(_0x451f44){if(_0x451f44){return _0x451f44[_0x69a8('0x25')]()[_0x69a8('0x24')](function(){_0x40a35d[_0x69a8('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x525883,_0x2381bf){return function(_0x55e45a){if(!_0x55e45a){_0x525883[_0x69a8('0x1a')](0x194);}return _0x55e45a;};}function handleError(_0x115cdd,_0x45f1e9){_0x45f1e9=_0x45f1e9||0x1f4;return function(_0x45a7c6){logger[_0x69a8('0x26')](_0x45a7c6[_0x69a8('0x27')]);if(_0x45a7c6[_0x69a8('0x28')]){delete _0x45a7c6[_0x69a8('0x28')];}_0x115cdd[_0x69a8('0x1b')](_0x45f1e9)[_0x69a8('0x29')](_0x45a7c6);};}exports[_0x69a8('0x2a')]=function(_0x21e789,_0x3d0754){var _0xb61a04={},_0x2244c7={},_0x277764={'count':0x0,'rows':[]};var _0x2238ac=_[_0x69a8('0x2b')](db[_0x69a8('0x2c')][_0x69a8('0x2d')],function(_0x2f8126){return{'name':_0x2f8126['fieldName'],'type':_0x2f8126[_0x69a8('0x2e')][_0x69a8('0x2f')]};});_0x2244c7['model']=_[_0x69a8('0x2b')](_0x2238ac,'name');_0x2244c7[_0x69a8('0x30')]=_[_0x69a8('0x31')](_0x21e789['query']);_0x2244c7['filters']=_[_0x69a8('0x32')](_0x2244c7[_0x69a8('0x33')],_0x2244c7['query']);_0xb61a04[_0x69a8('0x34')]=_['intersection'](_0x2244c7[_0x69a8('0x33')],qs[_0x69a8('0x35')](_0x21e789['query']['fields']));_0xb61a04[_0x69a8('0x34')]=_0xb61a04[_0x69a8('0x34')][_0x69a8('0x36')]?_0xb61a04['attributes']:_0x2244c7[_0x69a8('0x33')];if(!_0x21e789['query'][_0x69a8('0x37')](_0x69a8('0x38'))){_0xb61a04[_0x69a8('0x20')]=qs[_0x69a8('0x20')](_0x21e789['query'][_0x69a8('0x20')]);_0xb61a04[_0x69a8('0x1f')]=qs[_0x69a8('0x1f')](_0x21e789[_0x69a8('0x30')][_0x69a8('0x1f')]);}_0xb61a04['order']=qs['sort'](_0x21e789[_0x69a8('0x30')]['sort']);_0xb61a04['where']=qs[_0x69a8('0x39')](_['pick'](_0x21e789[_0x69a8('0x30')],_0x2244c7['filters']),_0x2238ac);if(_0x21e789[_0x69a8('0x30')][_0x69a8('0x3a')]){_0xb61a04[_0x69a8('0x3b')]=_[_0x69a8('0x3c')](_0xb61a04[_0x69a8('0x3b')],{'$or':_[_0x69a8('0x2b')](_0x2238ac,function(_0x5b448d){if(_0x5b448d[_0x69a8('0x2e')]!==_0x69a8('0x3d')){var _0x31bb6b={};_0x31bb6b[_0x5b448d[_0x69a8('0x28')]]={'$like':'%'+_0x21e789[_0x69a8('0x30')][_0x69a8('0x3a')]+'%'};return _0x31bb6b;}})});}_0xb61a04=_[_0x69a8('0x3c')]({},_0xb61a04,_0x21e789[_0x69a8('0x3e')]);var _0x6f5f9d={'where':_0xb61a04[_0x69a8('0x3b')]};return db['ServicenowField'][_0x69a8('0x1e')](_0x6f5f9d)[_0x69a8('0x24')](function(_0x34c2f5){_0x277764[_0x69a8('0x1e')]=_0x34c2f5;if(_0x21e789['query'][_0x69a8('0x3f')]){_0xb61a04['include']=[{'all':!![]}];}return db[_0x69a8('0x2c')]['findAll'](_0xb61a04);})[_0x69a8('0x24')](function(_0x464215){_0x277764[_0x69a8('0x40')]=_0x464215;return _0x277764;})[_0x69a8('0x24')](respondWithFilteredResult(_0x3d0754,_0xb61a04))[_0x69a8('0x41')](handleError(_0x3d0754,null));};exports[_0x69a8('0x42')]=function(_0x2269d6,_0x36b7d9){var _0x56bac1={'raw':!![],'where':{'id':_0x2269d6[_0x69a8('0x43')]['id']}},_0x48d610={};_0x48d610[_0x69a8('0x33')]=_[_0x69a8('0x31')](db['ServicenowField'][_0x69a8('0x2d')]);_0x48d610[_0x69a8('0x30')]=_['keys'](_0x2269d6[_0x69a8('0x30')]);_0x48d610['filters']=_[_0x69a8('0x32')](_0x48d610[_0x69a8('0x33')],_0x48d610[_0x69a8('0x30')]);_0x56bac1[_0x69a8('0x34')]=_[_0x69a8('0x32')](_0x48d610[_0x69a8('0x33')],qs['fields'](_0x2269d6['query']['fields']));_0x56bac1['attributes']=_0x56bac1[_0x69a8('0x34')][_0x69a8('0x36')]?_0x56bac1[_0x69a8('0x34')]:_0x48d610[_0x69a8('0x33')];if(_0x2269d6['query'][_0x69a8('0x3f')]){_0x56bac1['include']=[{'all':!![]}];}_0x56bac1=_[_0x69a8('0x3c')]({},_0x56bac1,_0x2269d6[_0x69a8('0x3e')]);return db[_0x69a8('0x2c')][_0x69a8('0x44')](_0x56bac1)[_0x69a8('0x24')](handleEntityNotFound(_0x36b7d9,null))[_0x69a8('0x24')](respondWithResult(_0x36b7d9,null))[_0x69a8('0x41')](handleError(_0x36b7d9,null));};exports[_0x69a8('0x45')]=function(_0x4f2eae,_0x264e5e){return db[_0x69a8('0x2c')]['create'](_0x4f2eae[_0x69a8('0x46')],{})[_0x69a8('0x24')](respondWithResult(_0x264e5e,0xc9))[_0x69a8('0x41')](handleError(_0x264e5e,null));};exports['update']=function(_0x46ca7d,_0x29de1c){if(_0x46ca7d['body']['id']){delete _0x46ca7d[_0x69a8('0x46')]['id'];}return db[_0x69a8('0x2c')][_0x69a8('0x44')]({'where':{'id':_0x46ca7d['params']['id']}})[_0x69a8('0x24')](handleEntityNotFound(_0x29de1c,null))[_0x69a8('0x24')](saveUpdates(_0x46ca7d[_0x69a8('0x46')],null))[_0x69a8('0x24')](respondWithResult(_0x29de1c,null))['catch'](handleError(_0x29de1c,null));};exports['destroy']=function(_0x231213,_0x54bc76){return db[_0x69a8('0x2c')]['find']({'where':{'id':_0x231213['params']['id']}})[_0x69a8('0x24')](handleEntityNotFound(_0x54bc76,null))[_0x69a8('0x24')](removeEntity(_0x54bc76,null))[_0x69a8('0x41')](handleError(_0x54bc76,null));};
\ No newline at end of file
+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