Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / intDynamics365Field / intDynamics365Field.controller.js
index 37d4c64..ad26a80 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x354f=['../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','index','Dynamics365Field','rawAttributes','fieldName','type','map','query','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','rows','catch','show','params','keys','include','options','find','create','body','update','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','papaparse','ioredis'];(function(_0x40c402,_0x42ee7d){var _0x4e7680=function(_0x52b150){while(--_0x52b150){_0x40c402['push'](_0x40c402['shift']());}};_0x4e7680(++_0x42ee7d);}(_0x354f,0xcb));var _0xf354=function(_0x1da527,_0x2dc953){_0x1da527=_0x1da527-0x0;var _0x40fc7c=_0x354f[_0x1da527];return _0x40fc7c;};'use strict';var emlformat=require(_0xf354('0x0'));var rimraf=require(_0xf354('0x1'));var zipdir=require(_0xf354('0x2'));var jsonpatch=require(_0xf354('0x3'));var rp=require(_0xf354('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xf354('0x5'));var util=require('util');var path=require(_0xf354('0x6'));var sox=require(_0xf354('0x7'));var csv=require(_0xf354('0x8'));var ejs=require(_0xf354('0x9'));var fs=require('fs');var fs_extra=require(_0xf354('0xa'));var _=require('lodash');var squel=require(_0xf354('0xb'));var crypto=require(_0xf354('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xf354('0xd'));var toCsv=require(_0xf354('0x8'));var querystring=require('querystring');var Papa=require(_0xf354('0xe'));var Redis=require(_0xf354('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf354('0x10'));var hardwareService=require(_0xf354('0x11'));var logger=require('../../config/logger')(_0xf354('0x12'));var utils=require(_0xf354('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xf354('0x14'));var db=require(_0xf354('0x15'))['db'];function respondWithStatusCode(_0xb18112,_0x498925){_0x498925=_0x498925||0xcc;return function(_0x59c370){if(_0x59c370){return _0xb18112[_0xf354('0x16')](_0x498925);}return _0xb18112[_0xf354('0x17')](_0x498925)[_0xf354('0x18')]();};}function respondWithResult(_0x430b68,_0x30d4f5){_0x30d4f5=_0x30d4f5||0xc8;return function(_0x459257){if(_0x459257){return _0x430b68[_0xf354('0x17')](_0x30d4f5)[_0xf354('0x19')](_0x459257);}};}function respondWithFilteredResult(_0x40b380,_0x1b930a){return function(_0x2420d3){if(_0x2420d3){var _0x49d9fa=typeof _0x1b930a[_0xf354('0x1a')]===_0xf354('0x1b')&&typeof _0x1b930a[_0xf354('0x1c')]==='undefined';var _0x50e1a5=_0x2420d3[_0xf354('0x1d')];var _0x6139d1=_0x49d9fa?0x0:_0x1b930a[_0xf354('0x1a')];var _0x38f356=_0x49d9fa?_0x2420d3[_0xf354('0x1d')]:_0x1b930a[_0xf354('0x1a')]+_0x1b930a[_0xf354('0x1c')];var _0x46758f;if(_0x38f356>=_0x50e1a5){_0x38f356=_0x50e1a5;_0x46758f=0xc8;}else{_0x46758f=0xce;}_0x40b380['status'](_0x46758f);return _0x40b380[_0xf354('0x1e')](_0xf354('0x1f'),_0x6139d1+'-'+_0x38f356+'/'+_0x50e1a5)[_0xf354('0x19')](_0x2420d3);}return null;};}function patchUpdates(_0x2f8253){return function(_0x9b0db1){try{jsonpatch[_0xf354('0x20')](_0x9b0db1,_0x2f8253,!![]);}catch(_0x253e01){return BPromise[_0xf354('0x21')](_0x253e01);}return _0x9b0db1[_0xf354('0x22')]();};}function saveUpdates(_0x4239f3,_0x48e62d){return function(_0x288893){if(_0x288893){return _0x288893['update'](_0x4239f3)[_0xf354('0x23')](function(_0x1b775f){return _0x1b775f;});}return null;};}function removeEntity(_0x4f8f44,_0x572618){return function(_0xfadc27){if(_0xfadc27){return _0xfadc27[_0xf354('0x24')]()[_0xf354('0x23')](function(){_0x4f8f44[_0xf354('0x17')](0xcc)[_0xf354('0x18')]();});}};}function handleEntityNotFound(_0x403f7f,_0xc1d749){return function(_0x4b54af){if(!_0x4b54af){_0x403f7f[_0xf354('0x16')](0x194);}return _0x4b54af;};}function handleError(_0x4f0e6d,_0x318792){_0x318792=_0x318792||0x1f4;return function(_0x58650d){logger[_0xf354('0x25')](_0x58650d[_0xf354('0x26')]);if(_0x58650d[_0xf354('0x27')]){delete _0x58650d['name'];}_0x4f0e6d[_0xf354('0x17')](_0x318792)['send'](_0x58650d);};}exports[_0xf354('0x28')]=function(_0x1f7436,_0x11be04){var _0x3191cc={},_0x334a21={},_0x5ef280={'count':0x0,'rows':[]};var _0x3da444=_['map'](db[_0xf354('0x29')][_0xf354('0x2a')],function(_0x5bbb16){return{'name':_0x5bbb16[_0xf354('0x2b')],'type':_0x5bbb16[_0xf354('0x2c')]['key']};});_0x334a21['model']=_[_0xf354('0x2d')](_0x3da444,_0xf354('0x27'));_0x334a21['query']=_['keys'](_0x1f7436[_0xf354('0x2e')]);_0x334a21[_0xf354('0x2f')]=_[_0xf354('0x30')](_0x334a21[_0xf354('0x31')],_0x334a21[_0xf354('0x2e')]);_0x3191cc[_0xf354('0x32')]=_[_0xf354('0x30')](_0x334a21[_0xf354('0x31')],qs['fields'](_0x1f7436[_0xf354('0x2e')][_0xf354('0x33')]));_0x3191cc['attributes']=_0x3191cc[_0xf354('0x32')][_0xf354('0x34')]?_0x3191cc[_0xf354('0x32')]:_0x334a21[_0xf354('0x31')];if(!_0x1f7436[_0xf354('0x2e')]['hasOwnProperty'](_0xf354('0x35'))){_0x3191cc[_0xf354('0x1c')]=qs[_0xf354('0x1c')](_0x1f7436[_0xf354('0x2e')][_0xf354('0x1c')]);_0x3191cc[_0xf354('0x1a')]=qs[_0xf354('0x1a')](_0x1f7436[_0xf354('0x2e')][_0xf354('0x1a')]);}_0x3191cc[_0xf354('0x36')]=qs[_0xf354('0x37')](_0x1f7436['query']['sort']);_0x3191cc[_0xf354('0x38')]=qs['filters'](_[_0xf354('0x39')](_0x1f7436[_0xf354('0x2e')],_0x334a21[_0xf354('0x2f')]),_0x3da444);if(_0x1f7436[_0xf354('0x2e')][_0xf354('0x3a')]){_0x3191cc[_0xf354('0x38')]=_[_0xf354('0x3b')](_0x3191cc['where'],{'$or':_[_0xf354('0x2d')](_0x3da444,function(_0x3dd5fe){if(_0x3dd5fe[_0xf354('0x2c')]!==_0xf354('0x3c')){var _0x566f99={};_0x566f99[_0x3dd5fe['name']]={'$like':'%'+_0x1f7436['query']['filter']+'%'};return _0x566f99;}})});}_0x3191cc=_['merge']({},_0x3191cc,_0x1f7436['options']);var _0x4944a2={'where':_0x3191cc['where']};return db['Dynamics365Field'][_0xf354('0x1d')](_0x4944a2)[_0xf354('0x23')](function(_0x53e0a2){_0x5ef280['count']=_0x53e0a2;if(_0x1f7436[_0xf354('0x2e')][_0xf354('0x3d')]){_0x3191cc['include']=[{'all':!![]}];}return db[_0xf354('0x29')]['findAll'](_0x3191cc);})['then'](function(_0x3cf6fc){_0x5ef280[_0xf354('0x3e')]=_0x3cf6fc;return _0x5ef280;})[_0xf354('0x23')](respondWithFilteredResult(_0x11be04,_0x3191cc))[_0xf354('0x3f')](handleError(_0x11be04,null));};exports[_0xf354('0x40')]=function(_0x3ce7dc,_0x5c7a1c){var _0x14b454={'raw':!![],'where':{'id':_0x3ce7dc[_0xf354('0x41')]['id']}},_0x419a02={};_0x419a02[_0xf354('0x31')]=_[_0xf354('0x42')](db['Dynamics365Field'][_0xf354('0x2a')]);_0x419a02[_0xf354('0x2e')]=_[_0xf354('0x42')](_0x3ce7dc[_0xf354('0x2e')]);_0x419a02[_0xf354('0x2f')]=_[_0xf354('0x30')](_0x419a02[_0xf354('0x31')],_0x419a02[_0xf354('0x2e')]);_0x14b454[_0xf354('0x32')]=_[_0xf354('0x30')](_0x419a02[_0xf354('0x31')],qs[_0xf354('0x33')](_0x3ce7dc[_0xf354('0x2e')][_0xf354('0x33')]));_0x14b454[_0xf354('0x32')]=_0x14b454[_0xf354('0x32')][_0xf354('0x34')]?_0x14b454[_0xf354('0x32')]:_0x419a02[_0xf354('0x31')];if(_0x3ce7dc[_0xf354('0x2e')][_0xf354('0x3d')]){_0x14b454[_0xf354('0x43')]=[{'all':!![]}];}_0x14b454=_['merge']({},_0x14b454,_0x3ce7dc[_0xf354('0x44')]);return db[_0xf354('0x29')][_0xf354('0x45')](_0x14b454)[_0xf354('0x23')](handleEntityNotFound(_0x5c7a1c,null))[_0xf354('0x23')](respondWithResult(_0x5c7a1c,null))[_0xf354('0x3f')](handleError(_0x5c7a1c,null));};exports[_0xf354('0x46')]=function(_0x80ad0e,_0x499d42){return db[_0xf354('0x29')]['create'](_0x80ad0e[_0xf354('0x47')],{})[_0xf354('0x23')](respondWithResult(_0x499d42,0xc9))[_0xf354('0x3f')](handleError(_0x499d42,null));};exports[_0xf354('0x48')]=function(_0x34f998,_0x9091ce){if(_0x34f998[_0xf354('0x47')]['id']){delete _0x34f998[_0xf354('0x47')]['id'];}return db[_0xf354('0x29')][_0xf354('0x45')]({'where':{'id':_0x34f998[_0xf354('0x41')]['id']}})[_0xf354('0x23')](handleEntityNotFound(_0x9091ce,null))[_0xf354('0x23')](saveUpdates(_0x34f998[_0xf354('0x47')],null))[_0xf354('0x23')](respondWithResult(_0x9091ce,null))['catch'](handleError(_0x9091ce,null));};exports[_0xf354('0x24')]=function(_0x1c97fb,_0x35b956){return db[_0xf354('0x29')]['find']({'where':{'id':_0x1c97fb[_0xf354('0x41')]['id']}})[_0xf354('0x23')](handleEntityNotFound(_0x35b956,null))[_0xf354('0x23')](removeEntity(_0x35b956,null))[_0xf354('0x3f')](handleError(_0x35b956,null));};
\ No newline at end of file
+var _0x493c=['find','create','body','rimraf','zip-dir','fast-json-patch','moment','bluebird','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','sendStatus','status','end','json','offset','limit','undefined','count','set','apply','save','destroy','then','error','stack','name','send','index','map','Dynamics365Field','rawAttributes','fieldName','type','key','keys','filters','model','query','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','includeAll','include','findAll','catch','show','params','intersection','length'];(function(_0x173441,_0x26b0d9){var _0x2423a8=function(_0x4d96c2){while(--_0x4d96c2){_0x173441['push'](_0x173441['shift']());}};_0x2423a8(++_0x26b0d9);}(_0x493c,0x161));var _0xc493=function(_0x231160,_0x4608b9){_0x231160=_0x231160-0x0;var _0xa373ce=_0x493c[_0x231160];return _0xa373ce;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc493('0x0'));var zipdir=require(_0xc493('0x1'));var jsonpatch=require(_0xc493('0x2'));var rp=require('request-promise');var moment=require(_0xc493('0x3'));var BPromise=require(_0xc493('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xc493('0x5'));var sox=require('sox');var csv=require(_0xc493('0x6'));var ejs=require(_0xc493('0x7'));var fs=require('fs');var fs_extra=require(_0xc493('0x8'));var _=require(_0xc493('0x9'));var squel=require(_0xc493('0xa'));var crypto=require(_0xc493('0xb'));var jsforce=require(_0xc493('0xc'));var deskjs=require(_0xc493('0xd'));var toCsv=require(_0xc493('0x6'));var querystring=require(_0xc493('0xe'));var Papa=require('papaparse');var Redis=require(_0xc493('0xf'));var authService=require(_0xc493('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc493('0x11'));var logger=require(_0xc493('0x12'))(_0xc493('0x13'));var utils=require(_0xc493('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x35dfcb,_0x7808e1){_0x7808e1=_0x7808e1||0xcc;return function(_0x2e4eaa){if(_0x2e4eaa){return _0x35dfcb[_0xc493('0x15')](_0x7808e1);}return _0x35dfcb[_0xc493('0x16')](_0x7808e1)[_0xc493('0x17')]();};}function respondWithResult(_0x3b3b6f,_0x10de41){_0x10de41=_0x10de41||0xc8;return function(_0x4b1b89){if(_0x4b1b89){return _0x3b3b6f[_0xc493('0x16')](_0x10de41)[_0xc493('0x18')](_0x4b1b89);}};}function respondWithFilteredResult(_0x1672eb,_0xee1c23){return function(_0x2293e2){if(_0x2293e2){var _0x10fba1=typeof _0xee1c23[_0xc493('0x19')]==='undefined'&&typeof _0xee1c23[_0xc493('0x1a')]===_0xc493('0x1b');var _0x185ef0=_0x2293e2[_0xc493('0x1c')];var _0x26783a=_0x10fba1?0x0:_0xee1c23[_0xc493('0x19')];var _0x65b13e=_0x10fba1?_0x2293e2[_0xc493('0x1c')]:_0xee1c23[_0xc493('0x19')]+_0xee1c23[_0xc493('0x1a')];var _0x10ab90;if(_0x65b13e>=_0x185ef0){_0x65b13e=_0x185ef0;_0x10ab90=0xc8;}else{_0x10ab90=0xce;}_0x1672eb[_0xc493('0x16')](_0x10ab90);return _0x1672eb[_0xc493('0x1d')]('Content-Range',_0x26783a+'-'+_0x65b13e+'/'+_0x185ef0)[_0xc493('0x18')](_0x2293e2);}return null;};}function patchUpdates(_0x1bfe43){return function(_0x5cb75b){try{jsonpatch[_0xc493('0x1e')](_0x5cb75b,_0x1bfe43,!![]);}catch(_0x50b416){return BPromise['reject'](_0x50b416);}return _0x5cb75b[_0xc493('0x1f')]();};}function saveUpdates(_0x5ddb9e,_0x4881ed){return function(_0x230f49){if(_0x230f49){return _0x230f49['update'](_0x5ddb9e)['then'](function(_0x531650){return _0x531650;});}return null;};}function removeEntity(_0x5d0147,_0x31a8ca){return function(_0x30230e){if(_0x30230e){return _0x30230e[_0xc493('0x20')]()[_0xc493('0x21')](function(){_0x5d0147[_0xc493('0x16')](0xcc)[_0xc493('0x17')]();});}};}function handleEntityNotFound(_0x4429ba,_0x39101b){return function(_0x161965){if(!_0x161965){_0x4429ba[_0xc493('0x15')](0x194);}return _0x161965;};}function handleError(_0x11dc88,_0xad98ff){_0xad98ff=_0xad98ff||0x1f4;return function(_0x1769de){logger[_0xc493('0x22')](_0x1769de[_0xc493('0x23')]);if(_0x1769de[_0xc493('0x24')]){delete _0x1769de[_0xc493('0x24')];}_0x11dc88[_0xc493('0x16')](_0xad98ff)[_0xc493('0x25')](_0x1769de);};}exports[_0xc493('0x26')]=function(_0x1c3dc2,_0x4fbe45){var _0x400445={},_0x99df85={},_0x7623c5={'count':0x0,'rows':[]};var _0x4618f2=_[_0xc493('0x27')](db[_0xc493('0x28')][_0xc493('0x29')],function(_0x1d099c){return{'name':_0x1d099c[_0xc493('0x2a')],'type':_0x1d099c[_0xc493('0x2b')][_0xc493('0x2c')]};});_0x99df85['model']=_['map'](_0x4618f2,'name');_0x99df85['query']=_[_0xc493('0x2d')](_0x1c3dc2['query']);_0x99df85[_0xc493('0x2e')]=_['intersection'](_0x99df85[_0xc493('0x2f')],_0x99df85[_0xc493('0x30')]);_0x400445[_0xc493('0x31')]=_['intersection'](_0x99df85[_0xc493('0x2f')],qs[_0xc493('0x32')](_0x1c3dc2[_0xc493('0x30')][_0xc493('0x32')]));_0x400445[_0xc493('0x31')]=_0x400445[_0xc493('0x31')]['length']?_0x400445[_0xc493('0x31')]:_0x99df85[_0xc493('0x2f')];if(!_0x1c3dc2[_0xc493('0x30')][_0xc493('0x33')](_0xc493('0x34'))){_0x400445[_0xc493('0x1a')]=qs[_0xc493('0x1a')](_0x1c3dc2[_0xc493('0x30')][_0xc493('0x1a')]);_0x400445[_0xc493('0x19')]=qs[_0xc493('0x19')](_0x1c3dc2['query'][_0xc493('0x19')]);}_0x400445['order']=qs[_0xc493('0x35')](_0x1c3dc2[_0xc493('0x30')][_0xc493('0x35')]);_0x400445[_0xc493('0x36')]=qs[_0xc493('0x2e')](_[_0xc493('0x37')](_0x1c3dc2[_0xc493('0x30')],_0x99df85[_0xc493('0x2e')]),_0x4618f2);if(_0x1c3dc2[_0xc493('0x30')][_0xc493('0x38')]){_0x400445[_0xc493('0x36')]=_[_0xc493('0x39')](_0x400445[_0xc493('0x36')],{'$or':_['map'](_0x4618f2,function(_0x516b3b){if(_0x516b3b['type']!=='VIRTUAL'){var _0x1b81d2={};_0x1b81d2[_0x516b3b[_0xc493('0x24')]]={'$like':'%'+_0x1c3dc2[_0xc493('0x30')]['filter']+'%'};return _0x1b81d2;}})});}_0x400445=_[_0xc493('0x39')]({},_0x400445,_0x1c3dc2[_0xc493('0x3a')]);var _0x27ce4c={'where':_0x400445['where']};return db[_0xc493('0x28')][_0xc493('0x1c')](_0x27ce4c)[_0xc493('0x21')](function(_0x4ac7b0){_0x7623c5[_0xc493('0x1c')]=_0x4ac7b0;if(_0x1c3dc2['query'][_0xc493('0x3b')]){_0x400445[_0xc493('0x3c')]=[{'all':!![]}];}return db[_0xc493('0x28')][_0xc493('0x3d')](_0x400445);})['then'](function(_0x2258f0){_0x7623c5['rows']=_0x2258f0;return _0x7623c5;})['then'](respondWithFilteredResult(_0x4fbe45,_0x400445))[_0xc493('0x3e')](handleError(_0x4fbe45,null));};exports[_0xc493('0x3f')]=function(_0x5530e2,_0xa48251){var _0x582312={'raw':!![],'where':{'id':_0x5530e2[_0xc493('0x40')]['id']}},_0x45f2d9={};_0x45f2d9[_0xc493('0x2f')]=_[_0xc493('0x2d')](db[_0xc493('0x28')][_0xc493('0x29')]);_0x45f2d9[_0xc493('0x30')]=_[_0xc493('0x2d')](_0x5530e2[_0xc493('0x30')]);_0x45f2d9[_0xc493('0x2e')]=_[_0xc493('0x41')](_0x45f2d9[_0xc493('0x2f')],_0x45f2d9[_0xc493('0x30')]);_0x582312[_0xc493('0x31')]=_['intersection'](_0x45f2d9[_0xc493('0x2f')],qs[_0xc493('0x32')](_0x5530e2[_0xc493('0x30')]['fields']));_0x582312[_0xc493('0x31')]=_0x582312[_0xc493('0x31')][_0xc493('0x42')]?_0x582312[_0xc493('0x31')]:_0x45f2d9[_0xc493('0x2f')];if(_0x5530e2[_0xc493('0x30')]['includeAll']){_0x582312['include']=[{'all':!![]}];}_0x582312=_[_0xc493('0x39')]({},_0x582312,_0x5530e2[_0xc493('0x3a')]);return db['Dynamics365Field'][_0xc493('0x43')](_0x582312)['then'](handleEntityNotFound(_0xa48251,null))[_0xc493('0x21')](respondWithResult(_0xa48251,null))[_0xc493('0x3e')](handleError(_0xa48251,null));};exports[_0xc493('0x44')]=function(_0x470d1c,_0x389227){return db[_0xc493('0x28')][_0xc493('0x44')](_0x470d1c[_0xc493('0x45')],{})['then'](respondWithResult(_0x389227,0xc9))[_0xc493('0x3e')](handleError(_0x389227,null));};exports['update']=function(_0x58b639,_0x2cfc16){if(_0x58b639[_0xc493('0x45')]['id']){delete _0x58b639['body']['id'];}return db[_0xc493('0x28')]['find']({'where':{'id':_0x58b639['params']['id']}})[_0xc493('0x21')](handleEntityNotFound(_0x2cfc16,null))[_0xc493('0x21')](saveUpdates(_0x58b639[_0xc493('0x45')],null))[_0xc493('0x21')](respondWithResult(_0x2cfc16,null))['catch'](handleError(_0x2cfc16,null));};exports[_0xc493('0x20')]=function(_0x7f809a,_0x367d01){return db[_0xc493('0x28')][_0xc493('0x43')]({'where':{'id':_0x7f809a[_0xc493('0x40')]['id']}})[_0xc493('0x21')](handleEntityNotFound(_0x367d01,null))['then'](removeEntity(_0x367d01,null))[_0xc493('0x3e')](handleError(_0x367d01,null));};
\ No newline at end of file