Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / api / intSalesforceField / intSalesforceField.controller.js
index 125817c..02adb77 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 _0x57e1=['key','model','map','query','keys','filters','attributes','intersection','fields','hasOwnProperty','order','sort','where','pick','filter','merge','options','includeAll','include','catch','show','params','length','find','create','update','body','destroy','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','limit','count','set','reject','then','sendStatus','error','stack','name','send','index','SalesforceField','rawAttributes','fieldName','type'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x57e1,0x17a));var _0x157e=function(_0x214185,_0x2d96bf){_0x214185=_0x214185-0x0;var _0x34abeb=_0x57e1[_0x214185];return _0x34abeb;};'use strict';var emlformat=require(_0x157e('0x0'));var rimraf=require(_0x157e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x157e('0x2'));var rp=require(_0x157e('0x3'));var moment=require(_0x157e('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x157e('0x5'));var util=require(_0x157e('0x6'));var path=require(_0x157e('0x7'));var sox=require(_0x157e('0x8'));var csv=require(_0x157e('0x9'));var ejs=require(_0x157e('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x157e('0xb'));var squel=require('squel');var crypto=require(_0x157e('0xc'));var jsforce=require(_0x157e('0xd'));var deskjs=require(_0x157e('0xe'));var toCsv=require(_0x157e('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x157e('0xf'));var qs=require(_0x157e('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x157e('0x11'));var logger=require(_0x157e('0x12'))('api');var utils=require(_0x157e('0x13'));var config=require(_0x157e('0x14'));var licenseUtil=require(_0x157e('0x15'));var db=require(_0x157e('0x16'))['db'];function respondWithStatusCode(_0x3d78f4,_0x19a1f8){_0x19a1f8=_0x19a1f8||0xcc;return function(_0xda02f1){if(_0xda02f1){return _0x3d78f4['sendStatus'](_0x19a1f8);}return _0x3d78f4[_0x157e('0x17')](_0x19a1f8)[_0x157e('0x18')]();};}function respondWithResult(_0x372e5d,_0xd0344a){_0xd0344a=_0xd0344a||0xc8;return function(_0x5aeabc){if(_0x5aeabc){return _0x372e5d['status'](_0xd0344a)[_0x157e('0x19')](_0x5aeabc);}};}function respondWithFilteredResult(_0x509237,_0x30a45d){return function(_0x53b864){if(_0x53b864){var _0x49ddff=typeof _0x30a45d[_0x157e('0x1a')]==='undefined'&&typeof _0x30a45d[_0x157e('0x1b')]==='undefined';var _0x1f5024=_0x53b864['count'];var _0x45defc=_0x49ddff?0x0:_0x30a45d[_0x157e('0x1a')];var _0x3405e5=_0x49ddff?_0x53b864[_0x157e('0x1c')]:_0x30a45d[_0x157e('0x1a')]+_0x30a45d['limit'];var _0x5f24bd;if(_0x3405e5>=_0x1f5024){_0x3405e5=_0x1f5024;_0x5f24bd=0xc8;}else{_0x5f24bd=0xce;}_0x509237['status'](_0x5f24bd);return _0x509237[_0x157e('0x1d')]('Content-Range',_0x45defc+'-'+_0x3405e5+'/'+_0x1f5024)['json'](_0x53b864);}return null;};}function patchUpdates(_0x315a1f){return function(_0x212947){try{jsonpatch['apply'](_0x212947,_0x315a1f,!![]);}catch(_0x2cb2c4){return BPromise[_0x157e('0x1e')](_0x2cb2c4);}return _0x212947['save']();};}function saveUpdates(_0x1a23d1,_0x31555f){return function(_0x578fba){if(_0x578fba){return _0x578fba['update'](_0x1a23d1)[_0x157e('0x1f')](function(_0x329c94){return _0x329c94;});}return null;};}function removeEntity(_0x3346c6,_0x4dc73c){return function(_0x2bb27a){if(_0x2bb27a){return _0x2bb27a['destroy']()[_0x157e('0x1f')](function(){_0x3346c6[_0x157e('0x17')](0xcc)[_0x157e('0x18')]();});}};}function handleEntityNotFound(_0x1400c2,_0x2fbf7c){return function(_0xb795d2){if(!_0xb795d2){_0x1400c2[_0x157e('0x20')](0x194);}return _0xb795d2;};}function handleError(_0x2b3fd8,_0x2b9f95){_0x2b9f95=_0x2b9f95||0x1f4;return function(_0x243053){logger[_0x157e('0x21')](_0x243053[_0x157e('0x22')]);if(_0x243053[_0x157e('0x23')]){delete _0x243053['name'];}_0x2b3fd8[_0x157e('0x17')](_0x2b9f95)[_0x157e('0x24')](_0x243053);};}exports[_0x157e('0x25')]=function(_0x4126aa,_0x408be3){var _0x21a7d6={},_0x3d2de6={},_0x58fe65={'count':0x0,'rows':[]};var _0x125a74=_['map'](db[_0x157e('0x26')][_0x157e('0x27')],function(_0x5b5a13){return{'name':_0x5b5a13[_0x157e('0x28')],'type':_0x5b5a13[_0x157e('0x29')][_0x157e('0x2a')]};});_0x3d2de6[_0x157e('0x2b')]=_[_0x157e('0x2c')](_0x125a74,'name');_0x3d2de6[_0x157e('0x2d')]=_[_0x157e('0x2e')](_0x4126aa['query']);_0x3d2de6[_0x157e('0x2f')]=_['intersection'](_0x3d2de6['model'],_0x3d2de6[_0x157e('0x2d')]);_0x21a7d6[_0x157e('0x30')]=_[_0x157e('0x31')](_0x3d2de6['model'],qs['fields'](_0x4126aa['query'][_0x157e('0x32')]));_0x21a7d6[_0x157e('0x30')]=_0x21a7d6['attributes']['length']?_0x21a7d6[_0x157e('0x30')]:_0x3d2de6[_0x157e('0x2b')];if(!_0x4126aa[_0x157e('0x2d')][_0x157e('0x33')]('nolimit')){_0x21a7d6[_0x157e('0x1b')]=qs['limit'](_0x4126aa[_0x157e('0x2d')][_0x157e('0x1b')]);_0x21a7d6[_0x157e('0x1a')]=qs[_0x157e('0x1a')](_0x4126aa[_0x157e('0x2d')][_0x157e('0x1a')]);}_0x21a7d6[_0x157e('0x34')]=qs[_0x157e('0x35')](_0x4126aa['query'][_0x157e('0x35')]);_0x21a7d6[_0x157e('0x36')]=qs[_0x157e('0x2f')](_[_0x157e('0x37')](_0x4126aa[_0x157e('0x2d')],_0x3d2de6[_0x157e('0x2f')]),_0x125a74);if(_0x4126aa[_0x157e('0x2d')][_0x157e('0x38')]){_0x21a7d6[_0x157e('0x36')]=_[_0x157e('0x39')](_0x21a7d6[_0x157e('0x36')],{'$or':_[_0x157e('0x2c')](_0x125a74,function(_0xd6d0c5){if(_0xd6d0c5[_0x157e('0x29')]!=='VIRTUAL'){var _0x26e323={};_0x26e323[_0xd6d0c5['name']]={'$like':'%'+_0x4126aa['query'][_0x157e('0x38')]+'%'};return _0x26e323;}})});}_0x21a7d6=_[_0x157e('0x39')]({},_0x21a7d6,_0x4126aa[_0x157e('0x3a')]);var _0x4a60b5={'where':_0x21a7d6[_0x157e('0x36')]};return db['SalesforceField']['count'](_0x4a60b5)[_0x157e('0x1f')](function(_0x53423a){_0x58fe65[_0x157e('0x1c')]=_0x53423a;if(_0x4126aa[_0x157e('0x2d')][_0x157e('0x3b')]){_0x21a7d6[_0x157e('0x3c')]=[{'all':!![]}];}return db[_0x157e('0x26')]['findAll'](_0x21a7d6);})[_0x157e('0x1f')](function(_0x2ae150){_0x58fe65['rows']=_0x2ae150;return _0x58fe65;})[_0x157e('0x1f')](respondWithFilteredResult(_0x408be3,_0x21a7d6))[_0x157e('0x3d')](handleError(_0x408be3,null));};exports[_0x157e('0x3e')]=function(_0x20c0f2,_0x5290ee){var _0x46dd5d={'raw':!![],'where':{'id':_0x20c0f2[_0x157e('0x3f')]['id']}},_0x3cc2ca={};_0x3cc2ca[_0x157e('0x2b')]=_['keys'](db[_0x157e('0x26')][_0x157e('0x27')]);_0x3cc2ca[_0x157e('0x2d')]=_['keys'](_0x20c0f2[_0x157e('0x2d')]);_0x3cc2ca[_0x157e('0x2f')]=_[_0x157e('0x31')](_0x3cc2ca['model'],_0x3cc2ca[_0x157e('0x2d')]);_0x46dd5d[_0x157e('0x30')]=_[_0x157e('0x31')](_0x3cc2ca[_0x157e('0x2b')],qs[_0x157e('0x32')](_0x20c0f2[_0x157e('0x2d')][_0x157e('0x32')]));_0x46dd5d[_0x157e('0x30')]=_0x46dd5d[_0x157e('0x30')][_0x157e('0x40')]?_0x46dd5d[_0x157e('0x30')]:_0x3cc2ca['model'];if(_0x20c0f2[_0x157e('0x2d')]['includeAll']){_0x46dd5d[_0x157e('0x3c')]=[{'all':!![]}];}_0x46dd5d=_['merge']({},_0x46dd5d,_0x20c0f2['options']);return db['SalesforceField'][_0x157e('0x41')](_0x46dd5d)[_0x157e('0x1f')](handleEntityNotFound(_0x5290ee,null))['then'](respondWithResult(_0x5290ee,null))[_0x157e('0x3d')](handleError(_0x5290ee,null));};exports[_0x157e('0x42')]=function(_0x13b119,_0x431cd9){return db[_0x157e('0x26')][_0x157e('0x42')](_0x13b119['body'],{})[_0x157e('0x1f')](respondWithResult(_0x431cd9,0xc9))[_0x157e('0x3d')](handleError(_0x431cd9,null));};exports[_0x157e('0x43')]=function(_0xba2ebb,_0x508b1c){if(_0xba2ebb[_0x157e('0x44')]['id']){delete _0xba2ebb[_0x157e('0x44')]['id'];}return db[_0x157e('0x26')][_0x157e('0x41')]({'where':{'id':_0xba2ebb['params']['id']}})[_0x157e('0x1f')](handleEntityNotFound(_0x508b1c,null))[_0x157e('0x1f')](saveUpdates(_0xba2ebb[_0x157e('0x44')],null))['then'](respondWithResult(_0x508b1c,null))[_0x157e('0x3d')](handleError(_0x508b1c,null));};exports[_0x157e('0x45')]=function(_0x46f835,_0x390419){return db[_0x157e('0x26')][_0x157e('0x41')]({'where':{'id':_0x46f835['params']['id']}})[_0x157e('0x1f')](handleEntityNotFound(_0x390419,null))[_0x157e('0x1f')](removeEntity(_0x390419,null))[_0x157e('0x3d')](handleError(_0x390419,null));};
\ No newline at end of file