Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 783ffa6..35e6418 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x235a=['stack','name','send','index','map','rawAttributes','query','intersection','model','fields','attributes','hasOwnProperty','nolimit','order','where','filters','pick','filter','type','VIRTUAL','options','SalesforceField','includeAll','include','findAll','rows','show','keys','length','merge','find','catch','body','params','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','apply','reject','then','end','error'];(function(_0x19e11a,_0x4fb378){var _0x3bc99e=function(_0x5b8e1a){while(--_0x5b8e1a){_0x19e11a['push'](_0x19e11a['shift']());}};_0x3bc99e(++_0x4fb378);}(_0x235a,0x100));var _0xa235=function(_0x4f28ab,_0x43d2f1){_0x4f28ab=_0x4f28ab-0x0;var _0x551362=_0x235a[_0x4f28ab];return _0x551362;};'use strict';var emlformat=require(_0xa235('0x0'));var rimraf=require(_0xa235('0x1'));var zipdir=require(_0xa235('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa235('0x3'));var BPromise=require(_0xa235('0x4'));var Mustache=require(_0xa235('0x5'));var util=require(_0xa235('0x6'));var path=require(_0xa235('0x7'));var sox=require(_0xa235('0x8'));var csv=require(_0xa235('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa235('0xa'));var _=require(_0xa235('0xb'));var squel=require(_0xa235('0xc'));var crypto=require(_0xa235('0xd'));var jsforce=require(_0xa235('0xe'));var deskjs=require(_0xa235('0xf'));var toCsv=require(_0xa235('0x9'));var querystring=require(_0xa235('0x10'));var Papa=require('papaparse');var Redis=require(_0xa235('0x11'));var authService=require(_0xa235('0x12'));var qs=require(_0xa235('0x13'));var as=require(_0xa235('0x14'));var hardwareService=require(_0xa235('0x15'));var logger=require(_0xa235('0x16'))(_0xa235('0x17'));var utils=require(_0xa235('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0xa235('0x19'));var db=require(_0xa235('0x1a'))['db'];function respondWithStatusCode(_0x2afea7,_0xdf11e5){_0xdf11e5=_0xdf11e5||0xcc;return function(_0x1f9a06){if(_0x1f9a06){return _0x2afea7[_0xa235('0x1b')](_0xdf11e5);}return _0x2afea7[_0xa235('0x1c')](_0xdf11e5)['end']();};}function respondWithResult(_0x43f994,_0x1de941){_0x1de941=_0x1de941||0xc8;return function(_0x2671c5){if(_0x2671c5){return _0x43f994[_0xa235('0x1c')](_0x1de941)[_0xa235('0x1d')](_0x2671c5);}};}function respondWithFilteredResult(_0x70733c,_0x8e42a5){return function(_0x20391c){if(_0x20391c){var _0x1ea7f7=typeof _0x8e42a5[_0xa235('0x1e')]===_0xa235('0x1f')&&typeof _0x8e42a5[_0xa235('0x20')]===_0xa235('0x1f');var _0x1a789c=_0x20391c['count'];var _0x39d9f4=_0x1ea7f7?0x0:_0x8e42a5['offset'];var _0x31c68b=_0x1ea7f7?_0x20391c[_0xa235('0x21')]:_0x8e42a5['offset']+_0x8e42a5[_0xa235('0x20')];var _0xa822e6;if(_0x31c68b>=_0x1a789c){_0x31c68b=_0x1a789c;_0xa822e6=0xc8;}else{_0xa822e6=0xce;}_0x70733c['status'](_0xa822e6);return _0x70733c[_0xa235('0x22')]('Content-Range',_0x39d9f4+'-'+_0x31c68b+'/'+_0x1a789c)[_0xa235('0x1d')](_0x20391c);}return null;};}function patchUpdates(_0x3f5108){return function(_0x327b82){try{jsonpatch[_0xa235('0x23')](_0x327b82,_0x3f5108,!![]);}catch(_0x34b1ba){return BPromise[_0xa235('0x24')](_0x34b1ba);}return _0x327b82['save']();};}function saveUpdates(_0x55bf39,_0x435370){return function(_0x509e77){if(_0x509e77){return _0x509e77['update'](_0x55bf39)[_0xa235('0x25')](function(_0x2cbc0a){return _0x2cbc0a;});}return null;};}function removeEntity(_0x3c07d0,_0x3c0c5e){return function(_0x9aecba){if(_0x9aecba){return _0x9aecba['destroy']()[_0xa235('0x25')](function(){_0x3c07d0['status'](0xcc)[_0xa235('0x26')]();});}};}function handleEntityNotFound(_0x3ebacd,_0x4dac4e){return function(_0x3e8449){if(!_0x3e8449){_0x3ebacd[_0xa235('0x1b')](0x194);}return _0x3e8449;};}function handleError(_0x2503d7,_0x599054){_0x599054=_0x599054||0x1f4;return function(_0x568d0f){logger[_0xa235('0x27')](_0x568d0f[_0xa235('0x28')]);if(_0x568d0f[_0xa235('0x29')]){delete _0x568d0f['name'];}_0x2503d7[_0xa235('0x1c')](_0x599054)[_0xa235('0x2a')](_0x568d0f);};}exports[_0xa235('0x2b')]=function(_0x270698,_0x1f6624){var _0x2de835={},_0x3db367={},_0x34f99f={'count':0x0,'rows':[]};var _0x325386=_[_0xa235('0x2c')](db['SalesforceField'][_0xa235('0x2d')],function(_0x30c223){return{'name':_0x30c223['fieldName'],'type':_0x30c223['type']['key']};});_0x3db367['model']=_[_0xa235('0x2c')](_0x325386,'name');_0x3db367['query']=_['keys'](_0x270698[_0xa235('0x2e')]);_0x3db367['filters']=_[_0xa235('0x2f')](_0x3db367[_0xa235('0x30')],_0x3db367[_0xa235('0x2e')]);_0x2de835['attributes']=_[_0xa235('0x2f')](_0x3db367[_0xa235('0x30')],qs[_0xa235('0x31')](_0x270698[_0xa235('0x2e')][_0xa235('0x31')]));_0x2de835[_0xa235('0x32')]=_0x2de835['attributes']['length']?_0x2de835['attributes']:_0x3db367[_0xa235('0x30')];if(!_0x270698[_0xa235('0x2e')][_0xa235('0x33')](_0xa235('0x34'))){_0x2de835[_0xa235('0x20')]=qs['limit'](_0x270698[_0xa235('0x2e')]['limit']);_0x2de835['offset']=qs['offset'](_0x270698[_0xa235('0x2e')][_0xa235('0x1e')]);}_0x2de835[_0xa235('0x35')]=qs['sort'](_0x270698['query']['sort']);_0x2de835[_0xa235('0x36')]=qs[_0xa235('0x37')](_[_0xa235('0x38')](_0x270698['query'],_0x3db367[_0xa235('0x37')]),_0x325386);if(_0x270698[_0xa235('0x2e')][_0xa235('0x39')]){_0x2de835[_0xa235('0x36')]=_['merge'](_0x2de835[_0xa235('0x36')],{'$or':_[_0xa235('0x2c')](_0x325386,function(_0xc5222){if(_0xc5222[_0xa235('0x3a')]!==_0xa235('0x3b')){var _0x2eb8f3={};_0x2eb8f3[_0xc5222[_0xa235('0x29')]]={'$like':'%'+_0x270698['query'][_0xa235('0x39')]+'%'};return _0x2eb8f3;}})});}_0x2de835=_['merge']({},_0x2de835,_0x270698[_0xa235('0x3c')]);var _0x235dec={'where':_0x2de835[_0xa235('0x36')]};return db[_0xa235('0x3d')][_0xa235('0x21')](_0x235dec)[_0xa235('0x25')](function(_0x13d376){_0x34f99f[_0xa235('0x21')]=_0x13d376;if(_0x270698[_0xa235('0x2e')][_0xa235('0x3e')]){_0x2de835[_0xa235('0x3f')]=[{'all':!![]}];}return db['SalesforceField'][_0xa235('0x40')](_0x2de835);})[_0xa235('0x25')](function(_0x3ae12e){_0x34f99f[_0xa235('0x41')]=_0x3ae12e;return _0x34f99f;})[_0xa235('0x25')](respondWithFilteredResult(_0x1f6624,_0x2de835))['catch'](handleError(_0x1f6624,null));};exports[_0xa235('0x42')]=function(_0x1009de,_0x3f55cf){var _0x27b9a5={'raw':!![],'where':{'id':_0x1009de['params']['id']}},_0x264c28={};_0x264c28[_0xa235('0x30')]=_[_0xa235('0x43')](db['SalesforceField'][_0xa235('0x2d')]);_0x264c28[_0xa235('0x2e')]=_[_0xa235('0x43')](_0x1009de[_0xa235('0x2e')]);_0x264c28[_0xa235('0x37')]=_[_0xa235('0x2f')](_0x264c28['model'],_0x264c28[_0xa235('0x2e')]);_0x27b9a5[_0xa235('0x32')]=_[_0xa235('0x2f')](_0x264c28['model'],qs[_0xa235('0x31')](_0x1009de['query'][_0xa235('0x31')]));_0x27b9a5[_0xa235('0x32')]=_0x27b9a5[_0xa235('0x32')][_0xa235('0x44')]?_0x27b9a5['attributes']:_0x264c28[_0xa235('0x30')];if(_0x1009de['query'][_0xa235('0x3e')]){_0x27b9a5['include']=[{'all':!![]}];}_0x27b9a5=_[_0xa235('0x45')]({},_0x27b9a5,_0x1009de[_0xa235('0x3c')]);return db['SalesforceField'][_0xa235('0x46')](_0x27b9a5)[_0xa235('0x25')](handleEntityNotFound(_0x3f55cf,null))[_0xa235('0x25')](respondWithResult(_0x3f55cf,null))[_0xa235('0x47')](handleError(_0x3f55cf,null));};exports['create']=function(_0x2d5fb8,_0x37a475){return db[_0xa235('0x3d')]['create'](_0x2d5fb8[_0xa235('0x48')],{})[_0xa235('0x25')](respondWithResult(_0x37a475,0xc9))['catch'](handleError(_0x37a475,null));};exports['update']=function(_0x2b8280,_0x5a182c){if(_0x2b8280['body']['id']){delete _0x2b8280[_0xa235('0x48')]['id'];}return db[_0xa235('0x3d')]['find']({'where':{'id':_0x2b8280[_0xa235('0x49')]['id']}})['then'](handleEntityNotFound(_0x5a182c,null))['then'](saveUpdates(_0x2b8280[_0xa235('0x48')],null))[_0xa235('0x25')](respondWithResult(_0x5a182c,null))[_0xa235('0x47')](handleError(_0x5a182c,null));};exports['destroy']=function(_0x2548ec,_0x1caf0c){return db[_0xa235('0x3d')][_0xa235('0x46')]({'where':{'id':_0x2548ec[_0xa235('0x49')]['id']}})['then'](handleEntityNotFound(_0x1caf0c,null))[_0xa235('0x25')](removeEntity(_0x1caf0c,null))[_0xa235('0x47')](handleError(_0x1caf0c,null));};
\ No newline at end of file
+var _0x4f07=['status','end','json','offset','undefined','limit','count','Content-Range','reject','save','update','then','destroy','stack','name','send','index','map','SalesforceField','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','include','findAll','show','params','rawAttributes','find','catch','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus'];(function(_0x1ad901,_0x852d9e){var _0x3c0249=function(_0x319eda){while(--_0x319eda){_0x1ad901['push'](_0x1ad901['shift']());}};_0x3c0249(++_0x852d9e);}(_0x4f07,0xca));var _0x74f0=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x4f07[_0x2641f9];return _0x585741;};'use strict';var emlformat=require(_0x74f0('0x0'));var rimraf=require(_0x74f0('0x1'));var zipdir=require(_0x74f0('0x2'));var jsonpatch=require(_0x74f0('0x3'));var rp=require(_0x74f0('0x4'));var moment=require(_0x74f0('0x5'));var BPromise=require(_0x74f0('0x6'));var Mustache=require(_0x74f0('0x7'));var util=require(_0x74f0('0x8'));var path=require(_0x74f0('0x9'));var sox=require(_0x74f0('0xa'));var csv=require(_0x74f0('0xb'));var ejs=require(_0x74f0('0xc'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x74f0('0xd'));var squel=require(_0x74f0('0xe'));var crypto=require(_0x74f0('0xf'));var jsforce=require(_0x74f0('0x10'));var deskjs=require(_0x74f0('0x11'));var toCsv=require(_0x74f0('0xb'));var querystring=require(_0x74f0('0x12'));var Papa=require(_0x74f0('0x13'));var Redis=require('ioredis');var authService=require(_0x74f0('0x14'));var qs=require(_0x74f0('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x74f0('0x16'));var logger=require(_0x74f0('0x17'))(_0x74f0('0x18'));var utils=require('../../config/utils');var config=require(_0x74f0('0x19'));var licenseUtil=require(_0x74f0('0x1a'));var db=require(_0x74f0('0x1b'))['db'];function respondWithStatusCode(_0x1c3d10,_0x245bf8){_0x245bf8=_0x245bf8||0xcc;return function(_0x1947ac){if(_0x1947ac){return _0x1c3d10[_0x74f0('0x1c')](_0x245bf8);}return _0x1c3d10[_0x74f0('0x1d')](_0x245bf8)[_0x74f0('0x1e')]();};}function respondWithResult(_0x46a0d0,_0xaeef11){_0xaeef11=_0xaeef11||0xc8;return function(_0x4e81a9){if(_0x4e81a9){return _0x46a0d0[_0x74f0('0x1d')](_0xaeef11)[_0x74f0('0x1f')](_0x4e81a9);}};}function respondWithFilteredResult(_0x434f32,_0x250ffb){return function(_0x348d2c){if(_0x348d2c){var _0x2ef7e3=typeof _0x250ffb[_0x74f0('0x20')]===_0x74f0('0x21')&&typeof _0x250ffb[_0x74f0('0x22')]===_0x74f0('0x21');var _0x16329f=_0x348d2c[_0x74f0('0x23')];var _0x53f4c6=_0x2ef7e3?0x0:_0x250ffb[_0x74f0('0x20')];var _0x5bf21e=_0x2ef7e3?_0x348d2c[_0x74f0('0x23')]:_0x250ffb[_0x74f0('0x20')]+_0x250ffb[_0x74f0('0x22')];var _0x4684e6;if(_0x5bf21e>=_0x16329f){_0x5bf21e=_0x16329f;_0x4684e6=0xc8;}else{_0x4684e6=0xce;}_0x434f32[_0x74f0('0x1d')](_0x4684e6);return _0x434f32['set'](_0x74f0('0x24'),_0x53f4c6+'-'+_0x5bf21e+'/'+_0x16329f)[_0x74f0('0x1f')](_0x348d2c);}return null;};}function patchUpdates(_0x5a4b3b){return function(_0x5db755){try{jsonpatch['apply'](_0x5db755,_0x5a4b3b,!![]);}catch(_0xf69ccd){return BPromise[_0x74f0('0x25')](_0xf69ccd);}return _0x5db755[_0x74f0('0x26')]();};}function saveUpdates(_0x1b0696,_0x2d442e){return function(_0x4f1d87){if(_0x4f1d87){return _0x4f1d87[_0x74f0('0x27')](_0x1b0696)[_0x74f0('0x28')](function(_0x305d19){return _0x305d19;});}return null;};}function removeEntity(_0x30a768,_0x515d83){return function(_0x3c98f3){if(_0x3c98f3){return _0x3c98f3[_0x74f0('0x29')]()[_0x74f0('0x28')](function(){_0x30a768[_0x74f0('0x1d')](0xcc)[_0x74f0('0x1e')]();});}};}function handleEntityNotFound(_0x256d79,_0x323430){return function(_0x1e8c8a){if(!_0x1e8c8a){_0x256d79[_0x74f0('0x1c')](0x194);}return _0x1e8c8a;};}function handleError(_0x39acf7,_0x23a313){_0x23a313=_0x23a313||0x1f4;return function(_0x438188){logger['error'](_0x438188[_0x74f0('0x2a')]);if(_0x438188[_0x74f0('0x2b')]){delete _0x438188[_0x74f0('0x2b')];}_0x39acf7[_0x74f0('0x1d')](_0x23a313)[_0x74f0('0x2c')](_0x438188);};}exports[_0x74f0('0x2d')]=function(_0x23d9ee,_0x39bcf7){var _0xd6735b={},_0x1775c8={},_0x32e4f0={'count':0x0,'rows':[]};var _0x1d20ae=_[_0x74f0('0x2e')](db[_0x74f0('0x2f')]['rawAttributes'],function(_0xd97ae4){return{'name':_0xd97ae4['fieldName'],'type':_0xd97ae4[_0x74f0('0x30')][_0x74f0('0x31')]};});_0x1775c8[_0x74f0('0x32')]=_[_0x74f0('0x2e')](_0x1d20ae,_0x74f0('0x2b'));_0x1775c8[_0x74f0('0x33')]=_[_0x74f0('0x34')](_0x23d9ee[_0x74f0('0x33')]);_0x1775c8[_0x74f0('0x35')]=_[_0x74f0('0x36')](_0x1775c8[_0x74f0('0x32')],_0x1775c8[_0x74f0('0x33')]);_0xd6735b['attributes']=_['intersection'](_0x1775c8[_0x74f0('0x32')],qs['fields'](_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x37')]));_0xd6735b[_0x74f0('0x38')]=_0xd6735b[_0x74f0('0x38')][_0x74f0('0x39')]?_0xd6735b[_0x74f0('0x38')]:_0x1775c8[_0x74f0('0x32')];if(!_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x3a')](_0x74f0('0x3b'))){_0xd6735b[_0x74f0('0x22')]=qs[_0x74f0('0x22')](_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x22')]);_0xd6735b[_0x74f0('0x20')]=qs['offset'](_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x20')]);}_0xd6735b[_0x74f0('0x3c')]=qs[_0x74f0('0x3d')](_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x3d')]);_0xd6735b[_0x74f0('0x3e')]=qs['filters'](_[_0x74f0('0x3f')](_0x23d9ee[_0x74f0('0x33')],_0x1775c8[_0x74f0('0x35')]),_0x1d20ae);if(_0x23d9ee['query']['filter']){_0xd6735b[_0x74f0('0x3e')]=_[_0x74f0('0x40')](_0xd6735b['where'],{'$or':_[_0x74f0('0x2e')](_0x1d20ae,function(_0x401d6c){if(_0x401d6c[_0x74f0('0x30')]!==_0x74f0('0x41')){var _0x30a247={};_0x30a247[_0x401d6c[_0x74f0('0x2b')]]={'$like':'%'+_0x23d9ee[_0x74f0('0x33')][_0x74f0('0x42')]+'%'};return _0x30a247;}})});}_0xd6735b=_[_0x74f0('0x40')]({},_0xd6735b,_0x23d9ee[_0x74f0('0x43')]);var _0x55e8ea={'where':_0xd6735b['where']};return db[_0x74f0('0x2f')][_0x74f0('0x23')](_0x55e8ea)[_0x74f0('0x28')](function(_0x1376b2){_0x32e4f0[_0x74f0('0x23')]=_0x1376b2;if(_0x23d9ee[_0x74f0('0x33')]['includeAll']){_0xd6735b[_0x74f0('0x44')]=[{'all':!![]}];}return db[_0x74f0('0x2f')][_0x74f0('0x45')](_0xd6735b);})['then'](function(_0x20e776){_0x32e4f0['rows']=_0x20e776;return _0x32e4f0;})['then'](respondWithFilteredResult(_0x39bcf7,_0xd6735b))['catch'](handleError(_0x39bcf7,null));};exports[_0x74f0('0x46')]=function(_0x4acd13,_0x45e77b){var _0x2b9353={'raw':!![],'where':{'id':_0x4acd13[_0x74f0('0x47')]['id']}},_0x397c0a={};_0x397c0a[_0x74f0('0x32')]=_[_0x74f0('0x34')](db['SalesforceField'][_0x74f0('0x48')]);_0x397c0a[_0x74f0('0x33')]=_[_0x74f0('0x34')](_0x4acd13[_0x74f0('0x33')]);_0x397c0a[_0x74f0('0x35')]=_[_0x74f0('0x36')](_0x397c0a[_0x74f0('0x32')],_0x397c0a[_0x74f0('0x33')]);_0x2b9353[_0x74f0('0x38')]=_[_0x74f0('0x36')](_0x397c0a[_0x74f0('0x32')],qs[_0x74f0('0x37')](_0x4acd13[_0x74f0('0x33')]['fields']));_0x2b9353['attributes']=_0x2b9353[_0x74f0('0x38')][_0x74f0('0x39')]?_0x2b9353['attributes']:_0x397c0a['model'];if(_0x4acd13[_0x74f0('0x33')]['includeAll']){_0x2b9353[_0x74f0('0x44')]=[{'all':!![]}];}_0x2b9353=_[_0x74f0('0x40')]({},_0x2b9353,_0x4acd13['options']);return db[_0x74f0('0x2f')][_0x74f0('0x49')](_0x2b9353)['then'](handleEntityNotFound(_0x45e77b,null))['then'](respondWithResult(_0x45e77b,null))[_0x74f0('0x4a')](handleError(_0x45e77b,null));};exports['create']=function(_0x105812,_0x14f661){return db['SalesforceField'][_0x74f0('0x4b')](_0x105812['body'],{})[_0x74f0('0x28')](respondWithResult(_0x14f661,0xc9))['catch'](handleError(_0x14f661,null));};exports[_0x74f0('0x27')]=function(_0x2af1c0,_0x217c8d){if(_0x2af1c0['body']['id']){delete _0x2af1c0[_0x74f0('0x4c')]['id'];}return db[_0x74f0('0x2f')][_0x74f0('0x49')]({'where':{'id':_0x2af1c0[_0x74f0('0x47')]['id']}})[_0x74f0('0x28')](handleEntityNotFound(_0x217c8d,null))[_0x74f0('0x28')](saveUpdates(_0x2af1c0['body'],null))[_0x74f0('0x28')](respondWithResult(_0x217c8d,null))[_0x74f0('0x4a')](handleError(_0x217c8d,null));};exports[_0x74f0('0x29')]=function(_0x4f1213,_0x2fc116){return db[_0x74f0('0x2f')][_0x74f0('0x49')]({'where':{'id':_0x4f1213[_0x74f0('0x47')]['id']}})[_0x74f0('0x28')](handleEntityNotFound(_0x2fc116,null))[_0x74f0('0x28')](removeEntity(_0x2fc116,null))['catch'](handleError(_0x2fc116,null));};
\ No newline at end of file