Built motion from commit 3d3e98f2.|2.6.29
[motion2.git] / server / api / intDynamics365Field / intDynamics365Field.controller.js
index bb3e825..da511d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x721d=['squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','error','stack','name','index','map','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','length','nolimit','sort','where','pick','filters','filter','VIRTUAL','merge','options','Dynamics365Field','includeAll','include','findAll','rows','catch','show','params','find','create','update','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','sox','to-csv'];(function(_0x27ff4d,_0x41a7d6){var _0x803d72=function(_0x4767cc){while(--_0x4767cc){_0x27ff4d['push'](_0x27ff4d['shift']());}};_0x803d72(++_0x41a7d6);}(_0x721d,0x190));var _0xd721=function(_0x4db561,_0x521d0d){_0x4db561=_0x4db561-0x0;var _0x299980=_0x721d[_0x4db561];return _0x299980;};'use strict';var emlformat=require(_0xd721('0x0'));var rimraf=require(_0xd721('0x1'));var zipdir=require(_0xd721('0x2'));var jsonpatch=require(_0xd721('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xd721('0x4'));var Mustache=require(_0xd721('0x5'));var util=require('util');var path=require('path');var sox=require(_0xd721('0x6'));var csv=require(_0xd721('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xd721('0x8'));var crypto=require(_0xd721('0x9'));var jsforce=require(_0xd721('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xd721('0x7'));var querystring=require(_0xd721('0xb'));var Papa=require(_0xd721('0xc'));var Redis=require(_0xd721('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xd721('0xe'));var as=require(_0xd721('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0xd721('0x10'));var config=require(_0xd721('0x11'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x194bd8,_0x501008){_0x501008=_0x501008||0xcc;return function(_0x4054d1){if(_0x4054d1){return _0x194bd8[_0xd721('0x12')](_0x501008);}return _0x194bd8[_0xd721('0x13')](_0x501008)[_0xd721('0x14')]();};}function respondWithResult(_0x294db4,_0x80ab05){_0x80ab05=_0x80ab05||0xc8;return function(_0x59a9d6){if(_0x59a9d6){return _0x294db4[_0xd721('0x13')](_0x80ab05)['json'](_0x59a9d6);}};}function respondWithFilteredResult(_0x1255e9,_0x49842c){return function(_0x2a9719){if(_0x2a9719){var _0x3c2c4c=typeof _0x49842c[_0xd721('0x15')]===_0xd721('0x16')&&typeof _0x49842c[_0xd721('0x17')]===_0xd721('0x16');var _0x19cb38=_0x2a9719['count'];var _0x527117=_0x3c2c4c?0x0:_0x49842c[_0xd721('0x15')];var _0x3eff8b=_0x3c2c4c?_0x2a9719[_0xd721('0x18')]:_0x49842c[_0xd721('0x15')]+_0x49842c['limit'];var _0xe15f8;if(_0x3eff8b>=_0x19cb38){_0x3eff8b=_0x19cb38;_0xe15f8=0xc8;}else{_0xe15f8=0xce;}_0x1255e9['status'](_0xe15f8);return _0x1255e9[_0xd721('0x19')](_0xd721('0x1a'),_0x527117+'-'+_0x3eff8b+'/'+_0x19cb38)['json'](_0x2a9719);}return null;};}function patchUpdates(_0x1e0411){return function(_0x5ef760){try{jsonpatch[_0xd721('0x1b')](_0x5ef760,_0x1e0411,!![]);}catch(_0x521f9b){return BPromise[_0xd721('0x1c')](_0x521f9b);}return _0x5ef760[_0xd721('0x1d')]();};}function saveUpdates(_0x47cd42,_0x26af89){return function(_0x277153){if(_0x277153){return _0x277153['update'](_0x47cd42)[_0xd721('0x1e')](function(_0x15c2ea){return _0x15c2ea;});}return null;};}function removeEntity(_0x1855d2,_0x52f860){return function(_0x3786f4){if(_0x3786f4){return _0x3786f4['destroy']()[_0xd721('0x1e')](function(){_0x1855d2[_0xd721('0x13')](0xcc)[_0xd721('0x14')]();});}};}function handleEntityNotFound(_0x36e147,_0x6a2543){return function(_0x55f39d){if(!_0x55f39d){_0x36e147['sendStatus'](0x194);}return _0x55f39d;};}function handleError(_0x2daf66,_0x57e1eb){_0x57e1eb=_0x57e1eb||0x1f4;return function(_0x2da3f6){logger[_0xd721('0x1f')](_0x2da3f6[_0xd721('0x20')]);if(_0x2da3f6[_0xd721('0x21')]){delete _0x2da3f6[_0xd721('0x21')];}_0x2daf66[_0xd721('0x13')](_0x57e1eb)['send'](_0x2da3f6);};}exports[_0xd721('0x22')]=function(_0x265eff,_0x4f0ea2){var _0x2488c0={},_0x28ec08={},_0x150127={'count':0x0,'rows':[]};var _0xf15460=_[_0xd721('0x23')](db['Dynamics365Field'][_0xd721('0x24')],function(_0xb076df){return{'name':_0xb076df[_0xd721('0x25')],'type':_0xb076df[_0xd721('0x26')][_0xd721('0x27')]};});_0x28ec08[_0xd721('0x28')]=_['map'](_0xf15460,_0xd721('0x21'));_0x28ec08['query']=_['keys'](_0x265eff['query']);_0x28ec08['filters']=_['intersection'](_0x28ec08[_0xd721('0x28')],_0x28ec08[_0xd721('0x29')]);_0x2488c0['attributes']=_[_0xd721('0x2a')](_0x28ec08[_0xd721('0x28')],qs[_0xd721('0x2b')](_0x265eff[_0xd721('0x29')][_0xd721('0x2b')]));_0x2488c0[_0xd721('0x2c')]=_0x2488c0[_0xd721('0x2c')][_0xd721('0x2d')]?_0x2488c0['attributes']:_0x28ec08[_0xd721('0x28')];if(!_0x265eff[_0xd721('0x29')]['hasOwnProperty'](_0xd721('0x2e'))){_0x2488c0[_0xd721('0x17')]=qs[_0xd721('0x17')](_0x265eff[_0xd721('0x29')][_0xd721('0x17')]);_0x2488c0[_0xd721('0x15')]=qs[_0xd721('0x15')](_0x265eff[_0xd721('0x29')]['offset']);}_0x2488c0['order']=qs[_0xd721('0x2f')](_0x265eff[_0xd721('0x29')][_0xd721('0x2f')]);_0x2488c0[_0xd721('0x30')]=qs['filters'](_[_0xd721('0x31')](_0x265eff[_0xd721('0x29')],_0x28ec08[_0xd721('0x32')]),_0xf15460);if(_0x265eff[_0xd721('0x29')][_0xd721('0x33')]){_0x2488c0[_0xd721('0x30')]=_['merge'](_0x2488c0[_0xd721('0x30')],{'$or':_[_0xd721('0x23')](_0xf15460,function(_0x4b1e4d){if(_0x4b1e4d[_0xd721('0x26')]!==_0xd721('0x34')){var _0x1020e7={};_0x1020e7[_0x4b1e4d['name']]={'$like':'%'+_0x265eff['query'][_0xd721('0x33')]+'%'};return _0x1020e7;}})});}_0x2488c0=_[_0xd721('0x35')]({},_0x2488c0,_0x265eff[_0xd721('0x36')]);var _0x17d5ce={'where':_0x2488c0[_0xd721('0x30')]};return db[_0xd721('0x37')]['count'](_0x17d5ce)['then'](function(_0x4456cf){_0x150127['count']=_0x4456cf;if(_0x265eff[_0xd721('0x29')][_0xd721('0x38')]){_0x2488c0[_0xd721('0x39')]=[{'all':!![]}];}return db['Dynamics365Field'][_0xd721('0x3a')](_0x2488c0);})[_0xd721('0x1e')](function(_0x438be0){_0x150127[_0xd721('0x3b')]=_0x438be0;return _0x150127;})[_0xd721('0x1e')](respondWithFilteredResult(_0x4f0ea2,_0x2488c0))[_0xd721('0x3c')](handleError(_0x4f0ea2,null));};exports[_0xd721('0x3d')]=function(_0x12bf32,_0x2475f1){var _0xb36a89={'raw':!![],'where':{'id':_0x12bf32[_0xd721('0x3e')]['id']}},_0xe7cf9f={};_0xe7cf9f[_0xd721('0x28')]=_['keys'](db[_0xd721('0x37')]['rawAttributes']);_0xe7cf9f[_0xd721('0x29')]=_['keys'](_0x12bf32[_0xd721('0x29')]);_0xe7cf9f[_0xd721('0x32')]=_[_0xd721('0x2a')](_0xe7cf9f[_0xd721('0x28')],_0xe7cf9f['query']);_0xb36a89[_0xd721('0x2c')]=_[_0xd721('0x2a')](_0xe7cf9f[_0xd721('0x28')],qs[_0xd721('0x2b')](_0x12bf32[_0xd721('0x29')][_0xd721('0x2b')]));_0xb36a89[_0xd721('0x2c')]=_0xb36a89[_0xd721('0x2c')][_0xd721('0x2d')]?_0xb36a89[_0xd721('0x2c')]:_0xe7cf9f[_0xd721('0x28')];if(_0x12bf32[_0xd721('0x29')][_0xd721('0x38')]){_0xb36a89[_0xd721('0x39')]=[{'all':!![]}];}_0xb36a89=_['merge']({},_0xb36a89,_0x12bf32[_0xd721('0x36')]);return db[_0xd721('0x37')][_0xd721('0x3f')](_0xb36a89)['then'](handleEntityNotFound(_0x2475f1,null))[_0xd721('0x1e')](respondWithResult(_0x2475f1,null))[_0xd721('0x3c')](handleError(_0x2475f1,null));};exports[_0xd721('0x40')]=function(_0x44ffea,_0x509dd1){return db['Dynamics365Field'][_0xd721('0x40')](_0x44ffea['body'],{})[_0xd721('0x1e')](respondWithResult(_0x509dd1,0xc9))[_0xd721('0x3c')](handleError(_0x509dd1,null));};exports[_0xd721('0x41')]=function(_0x10b771,_0x1ceda6){if(_0x10b771[_0xd721('0x42')]['id']){delete _0x10b771['body']['id'];}return db[_0xd721('0x37')][_0xd721('0x3f')]({'where':{'id':_0x10b771['params']['id']}})[_0xd721('0x1e')](handleEntityNotFound(_0x1ceda6,null))['then'](saveUpdates(_0x10b771[_0xd721('0x42')],null))[_0xd721('0x1e')](respondWithResult(_0x1ceda6,null))[_0xd721('0x3c')](handleError(_0x1ceda6,null));};exports[_0xd721('0x43')]=function(_0x765ad,_0x2c0a9a){return db[_0xd721('0x37')][_0xd721('0x3f')]({'where':{'id':_0x765ad['params']['id']}})[_0xd721('0x1e')](handleEntityNotFound(_0x2c0a9a,null))[_0xd721('0x1e')](removeEntity(_0x2c0a9a,null))[_0xd721('0x3c')](handleError(_0x2c0a9a,null));};
\ No newline at end of file
+var _0x771f=['count','offset','set','Content-Range','apply','save','destroy','then','error','stack','name','send','index','map','Dynamics365Field','rawAttributes','fieldName','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','filter','where','merge','type','VIRTUAL','options','includeAll','include','rows','show','params','keys','find','catch','create','body','update','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','to-csv','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','undefined','limit'];(function(_0x1e6b59,_0x5eca5d){var _0x40d7c5=function(_0x2dd544){while(--_0x2dd544){_0x1e6b59['push'](_0x1e6b59['shift']());}};_0x40d7c5(++_0x5eca5d);}(_0x771f,0x148));var _0xf771=function(_0xbe200f,_0x4b50eb){_0xbe200f=_0xbe200f-0x0;var _0x192597=_0x771f[_0xbe200f];return _0x192597;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf771('0x0'));var zipdir=require(_0xf771('0x1'));var jsonpatch=require(_0xf771('0x2'));var rp=require(_0xf771('0x3'));var moment=require(_0xf771('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xf771('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0xf771('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf771('0x7'));var _=require('lodash');var squel=require(_0xf771('0x8'));var crypto=require(_0xf771('0x9'));var jsforce=require(_0xf771('0xa'));var deskjs=require(_0xf771('0xb'));var toCsv=require(_0xf771('0x6'));var querystring=require('querystring');var Papa=require(_0xf771('0xc'));var Redis=require(_0xf771('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xf771('0xe'));var as=require(_0xf771('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf771('0x10'))(_0xf771('0x11'));var utils=require(_0xf771('0x12'));var config=require(_0xf771('0x13'));var licenseUtil=require(_0xf771('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x53ce19,_0x31b1c3){_0x31b1c3=_0x31b1c3||0xcc;return function(_0xd085d3){if(_0xd085d3){return _0x53ce19[_0xf771('0x15')](_0x31b1c3);}return _0x53ce19[_0xf771('0x16')](_0x31b1c3)[_0xf771('0x17')]();};}function respondWithResult(_0x1a9a60,_0x519d48){_0x519d48=_0x519d48||0xc8;return function(_0x20d65b){if(_0x20d65b){return _0x1a9a60[_0xf771('0x16')](_0x519d48)[_0xf771('0x18')](_0x20d65b);}};}function respondWithFilteredResult(_0x432174,_0x42923c){return function(_0x1cef86){if(_0x1cef86){var _0xadddd1=typeof _0x42923c['offset']===_0xf771('0x19')&&typeof _0x42923c[_0xf771('0x1a')]===_0xf771('0x19');var _0x454653=_0x1cef86[_0xf771('0x1b')];var _0x87f4d9=_0xadddd1?0x0:_0x42923c[_0xf771('0x1c')];var _0x647289=_0xadddd1?_0x1cef86[_0xf771('0x1b')]:_0x42923c[_0xf771('0x1c')]+_0x42923c[_0xf771('0x1a')];var _0x1e9fb4;if(_0x647289>=_0x454653){_0x647289=_0x454653;_0x1e9fb4=0xc8;}else{_0x1e9fb4=0xce;}_0x432174[_0xf771('0x16')](_0x1e9fb4);return _0x432174[_0xf771('0x1d')](_0xf771('0x1e'),_0x87f4d9+'-'+_0x647289+'/'+_0x454653)[_0xf771('0x18')](_0x1cef86);}return null;};}function patchUpdates(_0x5144ac){return function(_0x12829d){try{jsonpatch[_0xf771('0x1f')](_0x12829d,_0x5144ac,!![]);}catch(_0x169fd6){return BPromise['reject'](_0x169fd6);}return _0x12829d[_0xf771('0x20')]();};}function saveUpdates(_0x280309,_0x238e4d){return function(_0xaa198c){if(_0xaa198c){return _0xaa198c['update'](_0x280309)['then'](function(_0x10bebd){return _0x10bebd;});}return null;};}function removeEntity(_0x32f2e8,_0x30029b){return function(_0x1ed9ff){if(_0x1ed9ff){return _0x1ed9ff[_0xf771('0x21')]()[_0xf771('0x22')](function(){_0x32f2e8['status'](0xcc)[_0xf771('0x17')]();});}};}function handleEntityNotFound(_0x2de9cb,_0x411325){return function(_0x24a07e){if(!_0x24a07e){_0x2de9cb[_0xf771('0x15')](0x194);}return _0x24a07e;};}function handleError(_0x47d9e7,_0x44d8fc){_0x44d8fc=_0x44d8fc||0x1f4;return function(_0x365041){logger[_0xf771('0x23')](_0x365041[_0xf771('0x24')]);if(_0x365041[_0xf771('0x25')]){delete _0x365041[_0xf771('0x25')];}_0x47d9e7[_0xf771('0x16')](_0x44d8fc)[_0xf771('0x26')](_0x365041);};}exports[_0xf771('0x27')]=function(_0x5d9cb4,_0x36710a){var _0x783b34={},_0x5c7d1d={},_0x48a6f2={'count':0x0,'rows':[]};var _0x2b45f6=_[_0xf771('0x28')](db[_0xf771('0x29')][_0xf771('0x2a')],function(_0x1d720b){return{'name':_0x1d720b[_0xf771('0x2b')],'type':_0x1d720b['type'][_0xf771('0x2c')]};});_0x5c7d1d[_0xf771('0x2d')]=_['map'](_0x2b45f6,_0xf771('0x25'));_0x5c7d1d[_0xf771('0x2e')]=_['keys'](_0x5d9cb4[_0xf771('0x2e')]);_0x5c7d1d[_0xf771('0x2f')]=_[_0xf771('0x30')](_0x5c7d1d[_0xf771('0x2d')],_0x5c7d1d[_0xf771('0x2e')]);_0x783b34['attributes']=_[_0xf771('0x30')](_0x5c7d1d[_0xf771('0x2d')],qs[_0xf771('0x31')](_0x5d9cb4[_0xf771('0x2e')]['fields']));_0x783b34[_0xf771('0x32')]=_0x783b34['attributes'][_0xf771('0x33')]?_0x783b34['attributes']:_0x5c7d1d[_0xf771('0x2d')];if(!_0x5d9cb4['query'][_0xf771('0x34')]('nolimit')){_0x783b34[_0xf771('0x1a')]=qs[_0xf771('0x1a')](_0x5d9cb4[_0xf771('0x2e')]['limit']);_0x783b34[_0xf771('0x1c')]=qs[_0xf771('0x1c')](_0x5d9cb4[_0xf771('0x2e')]['offset']);}_0x783b34[_0xf771('0x35')]=qs['sort'](_0x5d9cb4[_0xf771('0x2e')]['sort']);_0x783b34['where']=qs[_0xf771('0x2f')](_['pick'](_0x5d9cb4['query'],_0x5c7d1d[_0xf771('0x2f')]),_0x2b45f6);if(_0x5d9cb4[_0xf771('0x2e')][_0xf771('0x36')]){_0x783b34[_0xf771('0x37')]=_[_0xf771('0x38')](_0x783b34['where'],{'$or':_['map'](_0x2b45f6,function(_0x416c23){if(_0x416c23[_0xf771('0x39')]!==_0xf771('0x3a')){var _0x3b268e={};_0x3b268e[_0x416c23[_0xf771('0x25')]]={'$like':'%'+_0x5d9cb4['query'][_0xf771('0x36')]+'%'};return _0x3b268e;}})});}_0x783b34=_[_0xf771('0x38')]({},_0x783b34,_0x5d9cb4[_0xf771('0x3b')]);var _0x20106b={'where':_0x783b34[_0xf771('0x37')]};return db['Dynamics365Field'][_0xf771('0x1b')](_0x20106b)[_0xf771('0x22')](function(_0x370c86){_0x48a6f2[_0xf771('0x1b')]=_0x370c86;if(_0x5d9cb4[_0xf771('0x2e')][_0xf771('0x3c')]){_0x783b34[_0xf771('0x3d')]=[{'all':!![]}];}return db['Dynamics365Field']['findAll'](_0x783b34);})[_0xf771('0x22')](function(_0x2b054c){_0x48a6f2[_0xf771('0x3e')]=_0x2b054c;return _0x48a6f2;})[_0xf771('0x22')](respondWithFilteredResult(_0x36710a,_0x783b34))['catch'](handleError(_0x36710a,null));};exports[_0xf771('0x3f')]=function(_0x193c8a,_0x30cf53){var _0x1f9a0a={'raw':!![],'where':{'id':_0x193c8a[_0xf771('0x40')]['id']}},_0x2721af={};_0x2721af[_0xf771('0x2d')]=_['keys'](db[_0xf771('0x29')][_0xf771('0x2a')]);_0x2721af[_0xf771('0x2e')]=_[_0xf771('0x41')](_0x193c8a[_0xf771('0x2e')]);_0x2721af[_0xf771('0x2f')]=_[_0xf771('0x30')](_0x2721af[_0xf771('0x2d')],_0x2721af[_0xf771('0x2e')]);_0x1f9a0a['attributes']=_[_0xf771('0x30')](_0x2721af[_0xf771('0x2d')],qs[_0xf771('0x31')](_0x193c8a[_0xf771('0x2e')][_0xf771('0x31')]));_0x1f9a0a[_0xf771('0x32')]=_0x1f9a0a[_0xf771('0x32')]['length']?_0x1f9a0a[_0xf771('0x32')]:_0x2721af[_0xf771('0x2d')];if(_0x193c8a['query'][_0xf771('0x3c')]){_0x1f9a0a[_0xf771('0x3d')]=[{'all':!![]}];}_0x1f9a0a=_[_0xf771('0x38')]({},_0x1f9a0a,_0x193c8a['options']);return db[_0xf771('0x29')][_0xf771('0x42')](_0x1f9a0a)['then'](handleEntityNotFound(_0x30cf53,null))[_0xf771('0x22')](respondWithResult(_0x30cf53,null))[_0xf771('0x43')](handleError(_0x30cf53,null));};exports[_0xf771('0x44')]=function(_0x1cfa56,_0x1b9b43){return db['Dynamics365Field'][_0xf771('0x44')](_0x1cfa56[_0xf771('0x45')],{})[_0xf771('0x22')](respondWithResult(_0x1b9b43,0xc9))[_0xf771('0x43')](handleError(_0x1b9b43,null));};exports[_0xf771('0x46')]=function(_0x23b16f,_0x137764){if(_0x23b16f[_0xf771('0x45')]['id']){delete _0x23b16f[_0xf771('0x45')]['id'];}return db[_0xf771('0x29')]['find']({'where':{'id':_0x23b16f[_0xf771('0x40')]['id']}})[_0xf771('0x22')](handleEntityNotFound(_0x137764,null))[_0xf771('0x22')](saveUpdates(_0x23b16f[_0xf771('0x45')],null))[_0xf771('0x22')](respondWithResult(_0x137764,null))['catch'](handleError(_0x137764,null));};exports[_0xf771('0x21')]=function(_0x2edd58,_0x30f702){return db[_0xf771('0x29')]['find']({'where':{'id':_0x2edd58[_0xf771('0x40')]['id']}})[_0xf771('0x22')](handleEntityNotFound(_0x30f702,null))[_0xf771('0x22')](removeEntity(_0x30f702,null))[_0xf771('0x43')](handleError(_0x30f702,null));};
\ No newline at end of file