Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 8e53ced..decb339 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x72a6=['includeAll','find','create','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','mustache','util','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','SalesforceField','include','findAll','rows','catch','show','params'];(function(_0x3e932e,_0x598c15){var _0x518b50=function(_0x4edd7e){while(--_0x4edd7e){_0x3e932e['push'](_0x3e932e['shift']());}};_0x518b50(++_0x598c15);}(_0x72a6,0x124));var _0x672a=function(_0x539831,_0x99d6b8){_0x539831=_0x539831-0x0;var _0x11d09a=_0x72a6[_0x539831];return _0x11d09a;};'use strict';var pdf=require(_0x672a('0x0'));var emlformat=require(_0x672a('0x1'));var rimraf=require(_0x672a('0x2'));var zipdir=require(_0x672a('0x3'));var jsonpatch=require(_0x672a('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x672a('0x5'));var util=require(_0x672a('0x6'));var path=require('path');var sox=require(_0x672a('0x7'));var csv=require(_0x672a('0x8'));var ejs=require(_0x672a('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x672a('0xa'));var crypto=require(_0x672a('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x672a('0xc'));var toCsv=require('to-csv');var querystring=require(_0x672a('0xd'));var Papa=require(_0x672a('0xe'));var Redis=require(_0x672a('0xf'));var authService=require(_0x672a('0x10'));var qs=require(_0x672a('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x672a('0x12'));var logger=require(_0x672a('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x672a('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x445a74,_0x4b5dcf){_0x4b5dcf=_0x4b5dcf||0xcc;return function(_0x5026c4){if(_0x5026c4){return _0x445a74[_0x672a('0x15')](_0x4b5dcf);}return _0x445a74[_0x672a('0x16')](_0x4b5dcf)[_0x672a('0x17')]();};}function respondWithResult(_0x15681a,_0x3f94be){_0x3f94be=_0x3f94be||0xc8;return function(_0x38bc43){if(_0x38bc43){return _0x15681a['status'](_0x3f94be)[_0x672a('0x18')](_0x38bc43);}};}function respondWithFilteredResult(_0xf0749b,_0x3500e8){return function(_0x1fae23){if(_0x1fae23){var _0x5c31a3=_0x1fae23[_0x672a('0x19')],_0x388dcf=_0x3500e8[_0x672a('0x1a')],_0x2ce7ce=_0x3500e8[_0x672a('0x1a')]+_0x3500e8[_0x672a('0x1b')],_0x6c202a;if(_0x2ce7ce>=_0x5c31a3){_0x2ce7ce=_0x5c31a3;_0x6c202a=0xc8;}else{_0x6c202a=0xce;}_0xf0749b['status'](_0x6c202a);return _0xf0749b[_0x672a('0x1c')](_0x672a('0x1d'),_0x388dcf+'-'+_0x2ce7ce+'/'+_0x5c31a3)['json'](_0x1fae23);}return null;};}function patchUpdates(_0xa084d0){return function(_0x2494aa){try{jsonpatch['apply'](_0x2494aa,_0xa084d0,!![]);}catch(_0x2d3b30){return BPromise[_0x672a('0x1e')](_0x2d3b30);}return _0x2494aa[_0x672a('0x1f')]();};}function saveUpdates(_0x10edac,_0x37e7a7){return function(_0xdfd19d){if(_0xdfd19d){return _0xdfd19d[_0x672a('0x20')](_0x10edac)[_0x672a('0x21')](function(_0x269148){return _0x269148;});}return null;};}function removeEntity(_0x27001a,_0x39d4e0){return function(_0x4d1193){if(_0x4d1193){return _0x4d1193[_0x672a('0x22')]()[_0x672a('0x21')](function(){_0x27001a[_0x672a('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5c4b49,_0x3dcfd2){return function(_0x3cec03){if(!_0x3cec03){_0x5c4b49[_0x672a('0x15')](0x194);}return _0x3cec03;};}function handleError(_0x1e064f,_0x4faa50){_0x4faa50=_0x4faa50||0x1f4;return function(_0xcb8d5c){logger[_0x672a('0x23')](_0xcb8d5c[_0x672a('0x24')]);if(_0xcb8d5c[_0x672a('0x25')]){delete _0xcb8d5c[_0x672a('0x25')];}_0x1e064f[_0x672a('0x16')](_0x4faa50)[_0x672a('0x26')](_0xcb8d5c);};}exports[_0x672a('0x27')]=function(_0x48da0b,_0x135f61){var _0x1d5e10={},_0x3615e5={},_0x5b0f29={'count':0x0,'rows':[]};var _0x4ebb00=_[_0x672a('0x28')](db['SalesforceField'][_0x672a('0x29')],function(_0x3f1aa5){return{'name':_0x3f1aa5[_0x672a('0x2a')],'type':_0x3f1aa5[_0x672a('0x2b')]['key']};});_0x3615e5[_0x672a('0x2c')]=_[_0x672a('0x28')](_0x4ebb00,_0x672a('0x25'));_0x3615e5[_0x672a('0x2d')]=_[_0x672a('0x2e')](_0x48da0b[_0x672a('0x2d')]);_0x3615e5[_0x672a('0x2f')]=_[_0x672a('0x30')](_0x3615e5['model'],_0x3615e5['query']);_0x1d5e10['attributes']=_[_0x672a('0x30')](_0x3615e5['model'],qs[_0x672a('0x31')](_0x48da0b[_0x672a('0x2d')]['fields']));_0x1d5e10['attributes']=_0x1d5e10[_0x672a('0x32')][_0x672a('0x33')]?_0x1d5e10[_0x672a('0x32')]:_0x3615e5['model'];if(!_0x48da0b['query']['hasOwnProperty'](_0x672a('0x34'))){_0x1d5e10['limit']=qs[_0x672a('0x1b')](_0x48da0b[_0x672a('0x2d')]['limit']);_0x1d5e10[_0x672a('0x1a')]=qs[_0x672a('0x1a')](_0x48da0b[_0x672a('0x2d')][_0x672a('0x1a')]);}_0x1d5e10[_0x672a('0x35')]=qs[_0x672a('0x36')](_0x48da0b['query']['sort']);_0x1d5e10[_0x672a('0x37')]=qs[_0x672a('0x2f')](_[_0x672a('0x38')](_0x48da0b[_0x672a('0x2d')],_0x3615e5['filters']),_0x4ebb00);if(_0x48da0b[_0x672a('0x2d')]['filter']){_0x1d5e10[_0x672a('0x37')]=_[_0x672a('0x39')](_0x1d5e10[_0x672a('0x37')],{'$or':_['map'](_0x4ebb00,function(_0x46607b){if(_0x46607b[_0x672a('0x2b')]!==_0x672a('0x3a')){var _0x358e43={};_0x358e43[_0x46607b[_0x672a('0x25')]]={'$like':'%'+_0x48da0b[_0x672a('0x2d')][_0x672a('0x3b')]+'%'};return _0x358e43;}})});}_0x1d5e10=_[_0x672a('0x39')]({},_0x1d5e10,_0x48da0b[_0x672a('0x3c')]);var _0x3289c4={'where':_0x1d5e10[_0x672a('0x37')]};return db[_0x672a('0x3d')][_0x672a('0x19')](_0x3289c4)[_0x672a('0x21')](function(_0x17df57){_0x5b0f29[_0x672a('0x19')]=_0x17df57;if(_0x48da0b[_0x672a('0x2d')]['includeAll']){_0x1d5e10[_0x672a('0x3e')]=[{'all':!![]}];}return db[_0x672a('0x3d')][_0x672a('0x3f')](_0x1d5e10);})[_0x672a('0x21')](function(_0x19ad8a){_0x5b0f29[_0x672a('0x40')]=_0x19ad8a;return _0x5b0f29;})[_0x672a('0x21')](respondWithFilteredResult(_0x135f61,_0x1d5e10))[_0x672a('0x41')](handleError(_0x135f61,null));};exports[_0x672a('0x42')]=function(_0x16662a,_0x96d97f){var _0x206e88={'raw':!![],'where':{'id':_0x16662a[_0x672a('0x43')]['id']}},_0x57e495={};_0x57e495[_0x672a('0x2c')]=_['keys'](db['SalesforceField']['rawAttributes']);_0x57e495[_0x672a('0x2d')]=_['keys'](_0x16662a[_0x672a('0x2d')]);_0x57e495['filters']=_['intersection'](_0x57e495[_0x672a('0x2c')],_0x57e495[_0x672a('0x2d')]);_0x206e88[_0x672a('0x32')]=_[_0x672a('0x30')](_0x57e495[_0x672a('0x2c')],qs[_0x672a('0x31')](_0x16662a[_0x672a('0x2d')][_0x672a('0x31')]));_0x206e88[_0x672a('0x32')]=_0x206e88[_0x672a('0x32')]['length']?_0x206e88[_0x672a('0x32')]:_0x57e495[_0x672a('0x2c')];if(_0x16662a['query'][_0x672a('0x44')]){_0x206e88[_0x672a('0x3e')]=[{'all':!![]}];}_0x206e88=_[_0x672a('0x39')]({},_0x206e88,_0x16662a[_0x672a('0x3c')]);return db[_0x672a('0x3d')][_0x672a('0x45')](_0x206e88)['then'](handleEntityNotFound(_0x96d97f,null))[_0x672a('0x21')](respondWithResult(_0x96d97f,null))[_0x672a('0x41')](handleError(_0x96d97f,null));};exports[_0x672a('0x46')]=function(_0xd3a66e,_0x41e6c3){return db[_0x672a('0x3d')][_0x672a('0x46')](_0xd3a66e[_0x672a('0x47')],{})['then'](respondWithResult(_0x41e6c3,0xc9))[_0x672a('0x41')](handleError(_0x41e6c3,null));};exports[_0x672a('0x20')]=function(_0x16b30a,_0x1b287d){if(_0x16b30a[_0x672a('0x47')]['id']){delete _0x16b30a[_0x672a('0x47')]['id'];}return db['SalesforceField'][_0x672a('0x45')]({'where':{'id':_0x16b30a[_0x672a('0x43')]['id']}})[_0x672a('0x21')](handleEntityNotFound(_0x1b287d,null))['then'](saveUpdates(_0x16b30a[_0x672a('0x47')],null))[_0x672a('0x21')](respondWithResult(_0x1b287d,null))[_0x672a('0x41')](handleError(_0x1b287d,null));};exports[_0x672a('0x22')]=function(_0x3347ca,_0x342627){return db[_0x672a('0x3d')]['find']({'where':{'id':_0x3347ca[_0x672a('0x43')]['id']}})['then'](handleEntityNotFound(_0x342627,null))['then'](removeEntity(_0x342627,null))['catch'](handleError(_0x342627,null));};
\ No newline at end of file
+var _0x126f=['offset','limit','set','json','apply','reject','save','update','then','error','stack','name','index','map','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','pick','type','VIRTUAL','filter','SalesforceField','rows','params','includeAll','include','merge','options','find','catch','create','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','undefined','count'];(function(_0x17f8b7,_0x2fd88d){var _0xb97796=function(_0x147b79){while(--_0x147b79){_0x17f8b7['push'](_0x17f8b7['shift']());}};_0xb97796(++_0x2fd88d);}(_0x126f,0x75));var _0xf126=function(_0x51f632,_0x5a14d5){_0x51f632=_0x51f632-0x0;var _0x24cf36=_0x126f[_0x51f632];return _0x24cf36;};'use strict';var emlformat=require(_0xf126('0x0'));var rimraf=require(_0xf126('0x1'));var zipdir=require(_0xf126('0x2'));var jsonpatch=require(_0xf126('0x3'));var rp=require(_0xf126('0x4'));var moment=require(_0xf126('0x5'));var BPromise=require(_0xf126('0x6'));var Mustache=require(_0xf126('0x7'));var util=require(_0xf126('0x8'));var path=require(_0xf126('0x9'));var sox=require(_0xf126('0xa'));var csv=require(_0xf126('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf126('0xc'));var _=require('lodash');var squel=require(_0xf126('0xd'));var crypto=require(_0xf126('0xe'));var jsforce=require(_0xf126('0xf'));var deskjs=require(_0xf126('0x10'));var toCsv=require(_0xf126('0xb'));var querystring=require('querystring');var Papa=require(_0xf126('0x11'));var Redis=require(_0xf126('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf126('0x13'));var hardwareService=require(_0xf126('0x14'));var logger=require(_0xf126('0x15'))(_0xf126('0x16'));var utils=require('../../config/utils');var config=require(_0xf126('0x17'));var licenseUtil=require(_0xf126('0x18'));var db=require(_0xf126('0x19'))['db'];function respondWithStatusCode(_0x21a6b9,_0x3b55cc){_0x3b55cc=_0x3b55cc||0xcc;return function(_0x30e6f2){if(_0x30e6f2){return _0x21a6b9[_0xf126('0x1a')](_0x3b55cc);}return _0x21a6b9[_0xf126('0x1b')](_0x3b55cc)[_0xf126('0x1c')]();};}function respondWithResult(_0xe63772,_0x2f5fcf){_0x2f5fcf=_0x2f5fcf||0xc8;return function(_0xf02020){if(_0xf02020){return _0xe63772[_0xf126('0x1b')](_0x2f5fcf)['json'](_0xf02020);}};}function respondWithFilteredResult(_0xdb780,_0x15df50){return function(_0x2021f9){if(_0x2021f9){var _0x1fbaf4=typeof _0x15df50['offset']===_0xf126('0x1d')&&typeof _0x15df50['limit']===_0xf126('0x1d');var _0x99568b=_0x2021f9[_0xf126('0x1e')];var _0x3ee184=_0x1fbaf4?0x0:_0x15df50[_0xf126('0x1f')];var _0x23a1ce=_0x1fbaf4?_0x2021f9[_0xf126('0x1e')]:_0x15df50['offset']+_0x15df50[_0xf126('0x20')];var _0x176a5d;if(_0x23a1ce>=_0x99568b){_0x23a1ce=_0x99568b;_0x176a5d=0xc8;}else{_0x176a5d=0xce;}_0xdb780[_0xf126('0x1b')](_0x176a5d);return _0xdb780[_0xf126('0x21')]('Content-Range',_0x3ee184+'-'+_0x23a1ce+'/'+_0x99568b)[_0xf126('0x22')](_0x2021f9);}return null;};}function patchUpdates(_0x1575c2){return function(_0x388487){try{jsonpatch[_0xf126('0x23')](_0x388487,_0x1575c2,!![]);}catch(_0x1ddb45){return BPromise[_0xf126('0x24')](_0x1ddb45);}return _0x388487[_0xf126('0x25')]();};}function saveUpdates(_0x790a5a,_0x5d1554){return function(_0x2b3300){if(_0x2b3300){return _0x2b3300[_0xf126('0x26')](_0x790a5a)['then'](function(_0x5151e1){return _0x5151e1;});}return null;};}function removeEntity(_0x4c5b99,_0x294ece){return function(_0x1a0c14){if(_0x1a0c14){return _0x1a0c14['destroy']()[_0xf126('0x27')](function(){_0x4c5b99['status'](0xcc)[_0xf126('0x1c')]();});}};}function handleEntityNotFound(_0x4eae3a,_0x2b301a){return function(_0x49632f){if(!_0x49632f){_0x4eae3a[_0xf126('0x1a')](0x194);}return _0x49632f;};}function handleError(_0x497d2f,_0x1a1081){_0x1a1081=_0x1a1081||0x1f4;return function(_0x5a1914){logger[_0xf126('0x28')](_0x5a1914[_0xf126('0x29')]);if(_0x5a1914[_0xf126('0x2a')]){delete _0x5a1914[_0xf126('0x2a')];}_0x497d2f[_0xf126('0x1b')](_0x1a1081)['send'](_0x5a1914);};}exports[_0xf126('0x2b')]=function(_0x51b5f7,_0x36afc0){var _0x503475={},_0x113a1c={},_0x27119b={'count':0x0,'rows':[]};var _0x204242=_[_0xf126('0x2c')](db['SalesforceField'][_0xf126('0x2d')],function(_0x39ae43){return{'name':_0x39ae43[_0xf126('0x2e')],'type':_0x39ae43['type']['key']};});_0x113a1c[_0xf126('0x2f')]=_[_0xf126('0x2c')](_0x204242,_0xf126('0x2a'));_0x113a1c[_0xf126('0x30')]=_[_0xf126('0x31')](_0x51b5f7['query']);_0x113a1c[_0xf126('0x32')]=_[_0xf126('0x33')](_0x113a1c[_0xf126('0x2f')],_0x113a1c[_0xf126('0x30')]);_0x503475[_0xf126('0x34')]=_[_0xf126('0x33')](_0x113a1c['model'],qs[_0xf126('0x35')](_0x51b5f7[_0xf126('0x30')][_0xf126('0x35')]));_0x503475[_0xf126('0x34')]=_0x503475[_0xf126('0x34')][_0xf126('0x36')]?_0x503475[_0xf126('0x34')]:_0x113a1c[_0xf126('0x2f')];if(!_0x51b5f7[_0xf126('0x30')]['hasOwnProperty']('nolimit')){_0x503475[_0xf126('0x20')]=qs[_0xf126('0x20')](_0x51b5f7[_0xf126('0x30')][_0xf126('0x20')]);_0x503475[_0xf126('0x1f')]=qs[_0xf126('0x1f')](_0x51b5f7[_0xf126('0x30')]['offset']);}_0x503475[_0xf126('0x37')]=qs[_0xf126('0x38')](_0x51b5f7[_0xf126('0x30')][_0xf126('0x38')]);_0x503475[_0xf126('0x39')]=qs[_0xf126('0x32')](_[_0xf126('0x3a')](_0x51b5f7[_0xf126('0x30')],_0x113a1c[_0xf126('0x32')]),_0x204242);if(_0x51b5f7[_0xf126('0x30')]['filter']){_0x503475[_0xf126('0x39')]=_['merge'](_0x503475[_0xf126('0x39')],{'$or':_[_0xf126('0x2c')](_0x204242,function(_0x4371a2){if(_0x4371a2[_0xf126('0x3b')]!==_0xf126('0x3c')){var _0x464b4d={};_0x464b4d[_0x4371a2[_0xf126('0x2a')]]={'$like':'%'+_0x51b5f7[_0xf126('0x30')][_0xf126('0x3d')]+'%'};return _0x464b4d;}})});}_0x503475=_['merge']({},_0x503475,_0x51b5f7['options']);var _0x3a3cba={'where':_0x503475[_0xf126('0x39')]};return db['SalesforceField']['count'](_0x3a3cba)[_0xf126('0x27')](function(_0x426459){_0x27119b['count']=_0x426459;if(_0x51b5f7[_0xf126('0x30')]['includeAll']){_0x503475['include']=[{'all':!![]}];}return db[_0xf126('0x3e')]['findAll'](_0x503475);})['then'](function(_0x4a75cf){_0x27119b[_0xf126('0x3f')]=_0x4a75cf;return _0x27119b;})[_0xf126('0x27')](respondWithFilteredResult(_0x36afc0,_0x503475))['catch'](handleError(_0x36afc0,null));};exports['show']=function(_0x5cadf5,_0x2f735a){var _0x4c97bf={'raw':!![],'where':{'id':_0x5cadf5[_0xf126('0x40')]['id']}},_0x388886={};_0x388886[_0xf126('0x2f')]=_[_0xf126('0x31')](db[_0xf126('0x3e')][_0xf126('0x2d')]);_0x388886['query']=_[_0xf126('0x31')](_0x5cadf5[_0xf126('0x30')]);_0x388886[_0xf126('0x32')]=_[_0xf126('0x33')](_0x388886[_0xf126('0x2f')],_0x388886[_0xf126('0x30')]);_0x4c97bf[_0xf126('0x34')]=_[_0xf126('0x33')](_0x388886[_0xf126('0x2f')],qs[_0xf126('0x35')](_0x5cadf5[_0xf126('0x30')][_0xf126('0x35')]));_0x4c97bf['attributes']=_0x4c97bf['attributes']['length']?_0x4c97bf[_0xf126('0x34')]:_0x388886[_0xf126('0x2f')];if(_0x5cadf5[_0xf126('0x30')][_0xf126('0x41')]){_0x4c97bf[_0xf126('0x42')]=[{'all':!![]}];}_0x4c97bf=_[_0xf126('0x43')]({},_0x4c97bf,_0x5cadf5[_0xf126('0x44')]);return db[_0xf126('0x3e')][_0xf126('0x45')](_0x4c97bf)[_0xf126('0x27')](handleEntityNotFound(_0x2f735a,null))[_0xf126('0x27')](respondWithResult(_0x2f735a,null))[_0xf126('0x46')](handleError(_0x2f735a,null));};exports[_0xf126('0x47')]=function(_0x13216e,_0x3f5e36){return db[_0xf126('0x3e')][_0xf126('0x47')](_0x13216e['body'],{})[_0xf126('0x27')](respondWithResult(_0x3f5e36,0xc9))[_0xf126('0x46')](handleError(_0x3f5e36,null));};exports['update']=function(_0x5dcd99,_0xf5a98b){if(_0x5dcd99[_0xf126('0x48')]['id']){delete _0x5dcd99[_0xf126('0x48')]['id'];}return db['SalesforceField']['find']({'where':{'id':_0x5dcd99[_0xf126('0x40')]['id']}})[_0xf126('0x27')](handleEntityNotFound(_0xf5a98b,null))[_0xf126('0x27')](saveUpdates(_0x5dcd99[_0xf126('0x48')],null))[_0xf126('0x27')](respondWithResult(_0xf5a98b,null))[_0xf126('0x46')](handleError(_0xf5a98b,null));};exports[_0xf126('0x49')]=function(_0x597ea1,_0x57dc96){return db['SalesforceField'][_0xf126('0x45')]({'where':{'id':_0x597ea1['params']['id']}})['then'](handleEntityNotFound(_0x57dc96,null))[_0xf126('0x27')](removeEntity(_0x57dc96,null))[_0xf126('0x46')](handleError(_0x57dc96,null));};
\ No newline at end of file