Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index ad79a04..c6ea0e1 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 _0x46e4=['Content-Range','apply','save','update','then','destroy','sendStatus','error','stack','name','send','index','map','Dynamics365Configuration','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','type','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','create','body','getFields','findOne','Dynamics365Field','nolimit','getSubjects','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','count','set'];(function(_0x109042,_0xc6d5f1){var _0x405dc0=function(_0xb4daa2){while(--_0xb4daa2){_0x109042['push'](_0x109042['shift']());}};_0x405dc0(++_0xc6d5f1);}(_0x46e4,0x8a));var _0x446e=function(_0x57c5e2,_0x10f331){_0x57c5e2=_0x57c5e2-0x0;var _0x19e57=_0x46e4[_0x57c5e2];return _0x19e57;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x446e('0x0'));var zipdir=require(_0x446e('0x1'));var jsonpatch=require(_0x446e('0x2'));var rp=require(_0x446e('0x3'));var moment=require(_0x446e('0x4'));var BPromise=require(_0x446e('0x5'));var Mustache=require('mustache');var util=require(_0x446e('0x6'));var path=require(_0x446e('0x7'));var sox=require(_0x446e('0x8'));var csv=require(_0x446e('0x9'));var ejs=require(_0x446e('0xa'));var fs=require('fs');var fs_extra=require(_0x446e('0xb'));var _=require('lodash');var squel=require(_0x446e('0xc'));var crypto=require(_0x446e('0xd'));var jsforce=require(_0x446e('0xe'));var deskjs=require(_0x446e('0xf'));var toCsv=require('to-csv');var querystring=require(_0x446e('0x10'));var Papa=require(_0x446e('0x11'));var Redis=require(_0x446e('0x12'));var authService=require(_0x446e('0x13'));var qs=require(_0x446e('0x14'));var as=require(_0x446e('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x446e('0x16'))(_0x446e('0x17'));var utils=require(_0x446e('0x18'));var config=require(_0x446e('0x19'));var licenseUtil=require(_0x446e('0x1a'));var db=require(_0x446e('0x1b'))['db'];function respondWithStatusCode(_0x3f4395,_0x1dd730){_0x1dd730=_0x1dd730||0xcc;return function(_0x1bf031){if(_0x1bf031){return _0x3f4395['sendStatus'](_0x1dd730);}return _0x3f4395['status'](_0x1dd730)[_0x446e('0x1c')]();};}function respondWithResult(_0x21b2a4,_0x5ec812){_0x5ec812=_0x5ec812||0xc8;return function(_0x2e9c04){if(_0x2e9c04){return _0x21b2a4[_0x446e('0x1d')](_0x5ec812)[_0x446e('0x1e')](_0x2e9c04);}};}function respondWithFilteredResult(_0x1e525d,_0x2bd496){return function(_0x1fe4ba){if(_0x1fe4ba){var _0x265cb8=typeof _0x2bd496[_0x446e('0x1f')]===_0x446e('0x20')&&typeof _0x2bd496[_0x446e('0x21')]===_0x446e('0x20');var _0x50be95=_0x1fe4ba[_0x446e('0x22')];var _0x235333=_0x265cb8?0x0:_0x2bd496[_0x446e('0x1f')];var _0x1a2332=_0x265cb8?_0x1fe4ba[_0x446e('0x22')]:_0x2bd496[_0x446e('0x1f')]+_0x2bd496[_0x446e('0x21')];var _0x1e4c8d;if(_0x1a2332>=_0x50be95){_0x1a2332=_0x50be95;_0x1e4c8d=0xc8;}else{_0x1e4c8d=0xce;}_0x1e525d[_0x446e('0x1d')](_0x1e4c8d);return _0x1e525d[_0x446e('0x23')](_0x446e('0x24'),_0x235333+'-'+_0x1a2332+'/'+_0x50be95)[_0x446e('0x1e')](_0x1fe4ba);}return null;};}function patchUpdates(_0x4170d6){return function(_0x6d429){try{jsonpatch[_0x446e('0x25')](_0x6d429,_0x4170d6,!![]);}catch(_0xec1fbb){return BPromise['reject'](_0xec1fbb);}return _0x6d429[_0x446e('0x26')]();};}function saveUpdates(_0x89ef93,_0x16c941){return function(_0x18a321){if(_0x18a321){return _0x18a321[_0x446e('0x27')](_0x89ef93)[_0x446e('0x28')](function(_0x46e581){return _0x46e581;});}return null;};}function removeEntity(_0x166d4d,_0x1f3742){return function(_0x2a5101){if(_0x2a5101){return _0x2a5101[_0x446e('0x29')]()[_0x446e('0x28')](function(){_0x166d4d['status'](0xcc)[_0x446e('0x1c')]();});}};}function handleEntityNotFound(_0x5b5141,_0x44cf40){return function(_0x272a17){if(!_0x272a17){_0x5b5141[_0x446e('0x2a')](0x194);}return _0x272a17;};}function handleError(_0x3cf52d,_0x37041d){_0x37041d=_0x37041d||0x1f4;return function(_0x3baae9){logger[_0x446e('0x2b')](_0x3baae9[_0x446e('0x2c')]);if(_0x3baae9[_0x446e('0x2d')]){delete _0x3baae9[_0x446e('0x2d')];}_0x3cf52d[_0x446e('0x1d')](_0x37041d)[_0x446e('0x2e')](_0x3baae9);};}exports[_0x446e('0x2f')]=function(_0x8c7af1,_0x21936a){var _0x8470a1={},_0x210d01={},_0x54af83={'count':0x0,'rows':[]};var _0x11b862=_[_0x446e('0x30')](db[_0x446e('0x31')]['rawAttributes'],function(_0x505980){return{'name':_0x505980[_0x446e('0x32')],'type':_0x505980['type'][_0x446e('0x33')]};});_0x210d01[_0x446e('0x34')]=_[_0x446e('0x30')](_0x11b862,_0x446e('0x2d'));_0x210d01[_0x446e('0x35')]=_[_0x446e('0x36')](_0x8c7af1[_0x446e('0x35')]);_0x210d01[_0x446e('0x37')]=_[_0x446e('0x38')](_0x210d01[_0x446e('0x34')],_0x210d01[_0x446e('0x35')]);_0x8470a1[_0x446e('0x39')]=_[_0x446e('0x38')](_0x210d01[_0x446e('0x34')],qs[_0x446e('0x3a')](_0x8c7af1[_0x446e('0x35')][_0x446e('0x3a')]));_0x8470a1[_0x446e('0x39')]=_0x8470a1[_0x446e('0x39')][_0x446e('0x3b')]?_0x8470a1['attributes']:_0x210d01[_0x446e('0x34')];if(!_0x8c7af1[_0x446e('0x35')][_0x446e('0x3c')]('nolimit')){_0x8470a1[_0x446e('0x21')]=qs['limit'](_0x8c7af1['query']['limit']);_0x8470a1[_0x446e('0x1f')]=qs[_0x446e('0x1f')](_0x8c7af1['query'][_0x446e('0x1f')]);}_0x8470a1[_0x446e('0x3d')]=qs[_0x446e('0x3e')](_0x8c7af1[_0x446e('0x35')][_0x446e('0x3e')]);_0x8470a1[_0x446e('0x3f')]=qs[_0x446e('0x37')](_[_0x446e('0x40')](_0x8c7af1['query'],_0x210d01[_0x446e('0x37')]),_0x11b862);if(_0x8c7af1[_0x446e('0x35')][_0x446e('0x41')]){_0x8470a1[_0x446e('0x3f')]=_['merge'](_0x8470a1['where'],{'$or':_['map'](_0x11b862,function(_0xe96c7f){if(_0xe96c7f[_0x446e('0x42')]!==_0x446e('0x43')){var _0x28ae29={};_0x28ae29[_0xe96c7f[_0x446e('0x2d')]]={'$like':'%'+_0x8c7af1[_0x446e('0x35')][_0x446e('0x41')]+'%'};return _0x28ae29;}})});}_0x8470a1=_[_0x446e('0x44')]({},_0x8470a1,_0x8c7af1[_0x446e('0x45')]);var _0x138ac5={'where':_0x8470a1[_0x446e('0x3f')]};return db['Dynamics365Configuration'][_0x446e('0x22')](_0x138ac5)['then'](function(_0x39d569){_0x54af83[_0x446e('0x22')]=_0x39d569;if(_0x8c7af1[_0x446e('0x35')][_0x446e('0x46')]){_0x8470a1[_0x446e('0x47')]=[{'all':!![]}];}return db[_0x446e('0x31')][_0x446e('0x48')](_0x8470a1);})[_0x446e('0x28')](function(_0x2adc0c){_0x54af83[_0x446e('0x49')]=_0x2adc0c;return _0x54af83;})['then'](respondWithFilteredResult(_0x21936a,_0x8470a1))[_0x446e('0x4a')](handleError(_0x21936a,null));};exports[_0x446e('0x4b')]=function(_0x310069,_0x1ed251){var _0x5bf65b={'raw':![],'where':{'id':_0x310069[_0x446e('0x4c')]['id']}},_0xb9b76d={};_0xb9b76d[_0x446e('0x34')]=_[_0x446e('0x36')](db[_0x446e('0x31')][_0x446e('0x4d')]);_0xb9b76d[_0x446e('0x35')]=_[_0x446e('0x36')](_0x310069[_0x446e('0x35')]);_0xb9b76d['filters']=_[_0x446e('0x38')](_0xb9b76d[_0x446e('0x34')],_0xb9b76d[_0x446e('0x35')]);_0x5bf65b[_0x446e('0x39')]=_[_0x446e('0x38')](_0xb9b76d[_0x446e('0x34')],qs['fields'](_0x310069[_0x446e('0x35')][_0x446e('0x3a')]));_0x5bf65b['attributes']=_0x5bf65b[_0x446e('0x39')][_0x446e('0x3b')]?_0x5bf65b['attributes']:_0xb9b76d['model'];if(_0x310069['query'][_0x446e('0x46')]){_0x5bf65b['include']=[{'all':!![]}];}_0x5bf65b=_['merge']({},_0x5bf65b,_0x310069[_0x446e('0x45')]);return db[_0x446e('0x31')][_0x446e('0x4e')](_0x5bf65b)[_0x446e('0x28')](handleEntityNotFound(_0x1ed251,null))['then'](respondWithResult(_0x1ed251,null))[_0x446e('0x4a')](handleError(_0x1ed251,null));};exports[_0x446e('0x4f')]=function(_0x730ae2,_0x355d67){return db[_0x446e('0x31')][_0x446e('0x4f')](_0x730ae2[_0x446e('0x50')],{})[_0x446e('0x28')](respondWithResult(_0x355d67,0xc9))['catch'](handleError(_0x355d67,null));};exports[_0x446e('0x27')]=function(_0x4e149c,_0x46a3b6){if(_0x4e149c[_0x446e('0x50')]['id']){delete _0x4e149c[_0x446e('0x50')]['id'];}return db[_0x446e('0x31')][_0x446e('0x4e')]({'where':{'id':_0x4e149c[_0x446e('0x4c')]['id']}})[_0x446e('0x28')](handleEntityNotFound(_0x46a3b6,null))['then'](saveUpdates(_0x4e149c[_0x446e('0x50')],null))['then'](respondWithResult(_0x46a3b6,null))[_0x446e('0x4a')](handleError(_0x46a3b6,null));};exports['destroy']=function(_0x3f169e,_0x4e0bbd){return db[_0x446e('0x31')]['find']({'where':{'id':_0x3f169e[_0x446e('0x4c')]['id']}})[_0x446e('0x28')](handleEntityNotFound(_0x4e0bbd,null))[_0x446e('0x28')](removeEntity(_0x4e0bbd,null))[_0x446e('0x4a')](handleError(_0x4e0bbd,null));};exports[_0x446e('0x51')]=function(_0x1542d3,_0x13dc9a,_0x6bffa3){var _0x5c8a9a={};var _0x4e1d06={};var _0x1e8082;var _0x290e02;return db[_0x446e('0x31')][_0x446e('0x52')]({'where':{'id':_0x1542d3[_0x446e('0x4c')]['id']}})[_0x446e('0x28')](handleEntityNotFound(_0x13dc9a,null))[_0x446e('0x28')](function(_0x4b2b1d){if(_0x4b2b1d){_0x1e8082=_0x4b2b1d;_0x4e1d06['model']=_[_0x446e('0x36')](db[_0x446e('0x53')][_0x446e('0x4d')]);_0x4e1d06['query']=_[_0x446e('0x36')](_0x1542d3[_0x446e('0x35')]);_0x4e1d06[_0x446e('0x37')]=_['intersection'](_0x4e1d06[_0x446e('0x34')],_0x4e1d06[_0x446e('0x35')]);_0x5c8a9a[_0x446e('0x39')]=_[_0x446e('0x38')](_0x4e1d06[_0x446e('0x34')],qs[_0x446e('0x3a')](_0x1542d3[_0x446e('0x35')][_0x446e('0x3a')]));_0x5c8a9a['attributes']=_0x5c8a9a[_0x446e('0x39')][_0x446e('0x3b')]?_0x5c8a9a[_0x446e('0x39')]:_0x4e1d06[_0x446e('0x34')];_0x5c8a9a['order']=qs[_0x446e('0x3e')](_0x1542d3[_0x446e('0x35')]['sort']);_0x5c8a9a['where']=qs['filters'](_[_0x446e('0x40')](_0x1542d3[_0x446e('0x35')],_0x4e1d06[_0x446e('0x37')]));if(_0x1542d3[_0x446e('0x35')][_0x446e('0x41')]){_0x5c8a9a[_0x446e('0x3f')]=_[_0x446e('0x44')](_0x5c8a9a['where'],{'$or':_[_0x446e('0x30')](_0x5c8a9a[_0x446e('0x39')],function(_0x58f1d9){var _0x440eb8={};_0x440eb8[_0x58f1d9]={'$like':'%'+_0x1542d3[_0x446e('0x35')]['filter']+'%'};return _0x440eb8;})});}_0x5c8a9a=_['merge']({},_0x5c8a9a,_0x1542d3['options']);return _0x1e8082[_0x446e('0x51')](_0x5c8a9a);}})['then'](function(_0x16b45b){if(_0x16b45b){_0x290e02=_0x16b45b[_0x446e('0x3b')];if(!_0x1542d3['query'][_0x446e('0x3c')](_0x446e('0x54'))){_0x5c8a9a[_0x446e('0x21')]=qs[_0x446e('0x21')](_0x1542d3[_0x446e('0x35')][_0x446e('0x21')]);_0x5c8a9a[_0x446e('0x1f')]=qs['offset'](_0x1542d3[_0x446e('0x35')][_0x446e('0x1f')]);}return _0x1e8082['getFields'](_0x5c8a9a);}})['then'](function(_0x1415c5){if(_0x1415c5){return _0x1415c5?{'count':_0x290e02,'rows':_0x1415c5}:null;}})[_0x446e('0x28')](respondWithResult(_0x13dc9a,null))[_0x446e('0x4a')](handleError(_0x13dc9a,null));};exports[_0x446e('0x55')]=function(_0x556a06,_0x178cb5,_0x24c75b){var _0x23b76e={};var _0x58cd36={};var _0x173bc3;var _0x2d6dab;return db[_0x446e('0x31')][_0x446e('0x52')]({'where':{'id':_0x556a06[_0x446e('0x4c')]['id']}})[_0x446e('0x28')](handleEntityNotFound(_0x178cb5,null))[_0x446e('0x28')](function(_0x282e68){if(_0x282e68){_0x173bc3=_0x282e68;_0x58cd36[_0x446e('0x34')]=_['keys'](db[_0x446e('0x53')][_0x446e('0x4d')]);_0x58cd36['query']=_[_0x446e('0x36')](_0x556a06['query']);_0x58cd36[_0x446e('0x37')]=_['intersection'](_0x58cd36[_0x446e('0x34')],_0x58cd36[_0x446e('0x35')]);_0x23b76e[_0x446e('0x39')]=_[_0x446e('0x38')](_0x58cd36['model'],qs['fields'](_0x556a06[_0x446e('0x35')][_0x446e('0x3a')]));_0x23b76e[_0x446e('0x39')]=_0x23b76e[_0x446e('0x39')][_0x446e('0x3b')]?_0x23b76e[_0x446e('0x39')]:_0x58cd36['model'];_0x23b76e['order']=qs[_0x446e('0x3e')](_0x556a06[_0x446e('0x35')][_0x446e('0x3e')]);_0x23b76e[_0x446e('0x3f')]=qs[_0x446e('0x37')](_[_0x446e('0x40')](_0x556a06[_0x446e('0x35')],_0x58cd36[_0x446e('0x37')]));if(_0x556a06[_0x446e('0x35')][_0x446e('0x41')]){_0x23b76e[_0x446e('0x3f')]=_['merge'](_0x23b76e[_0x446e('0x3f')],{'$or':_[_0x446e('0x30')](_0x23b76e[_0x446e('0x39')],function(_0x19a3fd){var _0x5044f9={};_0x5044f9[_0x19a3fd]={'$like':'%'+_0x556a06['query'][_0x446e('0x41')]+'%'};return _0x5044f9;})});}_0x23b76e=_[_0x446e('0x44')]({},_0x23b76e,_0x556a06[_0x446e('0x45')]);return _0x173bc3[_0x446e('0x55')](_0x23b76e);}})[_0x446e('0x28')](function(_0x3cbfa5){if(_0x3cbfa5){_0x2d6dab=_0x3cbfa5[_0x446e('0x3b')];if(!_0x556a06[_0x446e('0x35')][_0x446e('0x3c')]('nolimit')){_0x23b76e[_0x446e('0x21')]=qs[_0x446e('0x21')](_0x556a06['query'][_0x446e('0x21')]);_0x23b76e['offset']=qs[_0x446e('0x1f')](_0x556a06['query'][_0x446e('0x1f')]);}return _0x173bc3[_0x446e('0x55')](_0x23b76e);}})[_0x446e('0x28')](function(_0x236106){if(_0x236106){return _0x236106?{'count':_0x2d6dab,'rows':_0x236106}:null;}})[_0x446e('0x28')](respondWithResult(_0x178cb5,null))[_0x446e('0x4a')](handleError(_0x178cb5,null));};exports[_0x446e('0x56')]=function(_0x29c6ad,_0xddf771,_0xcd1157){var _0x2438b8={};var _0x57792b={};var _0x2bc67a;var _0x12dafb;return db[_0x446e('0x31')][_0x446e('0x52')]({'where':{'id':_0x29c6ad[_0x446e('0x4c')]['id']}})[_0x446e('0x28')](handleEntityNotFound(_0xddf771,null))[_0x446e('0x28')](function(_0x326b67){if(_0x326b67){_0x2bc67a=_0x326b67;_0x57792b['model']=_['keys'](db[_0x446e('0x53')][_0x446e('0x4d')]);_0x57792b[_0x446e('0x35')]=_['keys'](_0x29c6ad['query']);_0x57792b['filters']=_['intersection'](_0x57792b[_0x446e('0x34')],_0x57792b['query']);_0x2438b8[_0x446e('0x39')]=_[_0x446e('0x38')](_0x57792b[_0x446e('0x34')],qs[_0x446e('0x3a')](_0x29c6ad['query']['fields']));_0x2438b8[_0x446e('0x39')]=_0x2438b8[_0x446e('0x39')]['length']?_0x2438b8[_0x446e('0x39')]:_0x57792b['model'];_0x2438b8['order']=qs[_0x446e('0x3e')](_0x29c6ad[_0x446e('0x35')][_0x446e('0x3e')]);_0x2438b8['where']=qs[_0x446e('0x37')](_[_0x446e('0x40')](_0x29c6ad['query'],_0x57792b[_0x446e('0x37')]));if(_0x29c6ad[_0x446e('0x35')][_0x446e('0x41')]){_0x2438b8[_0x446e('0x3f')]=_[_0x446e('0x44')](_0x2438b8['where'],{'$or':_[_0x446e('0x30')](_0x2438b8[_0x446e('0x39')],function(_0x3020b0){var _0x19f396={};_0x19f396[_0x3020b0]={'$like':'%'+_0x29c6ad['query']['filter']+'%'};return _0x19f396;})});}_0x2438b8=_['merge']({},_0x2438b8,_0x29c6ad[_0x446e('0x45')]);return _0x2bc67a[_0x446e('0x56')](_0x2438b8);}})['then'](function(_0x384937){if(_0x384937){_0x12dafb=_0x384937['length'];if(!_0x29c6ad[_0x446e('0x35')]['hasOwnProperty']('nolimit')){_0x2438b8[_0x446e('0x21')]=qs['limit'](_0x29c6ad[_0x446e('0x35')]['limit']);_0x2438b8[_0x446e('0x1f')]=qs[_0x446e('0x1f')](_0x29c6ad[_0x446e('0x35')]['offset']);}return _0x2bc67a[_0x446e('0x56')](_0x2438b8);}})[_0x446e('0x28')](function(_0x406941){if(_0x406941){return _0x406941?{'count':_0x12dafb,'rows':_0x406941}:null;}})[_0x446e('0x28')](respondWithResult(_0xddf771,null))['catch'](handleError(_0xddf771,null));};
\ No newline at end of file