Built motion from commit fe909640.|2.6.8
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 619abf8..715b2a5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8ae=['moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/environment','../../mysqldb','json','offset','undefined','limit','count','status','set','Content-Range','reject','save','update','then','sendStatus','error','stack','name','send','index','map','SalesforceField','rawAttributes','fieldName','query','keys','filters','intersection','attributes','fields','length','model','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','includeAll','rows','catch','params','find','body','destroy','rimraf','request-promise'];(function(_0x1777d2,_0x384362){var _0x5f0a94=function(_0x202529){while(--_0x202529){_0x1777d2['push'](_0x1777d2['shift']());}};_0x5f0a94(++_0x384362);}(_0xb8ae,0x8a));var _0xeb8a=function(_0x2aea9e,_0x1f587f){_0x2aea9e=_0x2aea9e-0x0;var _0x430b92=_0xb8ae[_0x2aea9e];return _0x430b92;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xeb8a('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xeb8a('0x1'));var moment=require(_0xeb8a('0x2'));var BPromise=require(_0xeb8a('0x3'));var Mustache=require(_0xeb8a('0x4'));var util=require(_0xeb8a('0x5'));var path=require(_0xeb8a('0x6'));var sox=require(_0xeb8a('0x7'));var csv=require(_0xeb8a('0x8'));var ejs=require(_0xeb8a('0x9'));var fs=require('fs');var fs_extra=require(_0xeb8a('0xa'));var _=require(_0xeb8a('0xb'));var squel=require(_0xeb8a('0xc'));var crypto=require(_0xeb8a('0xd'));var jsforce=require(_0xeb8a('0xe'));var deskjs=require(_0xeb8a('0xf'));var toCsv=require(_0xeb8a('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xeb8a('0x10'));var qs=require(_0xeb8a('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeb8a('0x12'));var logger=require('../../config/logger')(_0xeb8a('0x13'));var utils=require('../../config/utils');var config=require(_0xeb8a('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xeb8a('0x15'))['db'];function respondWithStatusCode(_0x245824,_0x53d432){_0x53d432=_0x53d432||0xcc;return function(_0x2f3fc9){if(_0x2f3fc9){return _0x245824['sendStatus'](_0x53d432);}return _0x245824['status'](_0x53d432)['end']();};}function respondWithResult(_0xc3c516,_0x1075bf){_0x1075bf=_0x1075bf||0xc8;return function(_0x4ece45){if(_0x4ece45){return _0xc3c516['status'](_0x1075bf)[_0xeb8a('0x16')](_0x4ece45);}};}function respondWithFilteredResult(_0x466b97,_0x57aa41){return function(_0x3d19a0){if(_0x3d19a0){var _0xa7a086=typeof _0x57aa41[_0xeb8a('0x17')]===_0xeb8a('0x18')&&typeof _0x57aa41[_0xeb8a('0x19')]===_0xeb8a('0x18');var _0x25c213=_0x3d19a0[_0xeb8a('0x1a')];var _0x3af4be=_0xa7a086?0x0:_0x57aa41[_0xeb8a('0x17')];var _0x2eb5f0=_0xa7a086?_0x3d19a0['count']:_0x57aa41[_0xeb8a('0x17')]+_0x57aa41['limit'];var _0x33659c;if(_0x2eb5f0>=_0x25c213){_0x2eb5f0=_0x25c213;_0x33659c=0xc8;}else{_0x33659c=0xce;}_0x466b97[_0xeb8a('0x1b')](_0x33659c);return _0x466b97[_0xeb8a('0x1c')](_0xeb8a('0x1d'),_0x3af4be+'-'+_0x2eb5f0+'/'+_0x25c213)[_0xeb8a('0x16')](_0x3d19a0);}return null;};}function patchUpdates(_0x5c8734){return function(_0x9019ea){try{jsonpatch['apply'](_0x9019ea,_0x5c8734,!![]);}catch(_0x4c8a50){return BPromise[_0xeb8a('0x1e')](_0x4c8a50);}return _0x9019ea[_0xeb8a('0x1f')]();};}function saveUpdates(_0x2c3653,_0x406edb){return function(_0x351c1a){if(_0x351c1a){return _0x351c1a[_0xeb8a('0x20')](_0x2c3653)[_0xeb8a('0x21')](function(_0x3fc1fb){return _0x3fc1fb;});}return null;};}function removeEntity(_0xb7ba1f,_0x5ca26a){return function(_0x514897){if(_0x514897){return _0x514897['destroy']()[_0xeb8a('0x21')](function(){_0xb7ba1f[_0xeb8a('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0xa8baeb,_0x2410cd){return function(_0x2fc7e4){if(!_0x2fc7e4){_0xa8baeb[_0xeb8a('0x22')](0x194);}return _0x2fc7e4;};}function handleError(_0x4821d1,_0x20ddf7){_0x20ddf7=_0x20ddf7||0x1f4;return function(_0x1dfa3a){logger[_0xeb8a('0x23')](_0x1dfa3a[_0xeb8a('0x24')]);if(_0x1dfa3a[_0xeb8a('0x25')]){delete _0x1dfa3a[_0xeb8a('0x25')];}_0x4821d1['status'](_0x20ddf7)[_0xeb8a('0x26')](_0x1dfa3a);};}exports[_0xeb8a('0x27')]=function(_0x13e10b,_0x288e5b){var _0x4dba7a={},_0x442d62={},_0x558e01={'count':0x0,'rows':[]};var _0x2041d3=_[_0xeb8a('0x28')](db[_0xeb8a('0x29')][_0xeb8a('0x2a')],function(_0x44beb8){return{'name':_0x44beb8[_0xeb8a('0x2b')],'type':_0x44beb8['type']['key']};});_0x442d62['model']=_[_0xeb8a('0x28')](_0x2041d3,_0xeb8a('0x25'));_0x442d62[_0xeb8a('0x2c')]=_[_0xeb8a('0x2d')](_0x13e10b[_0xeb8a('0x2c')]);_0x442d62[_0xeb8a('0x2e')]=_[_0xeb8a('0x2f')](_0x442d62['model'],_0x442d62[_0xeb8a('0x2c')]);_0x4dba7a[_0xeb8a('0x30')]=_[_0xeb8a('0x2f')](_0x442d62['model'],qs[_0xeb8a('0x31')](_0x13e10b[_0xeb8a('0x2c')][_0xeb8a('0x31')]));_0x4dba7a[_0xeb8a('0x30')]=_0x4dba7a[_0xeb8a('0x30')][_0xeb8a('0x32')]?_0x4dba7a['attributes']:_0x442d62[_0xeb8a('0x33')];if(!_0x13e10b['query'][_0xeb8a('0x34')](_0xeb8a('0x35'))){_0x4dba7a['limit']=qs[_0xeb8a('0x19')](_0x13e10b['query'][_0xeb8a('0x19')]);_0x4dba7a['offset']=qs[_0xeb8a('0x17')](_0x13e10b[_0xeb8a('0x2c')]['offset']);}_0x4dba7a[_0xeb8a('0x36')]=qs[_0xeb8a('0x37')](_0x13e10b[_0xeb8a('0x2c')][_0xeb8a('0x37')]);_0x4dba7a['where']=qs[_0xeb8a('0x2e')](_[_0xeb8a('0x38')](_0x13e10b[_0xeb8a('0x2c')],_0x442d62[_0xeb8a('0x2e')]),_0x2041d3);if(_0x13e10b['query'][_0xeb8a('0x39')]){_0x4dba7a[_0xeb8a('0x3a')]=_[_0xeb8a('0x3b')](_0x4dba7a[_0xeb8a('0x3a')],{'$or':_[_0xeb8a('0x28')](_0x2041d3,function(_0x5b76d3){if(_0x5b76d3[_0xeb8a('0x3c')]!==_0xeb8a('0x3d')){var _0xfe0fea={};_0xfe0fea[_0x5b76d3['name']]={'$like':'%'+_0x13e10b[_0xeb8a('0x2c')]['filter']+'%'};return _0xfe0fea;}})});}_0x4dba7a=_[_0xeb8a('0x3b')]({},_0x4dba7a,_0x13e10b[_0xeb8a('0x3e')]);var _0x407c34={'where':_0x4dba7a[_0xeb8a('0x3a')]};return db[_0xeb8a('0x29')][_0xeb8a('0x1a')](_0x407c34)[_0xeb8a('0x21')](function(_0x5b0500){_0x558e01[_0xeb8a('0x1a')]=_0x5b0500;if(_0x13e10b['query'][_0xeb8a('0x3f')]){_0x4dba7a['include']=[{'all':!![]}];}return db[_0xeb8a('0x29')]['findAll'](_0x4dba7a);})['then'](function(_0x434e10){_0x558e01[_0xeb8a('0x40')]=_0x434e10;return _0x558e01;})[_0xeb8a('0x21')](respondWithFilteredResult(_0x288e5b,_0x4dba7a))[_0xeb8a('0x41')](handleError(_0x288e5b,null));};exports['show']=function(_0x52ba23,_0x33e9e5){var _0x1c8d23={'raw':!![],'where':{'id':_0x52ba23[_0xeb8a('0x42')]['id']}},_0x348991={};_0x348991[_0xeb8a('0x33')]=_[_0xeb8a('0x2d')](db[_0xeb8a('0x29')][_0xeb8a('0x2a')]);_0x348991[_0xeb8a('0x2c')]=_[_0xeb8a('0x2d')](_0x52ba23[_0xeb8a('0x2c')]);_0x348991[_0xeb8a('0x2e')]=_[_0xeb8a('0x2f')](_0x348991['model'],_0x348991['query']);_0x1c8d23[_0xeb8a('0x30')]=_[_0xeb8a('0x2f')](_0x348991['model'],qs[_0xeb8a('0x31')](_0x52ba23[_0xeb8a('0x2c')][_0xeb8a('0x31')]));_0x1c8d23['attributes']=_0x1c8d23[_0xeb8a('0x30')][_0xeb8a('0x32')]?_0x1c8d23['attributes']:_0x348991[_0xeb8a('0x33')];if(_0x52ba23[_0xeb8a('0x2c')][_0xeb8a('0x3f')]){_0x1c8d23['include']=[{'all':!![]}];}_0x1c8d23=_[_0xeb8a('0x3b')]({},_0x1c8d23,_0x52ba23[_0xeb8a('0x3e')]);return db['SalesforceField'][_0xeb8a('0x43')](_0x1c8d23)['then'](handleEntityNotFound(_0x33e9e5,null))[_0xeb8a('0x21')](respondWithResult(_0x33e9e5,null))['catch'](handleError(_0x33e9e5,null));};exports['create']=function(_0x49ffef,_0x1056f9){return db[_0xeb8a('0x29')]['create'](_0x49ffef[_0xeb8a('0x44')],{})['then'](respondWithResult(_0x1056f9,0xc9))[_0xeb8a('0x41')](handleError(_0x1056f9,null));};exports['update']=function(_0x5d7a26,_0x3b78b5){if(_0x5d7a26['body']['id']){delete _0x5d7a26[_0xeb8a('0x44')]['id'];}return db[_0xeb8a('0x29')][_0xeb8a('0x43')]({'where':{'id':_0x5d7a26[_0xeb8a('0x42')]['id']}})[_0xeb8a('0x21')](handleEntityNotFound(_0x3b78b5,null))[_0xeb8a('0x21')](saveUpdates(_0x5d7a26['body'],null))[_0xeb8a('0x21')](respondWithResult(_0x3b78b5,null))['catch'](handleError(_0x3b78b5,null));};exports[_0xeb8a('0x45')]=function(_0x6113e4,_0x296abd){return db[_0xeb8a('0x29')]['find']({'where':{'id':_0x6113e4['params']['id']}})[_0xeb8a('0x21')](handleEntityNotFound(_0x296abd,null))[_0xeb8a('0x21')](removeEntity(_0x296abd,null))[_0xeb8a('0x41')](handleError(_0x296abd,null));};
\ No newline at end of file
+var _0x1316=['../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','offset','limit','count','status','Content-Range','json','apply','save','update','then','destroy','stack','name','send','index','map','SalesforceField','rawAttributes','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','sort','where','filters','pick','filter','merge','type','VIRTUAL','includeAll','include','findAll','catch','params','options','find','create','body','eml-format','zip-dir','request-promise','moment','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api'];(function(_0x28f2f1,_0x5844b7){var _0x574934=function(_0x48eff6){while(--_0x48eff6){_0x28f2f1['push'](_0x28f2f1['shift']());}};_0x574934(++_0x5844b7);}(_0x1316,0x109));var _0x6131=function(_0x4e08da,_0x596944){_0x4e08da=_0x4e08da-0x0;var _0x2193f0=_0x1316[_0x4e08da];return _0x2193f0;};'use strict';var emlformat=require(_0x6131('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x6131('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6131('0x2'));var moment=require(_0x6131('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x6131('0x4'));var util=require('util');var path=require(_0x6131('0x5'));var sox=require(_0x6131('0x6'));var csv=require(_0x6131('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6131('0x8'));var _=require(_0x6131('0x9'));var squel=require(_0x6131('0xa'));var crypto=require(_0x6131('0xb'));var jsforce=require(_0x6131('0xc'));var deskjs=require(_0x6131('0xd'));var toCsv=require(_0x6131('0x7'));var querystring=require(_0x6131('0xe'));var Papa=require(_0x6131('0xf'));var Redis=require(_0x6131('0x10'));var authService=require(_0x6131('0x11'));var qs=require(_0x6131('0x12'));var as=require(_0x6131('0x13'));var hardwareService=require(_0x6131('0x14'));var logger=require(_0x6131('0x15'))(_0x6131('0x16'));var utils=require(_0x6131('0x17'));var config=require(_0x6131('0x18'));var licenseUtil=require(_0x6131('0x19'));var db=require(_0x6131('0x1a'))['db'];function respondWithStatusCode(_0x34c599,_0x4626f6){_0x4626f6=_0x4626f6||0xcc;return function(_0x5f3a92){if(_0x5f3a92){return _0x34c599[_0x6131('0x1b')](_0x4626f6);}return _0x34c599['status'](_0x4626f6)[_0x6131('0x1c')]();};}function respondWithResult(_0xa0acfa,_0x19f904){_0x19f904=_0x19f904||0xc8;return function(_0x46e9da){if(_0x46e9da){return _0xa0acfa['status'](_0x19f904)['json'](_0x46e9da);}};}function respondWithFilteredResult(_0x76b575,_0x2b2396){return function(_0x27e595){if(_0x27e595){var _0x820eb6=typeof _0x2b2396[_0x6131('0x1d')]==='undefined'&&typeof _0x2b2396[_0x6131('0x1e')]==='undefined';var _0x10d0f5=_0x27e595[_0x6131('0x1f')];var _0x340340=_0x820eb6?0x0:_0x2b2396[_0x6131('0x1d')];var _0x137ee1=_0x820eb6?_0x27e595[_0x6131('0x1f')]:_0x2b2396[_0x6131('0x1d')]+_0x2b2396[_0x6131('0x1e')];var _0x5321e6;if(_0x137ee1>=_0x10d0f5){_0x137ee1=_0x10d0f5;_0x5321e6=0xc8;}else{_0x5321e6=0xce;}_0x76b575[_0x6131('0x20')](_0x5321e6);return _0x76b575['set'](_0x6131('0x21'),_0x340340+'-'+_0x137ee1+'/'+_0x10d0f5)[_0x6131('0x22')](_0x27e595);}return null;};}function patchUpdates(_0x56594b){return function(_0x1d53ac){try{jsonpatch[_0x6131('0x23')](_0x1d53ac,_0x56594b,!![]);}catch(_0x5cf1da){return BPromise['reject'](_0x5cf1da);}return _0x1d53ac[_0x6131('0x24')]();};}function saveUpdates(_0x3f250e,_0xc0c731){return function(_0x20f871){if(_0x20f871){return _0x20f871[_0x6131('0x25')](_0x3f250e)[_0x6131('0x26')](function(_0x5ddd88){return _0x5ddd88;});}return null;};}function removeEntity(_0x4a2fae,_0x1ba605){return function(_0x4bae01){if(_0x4bae01){return _0x4bae01[_0x6131('0x27')]()[_0x6131('0x26')](function(){_0x4a2fae[_0x6131('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3c358e,_0x3a3a21){return function(_0x3fc366){if(!_0x3fc366){_0x3c358e[_0x6131('0x1b')](0x194);}return _0x3fc366;};}function handleError(_0x2a23ff,_0x1b8b8d){_0x1b8b8d=_0x1b8b8d||0x1f4;return function(_0x4da4cc){logger['error'](_0x4da4cc[_0x6131('0x28')]);if(_0x4da4cc[_0x6131('0x29')]){delete _0x4da4cc[_0x6131('0x29')];}_0x2a23ff[_0x6131('0x20')](_0x1b8b8d)[_0x6131('0x2a')](_0x4da4cc);};}exports[_0x6131('0x2b')]=function(_0x23ae3c,_0x1d0e7f){var _0x1465f1={},_0x49862f={},_0x11b4c7={'count':0x0,'rows':[]};var _0x471ceb=_[_0x6131('0x2c')](db[_0x6131('0x2d')][_0x6131('0x2e')],function(_0x5f2fcf){return{'name':_0x5f2fcf['fieldName'],'type':_0x5f2fcf['type']['key']};});_0x49862f[_0x6131('0x2f')]=_['map'](_0x471ceb,_0x6131('0x29'));_0x49862f['query']=_[_0x6131('0x30')](_0x23ae3c[_0x6131('0x31')]);_0x49862f['filters']=_[_0x6131('0x32')](_0x49862f[_0x6131('0x2f')],_0x49862f['query']);_0x1465f1[_0x6131('0x33')]=_[_0x6131('0x32')](_0x49862f[_0x6131('0x2f')],qs['fields'](_0x23ae3c['query'][_0x6131('0x34')]));_0x1465f1['attributes']=_0x1465f1['attributes'][_0x6131('0x35')]?_0x1465f1['attributes']:_0x49862f[_0x6131('0x2f')];if(!_0x23ae3c[_0x6131('0x31')][_0x6131('0x36')]('nolimit')){_0x1465f1[_0x6131('0x1e')]=qs[_0x6131('0x1e')](_0x23ae3c[_0x6131('0x31')]['limit']);_0x1465f1['offset']=qs[_0x6131('0x1d')](_0x23ae3c[_0x6131('0x31')][_0x6131('0x1d')]);}_0x1465f1['order']=qs[_0x6131('0x37')](_0x23ae3c['query'][_0x6131('0x37')]);_0x1465f1[_0x6131('0x38')]=qs[_0x6131('0x39')](_[_0x6131('0x3a')](_0x23ae3c[_0x6131('0x31')],_0x49862f[_0x6131('0x39')]),_0x471ceb);if(_0x23ae3c[_0x6131('0x31')][_0x6131('0x3b')]){_0x1465f1[_0x6131('0x38')]=_[_0x6131('0x3c')](_0x1465f1['where'],{'$or':_['map'](_0x471ceb,function(_0xc6b622){if(_0xc6b622[_0x6131('0x3d')]!==_0x6131('0x3e')){var _0x4b1bd2={};_0x4b1bd2[_0xc6b622[_0x6131('0x29')]]={'$like':'%'+_0x23ae3c['query']['filter']+'%'};return _0x4b1bd2;}})});}_0x1465f1=_[_0x6131('0x3c')]({},_0x1465f1,_0x23ae3c['options']);var _0x383872={'where':_0x1465f1['where']};return db['SalesforceField']['count'](_0x383872)[_0x6131('0x26')](function(_0x4ef826){_0x11b4c7[_0x6131('0x1f')]=_0x4ef826;if(_0x23ae3c[_0x6131('0x31')][_0x6131('0x3f')]){_0x1465f1[_0x6131('0x40')]=[{'all':!![]}];}return db[_0x6131('0x2d')][_0x6131('0x41')](_0x1465f1);})['then'](function(_0xebf2b5){_0x11b4c7['rows']=_0xebf2b5;return _0x11b4c7;})[_0x6131('0x26')](respondWithFilteredResult(_0x1d0e7f,_0x1465f1))[_0x6131('0x42')](handleError(_0x1d0e7f,null));};exports['show']=function(_0x3e0d7f,_0x444a12){var _0x2874b3={'raw':!![],'where':{'id':_0x3e0d7f[_0x6131('0x43')]['id']}},_0x5be069={};_0x5be069['model']=_[_0x6131('0x30')](db['SalesforceField']['rawAttributes']);_0x5be069[_0x6131('0x31')]=_['keys'](_0x3e0d7f[_0x6131('0x31')]);_0x5be069[_0x6131('0x39')]=_[_0x6131('0x32')](_0x5be069[_0x6131('0x2f')],_0x5be069['query']);_0x2874b3[_0x6131('0x33')]=_[_0x6131('0x32')](_0x5be069[_0x6131('0x2f')],qs[_0x6131('0x34')](_0x3e0d7f[_0x6131('0x31')][_0x6131('0x34')]));_0x2874b3[_0x6131('0x33')]=_0x2874b3[_0x6131('0x33')][_0x6131('0x35')]?_0x2874b3[_0x6131('0x33')]:_0x5be069[_0x6131('0x2f')];if(_0x3e0d7f[_0x6131('0x31')][_0x6131('0x3f')]){_0x2874b3[_0x6131('0x40')]=[{'all':!![]}];}_0x2874b3=_[_0x6131('0x3c')]({},_0x2874b3,_0x3e0d7f[_0x6131('0x44')]);return db[_0x6131('0x2d')][_0x6131('0x45')](_0x2874b3)[_0x6131('0x26')](handleEntityNotFound(_0x444a12,null))[_0x6131('0x26')](respondWithResult(_0x444a12,null))[_0x6131('0x42')](handleError(_0x444a12,null));};exports[_0x6131('0x46')]=function(_0x3c20c1,_0x48d143){return db[_0x6131('0x2d')][_0x6131('0x46')](_0x3c20c1[_0x6131('0x47')],{})['then'](respondWithResult(_0x48d143,0xc9))[_0x6131('0x42')](handleError(_0x48d143,null));};exports['update']=function(_0x367101,_0x2c4333){if(_0x367101[_0x6131('0x47')]['id']){delete _0x367101['body']['id'];}return db[_0x6131('0x2d')][_0x6131('0x45')]({'where':{'id':_0x367101[_0x6131('0x43')]['id']}})[_0x6131('0x26')](handleEntityNotFound(_0x2c4333,null))['then'](saveUpdates(_0x367101[_0x6131('0x47')],null))[_0x6131('0x26')](respondWithResult(_0x2c4333,null))[_0x6131('0x42')](handleError(_0x2c4333,null));};exports[_0x6131('0x27')]=function(_0x264df5,_0x33f048){return db['SalesforceField'][_0x6131('0x45')]({'where':{'id':_0x264df5[_0x6131('0x43')]['id']}})[_0x6131('0x26')](handleEntityNotFound(_0x33f048,null))['then'](removeEntity(_0x33f048,null))[_0x6131('0x42')](handleError(_0x33f048,null));};
\ No newline at end of file