Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index ad79a04..bcd5066 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa42d=['name','send','index','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','length','find','create','body','getFields','findOne','getSubjects','getDescriptions','eml-format','rimraf','moment','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','client','http','test','Sequelize','ValidationError','then','info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','status','json','count','offset','set','Content-Range','apply','reject','save','update','destroy','end','sendStatus','stack'];(function(_0x11bd78,_0x215f28){var _0x5864a7=function(_0x33735a){while(--_0x33735a){_0x11bd78['push'](_0x11bd78['shift']());}};_0x5864a7(++_0x215f28);}(_0xa42d,0xde));var _0xda42=function(_0x529391,_0x195752){_0x529391=_0x529391-0x0;var _0x50dc45=_0xa42d[_0x529391];return _0x50dc45;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xda42('0x0'));var rimraf=require(_0xda42('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xda42('0x2'));var BPromise=require(_0xda42('0x3'));var Mustache=require(_0xda42('0x4'));var util=require(_0xda42('0x5'));var path=require(_0xda42('0x6'));var sox=require('sox');var csv=require(_0xda42('0x7'));var ejs=require(_0xda42('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xda42('0x9'));var crypto=require(_0xda42('0xa'));var jsforce=require(_0xda42('0xb'));var deskjs=require(_0xda42('0xc'));var toCsv=require(_0xda42('0x7'));var querystring=require('querystring');var Papa=require(_0xda42('0xd'));var Redis=require(_0xda42('0xe'));var authService=require(_0xda42('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xda42('0x10'));var hardwareService=require(_0xda42('0x11'));var logger=require(_0xda42('0x12'))(_0xda42('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0xda42('0x14'))['db'];var jayson=require('jayson/promise');var client=jayson[_0xda42('0x15')][_0xda42('0x16')]({'port':0x232a});function checkPasswordPattern(_0x373bc6,_0x1c95b6,_0x43279b){if(_0x43279b){var _0x52db6a=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x52db6a[_0xda42('0x17')](_0x1c95b6)){return _0x373bc6;}else{throw new db[(_0xda42('0x18'))][(_0xda42('0x19'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x373bc6;}}function respondWithRpcPromise(_0x3440cd,_0x56b96a,_0x1fe68a,_0xa6b5a2){return new BPromise(function(_0x2a7e19,_0x46f032){var _0x346341=_0xa6b5a2||client;return _0x346341['request'](_0x3440cd,_0x1fe68a)[_0xda42('0x1a')](function(_0x46bd95){logger[_0xda42('0x1b')](_0xda42('0x1c'),_0x56b96a,_0xda42('0x1d'));logger['debug'](_0xda42('0x1e'),_0x56b96a,'request\x20sent',JSON[_0xda42('0x1f')](_0x46bd95));if(_0x46bd95[_0xda42('0x20')]){if(_0x46bd95[_0xda42('0x20')][_0xda42('0x21')]===0x1f4){logger[_0xda42('0x20')]('Dynamics365Configuration,\x20%s,\x20%s',_0x56b96a,_0x46bd95[_0xda42('0x20')][_0xda42('0x22')]);return _0x46f032(_0x46bd95[_0xda42('0x20')][_0xda42('0x22')]);}logger[_0xda42('0x20')](_0xda42('0x1c'),_0x56b96a,_0x46bd95[_0xda42('0x20')][_0xda42('0x22')]);return _0x2a7e19(_0x46bd95[_0xda42('0x20')][_0xda42('0x22')]);}else{logger[_0xda42('0x1b')](_0xda42('0x1c'),_0x56b96a,_0xda42('0x1d'));_0x2a7e19(_0x46bd95[_0xda42('0x23')][_0xda42('0x22')]);}})[_0xda42('0x24')](function(_0x6e8862){logger[_0xda42('0x20')](_0xda42('0x1c'),_0x56b96a,_0x6e8862);_0x46f032(_0x6e8862);});});}function respondWithStatusCode(_0x3babfd,_0x5a7109){_0x5a7109=_0x5a7109||0xcc;return function(_0x432c2c){if(_0x432c2c){return _0x3babfd['sendStatus'](_0x5a7109);}return _0x3babfd[_0xda42('0x25')](_0x5a7109)['end']();};}function respondWithResult(_0x205ad0,_0x16da96){_0x16da96=_0x16da96||0xc8;return function(_0x38729e){if(_0x38729e){return _0x205ad0[_0xda42('0x25')](_0x16da96)[_0xda42('0x26')](_0x38729e);}};}function respondWithFilteredResult(_0x2cc292,_0x18432e){return function(_0x31e3ac){if(_0x31e3ac){var _0x4b3fa1=_0x31e3ac[_0xda42('0x27')],_0xf1fc4c=_0x18432e[_0xda42('0x28')],_0x412d41=_0x18432e['offset']+_0x18432e['limit'],_0x2c8fae;if(_0x412d41>=_0x4b3fa1){_0x412d41=_0x4b3fa1;_0x2c8fae=0xc8;}else{_0x2c8fae=0xce;}_0x2cc292[_0xda42('0x25')](_0x2c8fae);return _0x2cc292[_0xda42('0x29')](_0xda42('0x2a'),_0xf1fc4c+'-'+_0x412d41+'/'+_0x4b3fa1)[_0xda42('0x26')](_0x31e3ac);}return null;};}function patchUpdates(_0x3cafa0){return function(_0x3a300f){try{jsonpatch[_0xda42('0x2b')](_0x3a300f,_0x3cafa0,!![]);}catch(_0x2690bf){return BPromise[_0xda42('0x2c')](_0x2690bf);}return _0x3a300f[_0xda42('0x2d')]();};}function saveUpdates(_0x3b9a68,_0x1e12d8){return function(_0x50c8eb){if(_0x50c8eb){return _0x50c8eb[_0xda42('0x2e')](_0x3b9a68)[_0xda42('0x1a')](function(_0x2eb64b){return _0x2eb64b;});}return null;};}function removeEntity(_0x535f97,_0x3eb0cc){return function(_0x3d4caa){if(_0x3d4caa){return _0x3d4caa[_0xda42('0x2f')]()[_0xda42('0x1a')](function(){_0x535f97[_0xda42('0x25')](0xcc)[_0xda42('0x30')]();});}};}function handleEntityNotFound(_0x39f89c,_0x52497b){return function(_0x34c284){if(!_0x34c284){_0x39f89c[_0xda42('0x31')](0x194);}return _0x34c284;};}function handleError(_0x45248b,_0x4868fe){_0x4868fe=_0x4868fe||0x1f4;return function(_0x240a65){logger['error'](_0x240a65[_0xda42('0x32')]);if(_0x240a65[_0xda42('0x33')]){delete _0x240a65[_0xda42('0x33')];}_0x45248b['status'](_0x4868fe)[_0xda42('0x34')](_0x240a65);};}exports[_0xda42('0x35')]=function(_0x4e43b5,_0x39463a){var _0x5bd484={},_0x55c935={},_0x54f71c={'count':0x0,'rows':[]};var _0x2c4365=_[_0xda42('0x36')](db[_0xda42('0x37')][_0xda42('0x38')],function(_0x4d7f3c){return{'name':_0x4d7f3c[_0xda42('0x39')],'type':_0x4d7f3c[_0xda42('0x3a')][_0xda42('0x3b')]};});_0x55c935[_0xda42('0x3c')]=_['map'](_0x2c4365,'name');_0x55c935[_0xda42('0x3d')]=_[_0xda42('0x3e')](_0x4e43b5[_0xda42('0x3d')]);_0x55c935[_0xda42('0x3f')]=_[_0xda42('0x40')](_0x55c935[_0xda42('0x3c')],_0x55c935['query']);_0x5bd484[_0xda42('0x41')]=_[_0xda42('0x40')](_0x55c935[_0xda42('0x3c')],qs[_0xda42('0x42')](_0x4e43b5[_0xda42('0x3d')]['fields']));_0x5bd484[_0xda42('0x41')]=_0x5bd484[_0xda42('0x41')]['length']?_0x5bd484['attributes']:_0x55c935['model'];if(!_0x4e43b5['query'][_0xda42('0x43')](_0xda42('0x44'))){_0x5bd484[_0xda42('0x45')]=qs[_0xda42('0x45')](_0x4e43b5['query'][_0xda42('0x45')]);_0x5bd484[_0xda42('0x28')]=qs[_0xda42('0x28')](_0x4e43b5[_0xda42('0x3d')]['offset']);}_0x5bd484[_0xda42('0x46')]=qs[_0xda42('0x47')](_0x4e43b5[_0xda42('0x3d')][_0xda42('0x47')]);_0x5bd484[_0xda42('0x48')]=qs[_0xda42('0x3f')](_[_0xda42('0x49')](_0x4e43b5['query'],_0x55c935[_0xda42('0x3f')]),_0x2c4365);if(_0x4e43b5[_0xda42('0x3d')][_0xda42('0x4a')]){_0x5bd484['where']=_['merge'](_0x5bd484[_0xda42('0x48')],{'$or':_[_0xda42('0x36')](_0x2c4365,function(_0x153079){if(_0x153079['type']!==_0xda42('0x4b')){var _0x3b0e38={};_0x3b0e38[_0x153079[_0xda42('0x33')]]={'$like':'%'+_0x4e43b5[_0xda42('0x3d')][_0xda42('0x4a')]+'%'};return _0x3b0e38;}})});}_0x5bd484=_[_0xda42('0x4c')]({},_0x5bd484,_0x4e43b5[_0xda42('0x4d')]);var _0xeaa16e={'where':_0x5bd484['where']};return db[_0xda42('0x37')][_0xda42('0x27')](_0xeaa16e)[_0xda42('0x1a')](function(_0x53d1b2){_0x54f71c['count']=_0x53d1b2;if(_0x4e43b5[_0xda42('0x3d')][_0xda42('0x4e')]){_0x5bd484[_0xda42('0x4f')]=[{'all':!![]}];}return db[_0xda42('0x37')][_0xda42('0x50')](_0x5bd484);})[_0xda42('0x1a')](function(_0x1d23d7){_0x54f71c['rows']=_0x1d23d7;return _0x54f71c;})[_0xda42('0x1a')](respondWithFilteredResult(_0x39463a,_0x5bd484))[_0xda42('0x24')](handleError(_0x39463a,null));};exports[_0xda42('0x51')]=function(_0x3a777c,_0xa4bcfd){var _0x1fc8d1={'raw':![],'where':{'id':_0x3a777c[_0xda42('0x52')]['id']}},_0x55fa7a={};_0x55fa7a['model']=_['keys'](db[_0xda42('0x37')][_0xda42('0x38')]);_0x55fa7a['query']=_[_0xda42('0x3e')](_0x3a777c[_0xda42('0x3d')]);_0x55fa7a['filters']=_[_0xda42('0x40')](_0x55fa7a[_0xda42('0x3c')],_0x55fa7a[_0xda42('0x3d')]);_0x1fc8d1[_0xda42('0x41')]=_[_0xda42('0x40')](_0x55fa7a[_0xda42('0x3c')],qs[_0xda42('0x42')](_0x3a777c[_0xda42('0x3d')][_0xda42('0x42')]));_0x1fc8d1[_0xda42('0x41')]=_0x1fc8d1['attributes'][_0xda42('0x53')]?_0x1fc8d1[_0xda42('0x41')]:_0x55fa7a[_0xda42('0x3c')];if(_0x3a777c[_0xda42('0x3d')][_0xda42('0x4e')]){_0x1fc8d1[_0xda42('0x4f')]=[{'all':!![]}];}_0x1fc8d1=_['merge']({},_0x1fc8d1,_0x3a777c[_0xda42('0x4d')]);return db[_0xda42('0x37')][_0xda42('0x54')](_0x1fc8d1)[_0xda42('0x1a')](handleEntityNotFound(_0xa4bcfd,null))[_0xda42('0x1a')](respondWithResult(_0xa4bcfd,null))['catch'](handleError(_0xa4bcfd,null));};exports[_0xda42('0x55')]=function(_0x54c76c,_0x5bfa49){return db['Dynamics365Configuration'][_0xda42('0x55')](_0x54c76c[_0xda42('0x56')],{})[_0xda42('0x1a')](respondWithResult(_0x5bfa49,0xc9))[_0xda42('0x24')](handleError(_0x5bfa49,null));};exports['update']=function(_0x2ca715,_0x3d4849){if(_0x2ca715[_0xda42('0x56')]['id']){delete _0x2ca715[_0xda42('0x56')]['id'];}return db[_0xda42('0x37')][_0xda42('0x54')]({'where':{'id':_0x2ca715[_0xda42('0x52')]['id']}})[_0xda42('0x1a')](handleEntityNotFound(_0x3d4849,null))[_0xda42('0x1a')](saveUpdates(_0x2ca715[_0xda42('0x56')],null))[_0xda42('0x1a')](respondWithResult(_0x3d4849,null))[_0xda42('0x24')](handleError(_0x3d4849,null));};exports[_0xda42('0x2f')]=function(_0x3a6e84,_0xe29aa1){return db['Dynamics365Configuration']['find']({'where':{'id':_0x3a6e84[_0xda42('0x52')]['id']}})[_0xda42('0x1a')](handleEntityNotFound(_0xe29aa1,null))[_0xda42('0x1a')](removeEntity(_0xe29aa1,null))[_0xda42('0x24')](handleError(_0xe29aa1,null));};exports[_0xda42('0x57')]=function(_0x1dd7c3,_0xbfcb17,_0xd3a363){var _0x458950={};var _0x1c0e3f={};var _0x25dfe2;var _0x3aada4;return db[_0xda42('0x37')][_0xda42('0x58')]({'where':{'id':_0x1dd7c3[_0xda42('0x52')]['id']}})[_0xda42('0x1a')](handleEntityNotFound(_0xbfcb17,null))[_0xda42('0x1a')](function(_0x17e2cb){if(_0x17e2cb){_0x25dfe2=_0x17e2cb;_0x1c0e3f[_0xda42('0x3c')]=_[_0xda42('0x3e')](db['Dynamics365Field'][_0xda42('0x38')]);_0x1c0e3f[_0xda42('0x3d')]=_[_0xda42('0x3e')](_0x1dd7c3[_0xda42('0x3d')]);_0x1c0e3f[_0xda42('0x3f')]=_['intersection'](_0x1c0e3f[_0xda42('0x3c')],_0x1c0e3f[_0xda42('0x3d')]);_0x458950[_0xda42('0x41')]=_['intersection'](_0x1c0e3f[_0xda42('0x3c')],qs[_0xda42('0x42')](_0x1dd7c3[_0xda42('0x3d')][_0xda42('0x42')]));_0x458950[_0xda42('0x41')]=_0x458950[_0xda42('0x41')][_0xda42('0x53')]?_0x458950[_0xda42('0x41')]:_0x1c0e3f[_0xda42('0x3c')];_0x458950[_0xda42('0x46')]=qs['sort'](_0x1dd7c3[_0xda42('0x3d')]['sort']);_0x458950[_0xda42('0x48')]=qs[_0xda42('0x3f')](_[_0xda42('0x49')](_0x1dd7c3['query'],_0x1c0e3f[_0xda42('0x3f')]));if(_0x1dd7c3[_0xda42('0x3d')]['filter']){_0x458950['where']=_[_0xda42('0x4c')](_0x458950['where'],{'$or':_[_0xda42('0x36')](_0x458950['attributes'],function(_0x163a1f){var _0x1479af={};_0x1479af[_0x163a1f]={'$like':'%'+_0x1dd7c3[_0xda42('0x3d')][_0xda42('0x4a')]+'%'};return _0x1479af;})});}_0x458950=_['merge']({},_0x458950,_0x1dd7c3[_0xda42('0x4d')]);return _0x25dfe2[_0xda42('0x57')](_0x458950);}})[_0xda42('0x1a')](function(_0x41cf93){if(_0x41cf93){_0x3aada4=_0x41cf93['length'];if(!_0x1dd7c3[_0xda42('0x3d')][_0xda42('0x43')]('nolimit')){_0x458950[_0xda42('0x45')]=qs[_0xda42('0x45')](_0x1dd7c3[_0xda42('0x3d')]['limit']);_0x458950['offset']=qs[_0xda42('0x28')](_0x1dd7c3[_0xda42('0x3d')]['offset']);}return _0x25dfe2[_0xda42('0x57')](_0x458950);}})['then'](function(_0x3ba0ad){if(_0x3ba0ad){return _0x3ba0ad?{'count':_0x3aada4,'rows':_0x3ba0ad}:null;}})[_0xda42('0x1a')](respondWithResult(_0xbfcb17,null))[_0xda42('0x24')](handleError(_0xbfcb17,null));};exports[_0xda42('0x59')]=function(_0x163bdf,_0x246578,_0x43ea44){var _0x42cf27={};var _0x33070b={};var _0xba8b39;var _0x192741;return db[_0xda42('0x37')][_0xda42('0x58')]({'where':{'id':_0x163bdf[_0xda42('0x52')]['id']}})[_0xda42('0x1a')](handleEntityNotFound(_0x246578,null))[_0xda42('0x1a')](function(_0x25d1db){if(_0x25d1db){_0xba8b39=_0x25d1db;_0x33070b[_0xda42('0x3c')]=_[_0xda42('0x3e')](db['Dynamics365Field'][_0xda42('0x38')]);_0x33070b[_0xda42('0x3d')]=_['keys'](_0x163bdf[_0xda42('0x3d')]);_0x33070b[_0xda42('0x3f')]=_['intersection'](_0x33070b[_0xda42('0x3c')],_0x33070b[_0xda42('0x3d')]);_0x42cf27[_0xda42('0x41')]=_[_0xda42('0x40')](_0x33070b[_0xda42('0x3c')],qs[_0xda42('0x42')](_0x163bdf[_0xda42('0x3d')][_0xda42('0x42')]));_0x42cf27[_0xda42('0x41')]=_0x42cf27['attributes'][_0xda42('0x53')]?_0x42cf27[_0xda42('0x41')]:_0x33070b[_0xda42('0x3c')];_0x42cf27['order']=qs['sort'](_0x163bdf[_0xda42('0x3d')][_0xda42('0x47')]);_0x42cf27['where']=qs[_0xda42('0x3f')](_[_0xda42('0x49')](_0x163bdf['query'],_0x33070b[_0xda42('0x3f')]));if(_0x163bdf['query'][_0xda42('0x4a')]){_0x42cf27[_0xda42('0x48')]=_[_0xda42('0x4c')](_0x42cf27[_0xda42('0x48')],{'$or':_['map'](_0x42cf27['attributes'],function(_0x3c617d){var _0x5a8dbb={};_0x5a8dbb[_0x3c617d]={'$like':'%'+_0x163bdf[_0xda42('0x3d')][_0xda42('0x4a')]+'%'};return _0x5a8dbb;})});}_0x42cf27=_['merge']({},_0x42cf27,_0x163bdf[_0xda42('0x4d')]);return _0xba8b39[_0xda42('0x59')](_0x42cf27);}})[_0xda42('0x1a')](function(_0x2ecb82){if(_0x2ecb82){_0x192741=_0x2ecb82[_0xda42('0x53')];if(!_0x163bdf[_0xda42('0x3d')]['hasOwnProperty']('nolimit')){_0x42cf27['limit']=qs['limit'](_0x163bdf[_0xda42('0x3d')][_0xda42('0x45')]);_0x42cf27[_0xda42('0x28')]=qs['offset'](_0x163bdf['query']['offset']);}return _0xba8b39[_0xda42('0x59')](_0x42cf27);}})['then'](function(_0x4b2e73){if(_0x4b2e73){return _0x4b2e73?{'count':_0x192741,'rows':_0x4b2e73}:null;}})['then'](respondWithResult(_0x246578,null))[_0xda42('0x24')](handleError(_0x246578,null));};exports['getDescriptions']=function(_0x51c2cc,_0xc422e7,_0x4429c5){var _0x5a4e72={};var _0x56afc9={};var _0x34906c;var _0x3efdc2;return db[_0xda42('0x37')][_0xda42('0x58')]({'where':{'id':_0x51c2cc[_0xda42('0x52')]['id']}})['then'](handleEntityNotFound(_0xc422e7,null))[_0xda42('0x1a')](function(_0x2382f5){if(_0x2382f5){_0x34906c=_0x2382f5;_0x56afc9['model']=_[_0xda42('0x3e')](db['Dynamics365Field'][_0xda42('0x38')]);_0x56afc9[_0xda42('0x3d')]=_[_0xda42('0x3e')](_0x51c2cc[_0xda42('0x3d')]);_0x56afc9[_0xda42('0x3f')]=_['intersection'](_0x56afc9[_0xda42('0x3c')],_0x56afc9['query']);_0x5a4e72[_0xda42('0x41')]=_[_0xda42('0x40')](_0x56afc9[_0xda42('0x3c')],qs[_0xda42('0x42')](_0x51c2cc['query']['fields']));_0x5a4e72[_0xda42('0x41')]=_0x5a4e72[_0xda42('0x41')][_0xda42('0x53')]?_0x5a4e72['attributes']:_0x56afc9[_0xda42('0x3c')];_0x5a4e72[_0xda42('0x46')]=qs[_0xda42('0x47')](_0x51c2cc[_0xda42('0x3d')][_0xda42('0x47')]);_0x5a4e72['where']=qs[_0xda42('0x3f')](_[_0xda42('0x49')](_0x51c2cc[_0xda42('0x3d')],_0x56afc9[_0xda42('0x3f')]));if(_0x51c2cc[_0xda42('0x3d')][_0xda42('0x4a')]){_0x5a4e72[_0xda42('0x48')]=_[_0xda42('0x4c')](_0x5a4e72[_0xda42('0x48')],{'$or':_[_0xda42('0x36')](_0x5a4e72['attributes'],function(_0x3d246c){var _0x5a2d14={};_0x5a2d14[_0x3d246c]={'$like':'%'+_0x51c2cc[_0xda42('0x3d')][_0xda42('0x4a')]+'%'};return _0x5a2d14;})});}_0x5a4e72=_[_0xda42('0x4c')]({},_0x5a4e72,_0x51c2cc[_0xda42('0x4d')]);return _0x34906c[_0xda42('0x5a')](_0x5a4e72);}})[_0xda42('0x1a')](function(_0x524459){if(_0x524459){_0x3efdc2=_0x524459[_0xda42('0x53')];if(!_0x51c2cc[_0xda42('0x3d')][_0xda42('0x43')]('nolimit')){_0x5a4e72[_0xda42('0x45')]=qs['limit'](_0x51c2cc[_0xda42('0x3d')]['limit']);_0x5a4e72[_0xda42('0x28')]=qs['offset'](_0x51c2cc[_0xda42('0x3d')][_0xda42('0x28')]);}return _0x34906c[_0xda42('0x5a')](_0x5a4e72);}})[_0xda42('0x1a')](function(_0x3de275){if(_0x3de275){return _0x3de275?{'count':_0x3efdc2,'rows':_0x3de275}:null;}})[_0xda42('0x1a')](respondWithResult(_0xc422e7,null))[_0xda42('0x24')](handleError(_0xc422e7,null));};
\ No newline at end of file
+var _0x2178=['request-promise','moment','bluebird','sox','to-csv','ejs','fs-extra','squel','crypto','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','catch','show','keys','find','create','body','update','params','getFields','Dynamics365Field','hasOwnProperty','getSubjects','order','getDescriptions','findOne','eml-format','rimraf','fast-json-patch'];(function(_0x4d0662,_0x145963){var _0x6eea6d=function(_0x2def06){while(--_0x2def06){_0x4d0662['push'](_0x4d0662['shift']());}};_0x6eea6d(++_0x145963);}(_0x2178,0x131));var _0x8217=function(_0x192136,_0x434d09){_0x192136=_0x192136-0x0;var _0x2524a5=_0x2178[_0x192136];return _0x2524a5;};'use strict';var emlformat=require(_0x8217('0x0'));var rimraf=require(_0x8217('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8217('0x2'));var rp=require(_0x8217('0x3'));var moment=require(_0x8217('0x4'));var BPromise=require(_0x8217('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x8217('0x6'));var csv=require(_0x8217('0x7'));var ejs=require(_0x8217('0x8'));var fs=require('fs');var fs_extra=require(_0x8217('0x9'));var _=require('lodash');var squel=require(_0x8217('0xa'));var crypto=require(_0x8217('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x8217('0x7'));var querystring=require('querystring');var Papa=require(_0x8217('0xc'));var Redis=require(_0x8217('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x8217('0xe'));var as=require(_0x8217('0xf'));var hardwareService=require(_0x8217('0x10'));var logger=require('../../config/logger')('api');var utils=require(_0x8217('0x11'));var config=require(_0x8217('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0x8217('0x13'))['db'];function respondWithStatusCode(_0x5a787a,_0x41b092){_0x41b092=_0x41b092||0xcc;return function(_0x36fa50){if(_0x36fa50){return _0x5a787a[_0x8217('0x14')](_0x41b092);}return _0x5a787a[_0x8217('0x15')](_0x41b092)[_0x8217('0x16')]();};}function respondWithResult(_0x24cc93,_0x5ae8cb){_0x5ae8cb=_0x5ae8cb||0xc8;return function(_0x3d8eba){if(_0x3d8eba){return _0x24cc93['status'](_0x5ae8cb)[_0x8217('0x17')](_0x3d8eba);}};}function respondWithFilteredResult(_0x7ccfd4,_0x1a1bfa){return function(_0x29a264){if(_0x29a264){var _0x62e2c0=typeof _0x1a1bfa[_0x8217('0x18')]===_0x8217('0x19')&&typeof _0x1a1bfa[_0x8217('0x1a')]===_0x8217('0x19');var _0x122f7b=_0x29a264['count'];var _0x241a34=_0x62e2c0?0x0:_0x1a1bfa[_0x8217('0x18')];var _0x195250=_0x62e2c0?_0x29a264[_0x8217('0x1b')]:_0x1a1bfa[_0x8217('0x18')]+_0x1a1bfa[_0x8217('0x1a')];var _0x509d35;if(_0x195250>=_0x122f7b){_0x195250=_0x122f7b;_0x509d35=0xc8;}else{_0x509d35=0xce;}_0x7ccfd4['status'](_0x509d35);return _0x7ccfd4[_0x8217('0x1c')](_0x8217('0x1d'),_0x241a34+'-'+_0x195250+'/'+_0x122f7b)[_0x8217('0x17')](_0x29a264);}return null;};}function patchUpdates(_0x4225d0){return function(_0x36f999){try{jsonpatch[_0x8217('0x1e')](_0x36f999,_0x4225d0,!![]);}catch(_0x3d7766){return BPromise[_0x8217('0x1f')](_0x3d7766);}return _0x36f999[_0x8217('0x20')]();};}function saveUpdates(_0x1ca81a,_0x5b3c3b){return function(_0x55ee67){if(_0x55ee67){return _0x55ee67['update'](_0x1ca81a)[_0x8217('0x21')](function(_0x126dbc){return _0x126dbc;});}return null;};}function removeEntity(_0x46fd3c,_0x43a686){return function(_0x35987b){if(_0x35987b){return _0x35987b[_0x8217('0x22')]()[_0x8217('0x21')](function(){_0x46fd3c['status'](0xcc)[_0x8217('0x16')]();});}};}function handleEntityNotFound(_0x569421,_0x248582){return function(_0x1d1562){if(!_0x1d1562){_0x569421[_0x8217('0x14')](0x194);}return _0x1d1562;};}function handleError(_0x528e64,_0x5cec74){_0x5cec74=_0x5cec74||0x1f4;return function(_0x2f6fee){logger[_0x8217('0x23')](_0x2f6fee[_0x8217('0x24')]);if(_0x2f6fee[_0x8217('0x25')]){delete _0x2f6fee[_0x8217('0x25')];}_0x528e64['status'](_0x5cec74)[_0x8217('0x26')](_0x2f6fee);};}exports['index']=function(_0x1bf9c7,_0x2fe551){var _0x4babcb={},_0x401475={},_0x3a8990={'count':0x0,'rows':[]};var _0x70110=_[_0x8217('0x27')](db[_0x8217('0x28')][_0x8217('0x29')],function(_0x515935){return{'name':_0x515935[_0x8217('0x2a')],'type':_0x515935[_0x8217('0x2b')][_0x8217('0x2c')]};});_0x401475[_0x8217('0x2d')]=_[_0x8217('0x27')](_0x70110,_0x8217('0x25'));_0x401475[_0x8217('0x2e')]=_['keys'](_0x1bf9c7['query']);_0x401475[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x401475[_0x8217('0x2d')],_0x401475['query']);_0x4babcb[_0x8217('0x31')]=_['intersection'](_0x401475['model'],qs[_0x8217('0x32')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x32')]));_0x4babcb[_0x8217('0x31')]=_0x4babcb['attributes'][_0x8217('0x33')]?_0x4babcb['attributes']:_0x401475[_0x8217('0x2d')];if(!_0x1bf9c7[_0x8217('0x2e')]['hasOwnProperty'](_0x8217('0x34'))){_0x4babcb['limit']=qs[_0x8217('0x1a')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x1a')]);_0x4babcb[_0x8217('0x18')]=qs[_0x8217('0x18')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x18')]);}_0x4babcb['order']=qs[_0x8217('0x35')](_0x1bf9c7[_0x8217('0x2e')]['sort']);_0x4babcb[_0x8217('0x36')]=qs['filters'](_[_0x8217('0x37')](_0x1bf9c7['query'],_0x401475['filters']),_0x70110);if(_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x38')]){_0x4babcb[_0x8217('0x36')]=_['merge'](_0x4babcb['where'],{'$or':_[_0x8217('0x27')](_0x70110,function(_0xab8687){if(_0xab8687[_0x8217('0x2b')]!==_0x8217('0x39')){var _0x1dfb7d={};_0x1dfb7d[_0xab8687['name']]={'$like':'%'+_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x38')]+'%'};return _0x1dfb7d;}})});}_0x4babcb=_[_0x8217('0x3a')]({},_0x4babcb,_0x1bf9c7[_0x8217('0x3b')]);var _0x29b589={'where':_0x4babcb['where']};return db[_0x8217('0x28')][_0x8217('0x1b')](_0x29b589)[_0x8217('0x21')](function(_0x10985b){_0x3a8990[_0x8217('0x1b')]=_0x10985b;if(_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x3c')]){_0x4babcb[_0x8217('0x3d')]=[{'all':!![]}];}return db[_0x8217('0x28')]['findAll'](_0x4babcb);})[_0x8217('0x21')](function(_0x4a15d3){_0x3a8990['rows']=_0x4a15d3;return _0x3a8990;})[_0x8217('0x21')](respondWithFilteredResult(_0x2fe551,_0x4babcb))[_0x8217('0x3e')](handleError(_0x2fe551,null));};exports[_0x8217('0x3f')]=function(_0x2a3853,_0x1fa8af){var _0x3c5c9e={'raw':![],'where':{'id':_0x2a3853['params']['id']}},_0x4b4367={};_0x4b4367[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x28')][_0x8217('0x29')]);_0x4b4367['query']=_[_0x8217('0x40')](_0x2a3853[_0x8217('0x2e')]);_0x4b4367[_0x8217('0x2f')]=_['intersection'](_0x4b4367[_0x8217('0x2d')],_0x4b4367[_0x8217('0x2e')]);_0x3c5c9e[_0x8217('0x31')]=_[_0x8217('0x30')](_0x4b4367[_0x8217('0x2d')],qs['fields'](_0x2a3853['query'][_0x8217('0x32')]));_0x3c5c9e[_0x8217('0x31')]=_0x3c5c9e[_0x8217('0x31')]['length']?_0x3c5c9e[_0x8217('0x31')]:_0x4b4367['model'];if(_0x2a3853[_0x8217('0x2e')][_0x8217('0x3c')]){_0x3c5c9e['include']=[{'all':!![]}];}_0x3c5c9e=_['merge']({},_0x3c5c9e,_0x2a3853[_0x8217('0x3b')]);return db[_0x8217('0x28')][_0x8217('0x41')](_0x3c5c9e)['then'](handleEntityNotFound(_0x1fa8af,null))[_0x8217('0x21')](respondWithResult(_0x1fa8af,null))[_0x8217('0x3e')](handleError(_0x1fa8af,null));};exports[_0x8217('0x42')]=function(_0x288304,_0x49cfb4){return db[_0x8217('0x28')][_0x8217('0x42')](_0x288304[_0x8217('0x43')],{})[_0x8217('0x21')](respondWithResult(_0x49cfb4,0xc9))[_0x8217('0x3e')](handleError(_0x49cfb4,null));};exports[_0x8217('0x44')]=function(_0x127fb4,_0x2240cb){if(_0x127fb4[_0x8217('0x43')]['id']){delete _0x127fb4['body']['id'];}return db[_0x8217('0x28')]['find']({'where':{'id':_0x127fb4[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x2240cb,null))['then'](saveUpdates(_0x127fb4[_0x8217('0x43')],null))[_0x8217('0x21')](respondWithResult(_0x2240cb,null))[_0x8217('0x3e')](handleError(_0x2240cb,null));};exports['destroy']=function(_0x30508f,_0x16b6d7){return db[_0x8217('0x28')][_0x8217('0x41')]({'where':{'id':_0x30508f[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x16b6d7,null))['then'](removeEntity(_0x16b6d7,null))[_0x8217('0x3e')](handleError(_0x16b6d7,null));};exports[_0x8217('0x46')]=function(_0x2fd2d3,_0x8c67de,_0x368634){var _0xf0f388={};var _0x4e3325={};var _0x1f12a2;var _0x2767c0;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x2fd2d3[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x8c67de,null))[_0x8217('0x21')](function(_0x2a29af){if(_0x2a29af){_0x1f12a2=_0x2a29af;_0x4e3325[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x47')]['rawAttributes']);_0x4e3325[_0x8217('0x2e')]=_[_0x8217('0x40')](_0x2fd2d3[_0x8217('0x2e')]);_0x4e3325[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x4e3325[_0x8217('0x2d')],_0x4e3325[_0x8217('0x2e')]);_0xf0f388[_0x8217('0x31')]=_['intersection'](_0x4e3325['model'],qs['fields'](_0x2fd2d3[_0x8217('0x2e')]['fields']));_0xf0f388[_0x8217('0x31')]=_0xf0f388[_0x8217('0x31')][_0x8217('0x33')]?_0xf0f388['attributes']:_0x4e3325[_0x8217('0x2d')];_0xf0f388['order']=qs['sort'](_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x35')]);_0xf0f388[_0x8217('0x36')]=qs[_0x8217('0x2f')](_[_0x8217('0x37')](_0x2fd2d3[_0x8217('0x2e')],_0x4e3325[_0x8217('0x2f')]));if(_0x2fd2d3[_0x8217('0x2e')]['filter']){_0xf0f388['where']=_[_0x8217('0x3a')](_0xf0f388['where'],{'$or':_[_0x8217('0x27')](_0xf0f388['attributes'],function(_0x14295a){var _0x25799e={};_0x25799e[_0x14295a]={'$like':'%'+_0x2fd2d3['query'][_0x8217('0x38')]+'%'};return _0x25799e;})});}_0xf0f388=_[_0x8217('0x3a')]({},_0xf0f388,_0x2fd2d3[_0x8217('0x3b')]);return _0x1f12a2[_0x8217('0x46')](_0xf0f388);}})[_0x8217('0x21')](function(_0x392ff0){if(_0x392ff0){_0x2767c0=_0x392ff0[_0x8217('0x33')];if(!_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x48')](_0x8217('0x34'))){_0xf0f388[_0x8217('0x1a')]=qs['limit'](_0x2fd2d3[_0x8217('0x2e')]['limit']);_0xf0f388['offset']=qs[_0x8217('0x18')](_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x18')]);}return _0x1f12a2['getFields'](_0xf0f388);}})[_0x8217('0x21')](function(_0x1751cd){if(_0x1751cd){return _0x1751cd?{'count':_0x2767c0,'rows':_0x1751cd}:null;}})[_0x8217('0x21')](respondWithResult(_0x8c67de,null))[_0x8217('0x3e')](handleError(_0x8c67de,null));};exports[_0x8217('0x49')]=function(_0xa1fea8,_0x224ffc,_0x1a1c12){var _0x159eab={};var _0x138aa4={};var _0xc1b466;var _0x361a4b;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0xa1fea8['params']['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x224ffc,null))[_0x8217('0x21')](function(_0x1f906b){if(_0x1f906b){_0xc1b466=_0x1f906b;_0x138aa4['model']=_[_0x8217('0x40')](db[_0x8217('0x47')]['rawAttributes']);_0x138aa4[_0x8217('0x2e')]=_['keys'](_0xa1fea8['query']);_0x138aa4[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x138aa4[_0x8217('0x2d')],_0x138aa4[_0x8217('0x2e')]);_0x159eab['attributes']=_[_0x8217('0x30')](_0x138aa4[_0x8217('0x2d')],qs[_0x8217('0x32')](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x32')]));_0x159eab['attributes']=_0x159eab[_0x8217('0x31')][_0x8217('0x33')]?_0x159eab[_0x8217('0x31')]:_0x138aa4[_0x8217('0x2d')];_0x159eab[_0x8217('0x4a')]=qs[_0x8217('0x35')](_0xa1fea8[_0x8217('0x2e')]['sort']);_0x159eab[_0x8217('0x36')]=qs[_0x8217('0x2f')](_['pick'](_0xa1fea8[_0x8217('0x2e')],_0x138aa4[_0x8217('0x2f')]));if(_0xa1fea8[_0x8217('0x2e')][_0x8217('0x38')]){_0x159eab['where']=_['merge'](_0x159eab['where'],{'$or':_[_0x8217('0x27')](_0x159eab[_0x8217('0x31')],function(_0x5587d9){var _0x9443c4={};_0x9443c4[_0x5587d9]={'$like':'%'+_0xa1fea8['query'][_0x8217('0x38')]+'%'};return _0x9443c4;})});}_0x159eab=_[_0x8217('0x3a')]({},_0x159eab,_0xa1fea8[_0x8217('0x3b')]);return _0xc1b466[_0x8217('0x49')](_0x159eab);}})['then'](function(_0x41c28c){if(_0x41c28c){_0x361a4b=_0x41c28c[_0x8217('0x33')];if(!_0xa1fea8[_0x8217('0x2e')][_0x8217('0x48')]('nolimit')){_0x159eab[_0x8217('0x1a')]=qs[_0x8217('0x1a')](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x1a')]);_0x159eab[_0x8217('0x18')]=qs['offset'](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x18')]);}return _0xc1b466[_0x8217('0x49')](_0x159eab);}})[_0x8217('0x21')](function(_0x136550){if(_0x136550){return _0x136550?{'count':_0x361a4b,'rows':_0x136550}:null;}})[_0x8217('0x21')](respondWithResult(_0x224ffc,null))[_0x8217('0x3e')](handleError(_0x224ffc,null));};exports[_0x8217('0x4b')]=function(_0x471f1b,_0x313a00,_0xaa8859){var _0x1bc89d={};var _0xf5f6d0={};var _0x586792;var _0x43e1f2;return db[_0x8217('0x28')][_0x8217('0x4c')]({'where':{'id':_0x471f1b[_0x8217('0x45')]['id']}})['then'](handleEntityNotFound(_0x313a00,null))['then'](function(_0x30731a){if(_0x30731a){_0x586792=_0x30731a;_0xf5f6d0[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x47')][_0x8217('0x29')]);_0xf5f6d0[_0x8217('0x2e')]=_[_0x8217('0x40')](_0x471f1b['query']);_0xf5f6d0[_0x8217('0x2f')]=_[_0x8217('0x30')](_0xf5f6d0[_0x8217('0x2d')],_0xf5f6d0[_0x8217('0x2e')]);_0x1bc89d[_0x8217('0x31')]=_[_0x8217('0x30')](_0xf5f6d0[_0x8217('0x2d')],qs['fields'](_0x471f1b['query'][_0x8217('0x32')]));_0x1bc89d[_0x8217('0x31')]=_0x1bc89d[_0x8217('0x31')][_0x8217('0x33')]?_0x1bc89d[_0x8217('0x31')]:_0xf5f6d0[_0x8217('0x2d')];_0x1bc89d[_0x8217('0x4a')]=qs[_0x8217('0x35')](_0x471f1b[_0x8217('0x2e')]['sort']);_0x1bc89d[_0x8217('0x36')]=qs['filters'](_['pick'](_0x471f1b[_0x8217('0x2e')],_0xf5f6d0[_0x8217('0x2f')]));if(_0x471f1b[_0x8217('0x2e')][_0x8217('0x38')]){_0x1bc89d[_0x8217('0x36')]=_[_0x8217('0x3a')](_0x1bc89d[_0x8217('0x36')],{'$or':_['map'](_0x1bc89d[_0x8217('0x31')],function(_0x5bc565){var _0x43c3e1={};_0x43c3e1[_0x5bc565]={'$like':'%'+_0x471f1b[_0x8217('0x2e')][_0x8217('0x38')]+'%'};return _0x43c3e1;})});}_0x1bc89d=_[_0x8217('0x3a')]({},_0x1bc89d,_0x471f1b[_0x8217('0x3b')]);return _0x586792[_0x8217('0x4b')](_0x1bc89d);}})[_0x8217('0x21')](function(_0x2430d7){if(_0x2430d7){_0x43e1f2=_0x2430d7[_0x8217('0x33')];if(!_0x471f1b['query']['hasOwnProperty'](_0x8217('0x34'))){_0x1bc89d[_0x8217('0x1a')]=qs['limit'](_0x471f1b[_0x8217('0x2e')]['limit']);_0x1bc89d[_0x8217('0x18')]=qs[_0x8217('0x18')](_0x471f1b[_0x8217('0x2e')][_0x8217('0x18')]);}return _0x586792['getDescriptions'](_0x1bc89d);}})[_0x8217('0x21')](function(_0xd683cd){if(_0xd683cd){return _0xd683cd?{'count':_0x43e1f2,'rows':_0xd683cd}:null;}})[_0x8217('0x21')](respondWithResult(_0x313a00,null))[_0x8217('0x3e')](handleError(_0x313a00,null));};
\ No newline at end of file