Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 125817c..decb339 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f2f=['set','Content-Range','apply','reject','save','update','destroy','end','error','stack','name','send','index','map','fieldName','type','query','keys','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','VIRTUAL','SalesforceField','then','include','rows','catch','show','params','intersection','options','find','create','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','sendStatus','status','json','count','offset','limit'];(function(_0x1e06c4,_0x53ae54){var _0x1f313c=function(_0xd614){while(--_0xd614){_0x1e06c4['push'](_0x1e06c4['shift']());}};_0x1f313c(++_0x53ae54);}(_0x5f2f,0x73));var _0xf5f2=function(_0x407aa0,_0x5ea282){_0x407aa0=_0x407aa0-0x0;var _0x117c8d=_0x5f2f[_0x407aa0];return _0x117c8d;};'use strict';var pdf=require(_0xf5f2('0x0'));var emlformat=require(_0xf5f2('0x1'));var rimraf=require(_0xf5f2('0x2'));var zipdir=require(_0xf5f2('0x3'));var jsonpatch=require(_0xf5f2('0x4'));var rp=require(_0xf5f2('0x5'));var moment=require(_0xf5f2('0x6'));var BPromise=require(_0xf5f2('0x7'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf5f2('0x8'));var sox=require(_0xf5f2('0x9'));var csv=require(_0xf5f2('0xa'));var ejs=require(_0xf5f2('0xb'));var fs=require('fs');var _=require(_0xf5f2('0xc'));var squel=require(_0xf5f2('0xd'));var crypto=require('crypto');var jsforce=require(_0xf5f2('0xe'));var deskjs=require(_0xf5f2('0xf'));var toCsv=require(_0xf5f2('0xa'));var querystring=require('querystring');var Papa=require(_0xf5f2('0x10'));var Redis=require(_0xf5f2('0x11'));var authService=require(_0xf5f2('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf5f2('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf5f2('0x14'));var utils=require(_0xf5f2('0x15'));var config=require('../../config/environment');var db=require(_0xf5f2('0x16'))['db'];function respondWithStatusCode(_0x14b51f,_0x331482){_0x331482=_0x331482||0xcc;return function(_0x3f2997){if(_0x3f2997){return _0x14b51f[_0xf5f2('0x17')](_0x331482);}return _0x14b51f[_0xf5f2('0x18')](_0x331482)['end']();};}function respondWithResult(_0x5850f4,_0xea612c){_0xea612c=_0xea612c||0xc8;return function(_0x269909){if(_0x269909){return _0x5850f4[_0xf5f2('0x18')](_0xea612c)[_0xf5f2('0x19')](_0x269909);}};}function respondWithFilteredResult(_0x4d97fc,_0xafe430){return function(_0x286197){if(_0x286197){var _0x17d656=_0x286197[_0xf5f2('0x1a')],_0x1b6dd2=_0xafe430[_0xf5f2('0x1b')],_0x23e23a=_0xafe430[_0xf5f2('0x1b')]+_0xafe430[_0xf5f2('0x1c')],_0x3a9dbb;if(_0x23e23a>=_0x17d656){_0x23e23a=_0x17d656;_0x3a9dbb=0xc8;}else{_0x3a9dbb=0xce;}_0x4d97fc[_0xf5f2('0x18')](_0x3a9dbb);return _0x4d97fc[_0xf5f2('0x1d')](_0xf5f2('0x1e'),_0x1b6dd2+'-'+_0x23e23a+'/'+_0x17d656)[_0xf5f2('0x19')](_0x286197);}return null;};}function patchUpdates(_0x3cf5ea){return function(_0x626999){try{jsonpatch[_0xf5f2('0x1f')](_0x626999,_0x3cf5ea,!![]);}catch(_0x56acc5){return BPromise[_0xf5f2('0x20')](_0x56acc5);}return _0x626999[_0xf5f2('0x21')]();};}function saveUpdates(_0x49dac2,_0x47acfc){return function(_0x2d2805){if(_0x2d2805){return _0x2d2805[_0xf5f2('0x22')](_0x49dac2)['then'](function(_0x45b74f){return _0x45b74f;});}return null;};}function removeEntity(_0x170042,_0x39e44a){return function(_0x39c024){if(_0x39c024){return _0x39c024[_0xf5f2('0x23')]()['then'](function(){_0x170042[_0xf5f2('0x18')](0xcc)[_0xf5f2('0x24')]();});}};}function handleEntityNotFound(_0x4e8bda,_0x2833fe){return function(_0x287ad5){if(!_0x287ad5){_0x4e8bda['sendStatus'](0x194);}return _0x287ad5;};}function handleError(_0x529f07,_0x5f1124){_0x5f1124=_0x5f1124||0x1f4;return function(_0x3f79d5){logger[_0xf5f2('0x25')](_0x3f79d5[_0xf5f2('0x26')]);if(_0x3f79d5[_0xf5f2('0x27')]){delete _0x3f79d5[_0xf5f2('0x27')];}_0x529f07[_0xf5f2('0x18')](_0x5f1124)[_0xf5f2('0x28')](_0x3f79d5);};}exports[_0xf5f2('0x29')]=function(_0x4ab014,_0xaa2602){var _0x102449={},_0x375ca8={},_0x31bfcb={'count':0x0,'rows':[]};var _0x198c73=_[_0xf5f2('0x2a')](db['SalesforceField']['rawAttributes'],function(_0x22c826){return{'name':_0x22c826[_0xf5f2('0x2b')],'type':_0x22c826[_0xf5f2('0x2c')]['key']};});_0x375ca8['model']=_[_0xf5f2('0x2a')](_0x198c73,_0xf5f2('0x27'));_0x375ca8[_0xf5f2('0x2d')]=_[_0xf5f2('0x2e')](_0x4ab014[_0xf5f2('0x2d')]);_0x375ca8['filters']=_['intersection'](_0x375ca8[_0xf5f2('0x2f')],_0x375ca8['query']);_0x102449[_0xf5f2('0x30')]=_['intersection'](_0x375ca8[_0xf5f2('0x2f')],qs[_0xf5f2('0x31')](_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x31')]));_0x102449[_0xf5f2('0x30')]=_0x102449[_0xf5f2('0x30')][_0xf5f2('0x32')]?_0x102449[_0xf5f2('0x30')]:_0x375ca8['model'];if(!_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x33')](_0xf5f2('0x34'))){_0x102449[_0xf5f2('0x1c')]=qs[_0xf5f2('0x1c')](_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x1c')]);_0x102449['offset']=qs[_0xf5f2('0x1b')](_0x4ab014[_0xf5f2('0x2d')]['offset']);}_0x102449[_0xf5f2('0x35')]=qs['sort'](_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x36')]);_0x102449[_0xf5f2('0x37')]=qs[_0xf5f2('0x38')](_['pick'](_0x4ab014['query'],_0x375ca8[_0xf5f2('0x38')]));if(_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x39')]){_0x102449['where']=_[_0xf5f2('0x3a')](_0x102449['where'],{'$or':_[_0xf5f2('0x2a')](_0x198c73,function(_0x566c47){if(_0x566c47[_0xf5f2('0x2c')]!==_0xf5f2('0x3b')){var _0x5337a6={};_0x5337a6[_0x566c47[_0xf5f2('0x27')]]={'$like':'%'+_0x4ab014[_0xf5f2('0x2d')][_0xf5f2('0x39')]+'%'};return _0x5337a6;}})});}_0x102449=_[_0xf5f2('0x3a')]({},_0x102449,_0x4ab014['options']);var _0x5d2d82={'where':_0x102449[_0xf5f2('0x37')]};return db[_0xf5f2('0x3c')][_0xf5f2('0x1a')](_0x5d2d82)[_0xf5f2('0x3d')](function(_0x2c7f65){_0x31bfcb[_0xf5f2('0x1a')]=_0x2c7f65;if(_0x4ab014[_0xf5f2('0x2d')]['includeAll']){_0x102449[_0xf5f2('0x3e')]=[{'all':!![]}];}return db[_0xf5f2('0x3c')]['findAll'](_0x102449);})[_0xf5f2('0x3d')](function(_0x3f3895){_0x31bfcb[_0xf5f2('0x3f')]=_0x3f3895;return _0x31bfcb;})[_0xf5f2('0x3d')](respondWithFilteredResult(_0xaa2602,_0x102449))[_0xf5f2('0x40')](handleError(_0xaa2602,null));};exports[_0xf5f2('0x41')]=function(_0x462ea3,_0x2083b3){var _0x574f24={'raw':!![],'where':{'id':_0x462ea3[_0xf5f2('0x42')]['id']}},_0x31c3c={};_0x31c3c[_0xf5f2('0x2f')]=_['keys'](db['SalesforceField']['rawAttributes']);_0x31c3c[_0xf5f2('0x2d')]=_[_0xf5f2('0x2e')](_0x462ea3['query']);_0x31c3c[_0xf5f2('0x38')]=_[_0xf5f2('0x43')](_0x31c3c[_0xf5f2('0x2f')],_0x31c3c[_0xf5f2('0x2d')]);_0x574f24[_0xf5f2('0x30')]=_[_0xf5f2('0x43')](_0x31c3c[_0xf5f2('0x2f')],qs[_0xf5f2('0x31')](_0x462ea3[_0xf5f2('0x2d')][_0xf5f2('0x31')]));_0x574f24[_0xf5f2('0x30')]=_0x574f24[_0xf5f2('0x30')][_0xf5f2('0x32')]?_0x574f24[_0xf5f2('0x30')]:_0x31c3c['model'];if(_0x462ea3[_0xf5f2('0x2d')]['includeAll']){_0x574f24[_0xf5f2('0x3e')]=[{'all':!![]}];}_0x574f24=_[_0xf5f2('0x3a')]({},_0x574f24,_0x462ea3[_0xf5f2('0x44')]);return db[_0xf5f2('0x3c')][_0xf5f2('0x45')](_0x574f24)[_0xf5f2('0x3d')](handleEntityNotFound(_0x2083b3,null))['then'](respondWithResult(_0x2083b3,null))[_0xf5f2('0x40')](handleError(_0x2083b3,null));};exports[_0xf5f2('0x46')]=function(_0x1c1497,_0x29b108){return db[_0xf5f2('0x3c')][_0xf5f2('0x46')](_0x1c1497[_0xf5f2('0x47')],{})[_0xf5f2('0x3d')](respondWithResult(_0x29b108,0xc9))['catch'](handleError(_0x29b108,null));};exports[_0xf5f2('0x22')]=function(_0x33ec29,_0x45db9a){if(_0x33ec29['body']['id']){delete _0x33ec29[_0xf5f2('0x47')]['id'];}return db[_0xf5f2('0x3c')][_0xf5f2('0x45')]({'where':{'id':_0x33ec29['params']['id']}})['then'](handleEntityNotFound(_0x45db9a,null))[_0xf5f2('0x3d')](saveUpdates(_0x33ec29[_0xf5f2('0x47')],null))['then'](respondWithResult(_0x45db9a,null))[_0xf5f2('0x40')](handleError(_0x45db9a,null));};exports['destroy']=function(_0x740321,_0x497eb8){return db[_0xf5f2('0x3c')]['find']({'where':{'id':_0x740321[_0xf5f2('0x42')]['id']}})[_0xf5f2('0x3d')](handleEntityNotFound(_0x497eb8,null))[_0xf5f2('0x3d')](removeEntity(_0x497eb8,null))[_0xf5f2('0x40')](handleError(_0x497eb8,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