Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / migration / migration.controller.js
index 113017f..929db9b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x59be=['../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','count','offset','json','reject','destroy','end','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','filters','intersection','query','attributes','fields','hasOwnProperty','limit','sort','where','VIRTUAL','filter','merge','options','then','includeAll','include','Migration','findAll','rows','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis'];(function(_0x152aa1,_0x307718){var _0x1bc01a=function(_0xd3211e){while(--_0xd3211e){_0x152aa1['push'](_0x152aa1['shift']());}};_0x1bc01a(++_0x307718);}(_0x59be,0x1ec));var _0xe59b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x59be[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xe59b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xe59b('0x1'));var zipdir=require(_0xe59b('0x2'));var jsonpatch=require(_0xe59b('0x3'));var rp=require(_0xe59b('0x4'));var moment=require(_0xe59b('0x5'));var BPromise=require(_0xe59b('0x6'));var Mustache=require(_0xe59b('0x7'));var util=require(_0xe59b('0x8'));var path=require(_0xe59b('0x9'));var sox=require(_0xe59b('0xa'));var csv=require(_0xe59b('0xb'));var ejs=require(_0xe59b('0xc'));var fs=require('fs');var _=require(_0xe59b('0xd'));var squel=require('squel');var crypto=require(_0xe59b('0xe'));var jsforce=require(_0xe59b('0xf'));var deskjs=require(_0xe59b('0x10'));var toCsv=require(_0xe59b('0xb'));var querystring=require(_0xe59b('0x11'));var Papa=require(_0xe59b('0x12'));var Redis=require(_0xe59b('0x13'));var authService=require(_0xe59b('0x14'));var qs=require(_0xe59b('0x15'));var as=require(_0xe59b('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0xe59b('0x17'));var config=require(_0xe59b('0x18'));var licenseUtil=require(_0xe59b('0x19'));var db=require(_0xe59b('0x1a'))['db'];function respondWithStatusCode(_0x5aad6e,_0x2d0cdf){_0x2d0cdf=_0x2d0cdf||0xcc;return function(_0x3e199b){if(_0x3e199b){return _0x5aad6e[_0xe59b('0x1b')](_0x2d0cdf);}return _0x5aad6e[_0xe59b('0x1c')](_0x2d0cdf)['end']();};}function respondWithResult(_0x596fc4,_0x1501c){_0x1501c=_0x1501c||0xc8;return function(_0x1c75f9){if(_0x1c75f9){return _0x596fc4[_0xe59b('0x1c')](_0x1501c)['json'](_0x1c75f9);}};}function respondWithFilteredResult(_0x2e218b,_0x5d5460){return function(_0x2c9c77){if(_0x2c9c77){var _0x1730d0=_0x2c9c77[_0xe59b('0x1d')],_0x16f1c2=_0x5d5460[_0xe59b('0x1e')],_0x2c4f5c=_0x5d5460[_0xe59b('0x1e')]+_0x5d5460['limit'],_0xb35c46;if(_0x2c4f5c>=_0x1730d0){_0x2c4f5c=_0x1730d0;_0xb35c46=0xc8;}else{_0xb35c46=0xce;}_0x2e218b['status'](_0xb35c46);return _0x2e218b['set']('Content-Range',_0x16f1c2+'-'+_0x2c4f5c+'/'+_0x1730d0)[_0xe59b('0x1f')](_0x2c9c77);}return null;};}function patchUpdates(_0x540809){return function(_0x1fc249){try{jsonpatch['apply'](_0x1fc249,_0x540809,!![]);}catch(_0x51a823){return BPromise[_0xe59b('0x20')](_0x51a823);}return _0x1fc249['save']();};}function saveUpdates(_0x5efcb9,_0x647e34){return function(_0x270657){if(_0x270657){return _0x270657['update'](_0x5efcb9)['then'](function(_0x1919f2){return _0x1919f2;});}return null;};}function removeEntity(_0x2670b9,_0x1f971f){return function(_0x16fc95){if(_0x16fc95){return _0x16fc95[_0xe59b('0x21')]()['then'](function(){_0x2670b9[_0xe59b('0x1c')](0xcc)[_0xe59b('0x22')]();});}};}function handleEntityNotFound(_0x429733,_0x224aa9){return function(_0x25cd06){if(!_0x25cd06){_0x429733[_0xe59b('0x1b')](0x194);}return _0x25cd06;};}function handleError(_0x28bfb9,_0x559b25){_0x559b25=_0x559b25||0x1f4;return function(_0x1d39d6){logger[_0xe59b('0x23')](_0x1d39d6[_0xe59b('0x24')]);if(_0x1d39d6[_0xe59b('0x25')]){delete _0x1d39d6['name'];}_0x28bfb9[_0xe59b('0x1c')](_0x559b25)[_0xe59b('0x26')](_0x1d39d6);};}exports[_0xe59b('0x27')]=function(_0x3363f9,_0x53adc3){var _0x21ff6b={},_0x550afc={},_0x31b6ca={'count':0x0,'rows':[]};var _0x480cca=_[_0xe59b('0x28')](db['Migration'][_0xe59b('0x29')],function(_0x2c1fd0){return{'name':_0x2c1fd0[_0xe59b('0x2a')],'type':_0x2c1fd0[_0xe59b('0x2b')]['key']};});_0x550afc[_0xe59b('0x2c')]=_['map'](_0x480cca,_0xe59b('0x25'));_0x550afc['query']=_['keys'](_0x3363f9['query']);_0x550afc[_0xe59b('0x2d')]=_[_0xe59b('0x2e')](_0x550afc[_0xe59b('0x2c')],_0x550afc[_0xe59b('0x2f')]);_0x21ff6b[_0xe59b('0x30')]=_[_0xe59b('0x2e')](_0x550afc['model'],qs[_0xe59b('0x31')](_0x3363f9[_0xe59b('0x2f')][_0xe59b('0x31')]));_0x21ff6b[_0xe59b('0x30')]=_0x21ff6b['attributes']['length']?_0x21ff6b[_0xe59b('0x30')]:_0x550afc[_0xe59b('0x2c')];if(!_0x3363f9['query'][_0xe59b('0x32')]('nolimit')){_0x21ff6b['limit']=qs['limit'](_0x3363f9['query'][_0xe59b('0x33')]);_0x21ff6b[_0xe59b('0x1e')]=qs['offset'](_0x3363f9['query'][_0xe59b('0x1e')]);}_0x21ff6b['order']=qs[_0xe59b('0x34')](_0x3363f9['query'][_0xe59b('0x34')]);_0x21ff6b[_0xe59b('0x35')]=qs[_0xe59b('0x2d')](_['pick'](_0x3363f9[_0xe59b('0x2f')],_0x550afc[_0xe59b('0x2d')]),_0x480cca);if(_0x3363f9['query']['filter']){_0x21ff6b[_0xe59b('0x35')]=_['merge'](_0x21ff6b[_0xe59b('0x35')],{'$or':_[_0xe59b('0x28')](_0x480cca,function(_0x2d1dcb){if(_0x2d1dcb[_0xe59b('0x2b')]!==_0xe59b('0x36')){var _0x3e7596={};_0x3e7596[_0x2d1dcb[_0xe59b('0x25')]]={'$like':'%'+_0x3363f9[_0xe59b('0x2f')][_0xe59b('0x37')]+'%'};return _0x3e7596;}})});}_0x21ff6b=_[_0xe59b('0x38')]({},_0x21ff6b,_0x3363f9[_0xe59b('0x39')]);var _0x2ddc02={'where':_0x21ff6b[_0xe59b('0x35')]};return db['Migration'][_0xe59b('0x1d')](_0x2ddc02)[_0xe59b('0x3a')](function(_0x114eb0){_0x31b6ca[_0xe59b('0x1d')]=_0x114eb0;if(_0x3363f9[_0xe59b('0x2f')][_0xe59b('0x3b')]){_0x21ff6b[_0xe59b('0x3c')]=[{'all':!![]}];}return db[_0xe59b('0x3d')][_0xe59b('0x3e')](_0x21ff6b);})[_0xe59b('0x3a')](function(_0x665a22){_0x31b6ca[_0xe59b('0x3f')]=_0x665a22;return _0x31b6ca;})[_0xe59b('0x3a')](respondWithFilteredResult(_0x53adc3,_0x21ff6b))['catch'](handleError(_0x53adc3,null));};
\ No newline at end of file
+var _0xabaf=['fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','merge','options','Migration','includeAll','include','catch','eml-format','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','jsforce','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','index','map'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0xabaf,0x1c7));var _0xfaba=function(_0x4a91e3,_0x423dcf){_0x4a91e3=_0x4a91e3-0x0;var _0x3e8066=_0xabaf[_0x4a91e3];return _0x3e8066;};'use strict';var emlformat=require(_0xfaba('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xfaba('0x1'));var jsonpatch=require(_0xfaba('0x2'));var rp=require('request-promise');var moment=require(_0xfaba('0x3'));var BPromise=require(_0xfaba('0x4'));var Mustache=require('mustache');var util=require(_0xfaba('0x5'));var path=require(_0xfaba('0x6'));var sox=require(_0xfaba('0x7'));var csv=require(_0xfaba('0x8'));var ejs=require(_0xfaba('0x9'));var fs=require('fs');var fs_extra=require(_0xfaba('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xfaba('0xb'));var deskjs=require(_0xfaba('0xc'));var toCsv=require(_0xfaba('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xfaba('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xfaba('0xe'));var as=require(_0xfaba('0xf'));var hardwareService=require(_0xfaba('0x10'));var logger=require(_0xfaba('0x11'))('api');var utils=require(_0xfaba('0x12'));var config=require(_0xfaba('0x13'));var licenseUtil=require(_0xfaba('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x542f81,_0x5023b5){_0x5023b5=_0x5023b5||0xcc;return function(_0x4d6b55){if(_0x4d6b55){return _0x542f81[_0xfaba('0x15')](_0x5023b5);}return _0x542f81[_0xfaba('0x16')](_0x5023b5)['end']();};}function respondWithResult(_0x40910d,_0x1a0aff){_0x1a0aff=_0x1a0aff||0xc8;return function(_0x1c0574){if(_0x1c0574){return _0x40910d[_0xfaba('0x16')](_0x1a0aff)[_0xfaba('0x17')](_0x1c0574);}};}function respondWithFilteredResult(_0x2322b0,_0x146374){return function(_0x10bbb0){if(_0x10bbb0){var _0x26b382=typeof _0x146374[_0xfaba('0x18')]===_0xfaba('0x19')&&typeof _0x146374[_0xfaba('0x1a')]===_0xfaba('0x19');var _0x519575=_0x10bbb0[_0xfaba('0x1b')];var _0x185d35=_0x26b382?0x0:_0x146374[_0xfaba('0x18')];var _0x1a37d8=_0x26b382?_0x10bbb0[_0xfaba('0x1b')]:_0x146374['offset']+_0x146374[_0xfaba('0x1a')];var _0x5bc195;if(_0x1a37d8>=_0x519575){_0x1a37d8=_0x519575;_0x5bc195=0xc8;}else{_0x5bc195=0xce;}_0x2322b0['status'](_0x5bc195);return _0x2322b0[_0xfaba('0x1c')](_0xfaba('0x1d'),_0x185d35+'-'+_0x1a37d8+'/'+_0x519575)[_0xfaba('0x17')](_0x10bbb0);}return null;};}function patchUpdates(_0x2a9d00){return function(_0x35c4fb){try{jsonpatch['apply'](_0x35c4fb,_0x2a9d00,!![]);}catch(_0x224b2f){return BPromise[_0xfaba('0x1e')](_0x224b2f);}return _0x35c4fb[_0xfaba('0x1f')]();};}function saveUpdates(_0x270587,_0x477ecf){return function(_0x4d67cd){if(_0x4d67cd){return _0x4d67cd[_0xfaba('0x20')](_0x270587)[_0xfaba('0x21')](function(_0x368920){return _0x368920;});}return null;};}function removeEntity(_0xd117b0,_0x24a541){return function(_0x42b98d){if(_0x42b98d){return _0x42b98d[_0xfaba('0x22')]()[_0xfaba('0x21')](function(){_0xd117b0[_0xfaba('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x376c0c,_0x44b3b5){return function(_0x5c5830){if(!_0x5c5830){_0x376c0c['sendStatus'](0x194);}return _0x5c5830;};}function handleError(_0x17ee2e,_0x2aa499){_0x2aa499=_0x2aa499||0x1f4;return function(_0x1094f9){logger[_0xfaba('0x23')](_0x1094f9[_0xfaba('0x24')]);if(_0x1094f9['name']){delete _0x1094f9[_0xfaba('0x25')];}_0x17ee2e[_0xfaba('0x16')](_0x2aa499)[_0xfaba('0x26')](_0x1094f9);};}exports[_0xfaba('0x27')]=function(_0x389146,_0x59a0c7){var _0x42dad4={},_0x4188a1={},_0x4d9f4d={'count':0x0,'rows':[]};var _0x5e5e87=_[_0xfaba('0x28')](db['Migration']['rawAttributes'],function(_0x511fdb){return{'name':_0x511fdb[_0xfaba('0x29')],'type':_0x511fdb[_0xfaba('0x2a')][_0xfaba('0x2b')]};});_0x4188a1[_0xfaba('0x2c')]=_['map'](_0x5e5e87,'name');_0x4188a1[_0xfaba('0x2d')]=_['keys'](_0x389146['query']);_0x4188a1[_0xfaba('0x2e')]=_[_0xfaba('0x2f')](_0x4188a1[_0xfaba('0x2c')],_0x4188a1['query']);_0x42dad4[_0xfaba('0x30')]=_[_0xfaba('0x2f')](_0x4188a1[_0xfaba('0x2c')],qs['fields'](_0x389146[_0xfaba('0x2d')][_0xfaba('0x31')]));_0x42dad4[_0xfaba('0x30')]=_0x42dad4[_0xfaba('0x30')][_0xfaba('0x32')]?_0x42dad4[_0xfaba('0x30')]:_0x4188a1[_0xfaba('0x2c')];if(!_0x389146['query'][_0xfaba('0x33')](_0xfaba('0x34'))){_0x42dad4[_0xfaba('0x1a')]=qs['limit'](_0x389146[_0xfaba('0x2d')][_0xfaba('0x1a')]);_0x42dad4['offset']=qs[_0xfaba('0x18')](_0x389146[_0xfaba('0x2d')]['offset']);}_0x42dad4[_0xfaba('0x35')]=qs[_0xfaba('0x36')](_0x389146[_0xfaba('0x2d')][_0xfaba('0x36')]);_0x42dad4[_0xfaba('0x37')]=qs[_0xfaba('0x2e')](_['pick'](_0x389146[_0xfaba('0x2d')],_0x4188a1[_0xfaba('0x2e')]),_0x5e5e87);if(_0x389146[_0xfaba('0x2d')]['filter']){_0x42dad4[_0xfaba('0x37')]=_[_0xfaba('0x38')](_0x42dad4[_0xfaba('0x37')],{'$or':_[_0xfaba('0x28')](_0x5e5e87,function(_0x88d019){if(_0x88d019[_0xfaba('0x2a')]!=='VIRTUAL'){var _0x26569e={};_0x26569e[_0x88d019[_0xfaba('0x25')]]={'$like':'%'+_0x389146['query']['filter']+'%'};return _0x26569e;}})});}_0x42dad4=_[_0xfaba('0x38')]({},_0x42dad4,_0x389146[_0xfaba('0x39')]);var _0x2a828e={'where':_0x42dad4['where']};return db[_0xfaba('0x3a')]['count'](_0x2a828e)['then'](function(_0x13747c){_0x4d9f4d[_0xfaba('0x1b')]=_0x13747c;if(_0x389146[_0xfaba('0x2d')][_0xfaba('0x3b')]){_0x42dad4[_0xfaba('0x3c')]=[{'all':!![]}];}return db[_0xfaba('0x3a')]['findAll'](_0x42dad4);})[_0xfaba('0x21')](function(_0x28ceb5){_0x4d9f4d['rows']=_0x28ceb5;return _0x4d9f4d;})['then'](respondWithFilteredResult(_0x59a0c7,_0x42dad4))[_0xfaba('0x3d')](handleError(_0x59a0c7,null));};
\ No newline at end of file