Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / api / migration / migration.controller.js
index c3059a5..8a5c468 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x68bd=['html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','ejs','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','limit','Content-Range','apply','save','update','then','error','stack','name','send','index','map','Migration','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','count','includeAll','include','rows','catch'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0x68bd,0x14f));var _0xd68b=function(_0x326a2a,_0x4303a4){_0x326a2a=_0x326a2a-0x0;var _0x1e8f5f=_0x68bd[_0x326a2a];return _0x1e8f5f;};'use strict';var pdf=require(_0xd68b('0x0'));var emlformat=require(_0xd68b('0x1'));var rimraf=require(_0xd68b('0x2'));var zipdir=require(_0xd68b('0x3'));var jsonpatch=require(_0xd68b('0x4'));var rp=require('request-promise');var moment=require(_0xd68b('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xd68b('0x6'));var util=require(_0xd68b('0x7'));var path=require(_0xd68b('0x8'));var sox=require(_0xd68b('0x9'));var csv=require('to-csv');var ejs=require(_0xd68b('0xa'));var fs=require('fs');var _=require(_0xd68b('0xb'));var squel=require(_0xd68b('0xc'));var crypto=require(_0xd68b('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xd68b('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xd68b('0xf'));var Redis=require(_0xd68b('0x10'));var authService=require(_0xd68b('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xd68b('0x12'))(_0xd68b('0x13'));var utils=require(_0xd68b('0x14'));var config=require(_0xd68b('0x15'));var licenseUtil=require(_0xd68b('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x52b85b,_0x1b5332){_0x1b5332=_0x1b5332||0xcc;return function(_0xaa38cc){if(_0xaa38cc){return _0x52b85b[_0xd68b('0x17')](_0x1b5332);}return _0x52b85b[_0xd68b('0x18')](_0x1b5332)[_0xd68b('0x19')]();};}function respondWithResult(_0x1791b6,_0x14e4da){_0x14e4da=_0x14e4da||0xc8;return function(_0x1851e0){if(_0x1851e0){return _0x1791b6[_0xd68b('0x18')](_0x14e4da)[_0xd68b('0x1a')](_0x1851e0);}};}function respondWithFilteredResult(_0xb91a6b,_0x24b091){return function(_0x54644f){if(_0x54644f){var _0x2cd9d9=_0x54644f['count'],_0x20dfc2=_0x24b091[_0xd68b('0x1b')],_0x22ed1f=_0x24b091[_0xd68b('0x1b')]+_0x24b091[_0xd68b('0x1c')],_0x1eb480;if(_0x22ed1f>=_0x2cd9d9){_0x22ed1f=_0x2cd9d9;_0x1eb480=0xc8;}else{_0x1eb480=0xce;}_0xb91a6b[_0xd68b('0x18')](_0x1eb480);return _0xb91a6b['set'](_0xd68b('0x1d'),_0x20dfc2+'-'+_0x22ed1f+'/'+_0x2cd9d9)[_0xd68b('0x1a')](_0x54644f);}return null;};}function patchUpdates(_0x12c75f){return function(_0x5c632a){try{jsonpatch[_0xd68b('0x1e')](_0x5c632a,_0x12c75f,!![]);}catch(_0x2b839a){return BPromise['reject'](_0x2b839a);}return _0x5c632a[_0xd68b('0x1f')]();};}function saveUpdates(_0xfb5745,_0x544d0d){return function(_0x49c94a){if(_0x49c94a){return _0x49c94a[_0xd68b('0x20')](_0xfb5745)[_0xd68b('0x21')](function(_0xfbbcf6){return _0xfbbcf6;});}return null;};}function removeEntity(_0x1873ad,_0x446a80){return function(_0x163bfd){if(_0x163bfd){return _0x163bfd['destroy']()[_0xd68b('0x21')](function(){_0x1873ad[_0xd68b('0x18')](0xcc)[_0xd68b('0x19')]();});}};}function handleEntityNotFound(_0x4ca0e8,_0x28ed9c){return function(_0x110b81){if(!_0x110b81){_0x4ca0e8[_0xd68b('0x17')](0x194);}return _0x110b81;};}function handleError(_0x2fdc88,_0xe35343){_0xe35343=_0xe35343||0x1f4;return function(_0x1ffa56){logger[_0xd68b('0x22')](_0x1ffa56[_0xd68b('0x23')]);if(_0x1ffa56[_0xd68b('0x24')]){delete _0x1ffa56[_0xd68b('0x24')];}_0x2fdc88['status'](_0xe35343)[_0xd68b('0x25')](_0x1ffa56);};}exports[_0xd68b('0x26')]=function(_0x7bca6c,_0x57e303){var _0x562cc0={},_0x5c5f94={},_0x183505={'count':0x0,'rows':[]};var _0x2699f3=_[_0xd68b('0x27')](db[_0xd68b('0x28')]['rawAttributes'],function(_0xc1ef14){return{'name':_0xc1ef14[_0xd68b('0x29')],'type':_0xc1ef14[_0xd68b('0x2a')][_0xd68b('0x2b')]};});_0x5c5f94[_0xd68b('0x2c')]=_[_0xd68b('0x27')](_0x2699f3,_0xd68b('0x24'));_0x5c5f94[_0xd68b('0x2d')]=_[_0xd68b('0x2e')](_0x7bca6c[_0xd68b('0x2d')]);_0x5c5f94['filters']=_[_0xd68b('0x2f')](_0x5c5f94[_0xd68b('0x2c')],_0x5c5f94['query']);_0x562cc0[_0xd68b('0x30')]=_['intersection'](_0x5c5f94[_0xd68b('0x2c')],qs['fields'](_0x7bca6c['query'][_0xd68b('0x31')]));_0x562cc0[_0xd68b('0x30')]=_0x562cc0[_0xd68b('0x30')][_0xd68b('0x32')]?_0x562cc0[_0xd68b('0x30')]:_0x5c5f94['model'];if(!_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x33')](_0xd68b('0x34'))){_0x562cc0[_0xd68b('0x1c')]=qs[_0xd68b('0x1c')](_0x7bca6c['query'][_0xd68b('0x1c')]);_0x562cc0[_0xd68b('0x1b')]=qs[_0xd68b('0x1b')](_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x1b')]);}_0x562cc0[_0xd68b('0x35')]=qs[_0xd68b('0x36')](_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x36')]);_0x562cc0[_0xd68b('0x37')]=qs[_0xd68b('0x38')](_[_0xd68b('0x39')](_0x7bca6c[_0xd68b('0x2d')],_0x5c5f94['filters']),_0x2699f3);if(_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x3a')]){_0x562cc0[_0xd68b('0x37')]=_[_0xd68b('0x3b')](_0x562cc0[_0xd68b('0x37')],{'$or':_['map'](_0x2699f3,function(_0x143db8){if(_0x143db8[_0xd68b('0x2a')]!==_0xd68b('0x3c')){var _0x17cbb8={};_0x17cbb8[_0x143db8[_0xd68b('0x24')]]={'$like':'%'+_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x3a')]+'%'};return _0x17cbb8;}})});}_0x562cc0=_[_0xd68b('0x3b')]({},_0x562cc0,_0x7bca6c[_0xd68b('0x3d')]);var _0x10961a={'where':_0x562cc0[_0xd68b('0x37')]};return db[_0xd68b('0x28')][_0xd68b('0x3e')](_0x10961a)['then'](function(_0xa70cc1){_0x183505[_0xd68b('0x3e')]=_0xa70cc1;if(_0x7bca6c[_0xd68b('0x2d')][_0xd68b('0x3f')]){_0x562cc0[_0xd68b('0x40')]=[{'all':!![]}];}return db[_0xd68b('0x28')]['findAll'](_0x562cc0);})[_0xd68b('0x21')](function(_0x398432){_0x183505[_0xd68b('0x41')]=_0x398432;return _0x183505;})[_0xd68b('0x21')](respondWithFilteredResult(_0x57e303,_0x562cc0))[_0xd68b('0x42')](handleError(_0x57e303,null));};
\ No newline at end of file
+var _0x34f9=['util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','map','Migration','rawAttributes','fieldName','key','model','keys','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','type','VIRTUAL','filter','options','includeAll','include','findAll','rows','rimraf','fast-json-patch','request-promise','moment','mustache'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0x34f9,0x1ec));var _0x934f=function(_0x3c77c7,_0x2287bd){_0x3c77c7=_0x3c77c7-0x0;var _0x2fcbd4=_0x34f9[_0x3c77c7];return _0x2fcbd4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x934f('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x934f('0x1'));var rp=require(_0x934f('0x2'));var moment=require(_0x934f('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x934f('0x4'));var util=require(_0x934f('0x5'));var path=require(_0x934f('0x6'));var sox=require(_0x934f('0x7'));var csv=require(_0x934f('0x8'));var ejs=require(_0x934f('0x9'));var fs=require('fs');var fs_extra=require(_0x934f('0xa'));var _=require(_0x934f('0xb'));var squel=require(_0x934f('0xc'));var crypto=require(_0x934f('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x934f('0xe'));var toCsv=require(_0x934f('0x8'));var querystring=require(_0x934f('0xf'));var Papa=require(_0x934f('0x10'));var Redis=require(_0x934f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x934f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x934f('0x13'));var logger=require(_0x934f('0x14'))(_0x934f('0x15'));var utils=require('../../config/utils');var config=require(_0x934f('0x16'));var licenseUtil=require(_0x934f('0x17'));var db=require(_0x934f('0x18'))['db'];function respondWithStatusCode(_0x2b66c7,_0x2cd9c4){_0x2cd9c4=_0x2cd9c4||0xcc;return function(_0x43f741){if(_0x43f741){return _0x2b66c7[_0x934f('0x19')](_0x2cd9c4);}return _0x2b66c7['status'](_0x2cd9c4)['end']();};}function respondWithResult(_0x1d5b8d,_0x5f487a){_0x5f487a=_0x5f487a||0xc8;return function(_0x5ef82c){if(_0x5ef82c){return _0x1d5b8d[_0x934f('0x1a')](_0x5f487a)[_0x934f('0x1b')](_0x5ef82c);}};}function respondWithFilteredResult(_0x1a5a13,_0x2bfbbe){return function(_0x243456){if(_0x243456){var _0xfe01d5=typeof _0x2bfbbe[_0x934f('0x1c')]===_0x934f('0x1d')&&typeof _0x2bfbbe[_0x934f('0x1e')]===_0x934f('0x1d');var _0x15e340=_0x243456[_0x934f('0x1f')];var _0x1b5719=_0xfe01d5?0x0:_0x2bfbbe[_0x934f('0x1c')];var _0x1b63ae=_0xfe01d5?_0x243456[_0x934f('0x1f')]:_0x2bfbbe[_0x934f('0x1c')]+_0x2bfbbe[_0x934f('0x1e')];var _0x3fb655;if(_0x1b63ae>=_0x15e340){_0x1b63ae=_0x15e340;_0x3fb655=0xc8;}else{_0x3fb655=0xce;}_0x1a5a13['status'](_0x3fb655);return _0x1a5a13[_0x934f('0x20')](_0x934f('0x21'),_0x1b5719+'-'+_0x1b63ae+'/'+_0x15e340)['json'](_0x243456);}return null;};}function patchUpdates(_0x6bd83b){return function(_0x21404f){try{jsonpatch[_0x934f('0x22')](_0x21404f,_0x6bd83b,!![]);}catch(_0x5a361a){return BPromise[_0x934f('0x23')](_0x5a361a);}return _0x21404f[_0x934f('0x24')]();};}function saveUpdates(_0x1b0cc5,_0x2d4157){return function(_0x1790fe){if(_0x1790fe){return _0x1790fe[_0x934f('0x25')](_0x1b0cc5)[_0x934f('0x26')](function(_0x275e6e){return _0x275e6e;});}return null;};}function removeEntity(_0x1583e0,_0x541340){return function(_0x5f945d){if(_0x5f945d){return _0x5f945d[_0x934f('0x27')]()[_0x934f('0x26')](function(){_0x1583e0[_0x934f('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0xa1fbe5,_0x45e1ad){return function(_0x424692){if(!_0x424692){_0xa1fbe5[_0x934f('0x19')](0x194);}return _0x424692;};}function handleError(_0x3109cd,_0x4b3cc0){_0x4b3cc0=_0x4b3cc0||0x1f4;return function(_0x1b9fc7){logger[_0x934f('0x28')](_0x1b9fc7[_0x934f('0x29')]);if(_0x1b9fc7['name']){delete _0x1b9fc7[_0x934f('0x2a')];}_0x3109cd[_0x934f('0x1a')](_0x4b3cc0)[_0x934f('0x2b')](_0x1b9fc7);};}exports['index']=function(_0x1b84b2,_0x4b1359){var _0x442e29={},_0x13bd82={},_0x5ccf69={'count':0x0,'rows':[]};var _0x40b767=_[_0x934f('0x2c')](db[_0x934f('0x2d')][_0x934f('0x2e')],function(_0x33ffee){return{'name':_0x33ffee[_0x934f('0x2f')],'type':_0x33ffee['type'][_0x934f('0x30')]};});_0x13bd82[_0x934f('0x31')]=_[_0x934f('0x2c')](_0x40b767,'name');_0x13bd82['query']=_[_0x934f('0x32')](_0x1b84b2[_0x934f('0x33')]);_0x13bd82['filters']=_[_0x934f('0x34')](_0x13bd82['model'],_0x13bd82[_0x934f('0x33')]);_0x442e29['attributes']=_[_0x934f('0x34')](_0x13bd82[_0x934f('0x31')],qs[_0x934f('0x35')](_0x1b84b2['query']['fields']));_0x442e29[_0x934f('0x36')]=_0x442e29['attributes']['length']?_0x442e29[_0x934f('0x36')]:_0x13bd82[_0x934f('0x31')];if(!_0x1b84b2[_0x934f('0x33')][_0x934f('0x37')](_0x934f('0x38'))){_0x442e29[_0x934f('0x1e')]=qs[_0x934f('0x1e')](_0x1b84b2[_0x934f('0x33')][_0x934f('0x1e')]);_0x442e29[_0x934f('0x1c')]=qs[_0x934f('0x1c')](_0x1b84b2[_0x934f('0x33')][_0x934f('0x1c')]);}_0x442e29[_0x934f('0x39')]=qs[_0x934f('0x3a')](_0x1b84b2[_0x934f('0x33')][_0x934f('0x3a')]);_0x442e29[_0x934f('0x3b')]=qs[_0x934f('0x3c')](_[_0x934f('0x3d')](_0x1b84b2[_0x934f('0x33')],_0x13bd82['filters']),_0x40b767);if(_0x1b84b2[_0x934f('0x33')]['filter']){_0x442e29['where']=_[_0x934f('0x3e')](_0x442e29[_0x934f('0x3b')],{'$or':_[_0x934f('0x2c')](_0x40b767,function(_0x1766f5){if(_0x1766f5[_0x934f('0x3f')]!==_0x934f('0x40')){var _0x4ff8a8={};_0x4ff8a8[_0x1766f5[_0x934f('0x2a')]]={'$like':'%'+_0x1b84b2['query'][_0x934f('0x41')]+'%'};return _0x4ff8a8;}})});}_0x442e29=_[_0x934f('0x3e')]({},_0x442e29,_0x1b84b2[_0x934f('0x42')]);var _0x131d24={'where':_0x442e29[_0x934f('0x3b')]};return db[_0x934f('0x2d')][_0x934f('0x1f')](_0x131d24)['then'](function(_0x5b4f36){_0x5ccf69[_0x934f('0x1f')]=_0x5b4f36;if(_0x1b84b2[_0x934f('0x33')][_0x934f('0x43')]){_0x442e29[_0x934f('0x44')]=[{'all':!![]}];}return db['Migration'][_0x934f('0x45')](_0x442e29);})[_0x934f('0x26')](function(_0x371b6c){_0x5ccf69[_0x934f('0x46')]=_0x371b6c;return _0x5ccf69;})[_0x934f('0x26')](respondWithFilteredResult(_0x4b1359,_0x442e29))['catch'](handleError(_0x4b1359,null));};
\ No newline at end of file