Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intDynamics365Field / intDynamics365Field.controller.js
index 7791650..910d10d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4fc5=['map','Dynamics365Field','fieldName','type','keys','filters','intersection','model','attributes','fields','query','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','rawAttributes','find','create','body','html-pdf','eml-format','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','then','destroy','stack','name','send','index'];(function(_0x2cc77e,_0x493147){var _0x1b0ab1=function(_0x4e26cf){while(--_0x4e26cf){_0x2cc77e['push'](_0x2cc77e['shift']());}};_0x1b0ab1(++_0x493147);}(_0x4fc5,0x1c8));var _0x54fc=function(_0x2bc326,_0x473cf8){_0x2bc326=_0x2bc326-0x0;var _0x43722e=_0x4fc5[_0x2bc326];return _0x43722e;};'use strict';var pdf=require(_0x54fc('0x0'));var emlformat=require(_0x54fc('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x54fc('0x2'));var Mustache=require(_0x54fc('0x3'));var util=require(_0x54fc('0x4'));var path=require(_0x54fc('0x5'));var sox=require(_0x54fc('0x6'));var csv=require('to-csv');var ejs=require(_0x54fc('0x7'));var fs=require('fs');var _=require(_0x54fc('0x8'));var squel=require(_0x54fc('0x9'));var crypto=require(_0x54fc('0xa'));var jsforce=require(_0x54fc('0xb'));var deskjs=require(_0x54fc('0xc'));var toCsv=require(_0x54fc('0xd'));var querystring=require(_0x54fc('0xe'));var Papa=require(_0x54fc('0xf'));var Redis=require(_0x54fc('0x10'));var authService=require(_0x54fc('0x11'));var qs=require(_0x54fc('0x12'));var as=require(_0x54fc('0x13'));var hardwareService=require(_0x54fc('0x14'));var logger=require(_0x54fc('0x15'))('api');var utils=require(_0x54fc('0x16'));var config=require(_0x54fc('0x17'));var licenseUtil=require(_0x54fc('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1c1a15,_0x4aa00e){_0x4aa00e=_0x4aa00e||0xcc;return function(_0x4d13db){if(_0x4d13db){return _0x1c1a15[_0x54fc('0x19')](_0x4aa00e);}return _0x1c1a15[_0x54fc('0x1a')](_0x4aa00e)[_0x54fc('0x1b')]();};}function respondWithResult(_0x1dfef1,_0x1a475a){_0x1a475a=_0x1a475a||0xc8;return function(_0x1d1b86){if(_0x1d1b86){return _0x1dfef1['status'](_0x1a475a)[_0x54fc('0x1c')](_0x1d1b86);}};}function respondWithFilteredResult(_0x4e697c,_0x37f48e){return function(_0xb27770){if(_0xb27770){var _0x50adf4=_0xb27770[_0x54fc('0x1d')],_0x51ee90=_0x37f48e[_0x54fc('0x1e')],_0x3dba37=_0x37f48e[_0x54fc('0x1e')]+_0x37f48e[_0x54fc('0x1f')],_0x1b1576;if(_0x3dba37>=_0x50adf4){_0x3dba37=_0x50adf4;_0x1b1576=0xc8;}else{_0x1b1576=0xce;}_0x4e697c['status'](_0x1b1576);return _0x4e697c[_0x54fc('0x20')](_0x54fc('0x21'),_0x51ee90+'-'+_0x3dba37+'/'+_0x50adf4)[_0x54fc('0x1c')](_0xb27770);}return null;};}function patchUpdates(_0x39711f){return function(_0x194de7){try{jsonpatch[_0x54fc('0x22')](_0x194de7,_0x39711f,!![]);}catch(_0x513a31){return BPromise['reject'](_0x513a31);}return _0x194de7['save']();};}function saveUpdates(_0x575b57,_0xe62c35){return function(_0x4d77ac){if(_0x4d77ac){return _0x4d77ac['update'](_0x575b57)[_0x54fc('0x23')](function(_0x2e385d){return _0x2e385d;});}return null;};}function removeEntity(_0x3664c9,_0x1defa7){return function(_0x1000f3){if(_0x1000f3){return _0x1000f3[_0x54fc('0x24')]()['then'](function(){_0x3664c9['status'](0xcc)[_0x54fc('0x1b')]();});}};}function handleEntityNotFound(_0x3d3cd2,_0xe4e1e2){return function(_0x4ff61e){if(!_0x4ff61e){_0x3d3cd2[_0x54fc('0x19')](0x194);}return _0x4ff61e;};}function handleError(_0x1e09e7,_0x327ee9){_0x327ee9=_0x327ee9||0x1f4;return function(_0x409289){logger['error'](_0x409289[_0x54fc('0x25')]);if(_0x409289[_0x54fc('0x26')]){delete _0x409289['name'];}_0x1e09e7[_0x54fc('0x1a')](_0x327ee9)[_0x54fc('0x27')](_0x409289);};}exports[_0x54fc('0x28')]=function(_0x56243a,_0x597a0f){var _0x3fe0fe={},_0x2c25b2={},_0x5e79ee={'count':0x0,'rows':[]};var _0xda7904=_[_0x54fc('0x29')](db[_0x54fc('0x2a')]['rawAttributes'],function(_0x38792f){return{'name':_0x38792f[_0x54fc('0x2b')],'type':_0x38792f[_0x54fc('0x2c')]['key']};});_0x2c25b2['model']=_[_0x54fc('0x29')](_0xda7904,_0x54fc('0x26'));_0x2c25b2['query']=_[_0x54fc('0x2d')](_0x56243a['query']);_0x2c25b2[_0x54fc('0x2e')]=_[_0x54fc('0x2f')](_0x2c25b2[_0x54fc('0x30')],_0x2c25b2['query']);_0x3fe0fe[_0x54fc('0x31')]=_[_0x54fc('0x2f')](_0x2c25b2['model'],qs[_0x54fc('0x32')](_0x56243a[_0x54fc('0x33')]['fields']));_0x3fe0fe[_0x54fc('0x31')]=_0x3fe0fe[_0x54fc('0x31')][_0x54fc('0x34')]?_0x3fe0fe[_0x54fc('0x31')]:_0x2c25b2[_0x54fc('0x30')];if(!_0x56243a['query'][_0x54fc('0x35')]('nolimit')){_0x3fe0fe[_0x54fc('0x1f')]=qs['limit'](_0x56243a[_0x54fc('0x33')][_0x54fc('0x1f')]);_0x3fe0fe[_0x54fc('0x1e')]=qs[_0x54fc('0x1e')](_0x56243a[_0x54fc('0x33')]['offset']);}_0x3fe0fe[_0x54fc('0x36')]=qs[_0x54fc('0x37')](_0x56243a[_0x54fc('0x33')][_0x54fc('0x37')]);_0x3fe0fe[_0x54fc('0x38')]=qs[_0x54fc('0x2e')](_['pick'](_0x56243a[_0x54fc('0x33')],_0x2c25b2[_0x54fc('0x2e')]),_0xda7904);if(_0x56243a[_0x54fc('0x33')][_0x54fc('0x39')]){_0x3fe0fe[_0x54fc('0x38')]=_[_0x54fc('0x3a')](_0x3fe0fe[_0x54fc('0x38')],{'$or':_[_0x54fc('0x29')](_0xda7904,function(_0x125f77){if(_0x125f77['type']!==_0x54fc('0x3b')){var _0x4518d4={};_0x4518d4[_0x125f77[_0x54fc('0x26')]]={'$like':'%'+_0x56243a[_0x54fc('0x33')]['filter']+'%'};return _0x4518d4;}})});}_0x3fe0fe=_[_0x54fc('0x3a')]({},_0x3fe0fe,_0x56243a[_0x54fc('0x3c')]);var _0x4277bb={'where':_0x3fe0fe['where']};return db[_0x54fc('0x2a')][_0x54fc('0x1d')](_0x4277bb)[_0x54fc('0x23')](function(_0x281dee){_0x5e79ee[_0x54fc('0x1d')]=_0x281dee;if(_0x56243a[_0x54fc('0x33')][_0x54fc('0x3d')]){_0x3fe0fe['include']=[{'all':!![]}];}return db[_0x54fc('0x2a')][_0x54fc('0x3e')](_0x3fe0fe);})[_0x54fc('0x23')](function(_0x3b4f7c){_0x5e79ee[_0x54fc('0x3f')]=_0x3b4f7c;return _0x5e79ee;})['then'](respondWithFilteredResult(_0x597a0f,_0x3fe0fe))[_0x54fc('0x40')](handleError(_0x597a0f,null));};exports[_0x54fc('0x41')]=function(_0x4cf1de,_0x31e576){var _0x43bded={'raw':!![],'where':{'id':_0x4cf1de[_0x54fc('0x42')]['id']}},_0x18e5d4={};_0x18e5d4[_0x54fc('0x30')]=_[_0x54fc('0x2d')](db['Dynamics365Field'][_0x54fc('0x43')]);_0x18e5d4[_0x54fc('0x33')]=_[_0x54fc('0x2d')](_0x4cf1de[_0x54fc('0x33')]);_0x18e5d4[_0x54fc('0x2e')]=_[_0x54fc('0x2f')](_0x18e5d4[_0x54fc('0x30')],_0x18e5d4[_0x54fc('0x33')]);_0x43bded[_0x54fc('0x31')]=_[_0x54fc('0x2f')](_0x18e5d4[_0x54fc('0x30')],qs[_0x54fc('0x32')](_0x4cf1de['query']['fields']));_0x43bded[_0x54fc('0x31')]=_0x43bded[_0x54fc('0x31')]['length']?_0x43bded[_0x54fc('0x31')]:_0x18e5d4['model'];if(_0x4cf1de['query'][_0x54fc('0x3d')]){_0x43bded['include']=[{'all':!![]}];}_0x43bded=_[_0x54fc('0x3a')]({},_0x43bded,_0x4cf1de['options']);return db[_0x54fc('0x2a')][_0x54fc('0x44')](_0x43bded)[_0x54fc('0x23')](handleEntityNotFound(_0x31e576,null))['then'](respondWithResult(_0x31e576,null))['catch'](handleError(_0x31e576,null));};exports[_0x54fc('0x45')]=function(_0x4c81fd,_0x309031){return db['Dynamics365Field'][_0x54fc('0x45')](_0x4c81fd[_0x54fc('0x46')],{})[_0x54fc('0x23')](respondWithResult(_0x309031,0xc9))[_0x54fc('0x40')](handleError(_0x309031,null));};exports['update']=function(_0x25223a,_0x4fe698){if(_0x25223a['body']['id']){delete _0x25223a[_0x54fc('0x46')]['id'];}return db[_0x54fc('0x2a')][_0x54fc('0x44')]({'where':{'id':_0x25223a[_0x54fc('0x42')]['id']}})[_0x54fc('0x23')](handleEntityNotFound(_0x4fe698,null))[_0x54fc('0x23')](saveUpdates(_0x25223a['body'],null))['then'](respondWithResult(_0x4fe698,null))['catch'](handleError(_0x4fe698,null));};exports[_0x54fc('0x24')]=function(_0x277641,_0x242eb0){return db[_0x54fc('0x2a')][_0x54fc('0x44')]({'where':{'id':_0x277641['params']['id']}})[_0x54fc('0x23')](handleEntityNotFound(_0x242eb0,null))[_0x54fc('0x23')](removeEntity(_0x242eb0,null))['catch'](handleError(_0x242eb0,null));};
\ No newline at end of file
+var _0x3bb7=['../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','destroy','then','error','stack','send','Dynamics365Field','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','options','includeAll','include','findAll','catch','show','params','length','find','create','body','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','lodash','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs'];(function(_0x9647da,_0x1f7117){var _0x25c414=function(_0x260ce6){while(--_0x260ce6){_0x9647da['push'](_0x9647da['shift']());}};_0x25c414(++_0x1f7117);}(_0x3bb7,0x14a));var _0x73bb=function(_0x1e5a0c,_0x3a16fc){_0x1e5a0c=_0x1e5a0c-0x0;var _0x5cc15b=_0x3bb7[_0x1e5a0c];return _0x5cc15b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x73bb('0x0'));var zipdir=require(_0x73bb('0x1'));var jsonpatch=require(_0x73bb('0x2'));var rp=require(_0x73bb('0x3'));var moment=require(_0x73bb('0x4'));var BPromise=require(_0x73bb('0x5'));var Mustache=require(_0x73bb('0x6'));var util=require(_0x73bb('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x73bb('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x73bb('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x73bb('0xa'));var deskjs=require(_0x73bb('0xb'));var toCsv=require(_0x73bb('0x8'));var querystring=require(_0x73bb('0xc'));var Papa=require('papaparse');var Redis=require(_0x73bb('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x73bb('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x73bb('0xf'));var logger=require('../../config/logger')(_0x73bb('0x10'));var utils=require(_0x73bb('0x11'));var config=require(_0x73bb('0x12'));var licenseUtil=require(_0x73bb('0x13'));var db=require(_0x73bb('0x14'))['db'];function respondWithStatusCode(_0x34c017,_0x510296){_0x510296=_0x510296||0xcc;return function(_0x35b2b1){if(_0x35b2b1){return _0x34c017[_0x73bb('0x15')](_0x510296);}return _0x34c017[_0x73bb('0x16')](_0x510296)[_0x73bb('0x17')]();};}function respondWithResult(_0x1c2251,_0x1c370e){_0x1c370e=_0x1c370e||0xc8;return function(_0x13163e){if(_0x13163e){return _0x1c2251[_0x73bb('0x16')](_0x1c370e)[_0x73bb('0x18')](_0x13163e);}};}function respondWithFilteredResult(_0x2188db,_0x5730f1){return function(_0x31db93){if(_0x31db93){var _0x4ef8ab=typeof _0x5730f1[_0x73bb('0x19')]===_0x73bb('0x1a')&&typeof _0x5730f1[_0x73bb('0x1b')]==='undefined';var _0x5abbfa=_0x31db93[_0x73bb('0x1c')];var _0xac33f1=_0x4ef8ab?0x0:_0x5730f1[_0x73bb('0x19')];var _0x4aac68=_0x4ef8ab?_0x31db93['count']:_0x5730f1[_0x73bb('0x19')]+_0x5730f1['limit'];var _0x2f0fce;if(_0x4aac68>=_0x5abbfa){_0x4aac68=_0x5abbfa;_0x2f0fce=0xc8;}else{_0x2f0fce=0xce;}_0x2188db[_0x73bb('0x16')](_0x2f0fce);return _0x2188db[_0x73bb('0x1d')]('Content-Range',_0xac33f1+'-'+_0x4aac68+'/'+_0x5abbfa)['json'](_0x31db93);}return null;};}function patchUpdates(_0x46629d){return function(_0x4a8bb7){try{jsonpatch[_0x73bb('0x1e')](_0x4a8bb7,_0x46629d,!![]);}catch(_0x498867){return BPromise[_0x73bb('0x1f')](_0x498867);}return _0x4a8bb7[_0x73bb('0x20')]();};}function saveUpdates(_0x28ff3c,_0x41de93){return function(_0x4d50fc){if(_0x4d50fc){return _0x4d50fc[_0x73bb('0x21')](_0x28ff3c)['then'](function(_0x220c09){return _0x220c09;});}return null;};}function removeEntity(_0x325779,_0x40be24){return function(_0x191ff0){if(_0x191ff0){return _0x191ff0[_0x73bb('0x22')]()[_0x73bb('0x23')](function(){_0x325779[_0x73bb('0x16')](0xcc)[_0x73bb('0x17')]();});}};}function handleEntityNotFound(_0x2c240a,_0x185c28){return function(_0x338813){if(!_0x338813){_0x2c240a[_0x73bb('0x15')](0x194);}return _0x338813;};}function handleError(_0x8b3a4,_0x3de248){_0x3de248=_0x3de248||0x1f4;return function(_0x3dd81c){logger[_0x73bb('0x24')](_0x3dd81c[_0x73bb('0x25')]);if(_0x3dd81c['name']){delete _0x3dd81c['name'];}_0x8b3a4['status'](_0x3de248)[_0x73bb('0x26')](_0x3dd81c);};}exports['index']=function(_0x242aa7,_0x57d1ab){var _0x94a63f={},_0x1b4b21={},_0x5ca22f={'count':0x0,'rows':[]};var _0x16c019=_['map'](db[_0x73bb('0x27')][_0x73bb('0x28')],function(_0x4d9673){return{'name':_0x4d9673[_0x73bb('0x29')],'type':_0x4d9673[_0x73bb('0x2a')][_0x73bb('0x2b')]};});_0x1b4b21[_0x73bb('0x2c')]=_[_0x73bb('0x2d')](_0x16c019,'name');_0x1b4b21[_0x73bb('0x2e')]=_[_0x73bb('0x2f')](_0x242aa7['query']);_0x1b4b21[_0x73bb('0x30')]=_[_0x73bb('0x31')](_0x1b4b21['model'],_0x1b4b21[_0x73bb('0x2e')]);_0x94a63f[_0x73bb('0x32')]=_['intersection'](_0x1b4b21[_0x73bb('0x2c')],qs[_0x73bb('0x33')](_0x242aa7[_0x73bb('0x2e')][_0x73bb('0x33')]));_0x94a63f[_0x73bb('0x32')]=_0x94a63f['attributes']['length']?_0x94a63f[_0x73bb('0x32')]:_0x1b4b21['model'];if(!_0x242aa7[_0x73bb('0x2e')][_0x73bb('0x34')](_0x73bb('0x35'))){_0x94a63f['limit']=qs[_0x73bb('0x1b')](_0x242aa7['query'][_0x73bb('0x1b')]);_0x94a63f[_0x73bb('0x19')]=qs[_0x73bb('0x19')](_0x242aa7[_0x73bb('0x2e')][_0x73bb('0x19')]);}_0x94a63f['order']=qs[_0x73bb('0x36')](_0x242aa7['query']['sort']);_0x94a63f[_0x73bb('0x37')]=qs[_0x73bb('0x30')](_[_0x73bb('0x38')](_0x242aa7[_0x73bb('0x2e')],_0x1b4b21[_0x73bb('0x30')]),_0x16c019);if(_0x242aa7['query']['filter']){_0x94a63f[_0x73bb('0x37')]=_['merge'](_0x94a63f[_0x73bb('0x37')],{'$or':_[_0x73bb('0x2d')](_0x16c019,function(_0x3487c7){if(_0x3487c7[_0x73bb('0x2a')]!=='VIRTUAL'){var _0x3504f3={};_0x3504f3[_0x3487c7['name']]={'$like':'%'+_0x242aa7[_0x73bb('0x2e')][_0x73bb('0x39')]+'%'};return _0x3504f3;}})});}_0x94a63f=_['merge']({},_0x94a63f,_0x242aa7[_0x73bb('0x3a')]);var _0x5cf6f3={'where':_0x94a63f['where']};return db['Dynamics365Field'][_0x73bb('0x1c')](_0x5cf6f3)['then'](function(_0x2eed1f){_0x5ca22f['count']=_0x2eed1f;if(_0x242aa7[_0x73bb('0x2e')][_0x73bb('0x3b')]){_0x94a63f[_0x73bb('0x3c')]=[{'all':!![]}];}return db['Dynamics365Field'][_0x73bb('0x3d')](_0x94a63f);})['then'](function(_0x1a893e){_0x5ca22f['rows']=_0x1a893e;return _0x5ca22f;})[_0x73bb('0x23')](respondWithFilteredResult(_0x57d1ab,_0x94a63f))[_0x73bb('0x3e')](handleError(_0x57d1ab,null));};exports[_0x73bb('0x3f')]=function(_0x2f29f6,_0x31f107){var _0x14099d={'raw':!![],'where':{'id':_0x2f29f6[_0x73bb('0x40')]['id']}},_0x1d1d5a={};_0x1d1d5a[_0x73bb('0x2c')]=_['keys'](db[_0x73bb('0x27')][_0x73bb('0x28')]);_0x1d1d5a[_0x73bb('0x2e')]=_[_0x73bb('0x2f')](_0x2f29f6[_0x73bb('0x2e')]);_0x1d1d5a['filters']=_[_0x73bb('0x31')](_0x1d1d5a[_0x73bb('0x2c')],_0x1d1d5a[_0x73bb('0x2e')]);_0x14099d[_0x73bb('0x32')]=_[_0x73bb('0x31')](_0x1d1d5a['model'],qs[_0x73bb('0x33')](_0x2f29f6['query'][_0x73bb('0x33')]));_0x14099d[_0x73bb('0x32')]=_0x14099d[_0x73bb('0x32')][_0x73bb('0x41')]?_0x14099d[_0x73bb('0x32')]:_0x1d1d5a['model'];if(_0x2f29f6[_0x73bb('0x2e')]['includeAll']){_0x14099d['include']=[{'all':!![]}];}_0x14099d=_['merge']({},_0x14099d,_0x2f29f6['options']);return db[_0x73bb('0x27')][_0x73bb('0x42')](_0x14099d)[_0x73bb('0x23')](handleEntityNotFound(_0x31f107,null))[_0x73bb('0x23')](respondWithResult(_0x31f107,null))['catch'](handleError(_0x31f107,null));};exports[_0x73bb('0x43')]=function(_0x2409d3,_0x6039d4){return db[_0x73bb('0x27')][_0x73bb('0x43')](_0x2409d3['body'],{})[_0x73bb('0x23')](respondWithResult(_0x6039d4,0xc9))[_0x73bb('0x3e')](handleError(_0x6039d4,null));};exports['update']=function(_0x377d58,_0x37623c){if(_0x377d58[_0x73bb('0x44')]['id']){delete _0x377d58[_0x73bb('0x44')]['id'];}return db['Dynamics365Field'][_0x73bb('0x42')]({'where':{'id':_0x377d58['params']['id']}})[_0x73bb('0x23')](handleEntityNotFound(_0x37623c,null))[_0x73bb('0x23')](saveUpdates(_0x377d58[_0x73bb('0x44')],null))[_0x73bb('0x23')](respondWithResult(_0x37623c,null))[_0x73bb('0x3e')](handleError(_0x37623c,null));};exports[_0x73bb('0x22')]=function(_0x320e36,_0x3c3815){return db[_0x73bb('0x27')]['find']({'where':{'id':_0x320e36['params']['id']}})[_0x73bb('0x23')](handleEntityNotFound(_0x3c3815,null))[_0x73bb('0x23')](removeEntity(_0x3c3815,null))[_0x73bb('0x3e')](handleError(_0x3c3815,null));};
\ No newline at end of file