Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index decb339..99aa601 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+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