Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 8ee1aa7..70dc1e3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x157a=['type','model','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','findAll','catch','show','params','include','find','create','body','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','apply','reject','update','then','destroy','stack','name','send','index','map','VtigerField','rawAttributes','fieldName'];(function(_0x2ba0ff,_0x4704ad){var _0xe20460=function(_0x2b3d00){while(--_0x2b3d00){_0x2ba0ff['push'](_0x2ba0ff['shift']());}};_0xe20460(++_0x4704ad);}(_0x157a,0x136));var _0xa157=function(_0x340fc7,_0x12a901){_0x340fc7=_0x340fc7-0x0;var _0x586c93=_0x157a[_0x340fc7];return _0x586c93;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa157('0x0'));var zipdir=require(_0xa157('0x1'));var jsonpatch=require(_0xa157('0x2'));var rp=require(_0xa157('0x3'));var moment=require(_0xa157('0x4'));var BPromise=require(_0xa157('0x5'));var Mustache=require(_0xa157('0x6'));var util=require(_0xa157('0x7'));var path=require(_0xa157('0x8'));var sox=require(_0xa157('0x9'));var csv=require(_0xa157('0xa'));var ejs=require(_0xa157('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xa157('0xc'));var crypto=require('crypto');var jsforce=require(_0xa157('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xa157('0xa'));var querystring=require(_0xa157('0xe'));var Papa=require(_0xa157('0xf'));var Redis=require('ioredis');var authService=require(_0xa157('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xa157('0x11'));var hardwareService=require(_0xa157('0x12'));var logger=require('../../config/logger')(_0xa157('0x13'));var utils=require(_0xa157('0x14'));var config=require(_0xa157('0x15'));var licenseUtil=require(_0xa157('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1c8204,_0x16737e){_0x16737e=_0x16737e||0xcc;return function(_0x547d08){if(_0x547d08){return _0x1c8204[_0xa157('0x17')](_0x16737e);}return _0x1c8204[_0xa157('0x18')](_0x16737e)[_0xa157('0x19')]();};}function respondWithResult(_0x481f2f,_0x12519c){_0x12519c=_0x12519c||0xc8;return function(_0x32dcc8){if(_0x32dcc8){return _0x481f2f[_0xa157('0x18')](_0x12519c)['json'](_0x32dcc8);}};}function respondWithFilteredResult(_0x149ffb,_0x1c1fda){return function(_0x3cbe05){if(_0x3cbe05){var _0x540463=typeof _0x1c1fda[_0xa157('0x1a')]==='undefined'&&typeof _0x1c1fda['limit']===_0xa157('0x1b');var _0x1d44c5=_0x3cbe05[_0xa157('0x1c')];var _0x42ec88=_0x540463?0x0:_0x1c1fda[_0xa157('0x1a')];var _0x28c782=_0x540463?_0x3cbe05['count']:_0x1c1fda['offset']+_0x1c1fda[_0xa157('0x1d')];var _0x29dcfc;if(_0x28c782>=_0x1d44c5){_0x28c782=_0x1d44c5;_0x29dcfc=0xc8;}else{_0x29dcfc=0xce;}_0x149ffb[_0xa157('0x18')](_0x29dcfc);return _0x149ffb[_0xa157('0x1e')](_0xa157('0x1f'),_0x42ec88+'-'+_0x28c782+'/'+_0x1d44c5)['json'](_0x3cbe05);}return null;};}function patchUpdates(_0x4460f3){return function(_0x39dfaa){try{jsonpatch[_0xa157('0x20')](_0x39dfaa,_0x4460f3,!![]);}catch(_0x111b9a){return BPromise[_0xa157('0x21')](_0x111b9a);}return _0x39dfaa['save']();};}function saveUpdates(_0x326037,_0x2211e4){return function(_0x590cc5){if(_0x590cc5){return _0x590cc5[_0xa157('0x22')](_0x326037)[_0xa157('0x23')](function(_0xfc07d6){return _0xfc07d6;});}return null;};}function removeEntity(_0x5e4488,_0x35ee2c){return function(_0x10f668){if(_0x10f668){return _0x10f668[_0xa157('0x24')]()[_0xa157('0x23')](function(){_0x5e4488[_0xa157('0x18')](0xcc)[_0xa157('0x19')]();});}};}function handleEntityNotFound(_0x5b4bee,_0x53546e){return function(_0x228e67){if(!_0x228e67){_0x5b4bee[_0xa157('0x17')](0x194);}return _0x228e67;};}function handleError(_0x192946,_0x5a1c26){_0x5a1c26=_0x5a1c26||0x1f4;return function(_0x367c16){logger['error'](_0x367c16[_0xa157('0x25')]);if(_0x367c16[_0xa157('0x26')]){delete _0x367c16['name'];}_0x192946['status'](_0x5a1c26)[_0xa157('0x27')](_0x367c16);};}exports[_0xa157('0x28')]=function(_0x141b01,_0x13af79){var _0x433584={},_0x3faf42={},_0x55d980={'count':0x0,'rows':[]};var _0x53e40=_[_0xa157('0x29')](db[_0xa157('0x2a')][_0xa157('0x2b')],function(_0xb65f79){return{'name':_0xb65f79[_0xa157('0x2c')],'type':_0xb65f79[_0xa157('0x2d')]['key']};});_0x3faf42[_0xa157('0x2e')]=_[_0xa157('0x29')](_0x53e40,_0xa157('0x26'));_0x3faf42[_0xa157('0x2f')]=_[_0xa157('0x30')](_0x141b01[_0xa157('0x2f')]);_0x3faf42[_0xa157('0x31')]=_[_0xa157('0x32')](_0x3faf42[_0xa157('0x2e')],_0x3faf42[_0xa157('0x2f')]);_0x433584['attributes']=_[_0xa157('0x32')](_0x3faf42['model'],qs[_0xa157('0x33')](_0x141b01[_0xa157('0x2f')][_0xa157('0x33')]));_0x433584[_0xa157('0x34')]=_0x433584[_0xa157('0x34')][_0xa157('0x35')]?_0x433584[_0xa157('0x34')]:_0x3faf42['model'];if(!_0x141b01[_0xa157('0x2f')]['hasOwnProperty'](_0xa157('0x36'))){_0x433584['limit']=qs[_0xa157('0x1d')](_0x141b01[_0xa157('0x2f')][_0xa157('0x1d')]);_0x433584[_0xa157('0x1a')]=qs[_0xa157('0x1a')](_0x141b01[_0xa157('0x2f')][_0xa157('0x1a')]);}_0x433584[_0xa157('0x37')]=qs[_0xa157('0x38')](_0x141b01[_0xa157('0x2f')][_0xa157('0x38')]);_0x433584[_0xa157('0x39')]=qs[_0xa157('0x31')](_['pick'](_0x141b01[_0xa157('0x2f')],_0x3faf42[_0xa157('0x31')]),_0x53e40);if(_0x141b01['query'][_0xa157('0x3a')]){_0x433584['where']=_[_0xa157('0x3b')](_0x433584[_0xa157('0x39')],{'$or':_[_0xa157('0x29')](_0x53e40,function(_0x3c9085){if(_0x3c9085[_0xa157('0x2d')]!==_0xa157('0x3c')){var _0x35531e={};_0x35531e[_0x3c9085[_0xa157('0x26')]]={'$like':'%'+_0x141b01[_0xa157('0x2f')][_0xa157('0x3a')]+'%'};return _0x35531e;}})});}_0x433584=_[_0xa157('0x3b')]({},_0x433584,_0x141b01[_0xa157('0x3d')]);var _0x154d2b={'where':_0x433584[_0xa157('0x39')]};return db['VtigerField'][_0xa157('0x1c')](_0x154d2b)['then'](function(_0x3d3ba2){_0x55d980[_0xa157('0x1c')]=_0x3d3ba2;if(_0x141b01[_0xa157('0x2f')][_0xa157('0x3e')]){_0x433584['include']=[{'all':!![]}];}return db[_0xa157('0x2a')][_0xa157('0x3f')](_0x433584);})['then'](function(_0x4e318c){_0x55d980['rows']=_0x4e318c;return _0x55d980;})[_0xa157('0x23')](respondWithFilteredResult(_0x13af79,_0x433584))[_0xa157('0x40')](handleError(_0x13af79,null));};exports[_0xa157('0x41')]=function(_0x38111c,_0x5722e3){var _0x19933a={'raw':!![],'where':{'id':_0x38111c[_0xa157('0x42')]['id']}},_0x1fb48d={};_0x1fb48d[_0xa157('0x2e')]=_[_0xa157('0x30')](db['VtigerField'][_0xa157('0x2b')]);_0x1fb48d[_0xa157('0x2f')]=_['keys'](_0x38111c[_0xa157('0x2f')]);_0x1fb48d['filters']=_[_0xa157('0x32')](_0x1fb48d['model'],_0x1fb48d[_0xa157('0x2f')]);_0x19933a['attributes']=_['intersection'](_0x1fb48d['model'],qs[_0xa157('0x33')](_0x38111c[_0xa157('0x2f')]['fields']));_0x19933a['attributes']=_0x19933a[_0xa157('0x34')][_0xa157('0x35')]?_0x19933a[_0xa157('0x34')]:_0x1fb48d[_0xa157('0x2e')];if(_0x38111c[_0xa157('0x2f')]['includeAll']){_0x19933a[_0xa157('0x43')]=[{'all':!![]}];}_0x19933a=_[_0xa157('0x3b')]({},_0x19933a,_0x38111c[_0xa157('0x3d')]);return db[_0xa157('0x2a')][_0xa157('0x44')](_0x19933a)[_0xa157('0x23')](handleEntityNotFound(_0x5722e3,null))[_0xa157('0x23')](respondWithResult(_0x5722e3,null))[_0xa157('0x40')](handleError(_0x5722e3,null));};exports[_0xa157('0x45')]=function(_0x48408,_0x39e2c1){return db[_0xa157('0x2a')]['create'](_0x48408[_0xa157('0x46')],{})[_0xa157('0x23')](respondWithResult(_0x39e2c1,0xc9))[_0xa157('0x40')](handleError(_0x39e2c1,null));};exports[_0xa157('0x22')]=function(_0x1cb3f5,_0x13c4c2){if(_0x1cb3f5[_0xa157('0x46')]['id']){delete _0x1cb3f5[_0xa157('0x46')]['id'];}return db['VtigerField'][_0xa157('0x44')]({'where':{'id':_0x1cb3f5['params']['id']}})[_0xa157('0x23')](handleEntityNotFound(_0x13c4c2,null))[_0xa157('0x23')](saveUpdates(_0x1cb3f5[_0xa157('0x46')],null))[_0xa157('0x23')](respondWithResult(_0x13c4c2,null))[_0xa157('0x40')](handleError(_0x13c4c2,null));};exports[_0xa157('0x24')]=function(_0x4c16ee,_0x4f3dbc){return db['VtigerField'][_0xa157('0x44')]({'where':{'id':_0x4c16ee[_0xa157('0x42')]['id']}})['then'](handleEntityNotFound(_0x4f3dbc,null))[_0xa157('0x23')](removeEntity(_0x4f3dbc,null))[_0xa157('0x40')](handleError(_0x4f3dbc,null));};
\ No newline at end of file
+var _0x7ed3=['query','filters','intersection','attributes','fields','length','order','sort','where','pick','filter','merge','type','VIRTUAL','options','include','catch','includeAll','find','create','body','params','destroy','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','fs-extra','lodash','squel','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','apply','reject','update','then','error','stack','name','send','index','map','VtigerField','rawAttributes','fieldName','key','model','keys'];(function(_0x5760f6,_0x498ace){var _0x17ef08=function(_0x568ad4){while(--_0x568ad4){_0x5760f6['push'](_0x5760f6['shift']());}};_0x17ef08(++_0x498ace);}(_0x7ed3,0x12b));var _0x37ed=function(_0x111969,_0x4507d3){_0x111969=_0x111969-0x0;var _0x40c0d7=_0x7ed3[_0x111969];return _0x40c0d7;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x37ed('0x0'));var jsonpatch=require(_0x37ed('0x1'));var rp=require(_0x37ed('0x2'));var moment=require(_0x37ed('0x3'));var BPromise=require(_0x37ed('0x4'));var Mustache=require('mustache');var util=require(_0x37ed('0x5'));var path=require(_0x37ed('0x6'));var sox=require('sox');var csv=require(_0x37ed('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x37ed('0x8'));var _=require(_0x37ed('0x9'));var squel=require(_0x37ed('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x37ed('0x7'));var querystring=require(_0x37ed('0xb'));var Papa=require(_0x37ed('0xc'));var Redis=require('ioredis');var authService=require(_0x37ed('0xd'));var qs=require(_0x37ed('0xe'));var as=require(_0x37ed('0xf'));var hardwareService=require(_0x37ed('0x10'));var logger=require(_0x37ed('0x11'))(_0x37ed('0x12'));var utils=require(_0x37ed('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x37ed('0x14'))['db'];function respondWithStatusCode(_0x29f82f,_0x136eee){_0x136eee=_0x136eee||0xcc;return function(_0x4f7041){if(_0x4f7041){return _0x29f82f[_0x37ed('0x15')](_0x136eee);}return _0x29f82f[_0x37ed('0x16')](_0x136eee)[_0x37ed('0x17')]();};}function respondWithResult(_0x3582b6,_0x7b2b45){_0x7b2b45=_0x7b2b45||0xc8;return function(_0x188998){if(_0x188998){return _0x3582b6[_0x37ed('0x16')](_0x7b2b45)[_0x37ed('0x18')](_0x188998);}};}function respondWithFilteredResult(_0x25e0d2,_0x1fd8d0){return function(_0x14ede0){if(_0x14ede0){var _0x56a8f5=typeof _0x1fd8d0['offset']===_0x37ed('0x19')&&typeof _0x1fd8d0[_0x37ed('0x1a')]===_0x37ed('0x19');var _0x332a06=_0x14ede0[_0x37ed('0x1b')];var _0x100bb4=_0x56a8f5?0x0:_0x1fd8d0[_0x37ed('0x1c')];var _0x584884=_0x56a8f5?_0x14ede0[_0x37ed('0x1b')]:_0x1fd8d0['offset']+_0x1fd8d0['limit'];var _0x173f30;if(_0x584884>=_0x332a06){_0x584884=_0x332a06;_0x173f30=0xc8;}else{_0x173f30=0xce;}_0x25e0d2[_0x37ed('0x16')](_0x173f30);return _0x25e0d2['set'](_0x37ed('0x1d'),_0x100bb4+'-'+_0x584884+'/'+_0x332a06)[_0x37ed('0x18')](_0x14ede0);}return null;};}function patchUpdates(_0x4d10dc){return function(_0x371692){try{jsonpatch[_0x37ed('0x1e')](_0x371692,_0x4d10dc,!![]);}catch(_0x158e58){return BPromise[_0x37ed('0x1f')](_0x158e58);}return _0x371692['save']();};}function saveUpdates(_0x9f8c42,_0x28ce0a){return function(_0x59b048){if(_0x59b048){return _0x59b048[_0x37ed('0x20')](_0x9f8c42)['then'](function(_0x9d2892){return _0x9d2892;});}return null;};}function removeEntity(_0x40fef9,_0x80ebcf){return function(_0x1a5ef3){if(_0x1a5ef3){return _0x1a5ef3['destroy']()[_0x37ed('0x21')](function(){_0x40fef9['status'](0xcc)[_0x37ed('0x17')]();});}};}function handleEntityNotFound(_0x249e50,_0xe533a1){return function(_0x3e0c4){if(!_0x3e0c4){_0x249e50[_0x37ed('0x15')](0x194);}return _0x3e0c4;};}function handleError(_0x43e6f5,_0x52920d){_0x52920d=_0x52920d||0x1f4;return function(_0x1e2321){logger[_0x37ed('0x22')](_0x1e2321[_0x37ed('0x23')]);if(_0x1e2321[_0x37ed('0x24')]){delete _0x1e2321[_0x37ed('0x24')];}_0x43e6f5[_0x37ed('0x16')](_0x52920d)[_0x37ed('0x25')](_0x1e2321);};}exports[_0x37ed('0x26')]=function(_0x2989d3,_0x21a4f0){var _0x197062={},_0x27ab2f={},_0x3b533b={'count':0x0,'rows':[]};var _0x2dac0a=_[_0x37ed('0x27')](db[_0x37ed('0x28')][_0x37ed('0x29')],function(_0x48f1e0){return{'name':_0x48f1e0[_0x37ed('0x2a')],'type':_0x48f1e0['type'][_0x37ed('0x2b')]};});_0x27ab2f[_0x37ed('0x2c')]=_[_0x37ed('0x27')](_0x2dac0a,_0x37ed('0x24'));_0x27ab2f['query']=_[_0x37ed('0x2d')](_0x2989d3[_0x37ed('0x2e')]);_0x27ab2f[_0x37ed('0x2f')]=_[_0x37ed('0x30')](_0x27ab2f[_0x37ed('0x2c')],_0x27ab2f[_0x37ed('0x2e')]);_0x197062[_0x37ed('0x31')]=_[_0x37ed('0x30')](_0x27ab2f[_0x37ed('0x2c')],qs[_0x37ed('0x32')](_0x2989d3[_0x37ed('0x2e')][_0x37ed('0x32')]));_0x197062[_0x37ed('0x31')]=_0x197062[_0x37ed('0x31')][_0x37ed('0x33')]?_0x197062[_0x37ed('0x31')]:_0x27ab2f[_0x37ed('0x2c')];if(!_0x2989d3[_0x37ed('0x2e')]['hasOwnProperty']('nolimit')){_0x197062['limit']=qs[_0x37ed('0x1a')](_0x2989d3['query'][_0x37ed('0x1a')]);_0x197062[_0x37ed('0x1c')]=qs[_0x37ed('0x1c')](_0x2989d3[_0x37ed('0x2e')][_0x37ed('0x1c')]);}_0x197062[_0x37ed('0x34')]=qs['sort'](_0x2989d3[_0x37ed('0x2e')][_0x37ed('0x35')]);_0x197062[_0x37ed('0x36')]=qs[_0x37ed('0x2f')](_[_0x37ed('0x37')](_0x2989d3['query'],_0x27ab2f['filters']),_0x2dac0a);if(_0x2989d3[_0x37ed('0x2e')][_0x37ed('0x38')]){_0x197062[_0x37ed('0x36')]=_[_0x37ed('0x39')](_0x197062[_0x37ed('0x36')],{'$or':_[_0x37ed('0x27')](_0x2dac0a,function(_0x2c91e5){if(_0x2c91e5[_0x37ed('0x3a')]!==_0x37ed('0x3b')){var _0x4a0890={};_0x4a0890[_0x2c91e5['name']]={'$like':'%'+_0x2989d3[_0x37ed('0x2e')][_0x37ed('0x38')]+'%'};return _0x4a0890;}})});}_0x197062=_[_0x37ed('0x39')]({},_0x197062,_0x2989d3[_0x37ed('0x3c')]);var _0x8a1e76={'where':_0x197062['where']};return db[_0x37ed('0x28')][_0x37ed('0x1b')](_0x8a1e76)[_0x37ed('0x21')](function(_0x3cecb1){_0x3b533b['count']=_0x3cecb1;if(_0x2989d3[_0x37ed('0x2e')]['includeAll']){_0x197062[_0x37ed('0x3d')]=[{'all':!![]}];}return db['VtigerField']['findAll'](_0x197062);})[_0x37ed('0x21')](function(_0x352414){_0x3b533b['rows']=_0x352414;return _0x3b533b;})[_0x37ed('0x21')](respondWithFilteredResult(_0x21a4f0,_0x197062))[_0x37ed('0x3e')](handleError(_0x21a4f0,null));};exports['show']=function(_0x483f7b,_0x30ba04){var _0x136810={'raw':!![],'where':{'id':_0x483f7b['params']['id']}},_0x51ba3={};_0x51ba3['model']=_[_0x37ed('0x2d')](db[_0x37ed('0x28')][_0x37ed('0x29')]);_0x51ba3['query']=_[_0x37ed('0x2d')](_0x483f7b[_0x37ed('0x2e')]);_0x51ba3[_0x37ed('0x2f')]=_[_0x37ed('0x30')](_0x51ba3[_0x37ed('0x2c')],_0x51ba3[_0x37ed('0x2e')]);_0x136810[_0x37ed('0x31')]=_['intersection'](_0x51ba3[_0x37ed('0x2c')],qs[_0x37ed('0x32')](_0x483f7b[_0x37ed('0x2e')][_0x37ed('0x32')]));_0x136810[_0x37ed('0x31')]=_0x136810[_0x37ed('0x31')][_0x37ed('0x33')]?_0x136810[_0x37ed('0x31')]:_0x51ba3[_0x37ed('0x2c')];if(_0x483f7b['query'][_0x37ed('0x3f')]){_0x136810[_0x37ed('0x3d')]=[{'all':!![]}];}_0x136810=_[_0x37ed('0x39')]({},_0x136810,_0x483f7b[_0x37ed('0x3c')]);return db[_0x37ed('0x28')][_0x37ed('0x40')](_0x136810)[_0x37ed('0x21')](handleEntityNotFound(_0x30ba04,null))[_0x37ed('0x21')](respondWithResult(_0x30ba04,null))[_0x37ed('0x3e')](handleError(_0x30ba04,null));};exports[_0x37ed('0x41')]=function(_0x260e13,_0x123158){return db[_0x37ed('0x28')][_0x37ed('0x41')](_0x260e13[_0x37ed('0x42')],{})[_0x37ed('0x21')](respondWithResult(_0x123158,0xc9))[_0x37ed('0x3e')](handleError(_0x123158,null));};exports[_0x37ed('0x20')]=function(_0x34d04a,_0x4b6f55){if(_0x34d04a[_0x37ed('0x42')]['id']){delete _0x34d04a[_0x37ed('0x42')]['id'];}return db[_0x37ed('0x28')][_0x37ed('0x40')]({'where':{'id':_0x34d04a[_0x37ed('0x43')]['id']}})[_0x37ed('0x21')](handleEntityNotFound(_0x4b6f55,null))['then'](saveUpdates(_0x34d04a[_0x37ed('0x42')],null))[_0x37ed('0x21')](respondWithResult(_0x4b6f55,null))[_0x37ed('0x3e')](handleError(_0x4b6f55,null));};exports[_0x37ed('0x44')]=function(_0x1bc647,_0x42c643){return db[_0x37ed('0x28')][_0x37ed('0x40')]({'where':{'id':_0x1bc647['params']['id']}})['then'](handleEntityNotFound(_0x42c643,null))['then'](removeEntity(_0x42c643,null))[_0x37ed('0x3e')](handleError(_0x42c643,null));};
\ No newline at end of file