Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / api / intServicenowField / intServicenowField.controller.js
index e3562e4..6455f9e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4bf3=['ServicenowField','rawAttributes','fieldName','type','model','query','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','keys','fields','find','create','body','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','limit','count','offset','set','apply','save','update','then','destroy','error','name','send','index','map'];(function(_0x2eeb56,_0x231565){var _0x1a252b=function(_0xff4b70){while(--_0xff4b70){_0x2eeb56['push'](_0x2eeb56['shift']());}};_0x1a252b(++_0x231565);}(_0x4bf3,0xb6));var _0x34bf=function(_0x426b98,_0x2f4631){_0x426b98=_0x426b98-0x0;var _0x4bd64c=_0x4bf3[_0x426b98];return _0x4bd64c;};'use strict';var emlformat=require(_0x34bf('0x0'));var rimraf=require(_0x34bf('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x34bf('0x2'));var rp=require(_0x34bf('0x3'));var moment=require(_0x34bf('0x4'));var BPromise=require(_0x34bf('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x34bf('0x6'));var sox=require(_0x34bf('0x7'));var csv=require(_0x34bf('0x8'));var ejs=require(_0x34bf('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x34bf('0xa'));var crypto=require(_0x34bf('0xb'));var jsforce=require(_0x34bf('0xc'));var deskjs=require(_0x34bf('0xd'));var toCsv=require(_0x34bf('0x8'));var querystring=require('querystring');var Papa=require(_0x34bf('0xe'));var Redis=require(_0x34bf('0xf'));var authService=require(_0x34bf('0x10'));var qs=require(_0x34bf('0x11'));var as=require(_0x34bf('0x12'));var hardwareService=require(_0x34bf('0x13'));var logger=require('../../config/logger')(_0x34bf('0x14'));var utils=require(_0x34bf('0x15'));var config=require(_0x34bf('0x16'));var licenseUtil=require(_0x34bf('0x17'));var db=require(_0x34bf('0x18'))['db'];function respondWithStatusCode(_0x53f1da,_0x3bb4b2){_0x3bb4b2=_0x3bb4b2||0xcc;return function(_0xb4f39d){if(_0xb4f39d){return _0x53f1da[_0x34bf('0x19')](_0x3bb4b2);}return _0x53f1da[_0x34bf('0x1a')](_0x3bb4b2)['end']();};}function respondWithResult(_0x44a641,_0x3d6d4d){_0x3d6d4d=_0x3d6d4d||0xc8;return function(_0x32e46a){if(_0x32e46a){return _0x44a641['status'](_0x3d6d4d)[_0x34bf('0x1b')](_0x32e46a);}};}function respondWithFilteredResult(_0x3d5557,_0x437697){return function(_0x35f05b){if(_0x35f05b){var _0x3033aa=typeof _0x437697['offset']===_0x34bf('0x1c')&&typeof _0x437697[_0x34bf('0x1d')]==='undefined';var _0x140991=_0x35f05b[_0x34bf('0x1e')];var _0x37bf8f=_0x3033aa?0x0:_0x437697[_0x34bf('0x1f')];var _0xd33cbe=_0x3033aa?_0x35f05b[_0x34bf('0x1e')]:_0x437697[_0x34bf('0x1f')]+_0x437697['limit'];var _0x156868;if(_0xd33cbe>=_0x140991){_0xd33cbe=_0x140991;_0x156868=0xc8;}else{_0x156868=0xce;}_0x3d5557['status'](_0x156868);return _0x3d5557[_0x34bf('0x20')]('Content-Range',_0x37bf8f+'-'+_0xd33cbe+'/'+_0x140991)[_0x34bf('0x1b')](_0x35f05b);}return null;};}function patchUpdates(_0xab1830){return function(_0xda4a94){try{jsonpatch[_0x34bf('0x21')](_0xda4a94,_0xab1830,!![]);}catch(_0x2f1170){return BPromise['reject'](_0x2f1170);}return _0xda4a94[_0x34bf('0x22')]();};}function saveUpdates(_0x30d588,_0x2b7baa){return function(_0x200338){if(_0x200338){return _0x200338[_0x34bf('0x23')](_0x30d588)[_0x34bf('0x24')](function(_0x12617c){return _0x12617c;});}return null;};}function removeEntity(_0xd1aa83,_0x2f8147){return function(_0x3379ce){if(_0x3379ce){return _0x3379ce[_0x34bf('0x25')]()[_0x34bf('0x24')](function(){_0xd1aa83['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x256532,_0x508362){return function(_0x59e429){if(!_0x59e429){_0x256532[_0x34bf('0x19')](0x194);}return _0x59e429;};}function handleError(_0x4b7424,_0x1a6cc3){_0x1a6cc3=_0x1a6cc3||0x1f4;return function(_0x153af0){logger[_0x34bf('0x26')](_0x153af0['stack']);if(_0x153af0[_0x34bf('0x27')]){delete _0x153af0[_0x34bf('0x27')];}_0x4b7424['status'](_0x1a6cc3)[_0x34bf('0x28')](_0x153af0);};}exports[_0x34bf('0x29')]=function(_0x2aa7f6,_0x13fd18){var _0x46e130={},_0x5d3f42={},_0x4d2532={'count':0x0,'rows':[]};var _0xdd46a5=_[_0x34bf('0x2a')](db[_0x34bf('0x2b')][_0x34bf('0x2c')],function(_0x48bc72){return{'name':_0x48bc72[_0x34bf('0x2d')],'type':_0x48bc72[_0x34bf('0x2e')]['key']};});_0x5d3f42[_0x34bf('0x2f')]=_[_0x34bf('0x2a')](_0xdd46a5,_0x34bf('0x27'));_0x5d3f42[_0x34bf('0x30')]=_['keys'](_0x2aa7f6['query']);_0x5d3f42['filters']=_[_0x34bf('0x31')](_0x5d3f42['model'],_0x5d3f42[_0x34bf('0x30')]);_0x46e130[_0x34bf('0x32')]=_[_0x34bf('0x31')](_0x5d3f42[_0x34bf('0x2f')],qs['fields'](_0x2aa7f6[_0x34bf('0x30')]['fields']));_0x46e130[_0x34bf('0x32')]=_0x46e130[_0x34bf('0x32')][_0x34bf('0x33')]?_0x46e130[_0x34bf('0x32')]:_0x5d3f42[_0x34bf('0x2f')];if(!_0x2aa7f6[_0x34bf('0x30')][_0x34bf('0x34')](_0x34bf('0x35'))){_0x46e130[_0x34bf('0x1d')]=qs[_0x34bf('0x1d')](_0x2aa7f6[_0x34bf('0x30')]['limit']);_0x46e130['offset']=qs[_0x34bf('0x1f')](_0x2aa7f6[_0x34bf('0x30')][_0x34bf('0x1f')]);}_0x46e130[_0x34bf('0x36')]=qs[_0x34bf('0x37')](_0x2aa7f6[_0x34bf('0x30')]['sort']);_0x46e130[_0x34bf('0x38')]=qs['filters'](_[_0x34bf('0x39')](_0x2aa7f6[_0x34bf('0x30')],_0x5d3f42[_0x34bf('0x3a')]),_0xdd46a5);if(_0x2aa7f6[_0x34bf('0x30')][_0x34bf('0x3b')]){_0x46e130[_0x34bf('0x38')]=_['merge'](_0x46e130['where'],{'$or':_[_0x34bf('0x2a')](_0xdd46a5,function(_0x2706f4){if(_0x2706f4[_0x34bf('0x2e')]!==_0x34bf('0x3c')){var _0x56e8c6={};_0x56e8c6[_0x2706f4[_0x34bf('0x27')]]={'$like':'%'+_0x2aa7f6[_0x34bf('0x30')][_0x34bf('0x3b')]+'%'};return _0x56e8c6;}})});}_0x46e130=_[_0x34bf('0x3d')]({},_0x46e130,_0x2aa7f6[_0x34bf('0x3e')]);var _0x5b42c9={'where':_0x46e130[_0x34bf('0x38')]};return db[_0x34bf('0x2b')][_0x34bf('0x1e')](_0x5b42c9)[_0x34bf('0x24')](function(_0x25edd1){_0x4d2532[_0x34bf('0x1e')]=_0x25edd1;if(_0x2aa7f6[_0x34bf('0x30')][_0x34bf('0x3f')]){_0x46e130[_0x34bf('0x40')]=[{'all':!![]}];}return db['ServicenowField'][_0x34bf('0x41')](_0x46e130);})[_0x34bf('0x24')](function(_0x2e6e78){_0x4d2532[_0x34bf('0x42')]=_0x2e6e78;return _0x4d2532;})[_0x34bf('0x24')](respondWithFilteredResult(_0x13fd18,_0x46e130))[_0x34bf('0x43')](handleError(_0x13fd18,null));};exports[_0x34bf('0x44')]=function(_0x161a22,_0x3ad50d){var _0x111cda={'raw':!![],'where':{'id':_0x161a22[_0x34bf('0x45')]['id']}},_0x123271={};_0x123271[_0x34bf('0x2f')]=_[_0x34bf('0x46')](db[_0x34bf('0x2b')][_0x34bf('0x2c')]);_0x123271[_0x34bf('0x30')]=_[_0x34bf('0x46')](_0x161a22[_0x34bf('0x30')]);_0x123271[_0x34bf('0x3a')]=_[_0x34bf('0x31')](_0x123271[_0x34bf('0x2f')],_0x123271[_0x34bf('0x30')]);_0x111cda[_0x34bf('0x32')]=_[_0x34bf('0x31')](_0x123271[_0x34bf('0x2f')],qs['fields'](_0x161a22[_0x34bf('0x30')][_0x34bf('0x47')]));_0x111cda[_0x34bf('0x32')]=_0x111cda[_0x34bf('0x32')][_0x34bf('0x33')]?_0x111cda[_0x34bf('0x32')]:_0x123271[_0x34bf('0x2f')];if(_0x161a22[_0x34bf('0x30')][_0x34bf('0x3f')]){_0x111cda['include']=[{'all':!![]}];}_0x111cda=_[_0x34bf('0x3d')]({},_0x111cda,_0x161a22['options']);return db[_0x34bf('0x2b')][_0x34bf('0x48')](_0x111cda)[_0x34bf('0x24')](handleEntityNotFound(_0x3ad50d,null))[_0x34bf('0x24')](respondWithResult(_0x3ad50d,null))[_0x34bf('0x43')](handleError(_0x3ad50d,null));};exports['create']=function(_0x25f1ef,_0x59cf5e){return db[_0x34bf('0x2b')][_0x34bf('0x49')](_0x25f1ef[_0x34bf('0x4a')],{})['then'](respondWithResult(_0x59cf5e,0xc9))[_0x34bf('0x43')](handleError(_0x59cf5e,null));};exports[_0x34bf('0x23')]=function(_0x32f49c,_0x39dd55){if(_0x32f49c[_0x34bf('0x4a')]['id']){delete _0x32f49c['body']['id'];}return db[_0x34bf('0x2b')][_0x34bf('0x48')]({'where':{'id':_0x32f49c[_0x34bf('0x45')]['id']}})['then'](handleEntityNotFound(_0x39dd55,null))['then'](saveUpdates(_0x32f49c['body'],null))['then'](respondWithResult(_0x39dd55,null))[_0x34bf('0x43')](handleError(_0x39dd55,null));};exports[_0x34bf('0x25')]=function(_0x13f632,_0x4dd9b1){return db[_0x34bf('0x2b')]['find']({'where':{'id':_0x13f632[_0x34bf('0x45')]['id']}})[_0x34bf('0x24')](handleEntityNotFound(_0x4dd9b1,null))[_0x34bf('0x24')](removeEntity(_0x4dd9b1,null))[_0x34bf('0x43')](handleError(_0x4dd9b1,null));};
\ No newline at end of file
+var _0x45f5=['update','then','destroy','error','name','index','map','rawAttributes','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filters','filter','merge','VIRTUAL','options','ServicenowField','include','rows','catch','show','params','includeAll','create','body','find','rimraf','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','apply','save'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0x45f5,0x6f));var _0x545f=function(_0x396539,_0x44d8b3){_0x396539=_0x396539-0x0;var _0x35540f=_0x45f5[_0x396539];return _0x35540f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x545f('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x545f('0x1'));var moment=require(_0x545f('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x545f('0x3'));var util=require(_0x545f('0x4'));var path=require(_0x545f('0x5'));var sox=require(_0x545f('0x6'));var csv=require(_0x545f('0x7'));var ejs=require(_0x545f('0x8'));var fs=require('fs');var fs_extra=require(_0x545f('0x9'));var _=require('lodash');var squel=require(_0x545f('0xa'));var crypto=require(_0x545f('0xb'));var jsforce=require(_0x545f('0xc'));var deskjs=require(_0x545f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x545f('0xe'));var Papa=require(_0x545f('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x545f('0x10'));var as=require(_0x545f('0x11'));var hardwareService=require(_0x545f('0x12'));var logger=require(_0x545f('0x13'))(_0x545f('0x14'));var utils=require('../../config/utils');var config=require(_0x545f('0x15'));var licenseUtil=require(_0x545f('0x16'));var db=require(_0x545f('0x17'))['db'];function respondWithStatusCode(_0x4827cf,_0x3ec44d){_0x3ec44d=_0x3ec44d||0xcc;return function(_0x18cd68){if(_0x18cd68){return _0x4827cf[_0x545f('0x18')](_0x3ec44d);}return _0x4827cf[_0x545f('0x19')](_0x3ec44d)[_0x545f('0x1a')]();};}function respondWithResult(_0x314fa2,_0x5c3415){_0x5c3415=_0x5c3415||0xc8;return function(_0x44ff4f){if(_0x44ff4f){return _0x314fa2[_0x545f('0x19')](_0x5c3415)['json'](_0x44ff4f);}};}function respondWithFilteredResult(_0x53cf5c,_0x1617ab){return function(_0x1138c2){if(_0x1138c2){var _0x457cc8=typeof _0x1617ab['offset']===_0x545f('0x1b')&&typeof _0x1617ab[_0x545f('0x1c')]===_0x545f('0x1b');var _0x155df4=_0x1138c2[_0x545f('0x1d')];var _0xaa2115=_0x457cc8?0x0:_0x1617ab[_0x545f('0x1e')];var _0x54c8e0=_0x457cc8?_0x1138c2[_0x545f('0x1d')]:_0x1617ab[_0x545f('0x1e')]+_0x1617ab[_0x545f('0x1c')];var _0x270ad8;if(_0x54c8e0>=_0x155df4){_0x54c8e0=_0x155df4;_0x270ad8=0xc8;}else{_0x270ad8=0xce;}_0x53cf5c['status'](_0x270ad8);return _0x53cf5c[_0x545f('0x1f')](_0x545f('0x20'),_0xaa2115+'-'+_0x54c8e0+'/'+_0x155df4)['json'](_0x1138c2);}return null;};}function patchUpdates(_0x12a343){return function(_0x3c9002){try{jsonpatch[_0x545f('0x21')](_0x3c9002,_0x12a343,!![]);}catch(_0x43ba71){return BPromise['reject'](_0x43ba71);}return _0x3c9002[_0x545f('0x22')]();};}function saveUpdates(_0x30f256,_0x5c0ce2){return function(_0x5afc85){if(_0x5afc85){return _0x5afc85[_0x545f('0x23')](_0x30f256)[_0x545f('0x24')](function(_0xcb616){return _0xcb616;});}return null;};}function removeEntity(_0x44c636,_0x3ad474){return function(_0x4fb93e){if(_0x4fb93e){return _0x4fb93e[_0x545f('0x25')]()[_0x545f('0x24')](function(){_0x44c636[_0x545f('0x19')](0xcc)[_0x545f('0x1a')]();});}};}function handleEntityNotFound(_0x24c6c1,_0x409ca3){return function(_0x3b115e){if(!_0x3b115e){_0x24c6c1[_0x545f('0x18')](0x194);}return _0x3b115e;};}function handleError(_0x29181b,_0x4b2f5f){_0x4b2f5f=_0x4b2f5f||0x1f4;return function(_0x3720e9){logger[_0x545f('0x26')](_0x3720e9['stack']);if(_0x3720e9[_0x545f('0x27')]){delete _0x3720e9['name'];}_0x29181b[_0x545f('0x19')](_0x4b2f5f)['send'](_0x3720e9);};}exports[_0x545f('0x28')]=function(_0x2baea5,_0x55e10c){var _0x1cad86={},_0x508121={},_0x39af86={'count':0x0,'rows':[]};var _0x2de85f=_[_0x545f('0x29')](db['ServicenowField'][_0x545f('0x2a')],function(_0x3b34b3){return{'name':_0x3b34b3[_0x545f('0x2b')],'type':_0x3b34b3[_0x545f('0x2c')][_0x545f('0x2d')]};});_0x508121[_0x545f('0x2e')]=_[_0x545f('0x29')](_0x2de85f,_0x545f('0x27'));_0x508121[_0x545f('0x2f')]=_[_0x545f('0x30')](_0x2baea5[_0x545f('0x2f')]);_0x508121['filters']=_[_0x545f('0x31')](_0x508121['model'],_0x508121[_0x545f('0x2f')]);_0x1cad86['attributes']=_[_0x545f('0x31')](_0x508121[_0x545f('0x2e')],qs[_0x545f('0x32')](_0x2baea5['query'][_0x545f('0x32')]));_0x1cad86['attributes']=_0x1cad86[_0x545f('0x33')][_0x545f('0x34')]?_0x1cad86[_0x545f('0x33')]:_0x508121[_0x545f('0x2e')];if(!_0x2baea5[_0x545f('0x2f')][_0x545f('0x35')](_0x545f('0x36'))){_0x1cad86[_0x545f('0x1c')]=qs[_0x545f('0x1c')](_0x2baea5['query'][_0x545f('0x1c')]);_0x1cad86[_0x545f('0x1e')]=qs['offset'](_0x2baea5['query'][_0x545f('0x1e')]);}_0x1cad86['order']=qs[_0x545f('0x37')](_0x2baea5[_0x545f('0x2f')][_0x545f('0x37')]);_0x1cad86[_0x545f('0x38')]=qs['filters'](_[_0x545f('0x39')](_0x2baea5[_0x545f('0x2f')],_0x508121[_0x545f('0x3a')]),_0x2de85f);if(_0x2baea5[_0x545f('0x2f')][_0x545f('0x3b')]){_0x1cad86['where']=_[_0x545f('0x3c')](_0x1cad86[_0x545f('0x38')],{'$or':_['map'](_0x2de85f,function(_0x1a1514){if(_0x1a1514['type']!==_0x545f('0x3d')){var _0x38247f={};_0x38247f[_0x1a1514[_0x545f('0x27')]]={'$like':'%'+_0x2baea5[_0x545f('0x2f')][_0x545f('0x3b')]+'%'};return _0x38247f;}})});}_0x1cad86=_[_0x545f('0x3c')]({},_0x1cad86,_0x2baea5[_0x545f('0x3e')]);var _0x553d83={'where':_0x1cad86[_0x545f('0x38')]};return db[_0x545f('0x3f')]['count'](_0x553d83)['then'](function(_0x3b5cb4){_0x39af86[_0x545f('0x1d')]=_0x3b5cb4;if(_0x2baea5[_0x545f('0x2f')]['includeAll']){_0x1cad86[_0x545f('0x40')]=[{'all':!![]}];}return db[_0x545f('0x3f')]['findAll'](_0x1cad86);})[_0x545f('0x24')](function(_0x47e174){_0x39af86[_0x545f('0x41')]=_0x47e174;return _0x39af86;})[_0x545f('0x24')](respondWithFilteredResult(_0x55e10c,_0x1cad86))[_0x545f('0x42')](handleError(_0x55e10c,null));};exports[_0x545f('0x43')]=function(_0x57a356,_0xd20e9b){var _0xd87124={'raw':!![],'where':{'id':_0x57a356[_0x545f('0x44')]['id']}},_0x30820c={};_0x30820c[_0x545f('0x2e')]=_[_0x545f('0x30')](db[_0x545f('0x3f')][_0x545f('0x2a')]);_0x30820c[_0x545f('0x2f')]=_[_0x545f('0x30')](_0x57a356[_0x545f('0x2f')]);_0x30820c['filters']=_[_0x545f('0x31')](_0x30820c[_0x545f('0x2e')],_0x30820c[_0x545f('0x2f')]);_0xd87124[_0x545f('0x33')]=_['intersection'](_0x30820c[_0x545f('0x2e')],qs[_0x545f('0x32')](_0x57a356['query'][_0x545f('0x32')]));_0xd87124[_0x545f('0x33')]=_0xd87124[_0x545f('0x33')][_0x545f('0x34')]?_0xd87124['attributes']:_0x30820c[_0x545f('0x2e')];if(_0x57a356[_0x545f('0x2f')][_0x545f('0x45')]){_0xd87124[_0x545f('0x40')]=[{'all':!![]}];}_0xd87124=_['merge']({},_0xd87124,_0x57a356[_0x545f('0x3e')]);return db[_0x545f('0x3f')]['find'](_0xd87124)[_0x545f('0x24')](handleEntityNotFound(_0xd20e9b,null))[_0x545f('0x24')](respondWithResult(_0xd20e9b,null))[_0x545f('0x42')](handleError(_0xd20e9b,null));};exports['create']=function(_0x3e0d83,_0x3ae561){return db[_0x545f('0x3f')][_0x545f('0x46')](_0x3e0d83[_0x545f('0x47')],{})[_0x545f('0x24')](respondWithResult(_0x3ae561,0xc9))[_0x545f('0x42')](handleError(_0x3ae561,null));};exports[_0x545f('0x23')]=function(_0x221312,_0x2140d9){if(_0x221312[_0x545f('0x47')]['id']){delete _0x221312['body']['id'];}return db[_0x545f('0x3f')]['find']({'where':{'id':_0x221312['params']['id']}})[_0x545f('0x24')](handleEntityNotFound(_0x2140d9,null))[_0x545f('0x24')](saveUpdates(_0x221312[_0x545f('0x47')],null))[_0x545f('0x24')](respondWithResult(_0x2140d9,null))['catch'](handleError(_0x2140d9,null));};exports[_0x545f('0x25')]=function(_0x3fa1df,_0x21a354){return db[_0x545f('0x3f')][_0x545f('0x48')]({'where':{'id':_0x3fa1df[_0x545f('0x44')]['id']}})[_0x545f('0x24')](handleEntityNotFound(_0x21a354,null))[_0x545f('0x24')](removeEntity(_0x21a354,null))[_0x545f('0x42')](handleError(_0x21a354,null));};
\ No newline at end of file