Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSugarcrmField / intSugarcrmField.controller.js
index 9ca8604..4717b5e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf7ca=['count','offset','limit','set','json','save','update','destroy','stack','name','send','index','map','SugarcrmField','rawAttributes','type','key','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','then','includeAll','findAll','catch','show','body','find','params','html-pdf','eml-format','rimraf','zip-dir','moment','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus','status','end'];(function(_0x5b66b6,_0x5ab70f){var _0x5b62e8=function(_0xe7cc76){while(--_0xe7cc76){_0x5b66b6['push'](_0x5b66b6['shift']());}};_0x5b62e8(++_0x5ab70f);}(_0xf7ca,0x6d));var _0xaf7c=function(_0x2ff849,_0x3742cb){_0x2ff849=_0x2ff849-0x0;var _0x509c06=_0xf7ca[_0x2ff849];return _0x509c06;};'use strict';var pdf=require(_0xaf7c('0x0'));var emlformat=require(_0xaf7c('0x1'));var rimraf=require(_0xaf7c('0x2'));var zipdir=require(_0xaf7c('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xaf7c('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xaf7c('0x5'));var util=require(_0xaf7c('0x6'));var path=require(_0xaf7c('0x7'));var sox=require(_0xaf7c('0x8'));var csv=require(_0xaf7c('0x9'));var ejs=require(_0xaf7c('0xa'));var fs=require('fs');var _=require(_0xaf7c('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xaf7c('0xc'));var deskjs=require(_0xaf7c('0xd'));var toCsv=require('to-csv');var querystring=require(_0xaf7c('0xe'));var Papa=require(_0xaf7c('0xf'));var Redis=require(_0xaf7c('0x10'));var authService=require(_0xaf7c('0x11'));var qs=require(_0xaf7c('0x12'));var as=require(_0xaf7c('0x13'));var hardwareService=require(_0xaf7c('0x14'));var logger=require('../../config/logger')(_0xaf7c('0x15'));var utils=require(_0xaf7c('0x16'));var config=require('../../config/environment');var db=require(_0xaf7c('0x17'))['db'];function respondWithStatusCode(_0xb2f0e3,_0x5e7290){_0x5e7290=_0x5e7290||0xcc;return function(_0x44898a){if(_0x44898a){return _0xb2f0e3[_0xaf7c('0x18')](_0x5e7290);}return _0xb2f0e3[_0xaf7c('0x19')](_0x5e7290)[_0xaf7c('0x1a')]();};}function respondWithResult(_0x2427f6,_0x387619){_0x387619=_0x387619||0xc8;return function(_0x459fb4){if(_0x459fb4){return _0x2427f6['status'](_0x387619)['json'](_0x459fb4);}};}function respondWithFilteredResult(_0x33b309,_0x28f4d7){return function(_0x387d77){if(_0x387d77){var _0x5a2548=_0x387d77[_0xaf7c('0x1b')],_0x4e28d6=_0x28f4d7[_0xaf7c('0x1c')],_0x225441=_0x28f4d7[_0xaf7c('0x1c')]+_0x28f4d7[_0xaf7c('0x1d')],_0x3a47e2;if(_0x225441>=_0x5a2548){_0x225441=_0x5a2548;_0x3a47e2=0xc8;}else{_0x3a47e2=0xce;}_0x33b309[_0xaf7c('0x19')](_0x3a47e2);return _0x33b309[_0xaf7c('0x1e')]('Content-Range',_0x4e28d6+'-'+_0x225441+'/'+_0x5a2548)[_0xaf7c('0x1f')](_0x387d77);}return null;};}function patchUpdates(_0x3da89a){return function(_0x1c0a26){try{jsonpatch['apply'](_0x1c0a26,_0x3da89a,!![]);}catch(_0x3d1dfe){return BPromise['reject'](_0x3d1dfe);}return _0x1c0a26[_0xaf7c('0x20')]();};}function saveUpdates(_0x8d6358,_0x3a88c0){return function(_0x1a73a3){if(_0x1a73a3){return _0x1a73a3[_0xaf7c('0x21')](_0x8d6358)['then'](function(_0x2a6836){return _0x2a6836;});}return null;};}function removeEntity(_0x7add29,_0x30672e){return function(_0x1ac2e3){if(_0x1ac2e3){return _0x1ac2e3[_0xaf7c('0x22')]()['then'](function(){_0x7add29['status'](0xcc)[_0xaf7c('0x1a')]();});}};}function handleEntityNotFound(_0x374614,_0x16b405){return function(_0x595e39){if(!_0x595e39){_0x374614[_0xaf7c('0x18')](0x194);}return _0x595e39;};}function handleError(_0x16fbba,_0xafdc02){_0xafdc02=_0xafdc02||0x1f4;return function(_0x733329){logger['error'](_0x733329[_0xaf7c('0x23')]);if(_0x733329['name']){delete _0x733329[_0xaf7c('0x24')];}_0x16fbba[_0xaf7c('0x19')](_0xafdc02)[_0xaf7c('0x25')](_0x733329);};}exports[_0xaf7c('0x26')]=function(_0x51067a,_0x230c9d){var _0x4f43ac={},_0x4b34a0={},_0x527929={'count':0x0,'rows':[]};var _0x5c616a=_[_0xaf7c('0x27')](db[_0xaf7c('0x28')][_0xaf7c('0x29')],function(_0x2a7a4c){return{'name':_0x2a7a4c['fieldName'],'type':_0x2a7a4c[_0xaf7c('0x2a')][_0xaf7c('0x2b')]};});_0x4b34a0['model']=_[_0xaf7c('0x27')](_0x5c616a,'name');_0x4b34a0[_0xaf7c('0x2c')]=_[_0xaf7c('0x2d')](_0x51067a[_0xaf7c('0x2c')]);_0x4b34a0[_0xaf7c('0x2e')]=_['intersection'](_0x4b34a0[_0xaf7c('0x2f')],_0x4b34a0['query']);_0x4f43ac[_0xaf7c('0x30')]=_[_0xaf7c('0x31')](_0x4b34a0[_0xaf7c('0x2f')],qs[_0xaf7c('0x32')](_0x51067a[_0xaf7c('0x2c')]['fields']));_0x4f43ac[_0xaf7c('0x30')]=_0x4f43ac[_0xaf7c('0x30')][_0xaf7c('0x33')]?_0x4f43ac[_0xaf7c('0x30')]:_0x4b34a0[_0xaf7c('0x2f')];if(!_0x51067a['query'][_0xaf7c('0x34')]('nolimit')){_0x4f43ac[_0xaf7c('0x1d')]=qs[_0xaf7c('0x1d')](_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x1d')]);_0x4f43ac[_0xaf7c('0x1c')]=qs['offset'](_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x1c')]);}_0x4f43ac[_0xaf7c('0x35')]=qs['sort'](_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x36')]);_0x4f43ac[_0xaf7c('0x37')]=qs['filters'](_[_0xaf7c('0x38')](_0x51067a[_0xaf7c('0x2c')],_0x4b34a0[_0xaf7c('0x2e')]),_0x5c616a);if(_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x39')]){_0x4f43ac[_0xaf7c('0x37')]=_[_0xaf7c('0x3a')](_0x4f43ac[_0xaf7c('0x37')],{'$or':_[_0xaf7c('0x27')](_0x5c616a,function(_0x20f0d2){if(_0x20f0d2[_0xaf7c('0x2a')]!=='VIRTUAL'){var _0x2f7024={};_0x2f7024[_0x20f0d2[_0xaf7c('0x24')]]={'$like':'%'+_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x39')]+'%'};return _0x2f7024;}})});}_0x4f43ac=_[_0xaf7c('0x3a')]({},_0x4f43ac,_0x51067a[_0xaf7c('0x3b')]);var _0x2d0902={'where':_0x4f43ac[_0xaf7c('0x37')]};return db[_0xaf7c('0x28')][_0xaf7c('0x1b')](_0x2d0902)[_0xaf7c('0x3c')](function(_0x4797ba){_0x527929[_0xaf7c('0x1b')]=_0x4797ba;if(_0x51067a[_0xaf7c('0x2c')][_0xaf7c('0x3d')]){_0x4f43ac['include']=[{'all':!![]}];}return db[_0xaf7c('0x28')][_0xaf7c('0x3e')](_0x4f43ac);})[_0xaf7c('0x3c')](function(_0x42b390){_0x527929['rows']=_0x42b390;return _0x527929;})[_0xaf7c('0x3c')](respondWithFilteredResult(_0x230c9d,_0x4f43ac))[_0xaf7c('0x3f')](handleError(_0x230c9d,null));};exports[_0xaf7c('0x40')]=function(_0xf86ab1,_0x243daf){var _0x40a284={'raw':!![],'where':{'id':_0xf86ab1['params']['id']}},_0x4e0033={};_0x4e0033[_0xaf7c('0x2f')]=_[_0xaf7c('0x2d')](db[_0xaf7c('0x28')][_0xaf7c('0x29')]);_0x4e0033['query']=_[_0xaf7c('0x2d')](_0xf86ab1['query']);_0x4e0033[_0xaf7c('0x2e')]=_[_0xaf7c('0x31')](_0x4e0033[_0xaf7c('0x2f')],_0x4e0033[_0xaf7c('0x2c')]);_0x40a284[_0xaf7c('0x30')]=_[_0xaf7c('0x31')](_0x4e0033[_0xaf7c('0x2f')],qs['fields'](_0xf86ab1[_0xaf7c('0x2c')][_0xaf7c('0x32')]));_0x40a284[_0xaf7c('0x30')]=_0x40a284[_0xaf7c('0x30')]['length']?_0x40a284[_0xaf7c('0x30')]:_0x4e0033['model'];if(_0xf86ab1['query'][_0xaf7c('0x3d')]){_0x40a284['include']=[{'all':!![]}];}_0x40a284=_[_0xaf7c('0x3a')]({},_0x40a284,_0xf86ab1[_0xaf7c('0x3b')]);return db[_0xaf7c('0x28')]['find'](_0x40a284)[_0xaf7c('0x3c')](handleEntityNotFound(_0x243daf,null))['then'](respondWithResult(_0x243daf,null))[_0xaf7c('0x3f')](handleError(_0x243daf,null));};exports['create']=function(_0x920fdd,_0x164c0c){return db[_0xaf7c('0x28')]['create'](_0x920fdd['body'],{})[_0xaf7c('0x3c')](respondWithResult(_0x164c0c,0xc9))[_0xaf7c('0x3f')](handleError(_0x164c0c,null));};exports['update']=function(_0x188bb5,_0x2d9f4b){if(_0x188bb5[_0xaf7c('0x41')]['id']){delete _0x188bb5[_0xaf7c('0x41')]['id'];}return db['SugarcrmField'][_0xaf7c('0x42')]({'where':{'id':_0x188bb5['params']['id']}})[_0xaf7c('0x3c')](handleEntityNotFound(_0x2d9f4b,null))[_0xaf7c('0x3c')](saveUpdates(_0x188bb5[_0xaf7c('0x41')],null))[_0xaf7c('0x3c')](respondWithResult(_0x2d9f4b,null))[_0xaf7c('0x3f')](handleError(_0x2d9f4b,null));};exports['destroy']=function(_0x479509,_0x2073f2){return db[_0xaf7c('0x28')]['find']({'where':{'id':_0x479509[_0xaf7c('0x43')]['id']}})[_0xaf7c('0x3c')](handleEntityNotFound(_0x2073f2,null))[_0xaf7c('0x3c')](removeEntity(_0x2073f2,null))[_0xaf7c('0x3f')](handleError(_0x2073f2,null));};
\ No newline at end of file
+var _0xe281=['reject','save','update','then','sendStatus','error','stack','name','send','index','map','fieldName','type','key','model','query','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','options','SugarcrmField','includeAll','include','findAll','rows','catch','show','params','keys','merge','find','create','body','destroy','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','status','end','json','undefined','offset','count','limit','set','apply'];(function(_0xadc6d5,_0x406c40){var _0x500fae=function(_0x10b90b){while(--_0x10b90b){_0xadc6d5['push'](_0xadc6d5['shift']());}};_0x500fae(++_0x406c40);}(_0xe281,0xb8));var _0x1e28=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0xe281[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x1e28('0x0'));var jsonpatch=require(_0x1e28('0x1'));var rp=require(_0x1e28('0x2'));var moment=require(_0x1e28('0x3'));var BPromise=require(_0x1e28('0x4'));var Mustache=require('mustache');var util=require(_0x1e28('0x5'));var path=require(_0x1e28('0x6'));var sox=require(_0x1e28('0x7'));var csv=require(_0x1e28('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1e28('0x9'));var _=require('lodash');var squel=require(_0x1e28('0xa'));var crypto=require(_0x1e28('0xb'));var jsforce=require(_0x1e28('0xc'));var deskjs=require(_0x1e28('0xd'));var toCsv=require(_0x1e28('0x8'));var querystring=require(_0x1e28('0xe'));var Papa=require(_0x1e28('0xf'));var Redis=require(_0x1e28('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x1e28('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x1e28('0x12'))('api');var utils=require(_0x1e28('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5b1d9c,_0x1e6b65){_0x1e6b65=_0x1e6b65||0xcc;return function(_0x9742a7){if(_0x9742a7){return _0x5b1d9c['sendStatus'](_0x1e6b65);}return _0x5b1d9c[_0x1e28('0x14')](_0x1e6b65)[_0x1e28('0x15')]();};}function respondWithResult(_0x4a6537,_0x45362b){_0x45362b=_0x45362b||0xc8;return function(_0x2bd7fe){if(_0x2bd7fe){return _0x4a6537[_0x1e28('0x14')](_0x45362b)[_0x1e28('0x16')](_0x2bd7fe);}};}function respondWithFilteredResult(_0x2b06a0,_0xffef51){return function(_0x15d752){if(_0x15d752){var _0x25cc58=typeof _0xffef51['offset']==='undefined'&&typeof _0xffef51['limit']===_0x1e28('0x17');var _0x166df2=_0x15d752['count'];var _0x35155b=_0x25cc58?0x0:_0xffef51[_0x1e28('0x18')];var _0x57fc87=_0x25cc58?_0x15d752[_0x1e28('0x19')]:_0xffef51[_0x1e28('0x18')]+_0xffef51[_0x1e28('0x1a')];var _0x43ef70;if(_0x57fc87>=_0x166df2){_0x57fc87=_0x166df2;_0x43ef70=0xc8;}else{_0x43ef70=0xce;}_0x2b06a0[_0x1e28('0x14')](_0x43ef70);return _0x2b06a0[_0x1e28('0x1b')]('Content-Range',_0x35155b+'-'+_0x57fc87+'/'+_0x166df2)[_0x1e28('0x16')](_0x15d752);}return null;};}function patchUpdates(_0x37f705){return function(_0x2be9a0){try{jsonpatch[_0x1e28('0x1c')](_0x2be9a0,_0x37f705,!![]);}catch(_0x22933d){return BPromise[_0x1e28('0x1d')](_0x22933d);}return _0x2be9a0[_0x1e28('0x1e')]();};}function saveUpdates(_0x4a1db6,_0x2c4315){return function(_0x4e9d54){if(_0x4e9d54){return _0x4e9d54[_0x1e28('0x1f')](_0x4a1db6)[_0x1e28('0x20')](function(_0x25dd04){return _0x25dd04;});}return null;};}function removeEntity(_0x40e6aa,_0x16924a){return function(_0x771204){if(_0x771204){return _0x771204['destroy']()[_0x1e28('0x20')](function(){_0x40e6aa['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x46098b,_0x3dc6d8){return function(_0x160830){if(!_0x160830){_0x46098b[_0x1e28('0x21')](0x194);}return _0x160830;};}function handleError(_0x242411,_0x2181dc){_0x2181dc=_0x2181dc||0x1f4;return function(_0x1b452e){logger[_0x1e28('0x22')](_0x1b452e[_0x1e28('0x23')]);if(_0x1b452e[_0x1e28('0x24')]){delete _0x1b452e[_0x1e28('0x24')];}_0x242411['status'](_0x2181dc)[_0x1e28('0x25')](_0x1b452e);};}exports[_0x1e28('0x26')]=function(_0x2eddea,_0x49106e){var _0x5eb351={},_0x3ad261={},_0x453904={'count':0x0,'rows':[]};var _0x245a60=_[_0x1e28('0x27')](db['SugarcrmField']['rawAttributes'],function(_0x489eb3){return{'name':_0x489eb3[_0x1e28('0x28')],'type':_0x489eb3[_0x1e28('0x29')][_0x1e28('0x2a')]};});_0x3ad261[_0x1e28('0x2b')]=_['map'](_0x245a60,'name');_0x3ad261[_0x1e28('0x2c')]=_['keys'](_0x2eddea['query']);_0x3ad261['filters']=_[_0x1e28('0x2d')](_0x3ad261['model'],_0x3ad261[_0x1e28('0x2c')]);_0x5eb351[_0x1e28('0x2e')]=_[_0x1e28('0x2d')](_0x3ad261[_0x1e28('0x2b')],qs['fields'](_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x2f')]));_0x5eb351[_0x1e28('0x2e')]=_0x5eb351[_0x1e28('0x2e')][_0x1e28('0x30')]?_0x5eb351[_0x1e28('0x2e')]:_0x3ad261[_0x1e28('0x2b')];if(!_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x31')]('nolimit')){_0x5eb351[_0x1e28('0x1a')]=qs['limit'](_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x1a')]);_0x5eb351['offset']=qs['offset'](_0x2eddea[_0x1e28('0x2c')]['offset']);}_0x5eb351[_0x1e28('0x32')]=qs[_0x1e28('0x33')](_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x33')]);_0x5eb351[_0x1e28('0x34')]=qs[_0x1e28('0x35')](_[_0x1e28('0x36')](_0x2eddea[_0x1e28('0x2c')],_0x3ad261['filters']),_0x245a60);if(_0x2eddea[_0x1e28('0x2c')]['filter']){_0x5eb351[_0x1e28('0x34')]=_['merge'](_0x5eb351['where'],{'$or':_['map'](_0x245a60,function(_0xc914ba){if(_0xc914ba[_0x1e28('0x29')]!=='VIRTUAL'){var _0x54888a={};_0x54888a[_0xc914ba['name']]={'$like':'%'+_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x37')]+'%'};return _0x54888a;}})});}_0x5eb351=_['merge']({},_0x5eb351,_0x2eddea[_0x1e28('0x38')]);var _0x2c1e6e={'where':_0x5eb351[_0x1e28('0x34')]};return db[_0x1e28('0x39')]['count'](_0x2c1e6e)[_0x1e28('0x20')](function(_0x3a258c){_0x453904['count']=_0x3a258c;if(_0x2eddea[_0x1e28('0x2c')][_0x1e28('0x3a')]){_0x5eb351[_0x1e28('0x3b')]=[{'all':!![]}];}return db[_0x1e28('0x39')][_0x1e28('0x3c')](_0x5eb351);})['then'](function(_0x394213){_0x453904[_0x1e28('0x3d')]=_0x394213;return _0x453904;})[_0x1e28('0x20')](respondWithFilteredResult(_0x49106e,_0x5eb351))[_0x1e28('0x3e')](handleError(_0x49106e,null));};exports[_0x1e28('0x3f')]=function(_0x54a04d,_0x3e3d2e){var _0x1401f2={'raw':!![],'where':{'id':_0x54a04d[_0x1e28('0x40')]['id']}},_0x41bbd5={};_0x41bbd5[_0x1e28('0x2b')]=_[_0x1e28('0x41')](db[_0x1e28('0x39')]['rawAttributes']);_0x41bbd5['query']=_[_0x1e28('0x41')](_0x54a04d['query']);_0x41bbd5[_0x1e28('0x35')]=_[_0x1e28('0x2d')](_0x41bbd5[_0x1e28('0x2b')],_0x41bbd5[_0x1e28('0x2c')]);_0x1401f2[_0x1e28('0x2e')]=_[_0x1e28('0x2d')](_0x41bbd5[_0x1e28('0x2b')],qs[_0x1e28('0x2f')](_0x54a04d[_0x1e28('0x2c')][_0x1e28('0x2f')]));_0x1401f2['attributes']=_0x1401f2[_0x1e28('0x2e')][_0x1e28('0x30')]?_0x1401f2[_0x1e28('0x2e')]:_0x41bbd5['model'];if(_0x54a04d['query'][_0x1e28('0x3a')]){_0x1401f2[_0x1e28('0x3b')]=[{'all':!![]}];}_0x1401f2=_[_0x1e28('0x42')]({},_0x1401f2,_0x54a04d[_0x1e28('0x38')]);return db[_0x1e28('0x39')][_0x1e28('0x43')](_0x1401f2)[_0x1e28('0x20')](handleEntityNotFound(_0x3e3d2e,null))[_0x1e28('0x20')](respondWithResult(_0x3e3d2e,null))[_0x1e28('0x3e')](handleError(_0x3e3d2e,null));};exports[_0x1e28('0x44')]=function(_0x2bf516,_0x551718){return db[_0x1e28('0x39')]['create'](_0x2bf516[_0x1e28('0x45')],{})['then'](respondWithResult(_0x551718,0xc9))[_0x1e28('0x3e')](handleError(_0x551718,null));};exports[_0x1e28('0x1f')]=function(_0x2f18ac,_0x143b31){if(_0x2f18ac[_0x1e28('0x45')]['id']){delete _0x2f18ac[_0x1e28('0x45')]['id'];}return db[_0x1e28('0x39')][_0x1e28('0x43')]({'where':{'id':_0x2f18ac['params']['id']}})[_0x1e28('0x20')](handleEntityNotFound(_0x143b31,null))[_0x1e28('0x20')](saveUpdates(_0x2f18ac[_0x1e28('0x45')],null))['then'](respondWithResult(_0x143b31,null))[_0x1e28('0x3e')](handleError(_0x143b31,null));};exports[_0x1e28('0x46')]=function(_0x442f6b,_0x2799ba){return db[_0x1e28('0x39')][_0x1e28('0x43')]({'where':{'id':_0x442f6b[_0x1e28('0x40')]['id']}})['then'](handleEntityNotFound(_0x2799ba,null))[_0x1e28('0x20')](removeEntity(_0x2799ba,null))[_0x1e28('0x3e')](handleError(_0x2799ba,null));};
\ No newline at end of file