Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 2b52607..99aa601 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6477=['params','length','body','find','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','undefined','count','limit','update','then','destroy','error','name','rawAttributes','fieldName','type','key','map','query','keys','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','SalesforceField','findAll','rows','catch','show'];(function(_0x5c2ae0,_0x57ca47){var _0x50d6d8=function(_0x164e4f){while(--_0x164e4f){_0x5c2ae0['push'](_0x5c2ae0['shift']());}};_0x50d6d8(++_0x57ca47);}(_0x6477,0xd3));var _0x7647=function(_0x14f89e,_0x139fce){_0x14f89e=_0x14f89e-0x0;var _0x26092d=_0x6477[_0x14f89e];return _0x26092d;};'use strict';var emlformat=require(_0x7647('0x0'));var rimraf=require(_0x7647('0x1'));var zipdir=require(_0x7647('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7647('0x3'));var moment=require(_0x7647('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x7647('0x5'));var util=require(_0x7647('0x6'));var path=require(_0x7647('0x7'));var sox=require(_0x7647('0x8'));var csv=require(_0x7647('0x9'));var ejs=require(_0x7647('0xa'));var fs=require('fs');var fs_extra=require(_0x7647('0xb'));var _=require(_0x7647('0xc'));var squel=require('squel');var crypto=require(_0x7647('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x7647('0xe'));var Redis=require('ioredis');var authService=require(_0x7647('0xf'));var qs=require(_0x7647('0x10'));var as=require(_0x7647('0x11'));var hardwareService=require(_0x7647('0x12'));var logger=require(_0x7647('0x13'))(_0x7647('0x14'));var utils=require(_0x7647('0x15'));var config=require(_0x7647('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x38b595,_0x47be1a){_0x47be1a=_0x47be1a||0xcc;return function(_0x4dce5d){if(_0x4dce5d){return _0x38b595[_0x7647('0x17')](_0x47be1a);}return _0x38b595[_0x7647('0x18')](_0x47be1a)[_0x7647('0x19')]();};}function respondWithResult(_0x216d72,_0x3d8c6f){_0x3d8c6f=_0x3d8c6f||0xc8;return function(_0x4c311f){if(_0x4c311f){return _0x216d72[_0x7647('0x18')](_0x3d8c6f)[_0x7647('0x1a')](_0x4c311f);}};}function respondWithFilteredResult(_0x10ae95,_0x1dfab3){return function(_0xef1424){if(_0xef1424){var _0x3a4229=typeof _0x1dfab3[_0x7647('0x1b')]==='undefined'&&typeof _0x1dfab3['limit']===_0x7647('0x1c');var _0x3fab5d=_0xef1424[_0x7647('0x1d')];var _0x1ed196=_0x3a4229?0x0:_0x1dfab3[_0x7647('0x1b')];var _0x23e27f=_0x3a4229?_0xef1424[_0x7647('0x1d')]:_0x1dfab3[_0x7647('0x1b')]+_0x1dfab3[_0x7647('0x1e')];var _0x4bc0f3;if(_0x23e27f>=_0x3fab5d){_0x23e27f=_0x3fab5d;_0x4bc0f3=0xc8;}else{_0x4bc0f3=0xce;}_0x10ae95[_0x7647('0x18')](_0x4bc0f3);return _0x10ae95['set']('Content-Range',_0x1ed196+'-'+_0x23e27f+'/'+_0x3fab5d)[_0x7647('0x1a')](_0xef1424);}return null;};}function patchUpdates(_0x3383e9){return function(_0x1495f3){try{jsonpatch['apply'](_0x1495f3,_0x3383e9,!![]);}catch(_0x36593d){return BPromise['reject'](_0x36593d);}return _0x1495f3['save']();};}function saveUpdates(_0x367f10,_0x35292f){return function(_0x249d9e){if(_0x249d9e){return _0x249d9e[_0x7647('0x1f')](_0x367f10)[_0x7647('0x20')](function(_0x47925a){return _0x47925a;});}return null;};}function removeEntity(_0x6bcd60,_0x140046){return function(_0xb5bc52){if(_0xb5bc52){return _0xb5bc52[_0x7647('0x21')]()['then'](function(){_0x6bcd60[_0x7647('0x18')](0xcc)[_0x7647('0x19')]();});}};}function handleEntityNotFound(_0x1be1d4,_0x3789e1){return function(_0x481161){if(!_0x481161){_0x1be1d4['sendStatus'](0x194);}return _0x481161;};}function handleError(_0x292278,_0x1051bf){_0x1051bf=_0x1051bf||0x1f4;return function(_0x2b1423){logger[_0x7647('0x22')](_0x2b1423['stack']);if(_0x2b1423['name']){delete _0x2b1423[_0x7647('0x23')];}_0x292278[_0x7647('0x18')](_0x1051bf)['send'](_0x2b1423);};}exports['index']=function(_0x2fc5f0,_0x519e10){var _0x40eaa6={},_0x13b3ef={},_0x457bf1={'count':0x0,'rows':[]};var _0x55359f=_['map'](db['SalesforceField'][_0x7647('0x24')],function(_0x49c0f5){return{'name':_0x49c0f5[_0x7647('0x25')],'type':_0x49c0f5[_0x7647('0x26')][_0x7647('0x27')]};});_0x13b3ef['model']=_[_0x7647('0x28')](_0x55359f,_0x7647('0x23'));_0x13b3ef[_0x7647('0x29')]=_[_0x7647('0x2a')](_0x2fc5f0[_0x7647('0x29')]);_0x13b3ef[_0x7647('0x2b')]=_[_0x7647('0x2c')](_0x13b3ef[_0x7647('0x2d')],_0x13b3ef[_0x7647('0x29')]);_0x40eaa6[_0x7647('0x2e')]=_[_0x7647('0x2c')](_0x13b3ef['model'],qs[_0x7647('0x2f')](_0x2fc5f0['query']['fields']));_0x40eaa6[_0x7647('0x2e')]=_0x40eaa6['attributes']['length']?_0x40eaa6[_0x7647('0x2e')]:_0x13b3ef[_0x7647('0x2d')];if(!_0x2fc5f0['query'][_0x7647('0x30')](_0x7647('0x31'))){_0x40eaa6[_0x7647('0x1e')]=qs[_0x7647('0x1e')](_0x2fc5f0[_0x7647('0x29')]['limit']);_0x40eaa6[_0x7647('0x1b')]=qs[_0x7647('0x1b')](_0x2fc5f0['query'][_0x7647('0x1b')]);}_0x40eaa6[_0x7647('0x32')]=qs[_0x7647('0x33')](_0x2fc5f0[_0x7647('0x29')][_0x7647('0x33')]);_0x40eaa6[_0x7647('0x34')]=qs[_0x7647('0x2b')](_[_0x7647('0x35')](_0x2fc5f0[_0x7647('0x29')],_0x13b3ef['filters']),_0x55359f);if(_0x2fc5f0['query']['filter']){_0x40eaa6[_0x7647('0x34')]=_[_0x7647('0x36')](_0x40eaa6['where'],{'$or':_['map'](_0x55359f,function(_0x3a50f5){if(_0x3a50f5[_0x7647('0x26')]!==_0x7647('0x37')){var _0x5536bf={};_0x5536bf[_0x3a50f5['name']]={'$like':'%'+_0x2fc5f0[_0x7647('0x29')][_0x7647('0x38')]+'%'};return _0x5536bf;}})});}_0x40eaa6=_[_0x7647('0x36')]({},_0x40eaa6,_0x2fc5f0[_0x7647('0x39')]);var _0x20f1ff={'where':_0x40eaa6[_0x7647('0x34')]};return db['SalesforceField'][_0x7647('0x1d')](_0x20f1ff)[_0x7647('0x20')](function(_0xb06a4a){_0x457bf1['count']=_0xb06a4a;if(_0x2fc5f0[_0x7647('0x29')][_0x7647('0x3a')]){_0x40eaa6[_0x7647('0x3b')]=[{'all':!![]}];}return db[_0x7647('0x3c')][_0x7647('0x3d')](_0x40eaa6);})[_0x7647('0x20')](function(_0x3262bf){_0x457bf1[_0x7647('0x3e')]=_0x3262bf;return _0x457bf1;})['then'](respondWithFilteredResult(_0x519e10,_0x40eaa6))[_0x7647('0x3f')](handleError(_0x519e10,null));};exports[_0x7647('0x40')]=function(_0x38f70a,_0x26dd0c){var _0x33506a={'raw':!![],'where':{'id':_0x38f70a[_0x7647('0x41')]['id']}},_0x216c5b={};_0x216c5b[_0x7647('0x2d')]=_['keys'](db[_0x7647('0x3c')][_0x7647('0x24')]);_0x216c5b[_0x7647('0x29')]=_[_0x7647('0x2a')](_0x38f70a['query']);_0x216c5b['filters']=_[_0x7647('0x2c')](_0x216c5b[_0x7647('0x2d')],_0x216c5b[_0x7647('0x29')]);_0x33506a[_0x7647('0x2e')]=_[_0x7647('0x2c')](_0x216c5b['model'],qs[_0x7647('0x2f')](_0x38f70a[_0x7647('0x29')][_0x7647('0x2f')]));_0x33506a[_0x7647('0x2e')]=_0x33506a[_0x7647('0x2e')][_0x7647('0x42')]?_0x33506a[_0x7647('0x2e')]:_0x216c5b[_0x7647('0x2d')];if(_0x38f70a[_0x7647('0x29')][_0x7647('0x3a')]){_0x33506a[_0x7647('0x3b')]=[{'all':!![]}];}_0x33506a=_[_0x7647('0x36')]({},_0x33506a,_0x38f70a[_0x7647('0x39')]);return db[_0x7647('0x3c')]['find'](_0x33506a)[_0x7647('0x20')](handleEntityNotFound(_0x26dd0c,null))[_0x7647('0x20')](respondWithResult(_0x26dd0c,null))[_0x7647('0x3f')](handleError(_0x26dd0c,null));};exports['create']=function(_0x6d9ae1,_0x5cb1bf){return db[_0x7647('0x3c')]['create'](_0x6d9ae1[_0x7647('0x43')],{})[_0x7647('0x20')](respondWithResult(_0x5cb1bf,0xc9))[_0x7647('0x3f')](handleError(_0x5cb1bf,null));};exports[_0x7647('0x1f')]=function(_0x154672,_0x22aa0d){if(_0x154672[_0x7647('0x43')]['id']){delete _0x154672[_0x7647('0x43')]['id'];}return db['SalesforceField']['find']({'where':{'id':_0x154672[_0x7647('0x41')]['id']}})[_0x7647('0x20')](handleEntityNotFound(_0x22aa0d,null))['then'](saveUpdates(_0x154672['body'],null))['then'](respondWithResult(_0x22aa0d,null))[_0x7647('0x3f')](handleError(_0x22aa0d,null));};exports[_0x7647('0x21')]=function(_0x3a11e1,_0x560458){return db[_0x7647('0x3c')][_0x7647('0x44')]({'where':{'id':_0x3a11e1[_0x7647('0x41')]['id']}})[_0x7647('0x20')](handleEntityNotFound(_0x560458,null))['then'](removeEntity(_0x560458,null))[_0x7647('0x3f')](handleError(_0x560458,null));};
\ No newline at end of file
+var _0x40b2=['zip-dir','request-promise','moment','util','path','sox','ejs','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','destroy','then','error','name','send','index','fieldName','type','key','model','map','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','SalesforceField','include','catch','show','params','keys','create','body','find','rimraf'];(function(_0x1fc88a,_0x2d4c80){var _0xf8c52=function(_0x1e0975){while(--_0x1e0975){_0x1fc88a['push'](_0x1fc88a['shift']());}};_0xf8c52(++_0x2d4c80);}(_0x40b2,0x89));var _0x240b=function(_0xdea41a,_0x552987){_0xdea41a=_0xdea41a-0x0;var _0x15d0d8=_0x40b2[_0xdea41a];return _0x15d0d8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x240b('0x0'));var zipdir=require(_0x240b('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x240b('0x2'));var moment=require(_0x240b('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x240b('0x4'));var path=require(_0x240b('0x5'));var sox=require(_0x240b('0x6'));var csv=require('to-csv');var ejs=require(_0x240b('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x240b('0x8'));var jsforce=require(_0x240b('0x9'));var deskjs=require(_0x240b('0xa'));var toCsv=require(_0x240b('0xb'));var querystring=require(_0x240b('0xc'));var Papa=require(_0x240b('0xd'));var Redis=require(_0x240b('0xe'));var authService=require(_0x240b('0xf'));var qs=require(_0x240b('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x240b('0x11'))(_0x240b('0x12'));var utils=require(_0x240b('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x240b('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x325c7e,_0x158ee0){_0x158ee0=_0x158ee0||0xcc;return function(_0x2680e7){if(_0x2680e7){return _0x325c7e[_0x240b('0x15')](_0x158ee0);}return _0x325c7e[_0x240b('0x16')](_0x158ee0)[_0x240b('0x17')]();};}function respondWithResult(_0x19fc3c,_0x26a861){_0x26a861=_0x26a861||0xc8;return function(_0xb27be7){if(_0xb27be7){return _0x19fc3c['status'](_0x26a861)[_0x240b('0x18')](_0xb27be7);}};}function respondWithFilteredResult(_0x31aeeb,_0x1319ed){return function(_0x46b4e2){if(_0x46b4e2){var _0x3493d1=typeof _0x1319ed[_0x240b('0x19')]===_0x240b('0x1a')&&typeof _0x1319ed['limit']===_0x240b('0x1a');var _0x4ca035=_0x46b4e2[_0x240b('0x1b')];var _0x59a936=_0x3493d1?0x0:_0x1319ed['offset'];var _0x9daa96=_0x3493d1?_0x46b4e2['count']:_0x1319ed[_0x240b('0x19')]+_0x1319ed[_0x240b('0x1c')];var _0x47e6a7;if(_0x9daa96>=_0x4ca035){_0x9daa96=_0x4ca035;_0x47e6a7=0xc8;}else{_0x47e6a7=0xce;}_0x31aeeb[_0x240b('0x16')](_0x47e6a7);return _0x31aeeb[_0x240b('0x1d')](_0x240b('0x1e'),_0x59a936+'-'+_0x9daa96+'/'+_0x4ca035)[_0x240b('0x18')](_0x46b4e2);}return null;};}function patchUpdates(_0x47b668){return function(_0x47759c){try{jsonpatch[_0x240b('0x1f')](_0x47759c,_0x47b668,!![]);}catch(_0x119346){return BPromise[_0x240b('0x20')](_0x119346);}return _0x47759c[_0x240b('0x21')]();};}function saveUpdates(_0x5aa6e3,_0x2d5bea){return function(_0x34c356){if(_0x34c356){return _0x34c356['update'](_0x5aa6e3)['then'](function(_0x47d705){return _0x47d705;});}return null;};}function removeEntity(_0x1d48b7,_0x2b3789){return function(_0xdfcc1e){if(_0xdfcc1e){return _0xdfcc1e[_0x240b('0x22')]()[_0x240b('0x23')](function(){_0x1d48b7[_0x240b('0x16')](0xcc)[_0x240b('0x17')]();});}};}function handleEntityNotFound(_0x509e56,_0x325566){return function(_0x3e6473){if(!_0x3e6473){_0x509e56[_0x240b('0x15')](0x194);}return _0x3e6473;};}function handleError(_0x247432,_0x4109b8){_0x4109b8=_0x4109b8||0x1f4;return function(_0x101aca){logger[_0x240b('0x24')](_0x101aca['stack']);if(_0x101aca['name']){delete _0x101aca[_0x240b('0x25')];}_0x247432[_0x240b('0x16')](_0x4109b8)[_0x240b('0x26')](_0x101aca);};}exports[_0x240b('0x27')]=function(_0x4304e9,_0x1f04da){var _0x33d8fe={},_0xb6821a={},_0x4cb980={'count':0x0,'rows':[]};var _0x3c9a4f=_['map'](db['SalesforceField']['rawAttributes'],function(_0x4f67fb){return{'name':_0x4f67fb[_0x240b('0x28')],'type':_0x4f67fb[_0x240b('0x29')][_0x240b('0x2a')]};});_0xb6821a[_0x240b('0x2b')]=_[_0x240b('0x2c')](_0x3c9a4f,_0x240b('0x25'));_0xb6821a[_0x240b('0x2d')]=_['keys'](_0x4304e9[_0x240b('0x2d')]);_0xb6821a[_0x240b('0x2e')]=_['intersection'](_0xb6821a[_0x240b('0x2b')],_0xb6821a[_0x240b('0x2d')]);_0x33d8fe['attributes']=_[_0x240b('0x2f')](_0xb6821a[_0x240b('0x2b')],qs[_0x240b('0x30')](_0x4304e9[_0x240b('0x2d')][_0x240b('0x30')]));_0x33d8fe['attributes']=_0x33d8fe[_0x240b('0x31')][_0x240b('0x32')]?_0x33d8fe[_0x240b('0x31')]:_0xb6821a[_0x240b('0x2b')];if(!_0x4304e9[_0x240b('0x2d')]['hasOwnProperty'](_0x240b('0x33'))){_0x33d8fe[_0x240b('0x1c')]=qs[_0x240b('0x1c')](_0x4304e9['query'][_0x240b('0x1c')]);_0x33d8fe[_0x240b('0x19')]=qs[_0x240b('0x19')](_0x4304e9[_0x240b('0x2d')][_0x240b('0x19')]);}_0x33d8fe[_0x240b('0x34')]=qs['sort'](_0x4304e9[_0x240b('0x2d')][_0x240b('0x35')]);_0x33d8fe[_0x240b('0x36')]=qs[_0x240b('0x2e')](_[_0x240b('0x37')](_0x4304e9[_0x240b('0x2d')],_0xb6821a[_0x240b('0x2e')]),_0x3c9a4f);if(_0x4304e9[_0x240b('0x2d')][_0x240b('0x38')]){_0x33d8fe[_0x240b('0x36')]=_['merge'](_0x33d8fe[_0x240b('0x36')],{'$or':_[_0x240b('0x2c')](_0x3c9a4f,function(_0x2d0f2e){if(_0x2d0f2e[_0x240b('0x29')]!==_0x240b('0x39')){var _0x94cfe7={};_0x94cfe7[_0x2d0f2e[_0x240b('0x25')]]={'$like':'%'+_0x4304e9['query'][_0x240b('0x38')]+'%'};return _0x94cfe7;}})});}_0x33d8fe=_[_0x240b('0x3a')]({},_0x33d8fe,_0x4304e9[_0x240b('0x3b')]);var _0xb78213={'where':_0x33d8fe[_0x240b('0x36')]};return db[_0x240b('0x3c')][_0x240b('0x1b')](_0xb78213)[_0x240b('0x23')](function(_0x3766df){_0x4cb980[_0x240b('0x1b')]=_0x3766df;if(_0x4304e9[_0x240b('0x2d')]['includeAll']){_0x33d8fe[_0x240b('0x3d')]=[{'all':!![]}];}return db['SalesforceField']['findAll'](_0x33d8fe);})[_0x240b('0x23')](function(_0x1b8ef8){_0x4cb980['rows']=_0x1b8ef8;return _0x4cb980;})[_0x240b('0x23')](respondWithFilteredResult(_0x1f04da,_0x33d8fe))[_0x240b('0x3e')](handleError(_0x1f04da,null));};exports[_0x240b('0x3f')]=function(_0x3b1d9b,_0x251edb){var _0x39f345={'raw':!![],'where':{'id':_0x3b1d9b[_0x240b('0x40')]['id']}},_0x1b632b={};_0x1b632b[_0x240b('0x2b')]=_[_0x240b('0x41')](db[_0x240b('0x3c')]['rawAttributes']);_0x1b632b['query']=_[_0x240b('0x41')](_0x3b1d9b['query']);_0x1b632b['filters']=_[_0x240b('0x2f')](_0x1b632b['model'],_0x1b632b['query']);_0x39f345[_0x240b('0x31')]=_[_0x240b('0x2f')](_0x1b632b['model'],qs[_0x240b('0x30')](_0x3b1d9b[_0x240b('0x2d')][_0x240b('0x30')]));_0x39f345[_0x240b('0x31')]=_0x39f345[_0x240b('0x31')][_0x240b('0x32')]?_0x39f345[_0x240b('0x31')]:_0x1b632b[_0x240b('0x2b')];if(_0x3b1d9b[_0x240b('0x2d')]['includeAll']){_0x39f345['include']=[{'all':!![]}];}_0x39f345=_[_0x240b('0x3a')]({},_0x39f345,_0x3b1d9b[_0x240b('0x3b')]);return db[_0x240b('0x3c')]['find'](_0x39f345)[_0x240b('0x23')](handleEntityNotFound(_0x251edb,null))[_0x240b('0x23')](respondWithResult(_0x251edb,null))[_0x240b('0x3e')](handleError(_0x251edb,null));};exports[_0x240b('0x42')]=function(_0x46ed9f,_0x4177dc){return db['SalesforceField']['create'](_0x46ed9f[_0x240b('0x43')],{})['then'](respondWithResult(_0x4177dc,0xc9))[_0x240b('0x3e')](handleError(_0x4177dc,null));};exports['update']=function(_0x59cde3,_0x5d724d){if(_0x59cde3[_0x240b('0x43')]['id']){delete _0x59cde3[_0x240b('0x43')]['id'];}return db[_0x240b('0x3c')]['find']({'where':{'id':_0x59cde3[_0x240b('0x40')]['id']}})[_0x240b('0x23')](handleEntityNotFound(_0x5d724d,null))['then'](saveUpdates(_0x59cde3[_0x240b('0x43')],null))['then'](respondWithResult(_0x5d724d,null))[_0x240b('0x3e')](handleError(_0x5d724d,null));};exports[_0x240b('0x22')]=function(_0x3b272d,_0x331f5c){return db[_0x240b('0x3c')][_0x240b('0x44')]({'where':{'id':_0x3b272d[_0x240b('0x40')]['id']}})[_0x240b('0x23')](handleEntityNotFound(_0x331f5c,null))[_0x240b('0x23')](removeEntity(_0x331f5c,null))['catch'](handleError(_0x331f5c,null));};
\ No newline at end of file