Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 070eb89..7de2919 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x45ce=['jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','sendStatus','status','json','limit','undefined','offset','count','reject','update','then','destroy','error','stack','name','send','index','map','Dynamics365Configuration','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','show','find','catch','create','body','params','getFields','findOne','Dynamics365Field','rawAttributes','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto'];(function(_0x144bed,_0x115974){var _0x4f3d52=function(_0x12dd2d){while(--_0x12dd2d){_0x144bed['push'](_0x144bed['shift']());}};_0x4f3d52(++_0x115974);}(_0x45ce,0xd8));var _0xe45c=function(_0x3a3dc2,_0x239f03){_0x3a3dc2=_0x3a3dc2-0x0;var _0x411c98=_0x45ce[_0x3a3dc2];return _0x411c98;};'use strict';var emlformat=require(_0xe45c('0x0'));var rimraf=require(_0xe45c('0x1'));var zipdir=require(_0xe45c('0x2'));var jsonpatch=require(_0xe45c('0x3'));var rp=require(_0xe45c('0x4'));var moment=require(_0xe45c('0x5'));var BPromise=require(_0xe45c('0x6'));var Mustache=require(_0xe45c('0x7'));var util=require('util');var path=require('path');var sox=require(_0xe45c('0x8'));var csv=require(_0xe45c('0x9'));var ejs=require(_0xe45c('0xa'));var fs=require('fs');var fs_extra=require(_0xe45c('0xb'));var _=require(_0xe45c('0xc'));var squel=require(_0xe45c('0xd'));var crypto=require(_0xe45c('0xe'));var jsforce=require(_0xe45c('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xe45c('0x9'));var querystring=require(_0xe45c('0x10'));var Papa=require(_0xe45c('0x11'));var Redis=require(_0xe45c('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xe45c('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xe45c('0x14'))(_0xe45c('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xe45c('0x16'))['db'];function respondWithStatusCode(_0x5bc473,_0x27cc41){_0x27cc41=_0x27cc41||0xcc;return function(_0xc8dd64){if(_0xc8dd64){return _0x5bc473[_0xe45c('0x17')](_0x27cc41);}return _0x5bc473[_0xe45c('0x18')](_0x27cc41)['end']();};}function respondWithResult(_0x279002,_0xfc6be7){_0xfc6be7=_0xfc6be7||0xc8;return function(_0x50c742){if(_0x50c742){return _0x279002[_0xe45c('0x18')](_0xfc6be7)[_0xe45c('0x19')](_0x50c742);}};}function respondWithFilteredResult(_0xe21a9d,_0x545ac9){return function(_0x50be9d){if(_0x50be9d){var _0x2f9c25=typeof _0x545ac9['offset']==='undefined'&&typeof _0x545ac9[_0xe45c('0x1a')]===_0xe45c('0x1b');var _0x5f2b8c=_0x50be9d['count'];var _0x18c7d9=_0x2f9c25?0x0:_0x545ac9[_0xe45c('0x1c')];var _0x50ca57=_0x2f9c25?_0x50be9d[_0xe45c('0x1d')]:_0x545ac9['offset']+_0x545ac9[_0xe45c('0x1a')];var _0x4d0014;if(_0x50ca57>=_0x5f2b8c){_0x50ca57=_0x5f2b8c;_0x4d0014=0xc8;}else{_0x4d0014=0xce;}_0xe21a9d[_0xe45c('0x18')](_0x4d0014);return _0xe21a9d['set']('Content-Range',_0x18c7d9+'-'+_0x50ca57+'/'+_0x5f2b8c)['json'](_0x50be9d);}return null;};}function patchUpdates(_0x3bf501){return function(_0x39ae5f){try{jsonpatch['apply'](_0x39ae5f,_0x3bf501,!![]);}catch(_0x33c804){return BPromise[_0xe45c('0x1e')](_0x33c804);}return _0x39ae5f['save']();};}function saveUpdates(_0x3972dd,_0x20dc23){return function(_0x5f1c25){if(_0x5f1c25){return _0x5f1c25[_0xe45c('0x1f')](_0x3972dd)[_0xe45c('0x20')](function(_0x4853d8){return _0x4853d8;});}return null;};}function removeEntity(_0x33fea8,_0x16538e){return function(_0xde99fa){if(_0xde99fa){return _0xde99fa[_0xe45c('0x21')]()[_0xe45c('0x20')](function(){_0x33fea8[_0xe45c('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4fcf02,_0x167bfe){return function(_0x529110){if(!_0x529110){_0x4fcf02[_0xe45c('0x17')](0x194);}return _0x529110;};}function handleError(_0xd3895a,_0x494e6b){_0x494e6b=_0x494e6b||0x1f4;return function(_0x46e2e0){logger[_0xe45c('0x22')](_0x46e2e0[_0xe45c('0x23')]);if(_0x46e2e0[_0xe45c('0x24')]){delete _0x46e2e0[_0xe45c('0x24')];}_0xd3895a[_0xe45c('0x18')](_0x494e6b)[_0xe45c('0x25')](_0x46e2e0);};}exports[_0xe45c('0x26')]=function(_0x308b24,_0x3c27a4){var _0x2733df={},_0x5316c2={},_0x387fc2={'count':0x0,'rows':[]};var _0x3defc8=_[_0xe45c('0x27')](db[_0xe45c('0x28')]['rawAttributes'],function(_0x15e60e){return{'name':_0x15e60e[_0xe45c('0x29')],'type':_0x15e60e[_0xe45c('0x2a')][_0xe45c('0x2b')]};});_0x5316c2[_0xe45c('0x2c')]=_[_0xe45c('0x27')](_0x3defc8,'name');_0x5316c2[_0xe45c('0x2d')]=_[_0xe45c('0x2e')](_0x308b24['query']);_0x5316c2[_0xe45c('0x2f')]=_[_0xe45c('0x30')](_0x5316c2['model'],_0x5316c2['query']);_0x2733df[_0xe45c('0x31')]=_[_0xe45c('0x30')](_0x5316c2[_0xe45c('0x2c')],qs['fields'](_0x308b24[_0xe45c('0x2d')][_0xe45c('0x32')]));_0x2733df[_0xe45c('0x31')]=_0x2733df['attributes'][_0xe45c('0x33')]?_0x2733df[_0xe45c('0x31')]:_0x5316c2['model'];if(!_0x308b24['query'][_0xe45c('0x34')](_0xe45c('0x35'))){_0x2733df[_0xe45c('0x1a')]=qs['limit'](_0x308b24[_0xe45c('0x2d')][_0xe45c('0x1a')]);_0x2733df[_0xe45c('0x1c')]=qs[_0xe45c('0x1c')](_0x308b24[_0xe45c('0x2d')][_0xe45c('0x1c')]);}_0x2733df[_0xe45c('0x36')]=qs['sort'](_0x308b24[_0xe45c('0x2d')][_0xe45c('0x37')]);_0x2733df[_0xe45c('0x38')]=qs['filters'](_[_0xe45c('0x39')](_0x308b24['query'],_0x5316c2['filters']),_0x3defc8);if(_0x308b24['query'][_0xe45c('0x3a')]){_0x2733df[_0xe45c('0x38')]=_[_0xe45c('0x3b')](_0x2733df[_0xe45c('0x38')],{'$or':_['map'](_0x3defc8,function(_0x2018a8){if(_0x2018a8[_0xe45c('0x2a')]!=='VIRTUAL'){var _0x1fd91c={};_0x1fd91c[_0x2018a8[_0xe45c('0x24')]]={'$like':'%'+_0x308b24[_0xe45c('0x2d')][_0xe45c('0x3a')]+'%'};return _0x1fd91c;}})});}_0x2733df=_['merge']({},_0x2733df,_0x308b24[_0xe45c('0x3c')]);var _0x35353d={'where':_0x2733df[_0xe45c('0x38')]};return db[_0xe45c('0x28')][_0xe45c('0x1d')](_0x35353d)['then'](function(_0x4a5e70){_0x387fc2['count']=_0x4a5e70;if(_0x308b24[_0xe45c('0x2d')][_0xe45c('0x3d')]){_0x2733df[_0xe45c('0x3e')]=[{'all':!![]}];}return db[_0xe45c('0x28')][_0xe45c('0x3f')](_0x2733df);})['then'](function(_0x49c9cb){_0x387fc2[_0xe45c('0x40')]=_0x49c9cb;return _0x387fc2;})[_0xe45c('0x20')](respondWithFilteredResult(_0x3c27a4,_0x2733df))['catch'](handleError(_0x3c27a4,null));};exports[_0xe45c('0x41')]=function(_0x2fcb4d,_0x357397){var _0x261a58={'raw':![],'where':{'id':_0x2fcb4d['params']['id']}},_0x220f00={};_0x220f00[_0xe45c('0x2c')]=_['keys'](db[_0xe45c('0x28')]['rawAttributes']);_0x220f00[_0xe45c('0x2d')]=_[_0xe45c('0x2e')](_0x2fcb4d[_0xe45c('0x2d')]);_0x220f00[_0xe45c('0x2f')]=_[_0xe45c('0x30')](_0x220f00[_0xe45c('0x2c')],_0x220f00[_0xe45c('0x2d')]);_0x261a58[_0xe45c('0x31')]=_['intersection'](_0x220f00[_0xe45c('0x2c')],qs['fields'](_0x2fcb4d['query'][_0xe45c('0x32')]));_0x261a58['attributes']=_0x261a58[_0xe45c('0x31')][_0xe45c('0x33')]?_0x261a58[_0xe45c('0x31')]:_0x220f00['model'];if(_0x2fcb4d[_0xe45c('0x2d')]['includeAll']){_0x261a58[_0xe45c('0x3e')]=[{'all':!![]}];}_0x261a58=_['merge']({},_0x261a58,_0x2fcb4d[_0xe45c('0x3c')]);return db['Dynamics365Configuration'][_0xe45c('0x42')](_0x261a58)['then'](handleEntityNotFound(_0x357397,null))[_0xe45c('0x20')](respondWithResult(_0x357397,null))[_0xe45c('0x43')](handleError(_0x357397,null));};exports[_0xe45c('0x44')]=function(_0x3f0a96,_0x1ab60e){return db[_0xe45c('0x28')][_0xe45c('0x44')](_0x3f0a96[_0xe45c('0x45')],{})[_0xe45c('0x20')](respondWithResult(_0x1ab60e,0xc9))[_0xe45c('0x43')](handleError(_0x1ab60e,null));};exports[_0xe45c('0x1f')]=function(_0x353d0d,_0x25bfbd){if(_0x353d0d[_0xe45c('0x45')]['id']){delete _0x353d0d['body']['id'];}return db['Dynamics365Configuration'][_0xe45c('0x42')]({'where':{'id':_0x353d0d['params']['id']}})[_0xe45c('0x20')](handleEntityNotFound(_0x25bfbd,null))['then'](saveUpdates(_0x353d0d[_0xe45c('0x45')],null))[_0xe45c('0x20')](respondWithResult(_0x25bfbd,null))[_0xe45c('0x43')](handleError(_0x25bfbd,null));};exports[_0xe45c('0x21')]=function(_0x35bf06,_0x55a9ce){return db['Dynamics365Configuration'][_0xe45c('0x42')]({'where':{'id':_0x35bf06[_0xe45c('0x46')]['id']}})['then'](handleEntityNotFound(_0x55a9ce,null))[_0xe45c('0x20')](removeEntity(_0x55a9ce,null))[_0xe45c('0x43')](handleError(_0x55a9ce,null));};exports[_0xe45c('0x47')]=function(_0x250be9,_0x2732ac,_0x3a685d){var _0x76feb9={};var _0x203dbd={};var _0x20af36;var _0x4b90cd;return db['Dynamics365Configuration'][_0xe45c('0x48')]({'where':{'id':_0x250be9['params']['id']}})[_0xe45c('0x20')](handleEntityNotFound(_0x2732ac,null))[_0xe45c('0x20')](function(_0x5988c6){if(_0x5988c6){_0x20af36=_0x5988c6;_0x203dbd[_0xe45c('0x2c')]=_[_0xe45c('0x2e')](db[_0xe45c('0x49')][_0xe45c('0x4a')]);_0x203dbd['query']=_['keys'](_0x250be9['query']);_0x203dbd[_0xe45c('0x2f')]=_['intersection'](_0x203dbd[_0xe45c('0x2c')],_0x203dbd[_0xe45c('0x2d')]);_0x76feb9[_0xe45c('0x31')]=_[_0xe45c('0x30')](_0x203dbd[_0xe45c('0x2c')],qs[_0xe45c('0x32')](_0x250be9[_0xe45c('0x2d')][_0xe45c('0x32')]));_0x76feb9[_0xe45c('0x31')]=_0x76feb9[_0xe45c('0x31')][_0xe45c('0x33')]?_0x76feb9[_0xe45c('0x31')]:_0x203dbd[_0xe45c('0x2c')];_0x76feb9['order']=qs[_0xe45c('0x37')](_0x250be9[_0xe45c('0x2d')][_0xe45c('0x37')]);_0x76feb9[_0xe45c('0x38')]=qs['filters'](_[_0xe45c('0x39')](_0x250be9[_0xe45c('0x2d')],_0x203dbd[_0xe45c('0x2f')]));if(_0x250be9[_0xe45c('0x2d')][_0xe45c('0x3a')]){_0x76feb9[_0xe45c('0x38')]=_['merge'](_0x76feb9['where'],{'$or':_[_0xe45c('0x27')](_0x76feb9['attributes'],function(_0x416c2c){var _0x2acc54={};_0x2acc54[_0x416c2c]={'$like':'%'+_0x250be9[_0xe45c('0x2d')]['filter']+'%'};return _0x2acc54;})});}_0x76feb9=_[_0xe45c('0x3b')]({},_0x76feb9,_0x250be9['options']);return _0x20af36[_0xe45c('0x47')](_0x76feb9);}})[_0xe45c('0x20')](function(_0x78451e){if(_0x78451e){_0x4b90cd=_0x78451e[_0xe45c('0x33')];if(!_0x250be9[_0xe45c('0x2d')][_0xe45c('0x34')]('nolimit')){_0x76feb9[_0xe45c('0x1a')]=qs[_0xe45c('0x1a')](_0x250be9[_0xe45c('0x2d')]['limit']);_0x76feb9[_0xe45c('0x1c')]=qs['offset'](_0x250be9[_0xe45c('0x2d')][_0xe45c('0x1c')]);}return _0x20af36['getFields'](_0x76feb9);}})[_0xe45c('0x20')](function(_0x1936c8){if(_0x1936c8){return _0x1936c8?{'count':_0x4b90cd,'rows':_0x1936c8}:null;}})[_0xe45c('0x20')](respondWithResult(_0x2732ac,null))[_0xe45c('0x43')](handleError(_0x2732ac,null));};exports['getSubjects']=function(_0xf1b89c,_0x39bdda,_0x387aca){var _0xc8eaf0={};var _0x240da9={};var _0x5ab487;var _0x12b4eb;return db[_0xe45c('0x28')][_0xe45c('0x48')]({'where':{'id':_0xf1b89c[_0xe45c('0x46')]['id']}})[_0xe45c('0x20')](handleEntityNotFound(_0x39bdda,null))['then'](function(_0x2ab9d5){if(_0x2ab9d5){_0x5ab487=_0x2ab9d5;_0x240da9[_0xe45c('0x2c')]=_[_0xe45c('0x2e')](db[_0xe45c('0x49')]['rawAttributes']);_0x240da9[_0xe45c('0x2d')]=_['keys'](_0xf1b89c['query']);_0x240da9[_0xe45c('0x2f')]=_[_0xe45c('0x30')](_0x240da9[_0xe45c('0x2c')],_0x240da9[_0xe45c('0x2d')]);_0xc8eaf0[_0xe45c('0x31')]=_[_0xe45c('0x30')](_0x240da9[_0xe45c('0x2c')],qs[_0xe45c('0x32')](_0xf1b89c[_0xe45c('0x2d')][_0xe45c('0x32')]));_0xc8eaf0['attributes']=_0xc8eaf0[_0xe45c('0x31')][_0xe45c('0x33')]?_0xc8eaf0[_0xe45c('0x31')]:_0x240da9[_0xe45c('0x2c')];_0xc8eaf0[_0xe45c('0x36')]=qs[_0xe45c('0x37')](_0xf1b89c[_0xe45c('0x2d')][_0xe45c('0x37')]);_0xc8eaf0[_0xe45c('0x38')]=qs[_0xe45c('0x2f')](_[_0xe45c('0x39')](_0xf1b89c['query'],_0x240da9[_0xe45c('0x2f')]));if(_0xf1b89c[_0xe45c('0x2d')]['filter']){_0xc8eaf0['where']=_[_0xe45c('0x3b')](_0xc8eaf0[_0xe45c('0x38')],{'$or':_[_0xe45c('0x27')](_0xc8eaf0[_0xe45c('0x31')],function(_0x55bb7b){var _0x37f425={};_0x37f425[_0x55bb7b]={'$like':'%'+_0xf1b89c[_0xe45c('0x2d')][_0xe45c('0x3a')]+'%'};return _0x37f425;})});}_0xc8eaf0=_['merge']({},_0xc8eaf0,_0xf1b89c[_0xe45c('0x3c')]);return _0x5ab487['getSubjects'](_0xc8eaf0);}})[_0xe45c('0x20')](function(_0x3dcb40){if(_0x3dcb40){_0x12b4eb=_0x3dcb40['length'];if(!_0xf1b89c[_0xe45c('0x2d')][_0xe45c('0x34')](_0xe45c('0x35'))){_0xc8eaf0[_0xe45c('0x1a')]=qs[_0xe45c('0x1a')](_0xf1b89c['query']['limit']);_0xc8eaf0['offset']=qs[_0xe45c('0x1c')](_0xf1b89c[_0xe45c('0x2d')][_0xe45c('0x1c')]);}return _0x5ab487[_0xe45c('0x4b')](_0xc8eaf0);}})[_0xe45c('0x20')](function(_0xc99a98){if(_0xc99a98){return _0xc99a98?{'count':_0x12b4eb,'rows':_0xc99a98}:null;}})[_0xe45c('0x20')](respondWithResult(_0x39bdda,null))[_0xe45c('0x43')](handleError(_0x39bdda,null));};exports[_0xe45c('0x4c')]=function(_0x4dd805,_0x4e5060,_0x5cb258){var _0x4144b5={};var _0x1fa82c={};var _0x2fd208;var _0x1a6ba7;return db[_0xe45c('0x28')][_0xe45c('0x48')]({'where':{'id':_0x4dd805['params']['id']}})[_0xe45c('0x20')](handleEntityNotFound(_0x4e5060,null))['then'](function(_0x566c0f){if(_0x566c0f){_0x2fd208=_0x566c0f;_0x1fa82c[_0xe45c('0x2c')]=_[_0xe45c('0x2e')](db[_0xe45c('0x49')][_0xe45c('0x4a')]);_0x1fa82c['query']=_[_0xe45c('0x2e')](_0x4dd805['query']);_0x1fa82c[_0xe45c('0x2f')]=_[_0xe45c('0x30')](_0x1fa82c[_0xe45c('0x2c')],_0x1fa82c[_0xe45c('0x2d')]);_0x4144b5['attributes']=_['intersection'](_0x1fa82c[_0xe45c('0x2c')],qs[_0xe45c('0x32')](_0x4dd805['query'][_0xe45c('0x32')]));_0x4144b5[_0xe45c('0x31')]=_0x4144b5[_0xe45c('0x31')]['length']?_0x4144b5['attributes']:_0x1fa82c[_0xe45c('0x2c')];_0x4144b5[_0xe45c('0x36')]=qs['sort'](_0x4dd805[_0xe45c('0x2d')][_0xe45c('0x37')]);_0x4144b5[_0xe45c('0x38')]=qs[_0xe45c('0x2f')](_['pick'](_0x4dd805[_0xe45c('0x2d')],_0x1fa82c[_0xe45c('0x2f')]));if(_0x4dd805[_0xe45c('0x2d')][_0xe45c('0x3a')]){_0x4144b5[_0xe45c('0x38')]=_['merge'](_0x4144b5[_0xe45c('0x38')],{'$or':_[_0xe45c('0x27')](_0x4144b5[_0xe45c('0x31')],function(_0x57ea88){var _0x45dca4={};_0x45dca4[_0x57ea88]={'$like':'%'+_0x4dd805[_0xe45c('0x2d')][_0xe45c('0x3a')]+'%'};return _0x45dca4;})});}_0x4144b5=_['merge']({},_0x4144b5,_0x4dd805['options']);return _0x2fd208[_0xe45c('0x4c')](_0x4144b5);}})[_0xe45c('0x20')](function(_0x1bfe77){if(_0x1bfe77){_0x1a6ba7=_0x1bfe77[_0xe45c('0x33')];if(!_0x4dd805['query'][_0xe45c('0x34')](_0xe45c('0x35'))){_0x4144b5[_0xe45c('0x1a')]=qs[_0xe45c('0x1a')](_0x4dd805[_0xe45c('0x2d')][_0xe45c('0x1a')]);_0x4144b5[_0xe45c('0x1c')]=qs[_0xe45c('0x1c')](_0x4dd805[_0xe45c('0x2d')][_0xe45c('0x1c')]);}return _0x2fd208[_0xe45c('0x4c')](_0x4144b5);}})[_0xe45c('0x20')](function(_0x1ecf07){if(_0x1ecf07){return _0x1ecf07?{'count':_0x1a6ba7,'rows':_0x1ecf07}:null;}})[_0xe45c('0x20')](respondWithResult(_0x4e5060,null))[_0xe45c('0x43')](handleError(_0x4e5060,null));};
\ No newline at end of file
+var _0x3c8b=['where','filters','pick','filter','merge','VIRTUAL','name','options','count','then','includeAll','include','findAll','rows','catch','show','params','create','body','find','getFields','findOne','Dynamics365Field','hasOwnProperty','getSubjects','getDescriptions','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','offset','limit','undefined','Content-Range','json','apply','reject','save','update','destroy','end','stack','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort'];(function(_0x159235,_0x6c7f91){var _0x5345de=function(_0xf7aa28){while(--_0xf7aa28){_0x159235['push'](_0x159235['shift']());}};_0x5345de(++_0x6c7f91);}(_0x3c8b,0x67));var _0xb3c8=function(_0x152c79,_0x521f52){_0x152c79=_0x152c79-0x0;var _0x5d08eb=_0x3c8b[_0x152c79];return _0x5d08eb;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb3c8('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb3c8('0x1'));var rp=require(_0xb3c8('0x2'));var moment=require(_0xb3c8('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xb3c8('0x4'));var util=require(_0xb3c8('0x5'));var path=require(_0xb3c8('0x6'));var sox=require(_0xb3c8('0x7'));var csv=require(_0xb3c8('0x8'));var ejs=require(_0xb3c8('0x9'));var fs=require('fs');var fs_extra=require(_0xb3c8('0xa'));var _=require(_0xb3c8('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xb3c8('0xc'));var Papa=require(_0xb3c8('0xd'));var Redis=require('ioredis');var authService=require(_0xb3c8('0xe'));var qs=require(_0xb3c8('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb3c8('0x10'));var logger=require('../../config/logger')(_0xb3c8('0x11'));var utils=require(_0xb3c8('0x12'));var config=require(_0xb3c8('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0xb3c8('0x14'))['db'];function respondWithStatusCode(_0x898559,_0x1eb167){_0x1eb167=_0x1eb167||0xcc;return function(_0x3938d8){if(_0x3938d8){return _0x898559[_0xb3c8('0x15')](_0x1eb167);}return _0x898559[_0xb3c8('0x16')](_0x1eb167)['end']();};}function respondWithResult(_0x4f7b73,_0x165c61){_0x165c61=_0x165c61||0xc8;return function(_0x32844f){if(_0x32844f){return _0x4f7b73[_0xb3c8('0x16')](_0x165c61)['json'](_0x32844f);}};}function respondWithFilteredResult(_0x25b426,_0x2c4a8d){return function(_0x175116){if(_0x175116){var _0x43dfc2=typeof _0x2c4a8d[_0xb3c8('0x17')]==='undefined'&&typeof _0x2c4a8d[_0xb3c8('0x18')]===_0xb3c8('0x19');var _0x13bb07=_0x175116['count'];var _0xaf0822=_0x43dfc2?0x0:_0x2c4a8d[_0xb3c8('0x17')];var _0x305fae=_0x43dfc2?_0x175116['count']:_0x2c4a8d[_0xb3c8('0x17')]+_0x2c4a8d[_0xb3c8('0x18')];var _0x437327;if(_0x305fae>=_0x13bb07){_0x305fae=_0x13bb07;_0x437327=0xc8;}else{_0x437327=0xce;}_0x25b426[_0xb3c8('0x16')](_0x437327);return _0x25b426['set'](_0xb3c8('0x1a'),_0xaf0822+'-'+_0x305fae+'/'+_0x13bb07)[_0xb3c8('0x1b')](_0x175116);}return null;};}function patchUpdates(_0x40b886){return function(_0x26be5f){try{jsonpatch[_0xb3c8('0x1c')](_0x26be5f,_0x40b886,!![]);}catch(_0x4d1c58){return BPromise[_0xb3c8('0x1d')](_0x4d1c58);}return _0x26be5f[_0xb3c8('0x1e')]();};}function saveUpdates(_0x311de6,_0xbce116){return function(_0x4d1b5c){if(_0x4d1b5c){return _0x4d1b5c[_0xb3c8('0x1f')](_0x311de6)['then'](function(_0x31b032){return _0x31b032;});}return null;};}function removeEntity(_0x30ff0d,_0x588c24){return function(_0x50a7df){if(_0x50a7df){return _0x50a7df[_0xb3c8('0x20')]()['then'](function(){_0x30ff0d['status'](0xcc)[_0xb3c8('0x21')]();});}};}function handleEntityNotFound(_0x57607b,_0xa80aaa){return function(_0x267001){if(!_0x267001){_0x57607b['sendStatus'](0x194);}return _0x267001;};}function handleError(_0x4aec78,_0x247c17){_0x247c17=_0x247c17||0x1f4;return function(_0x2180ab){logger['error'](_0x2180ab[_0xb3c8('0x22')]);if(_0x2180ab['name']){delete _0x2180ab['name'];}_0x4aec78[_0xb3c8('0x16')](_0x247c17)['send'](_0x2180ab);};}exports['index']=function(_0xc95642,_0x2a57b2){var _0x54ede1={},_0x34c34b={},_0x597ff0={'count':0x0,'rows':[]};var _0x1d3699=_[_0xb3c8('0x23')](db[_0xb3c8('0x24')][_0xb3c8('0x25')],function(_0x472787){return{'name':_0x472787[_0xb3c8('0x26')],'type':_0x472787[_0xb3c8('0x27')][_0xb3c8('0x28')]};});_0x34c34b[_0xb3c8('0x29')]=_['map'](_0x1d3699,'name');_0x34c34b[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0xc95642[_0xb3c8('0x2a')]);_0x34c34b['filters']=_[_0xb3c8('0x2c')](_0x34c34b[_0xb3c8('0x29')],_0x34c34b[_0xb3c8('0x2a')]);_0x54ede1[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x34c34b[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x54ede1[_0xb3c8('0x2d')]=_0x54ede1[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x54ede1[_0xb3c8('0x2d')]:_0x34c34b[_0xb3c8('0x29')];if(!_0xc95642[_0xb3c8('0x2a')]['hasOwnProperty'](_0xb3c8('0x30'))){_0x54ede1[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x54ede1[_0xb3c8('0x17')]=qs['offset'](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}_0x54ede1[_0xb3c8('0x31')]=qs['sort'](_0xc95642['query'][_0xb3c8('0x32')]);_0x54ede1[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0xc95642[_0xb3c8('0x2a')],_0x34c34b[_0xb3c8('0x34')]),_0x1d3699);if(_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x54ede1[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x54ede1['where'],{'$or':_['map'](_0x1d3699,function(_0x27d11d){if(_0x27d11d[_0xb3c8('0x27')]!==_0xb3c8('0x38')){var _0x435e90={};_0x435e90[_0x27d11d[_0xb3c8('0x39')]]={'$like':'%'+_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x36')]+'%'};return _0x435e90;}})});}_0x54ede1=_[_0xb3c8('0x37')]({},_0x54ede1,_0xc95642[_0xb3c8('0x3a')]);var _0x4183e5={'where':_0x54ede1['where']};return db['Dynamics365Configuration'][_0xb3c8('0x3b')](_0x4183e5)[_0xb3c8('0x3c')](function(_0x10e460){_0x597ff0[_0xb3c8('0x3b')]=_0x10e460;if(_0xc95642['query'][_0xb3c8('0x3d')]){_0x54ede1[_0xb3c8('0x3e')]=[{'all':!![]}];}return db[_0xb3c8('0x24')][_0xb3c8('0x3f')](_0x54ede1);})[_0xb3c8('0x3c')](function(_0x5ddaaa){_0x597ff0[_0xb3c8('0x40')]=_0x5ddaaa;return _0x597ff0;})['then'](respondWithFilteredResult(_0x2a57b2,_0x54ede1))[_0xb3c8('0x41')](handleError(_0x2a57b2,null));};exports[_0xb3c8('0x42')]=function(_0x1f9e5e,_0x3b414d){var _0x304e74={'raw':![],'where':{'id':_0x1f9e5e[_0xb3c8('0x43')]['id']}},_0x425ffd={};_0x425ffd[_0xb3c8('0x29')]=_[_0xb3c8('0x2b')](db[_0xb3c8('0x24')]['rawAttributes']);_0x425ffd[_0xb3c8('0x2a')]=_['keys'](_0x1f9e5e[_0xb3c8('0x2a')]);_0x425ffd[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x425ffd[_0xb3c8('0x29')],_0x425ffd[_0xb3c8('0x2a')]);_0x304e74['attributes']=_['intersection'](_0x425ffd[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x1f9e5e[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x304e74['attributes']=_0x304e74[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x304e74[_0xb3c8('0x2d')]:_0x425ffd[_0xb3c8('0x29')];if(_0x1f9e5e[_0xb3c8('0x2a')][_0xb3c8('0x3d')]){_0x304e74[_0xb3c8('0x3e')]=[{'all':!![]}];}_0x304e74=_[_0xb3c8('0x37')]({},_0x304e74,_0x1f9e5e[_0xb3c8('0x3a')]);return db[_0xb3c8('0x24')]['find'](_0x304e74)[_0xb3c8('0x3c')](handleEntityNotFound(_0x3b414d,null))['then'](respondWithResult(_0x3b414d,null))[_0xb3c8('0x41')](handleError(_0x3b414d,null));};exports['create']=function(_0x5b94cf,_0x24dfa0){return db[_0xb3c8('0x24')][_0xb3c8('0x44')](_0x5b94cf[_0xb3c8('0x45')],{})[_0xb3c8('0x3c')](respondWithResult(_0x24dfa0,0xc9))[_0xb3c8('0x41')](handleError(_0x24dfa0,null));};exports[_0xb3c8('0x1f')]=function(_0x182d38,_0x56302e){if(_0x182d38[_0xb3c8('0x45')]['id']){delete _0x182d38['body']['id'];}return db['Dynamics365Configuration'][_0xb3c8('0x46')]({'where':{'id':_0x182d38[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x56302e,null))['then'](saveUpdates(_0x182d38['body'],null))[_0xb3c8('0x3c')](respondWithResult(_0x56302e,null))[_0xb3c8('0x41')](handleError(_0x56302e,null));};exports['destroy']=function(_0x134653,_0x39a972){return db[_0xb3c8('0x24')][_0xb3c8('0x46')]({'where':{'id':_0x134653[_0xb3c8('0x43')]['id']}})['then'](handleEntityNotFound(_0x39a972,null))[_0xb3c8('0x3c')](removeEntity(_0x39a972,null))['catch'](handleError(_0x39a972,null));};exports[_0xb3c8('0x47')]=function(_0x336a80,_0x243641,_0x1b2b6d){var _0x373e9c={};var _0x1d3e76={};var _0x3b3db4;var _0xc6797c;return db[_0xb3c8('0x24')][_0xb3c8('0x48')]({'where':{'id':_0x336a80[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x243641,null))[_0xb3c8('0x3c')](function(_0x35d238){if(_0x35d238){_0x3b3db4=_0x35d238;_0x1d3e76['model']=_[_0xb3c8('0x2b')](db[_0xb3c8('0x49')]['rawAttributes']);_0x1d3e76[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0x336a80[_0xb3c8('0x2a')]);_0x1d3e76[_0xb3c8('0x34')]=_['intersection'](_0x1d3e76['model'],_0x1d3e76['query']);_0x373e9c[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x1d3e76[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x336a80['query'][_0xb3c8('0x2e')]));_0x373e9c[_0xb3c8('0x2d')]=_0x373e9c[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x373e9c[_0xb3c8('0x2d')]:_0x1d3e76['model'];_0x373e9c[_0xb3c8('0x31')]=qs['sort'](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x32')]);_0x373e9c[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0x336a80[_0xb3c8('0x2a')],_0x1d3e76[_0xb3c8('0x34')]));if(_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x373e9c['where']=_[_0xb3c8('0x37')](_0x373e9c[_0xb3c8('0x33')],{'$or':_[_0xb3c8('0x23')](_0x373e9c[_0xb3c8('0x2d')],function(_0xe7166e){var _0xfdd074={};_0xfdd074[_0xe7166e]={'$like':'%'+_0x336a80['query'][_0xb3c8('0x36')]+'%'};return _0xfdd074;})});}_0x373e9c=_[_0xb3c8('0x37')]({},_0x373e9c,_0x336a80[_0xb3c8('0x3a')]);return _0x3b3db4[_0xb3c8('0x47')](_0x373e9c);}})[_0xb3c8('0x3c')](function(_0x47c111){if(_0x47c111){_0xc6797c=_0x47c111['length'];if(!_0x336a80['query'][_0xb3c8('0x4a')]('nolimit')){_0x373e9c[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x373e9c['offset']=qs[_0xb3c8('0x17')](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x3b3db4[_0xb3c8('0x47')](_0x373e9c);}})['then'](function(_0x12e6fd){if(_0x12e6fd){return _0x12e6fd?{'count':_0xc6797c,'rows':_0x12e6fd}:null;}})['then'](respondWithResult(_0x243641,null))[_0xb3c8('0x41')](handleError(_0x243641,null));};exports[_0xb3c8('0x4b')]=function(_0x1e14a1,_0x37ae5e,_0x58c4e3){var _0x26f433={};var _0x24b984={};var _0x21c556;var _0x367cee;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x1e14a1[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x37ae5e,null))[_0xb3c8('0x3c')](function(_0x4f1f8c){if(_0x4f1f8c){_0x21c556=_0x4f1f8c;_0x24b984[_0xb3c8('0x29')]=_['keys'](db['Dynamics365Field'][_0xb3c8('0x25')]);_0x24b984[_0xb3c8('0x2a')]=_['keys'](_0x1e14a1[_0xb3c8('0x2a')]);_0x24b984[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x24b984[_0xb3c8('0x29')],_0x24b984[_0xb3c8('0x2a')]);_0x26f433[_0xb3c8('0x2d')]=_['intersection'](_0x24b984[_0xb3c8('0x29')],qs['fields'](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x26f433[_0xb3c8('0x2d')]=_0x26f433[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x26f433[_0xb3c8('0x2d')]:_0x24b984['model'];_0x26f433['order']=qs[_0xb3c8('0x32')](_0x1e14a1['query'][_0xb3c8('0x32')]);_0x26f433[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0x1e14a1[_0xb3c8('0x2a')],_0x24b984['filters']));if(_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x26f433[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x26f433['where'],{'$or':_['map'](_0x26f433['attributes'],function(_0x4a499e){var _0x1071dd={};_0x1071dd[_0x4a499e]={'$like':'%'+_0x1e14a1['query'][_0xb3c8('0x36')]+'%'};return _0x1071dd;})});}_0x26f433=_[_0xb3c8('0x37')]({},_0x26f433,_0x1e14a1[_0xb3c8('0x3a')]);return _0x21c556[_0xb3c8('0x4b')](_0x26f433);}})[_0xb3c8('0x3c')](function(_0x2999c4){if(_0x2999c4){_0x367cee=_0x2999c4['length'];if(!_0x1e14a1['query'][_0xb3c8('0x4a')](_0xb3c8('0x30'))){_0x26f433[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x26f433['offset']=qs['offset'](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x21c556[_0xb3c8('0x4b')](_0x26f433);}})[_0xb3c8('0x3c')](function(_0x520054){if(_0x520054){return _0x520054?{'count':_0x367cee,'rows':_0x520054}:null;}})[_0xb3c8('0x3c')](respondWithResult(_0x37ae5e,null))[_0xb3c8('0x41')](handleError(_0x37ae5e,null));};exports[_0xb3c8('0x4c')]=function(_0x3184d5,_0x5acd43,_0x47cc90){var _0x39cb2c={};var _0x56095f={};var _0x35b358;var _0x39298f;return db[_0xb3c8('0x24')][_0xb3c8('0x48')]({'where':{'id':_0x3184d5[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x5acd43,null))[_0xb3c8('0x3c')](function(_0x59d097){if(_0x59d097){_0x35b358=_0x59d097;_0x56095f[_0xb3c8('0x29')]=_[_0xb3c8('0x2b')](db['Dynamics365Field']['rawAttributes']);_0x56095f[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0x3184d5[_0xb3c8('0x2a')]);_0x56095f[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x56095f[_0xb3c8('0x29')],_0x56095f[_0xb3c8('0x2a')]);_0x39cb2c[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x56095f[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x39cb2c[_0xb3c8('0x2d')]=_0x39cb2c[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x39cb2c[_0xb3c8('0x2d')]:_0x56095f['model'];_0x39cb2c[_0xb3c8('0x31')]=qs[_0xb3c8('0x32')](_0x3184d5[_0xb3c8('0x2a')]['sort']);_0x39cb2c[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_['pick'](_0x3184d5['query'],_0x56095f[_0xb3c8('0x34')]));if(_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x39cb2c[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x39cb2c[_0xb3c8('0x33')],{'$or':_[_0xb3c8('0x23')](_0x39cb2c[_0xb3c8('0x2d')],function(_0x5db6d7){var _0x51ef5b={};_0x51ef5b[_0x5db6d7]={'$like':'%'+_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x36')]+'%'};return _0x51ef5b;})});}_0x39cb2c=_[_0xb3c8('0x37')]({},_0x39cb2c,_0x3184d5['options']);return _0x35b358[_0xb3c8('0x4c')](_0x39cb2c);}})[_0xb3c8('0x3c')](function(_0x353823){if(_0x353823){_0x39298f=_0x353823[_0xb3c8('0x2f')];if(!_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x4a')](_0xb3c8('0x30'))){_0x39cb2c[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x3184d5[_0xb3c8('0x2a')]['limit']);_0x39cb2c[_0xb3c8('0x17')]=qs['offset'](_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x35b358[_0xb3c8('0x4c')](_0x39cb2c);}})[_0xb3c8('0x3c')](function(_0x1928d5){if(_0x1928d5){return _0x1928d5?{'count':_0x39298f,'rows':_0x1928d5}:null;}})['then'](respondWithResult(_0x5acd43,null))[_0xb3c8('0x41')](handleError(_0x5acd43,null));};
\ No newline at end of file