Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 031da3f..043767a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x534f=['options','includeAll','rows','catch','show','params','rawAttributes','include','find','create','body','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','reject','update','then','stack','name','send','index','map','SalesforceField','fieldName','key','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL'];(function(_0x5dc4fb,_0x4793fb){var _0x113af4=function(_0x454b48){while(--_0x454b48){_0x5dc4fb['push'](_0x5dc4fb['shift']());}};_0x113af4(++_0x4793fb);}(_0x534f,0x127));var _0xf534=function(_0x381942,_0x5ca64b){_0x381942=_0x381942-0x0;var _0x5e8d3b=_0x534f[_0x381942];return _0x5e8d3b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf534('0x0'));var zipdir=require(_0xf534('0x1'));var jsonpatch=require(_0xf534('0x2'));var rp=require('request-promise');var moment=require(_0xf534('0x3'));var BPromise=require(_0xf534('0x4'));var Mustache=require(_0xf534('0x5'));var util=require('util');var path=require(_0xf534('0x6'));var sox=require('sox');var csv=require(_0xf534('0x7'));var ejs=require(_0xf534('0x8'));var fs=require('fs');var fs_extra=require(_0xf534('0x9'));var _=require(_0xf534('0xa'));var squel=require('squel');var crypto=require(_0xf534('0xb'));var jsforce=require(_0xf534('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xf534('0x7'));var querystring=require(_0xf534('0xd'));var Papa=require(_0xf534('0xe'));var Redis=require(_0xf534('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xf534('0x10'));var as=require(_0xf534('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0xf534('0x12'));var config=require(_0xf534('0x13'));var licenseUtil=require(_0xf534('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x930efe,_0x124beb){_0x124beb=_0x124beb||0xcc;return function(_0x32cad7){if(_0x32cad7){return _0x930efe[_0xf534('0x15')](_0x124beb);}return _0x930efe[_0xf534('0x16')](_0x124beb)[_0xf534('0x17')]();};}function respondWithResult(_0x3b5f1b,_0x375b51){_0x375b51=_0x375b51||0xc8;return function(_0x1ac513){if(_0x1ac513){return _0x3b5f1b['status'](_0x375b51)[_0xf534('0x18')](_0x1ac513);}};}function respondWithFilteredResult(_0x56bdee,_0x254865){return function(_0x5ad3e8){if(_0x5ad3e8){var _0x3d42bb=typeof _0x254865[_0xf534('0x19')]===_0xf534('0x1a')&&typeof _0x254865['limit']===_0xf534('0x1a');var _0xebc09d=_0x5ad3e8['count'];var _0x16128e=_0x3d42bb?0x0:_0x254865['offset'];var _0x16659d=_0x3d42bb?_0x5ad3e8[_0xf534('0x1b')]:_0x254865['offset']+_0x254865[_0xf534('0x1c')];var _0x3820ca;if(_0x16659d>=_0xebc09d){_0x16659d=_0xebc09d;_0x3820ca=0xc8;}else{_0x3820ca=0xce;}_0x56bdee[_0xf534('0x16')](_0x3820ca);return _0x56bdee[_0xf534('0x1d')](_0xf534('0x1e'),_0x16128e+'-'+_0x16659d+'/'+_0xebc09d)[_0xf534('0x18')](_0x5ad3e8);}return null;};}function patchUpdates(_0x1e4f46){return function(_0x39e094){try{jsonpatch['apply'](_0x39e094,_0x1e4f46,!![]);}catch(_0x3c9cfc){return BPromise[_0xf534('0x1f')](_0x3c9cfc);}return _0x39e094['save']();};}function saveUpdates(_0x533b33,_0x4edd7f){return function(_0x5bcfd6){if(_0x5bcfd6){return _0x5bcfd6[_0xf534('0x20')](_0x533b33)[_0xf534('0x21')](function(_0x527632){return _0x527632;});}return null;};}function removeEntity(_0x87f75f,_0x2effb3){return function(_0x15db7d){if(_0x15db7d){return _0x15db7d['destroy']()['then'](function(){_0x87f75f['status'](0xcc)[_0xf534('0x17')]();});}};}function handleEntityNotFound(_0x509d4d,_0x2dd8f8){return function(_0xfc9448){if(!_0xfc9448){_0x509d4d[_0xf534('0x15')](0x194);}return _0xfc9448;};}function handleError(_0x433463,_0x255c06){_0x255c06=_0x255c06||0x1f4;return function(_0x1d542c){logger['error'](_0x1d542c[_0xf534('0x22')]);if(_0x1d542c[_0xf534('0x23')]){delete _0x1d542c[_0xf534('0x23')];}_0x433463['status'](_0x255c06)[_0xf534('0x24')](_0x1d542c);};}exports[_0xf534('0x25')]=function(_0x4c233d,_0x2ee2d6){var _0xa00f37={},_0x689586={},_0xb08797={'count':0x0,'rows':[]};var _0x3f1eea=_[_0xf534('0x26')](db[_0xf534('0x27')]['rawAttributes'],function(_0x1dc24b){return{'name':_0x1dc24b[_0xf534('0x28')],'type':_0x1dc24b['type'][_0xf534('0x29')]};});_0x689586['model']=_[_0xf534('0x26')](_0x3f1eea,_0xf534('0x23'));_0x689586[_0xf534('0x2a')]=_[_0xf534('0x2b')](_0x4c233d[_0xf534('0x2a')]);_0x689586[_0xf534('0x2c')]=_[_0xf534('0x2d')](_0x689586['model'],_0x689586[_0xf534('0x2a')]);_0xa00f37[_0xf534('0x2e')]=_[_0xf534('0x2d')](_0x689586[_0xf534('0x2f')],qs[_0xf534('0x30')](_0x4c233d[_0xf534('0x2a')][_0xf534('0x30')]));_0xa00f37[_0xf534('0x2e')]=_0xa00f37['attributes'][_0xf534('0x31')]?_0xa00f37[_0xf534('0x2e')]:_0x689586[_0xf534('0x2f')];if(!_0x4c233d[_0xf534('0x2a')][_0xf534('0x32')](_0xf534('0x33'))){_0xa00f37[_0xf534('0x1c')]=qs[_0xf534('0x1c')](_0x4c233d[_0xf534('0x2a')][_0xf534('0x1c')]);_0xa00f37[_0xf534('0x19')]=qs[_0xf534('0x19')](_0x4c233d[_0xf534('0x2a')][_0xf534('0x19')]);}_0xa00f37[_0xf534('0x34')]=qs[_0xf534('0x35')](_0x4c233d['query'][_0xf534('0x35')]);_0xa00f37[_0xf534('0x36')]=qs['filters'](_[_0xf534('0x37')](_0x4c233d[_0xf534('0x2a')],_0x689586['filters']),_0x3f1eea);if(_0x4c233d[_0xf534('0x2a')][_0xf534('0x38')]){_0xa00f37['where']=_[_0xf534('0x39')](_0xa00f37[_0xf534('0x36')],{'$or':_[_0xf534('0x26')](_0x3f1eea,function(_0x10b03e){if(_0x10b03e[_0xf534('0x3a')]!==_0xf534('0x3b')){var _0x3e3a6f={};_0x3e3a6f[_0x10b03e[_0xf534('0x23')]]={'$like':'%'+_0x4c233d[_0xf534('0x2a')][_0xf534('0x38')]+'%'};return _0x3e3a6f;}})});}_0xa00f37=_['merge']({},_0xa00f37,_0x4c233d[_0xf534('0x3c')]);var _0x55582d={'where':_0xa00f37[_0xf534('0x36')]};return db[_0xf534('0x27')][_0xf534('0x1b')](_0x55582d)[_0xf534('0x21')](function(_0x3636a6){_0xb08797['count']=_0x3636a6;if(_0x4c233d[_0xf534('0x2a')][_0xf534('0x3d')]){_0xa00f37['include']=[{'all':!![]}];}return db[_0xf534('0x27')]['findAll'](_0xa00f37);})[_0xf534('0x21')](function(_0x450247){_0xb08797[_0xf534('0x3e')]=_0x450247;return _0xb08797;})[_0xf534('0x21')](respondWithFilteredResult(_0x2ee2d6,_0xa00f37))[_0xf534('0x3f')](handleError(_0x2ee2d6,null));};exports[_0xf534('0x40')]=function(_0x529f1e,_0x16d634){var _0x3a622b={'raw':!![],'where':{'id':_0x529f1e[_0xf534('0x41')]['id']}},_0x1f412f={};_0x1f412f[_0xf534('0x2f')]=_[_0xf534('0x2b')](db[_0xf534('0x27')][_0xf534('0x42')]);_0x1f412f[_0xf534('0x2a')]=_[_0xf534('0x2b')](_0x529f1e['query']);_0x1f412f[_0xf534('0x2c')]=_[_0xf534('0x2d')](_0x1f412f['model'],_0x1f412f[_0xf534('0x2a')]);_0x3a622b[_0xf534('0x2e')]=_['intersection'](_0x1f412f[_0xf534('0x2f')],qs['fields'](_0x529f1e[_0xf534('0x2a')][_0xf534('0x30')]));_0x3a622b[_0xf534('0x2e')]=_0x3a622b[_0xf534('0x2e')][_0xf534('0x31')]?_0x3a622b[_0xf534('0x2e')]:_0x1f412f[_0xf534('0x2f')];if(_0x529f1e[_0xf534('0x2a')][_0xf534('0x3d')]){_0x3a622b[_0xf534('0x43')]=[{'all':!![]}];}_0x3a622b=_[_0xf534('0x39')]({},_0x3a622b,_0x529f1e[_0xf534('0x3c')]);return db['SalesforceField'][_0xf534('0x44')](_0x3a622b)['then'](handleEntityNotFound(_0x16d634,null))['then'](respondWithResult(_0x16d634,null))['catch'](handleError(_0x16d634,null));};exports[_0xf534('0x45')]=function(_0x2af886,_0xa871fb){return db[_0xf534('0x27')]['create'](_0x2af886[_0xf534('0x46')],{})['then'](respondWithResult(_0xa871fb,0xc9))[_0xf534('0x3f')](handleError(_0xa871fb,null));};exports[_0xf534('0x20')]=function(_0x56bcf1,_0x49f24a){if(_0x56bcf1[_0xf534('0x46')]['id']){delete _0x56bcf1['body']['id'];}return db[_0xf534('0x27')][_0xf534('0x44')]({'where':{'id':_0x56bcf1[_0xf534('0x41')]['id']}})[_0xf534('0x21')](handleEntityNotFound(_0x49f24a,null))[_0xf534('0x21')](saveUpdates(_0x56bcf1[_0xf534('0x46')],null))[_0xf534('0x21')](respondWithResult(_0x49f24a,null))[_0xf534('0x3f')](handleError(_0x49f24a,null));};exports['destroy']=function(_0xefd2f7,_0x71c5bc){return db[_0xf534('0x27')][_0xf534('0x44')]({'where':{'id':_0xefd2f7[_0xf534('0x41')]['id']}})[_0xf534('0x21')](handleEntityNotFound(_0x71c5bc,null))['then'](removeEntity(_0x71c5bc,null))[_0xf534('0x3f')](handleError(_0x71c5bc,null));};
\ No newline at end of file
+var _0x41ca=['sort','where','filters','pick','merge','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','eml-format','request-promise','moment','mustache','util','to-csv','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','update','destroy','then','stack','name','send','map','SalesforceField','rawAttributes','fieldName','type','query','keys','attributes','intersection','model','fields','length','nolimit','order'];(function(_0x28578d,_0xcf5cf0){var _0x524826=function(_0x4a51b7){while(--_0x4a51b7){_0x28578d['push'](_0x28578d['shift']());}};_0x524826(++_0xcf5cf0);}(_0x41ca,0xe2));var _0xa41c=function(_0xf6b2b8,_0xbfe716){_0xf6b2b8=_0xf6b2b8-0x0;var _0xc0a21a=_0x41ca[_0xf6b2b8];return _0xc0a21a;};'use strict';var emlformat=require(_0xa41c('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xa41c('0x1'));var moment=require(_0xa41c('0x2'));var BPromise=require('bluebird');var Mustache=require(_0xa41c('0x3'));var util=require(_0xa41c('0x4'));var path=require('path');var sox=require('sox');var csv=require(_0xa41c('0x5'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa41c('0x6'));var squel=require('squel');var crypto=require(_0xa41c('0x7'));var jsforce=require(_0xa41c('0x8'));var deskjs=require(_0xa41c('0x9'));var toCsv=require(_0xa41c('0x5'));var querystring=require(_0xa41c('0xa'));var Papa=require('papaparse');var Redis=require(_0xa41c('0xb'));var authService=require(_0xa41c('0xc'));var qs=require(_0xa41c('0xd'));var as=require(_0xa41c('0xe'));var hardwareService=require(_0xa41c('0xf'));var logger=require(_0xa41c('0x10'))(_0xa41c('0x11'));var utils=require(_0xa41c('0x12'));var config=require(_0xa41c('0x13'));var licenseUtil=require(_0xa41c('0x14'));var db=require(_0xa41c('0x15'))['db'];function respondWithStatusCode(_0x2badd5,_0x3dda96){_0x3dda96=_0x3dda96||0xcc;return function(_0x3cbc3b){if(_0x3cbc3b){return _0x2badd5[_0xa41c('0x16')](_0x3dda96);}return _0x2badd5[_0xa41c('0x17')](_0x3dda96)[_0xa41c('0x18')]();};}function respondWithResult(_0x1d1d3d,_0x1f3de2){_0x1f3de2=_0x1f3de2||0xc8;return function(_0x5b00ab){if(_0x5b00ab){return _0x1d1d3d[_0xa41c('0x17')](_0x1f3de2)[_0xa41c('0x19')](_0x5b00ab);}};}function respondWithFilteredResult(_0x3c7605,_0x44c7de){return function(_0x3f4411){if(_0x3f4411){var _0x964d78=typeof _0x44c7de['offset']===_0xa41c('0x1a')&&typeof _0x44c7de[_0xa41c('0x1b')]===_0xa41c('0x1a');var _0x4c93cd=_0x3f4411[_0xa41c('0x1c')];var _0x28c7dd=_0x964d78?0x0:_0x44c7de[_0xa41c('0x1d')];var _0x2e80f4=_0x964d78?_0x3f4411['count']:_0x44c7de[_0xa41c('0x1d')]+_0x44c7de[_0xa41c('0x1b')];var _0x13a3a0;if(_0x2e80f4>=_0x4c93cd){_0x2e80f4=_0x4c93cd;_0x13a3a0=0xc8;}else{_0x13a3a0=0xce;}_0x3c7605[_0xa41c('0x17')](_0x13a3a0);return _0x3c7605[_0xa41c('0x1e')](_0xa41c('0x1f'),_0x28c7dd+'-'+_0x2e80f4+'/'+_0x4c93cd)[_0xa41c('0x19')](_0x3f4411);}return null;};}function patchUpdates(_0x2a06af){return function(_0x33791b){try{jsonpatch[_0xa41c('0x20')](_0x33791b,_0x2a06af,!![]);}catch(_0xaa1d77){return BPromise[_0xa41c('0x21')](_0xaa1d77);}return _0x33791b['save']();};}function saveUpdates(_0x5e56e5,_0x2871c7){return function(_0x23567d){if(_0x23567d){return _0x23567d[_0xa41c('0x22')](_0x5e56e5)['then'](function(_0x4f6051){return _0x4f6051;});}return null;};}function removeEntity(_0xc76eb4,_0x53210b){return function(_0x44e109){if(_0x44e109){return _0x44e109[_0xa41c('0x23')]()[_0xa41c('0x24')](function(){_0xc76eb4[_0xa41c('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x32eb80,_0x4912d2){return function(_0x380d8f){if(!_0x380d8f){_0x32eb80['sendStatus'](0x194);}return _0x380d8f;};}function handleError(_0x188a21,_0x3056c8){_0x3056c8=_0x3056c8||0x1f4;return function(_0x2779ae){logger['error'](_0x2779ae[_0xa41c('0x25')]);if(_0x2779ae[_0xa41c('0x26')]){delete _0x2779ae[_0xa41c('0x26')];}_0x188a21[_0xa41c('0x17')](_0x3056c8)[_0xa41c('0x27')](_0x2779ae);};}exports['index']=function(_0x175135,_0x368e1a){var _0x1b57da={},_0x4bb43e={},_0x1a77e5={'count':0x0,'rows':[]};var _0x44528c=_[_0xa41c('0x28')](db[_0xa41c('0x29')][_0xa41c('0x2a')],function(_0xbe180b){return{'name':_0xbe180b[_0xa41c('0x2b')],'type':_0xbe180b[_0xa41c('0x2c')]['key']};});_0x4bb43e['model']=_['map'](_0x44528c,_0xa41c('0x26'));_0x4bb43e[_0xa41c('0x2d')]=_[_0xa41c('0x2e')](_0x175135['query']);_0x4bb43e['filters']=_['intersection'](_0x4bb43e['model'],_0x4bb43e[_0xa41c('0x2d')]);_0x1b57da[_0xa41c('0x2f')]=_[_0xa41c('0x30')](_0x4bb43e[_0xa41c('0x31')],qs['fields'](_0x175135[_0xa41c('0x2d')][_0xa41c('0x32')]));_0x1b57da[_0xa41c('0x2f')]=_0x1b57da['attributes'][_0xa41c('0x33')]?_0x1b57da[_0xa41c('0x2f')]:_0x4bb43e[_0xa41c('0x31')];if(!_0x175135[_0xa41c('0x2d')]['hasOwnProperty'](_0xa41c('0x34'))){_0x1b57da[_0xa41c('0x1b')]=qs[_0xa41c('0x1b')](_0x175135['query']['limit']);_0x1b57da[_0xa41c('0x1d')]=qs[_0xa41c('0x1d')](_0x175135[_0xa41c('0x2d')][_0xa41c('0x1d')]);}_0x1b57da[_0xa41c('0x35')]=qs[_0xa41c('0x36')](_0x175135['query'][_0xa41c('0x36')]);_0x1b57da[_0xa41c('0x37')]=qs[_0xa41c('0x38')](_[_0xa41c('0x39')](_0x175135[_0xa41c('0x2d')],_0x4bb43e[_0xa41c('0x38')]),_0x44528c);if(_0x175135['query']['filter']){_0x1b57da[_0xa41c('0x37')]=_[_0xa41c('0x3a')](_0x1b57da[_0xa41c('0x37')],{'$or':_[_0xa41c('0x28')](_0x44528c,function(_0x3b4d3f){if(_0x3b4d3f['type']!=='VIRTUAL'){var _0x54c3d4={};_0x54c3d4[_0x3b4d3f[_0xa41c('0x26')]]={'$like':'%'+_0x175135[_0xa41c('0x2d')]['filter']+'%'};return _0x54c3d4;}})});}_0x1b57da=_[_0xa41c('0x3a')]({},_0x1b57da,_0x175135['options']);var _0x1045af={'where':_0x1b57da[_0xa41c('0x37')]};return db[_0xa41c('0x29')][_0xa41c('0x1c')](_0x1045af)[_0xa41c('0x24')](function(_0x1402f9){_0x1a77e5['count']=_0x1402f9;if(_0x175135['query'][_0xa41c('0x3b')]){_0x1b57da[_0xa41c('0x3c')]=[{'all':!![]}];}return db[_0xa41c('0x29')][_0xa41c('0x3d')](_0x1b57da);})[_0xa41c('0x24')](function(_0xb0ab5){_0x1a77e5[_0xa41c('0x3e')]=_0xb0ab5;return _0x1a77e5;})['then'](respondWithFilteredResult(_0x368e1a,_0x1b57da))[_0xa41c('0x3f')](handleError(_0x368e1a,null));};exports[_0xa41c('0x40')]=function(_0x3bcea5,_0x154fa4){var _0x11d4dd={'raw':!![],'where':{'id':_0x3bcea5[_0xa41c('0x41')]['id']}},_0x587a91={};_0x587a91['model']=_[_0xa41c('0x2e')](db[_0xa41c('0x29')][_0xa41c('0x2a')]);_0x587a91['query']=_[_0xa41c('0x2e')](_0x3bcea5[_0xa41c('0x2d')]);_0x587a91['filters']=_[_0xa41c('0x30')](_0x587a91[_0xa41c('0x31')],_0x587a91[_0xa41c('0x2d')]);_0x11d4dd[_0xa41c('0x2f')]=_[_0xa41c('0x30')](_0x587a91['model'],qs[_0xa41c('0x32')](_0x3bcea5[_0xa41c('0x2d')][_0xa41c('0x32')]));_0x11d4dd[_0xa41c('0x2f')]=_0x11d4dd[_0xa41c('0x2f')][_0xa41c('0x33')]?_0x11d4dd[_0xa41c('0x2f')]:_0x587a91[_0xa41c('0x31')];if(_0x3bcea5['query'][_0xa41c('0x3b')]){_0x11d4dd['include']=[{'all':!![]}];}_0x11d4dd=_[_0xa41c('0x3a')]({},_0x11d4dd,_0x3bcea5[_0xa41c('0x42')]);return db[_0xa41c('0x29')][_0xa41c('0x43')](_0x11d4dd)[_0xa41c('0x24')](handleEntityNotFound(_0x154fa4,null))[_0xa41c('0x24')](respondWithResult(_0x154fa4,null))[_0xa41c('0x3f')](handleError(_0x154fa4,null));};exports[_0xa41c('0x44')]=function(_0x2b76be,_0x2f236d){return db[_0xa41c('0x29')][_0xa41c('0x44')](_0x2b76be['body'],{})[_0xa41c('0x24')](respondWithResult(_0x2f236d,0xc9))[_0xa41c('0x3f')](handleError(_0x2f236d,null));};exports[_0xa41c('0x22')]=function(_0x49e687,_0x3f7f62){if(_0x49e687[_0xa41c('0x45')]['id']){delete _0x49e687[_0xa41c('0x45')]['id'];}return db['SalesforceField'][_0xa41c('0x43')]({'where':{'id':_0x49e687['params']['id']}})[_0xa41c('0x24')](handleEntityNotFound(_0x3f7f62,null))['then'](saveUpdates(_0x49e687[_0xa41c('0x45')],null))[_0xa41c('0x24')](respondWithResult(_0x3f7f62,null))[_0xa41c('0x3f')](handleError(_0x3f7f62,null));};exports[_0xa41c('0x23')]=function(_0x2b1a7c,_0x108597){return db[_0xa41c('0x29')][_0xa41c('0x43')]({'where':{'id':_0x2b1a7c[_0xa41c('0x41')]['id']}})[_0xa41c('0x24')](handleEntityNotFound(_0x108597,null))[_0xa41c('0x24')](removeEntity(_0x108597,null))[_0xa41c('0x3f')](handleError(_0x108597,null));};
\ No newline at end of file