Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 01fb0e6..5c43292 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x65f6=['../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','index','map','VtigerField','rawAttributes','keys','filters','intersection','model','query','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filter','merge','type','options','include','findAll','rows','catch','show','find','create','body','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0x65f6,0x77));var _0x665f=function(_0x532c54,_0x54f860){_0x532c54=_0x532c54-0x0;var _0x5887e5=_0x65f6[_0x532c54];return _0x5887e5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x665f('0x0'));var zipdir=require(_0x665f('0x1'));var jsonpatch=require(_0x665f('0x2'));var rp=require(_0x665f('0x3'));var moment=require(_0x665f('0x4'));var BPromise=require(_0x665f('0x5'));var Mustache=require('mustache');var util=require(_0x665f('0x6'));var path=require('path');var sox=require(_0x665f('0x7'));var csv=require(_0x665f('0x8'));var ejs=require(_0x665f('0x9'));var fs=require('fs');var fs_extra=require(_0x665f('0xa'));var _=require('lodash');var squel=require(_0x665f('0xb'));var crypto=require(_0x665f('0xc'));var jsforce=require(_0x665f('0xd'));var deskjs=require(_0x665f('0xe'));var toCsv=require(_0x665f('0x8'));var querystring=require(_0x665f('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x665f('0x10'));var as=require(_0x665f('0x11'));var hardwareService=require(_0x665f('0x12'));var logger=require(_0x665f('0x13'))(_0x665f('0x14'));var utils=require(_0x665f('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x665f('0x16'));var db=require(_0x665f('0x17'))['db'];function respondWithStatusCode(_0x2b64d5,_0x4e7286){_0x4e7286=_0x4e7286||0xcc;return function(_0x2cc1f8){if(_0x2cc1f8){return _0x2b64d5[_0x665f('0x18')](_0x4e7286);}return _0x2b64d5[_0x665f('0x19')](_0x4e7286)[_0x665f('0x1a')]();};}function respondWithResult(_0x2ff680,_0x16f677){_0x16f677=_0x16f677||0xc8;return function(_0x58f48c){if(_0x58f48c){return _0x2ff680[_0x665f('0x19')](_0x16f677)[_0x665f('0x1b')](_0x58f48c);}};}function respondWithFilteredResult(_0x5ff7e0,_0x43960a){return function(_0x2fe036){if(_0x2fe036){var _0x13bb64=typeof _0x43960a[_0x665f('0x1c')]===_0x665f('0x1d')&&typeof _0x43960a[_0x665f('0x1e')]==='undefined';var _0x498c9b=_0x2fe036[_0x665f('0x1f')];var _0xfd7b35=_0x13bb64?0x0:_0x43960a[_0x665f('0x1c')];var _0x28ea1e=_0x13bb64?_0x2fe036['count']:_0x43960a[_0x665f('0x1c')]+_0x43960a[_0x665f('0x1e')];var _0x5a9715;if(_0x28ea1e>=_0x498c9b){_0x28ea1e=_0x498c9b;_0x5a9715=0xc8;}else{_0x5a9715=0xce;}_0x5ff7e0[_0x665f('0x19')](_0x5a9715);return _0x5ff7e0[_0x665f('0x20')](_0x665f('0x21'),_0xfd7b35+'-'+_0x28ea1e+'/'+_0x498c9b)[_0x665f('0x1b')](_0x2fe036);}return null;};}function patchUpdates(_0x389516){return function(_0x44afde){try{jsonpatch[_0x665f('0x22')](_0x44afde,_0x389516,!![]);}catch(_0x45b448){return BPromise[_0x665f('0x23')](_0x45b448);}return _0x44afde[_0x665f('0x24')]();};}function saveUpdates(_0x4ad07e,_0x32eb12){return function(_0x2c0370){if(_0x2c0370){return _0x2c0370[_0x665f('0x25')](_0x4ad07e)[_0x665f('0x26')](function(_0x4483af){return _0x4483af;});}return null;};}function removeEntity(_0x841de,_0x4cc8ec){return function(_0x270e36){if(_0x270e36){return _0x270e36[_0x665f('0x27')]()[_0x665f('0x26')](function(){_0x841de[_0x665f('0x19')](0xcc)[_0x665f('0x1a')]();});}};}function handleEntityNotFound(_0x9d1e8d,_0x40ff2b){return function(_0x538529){if(!_0x538529){_0x9d1e8d[_0x665f('0x18')](0x194);}return _0x538529;};}function handleError(_0x4d685c,_0x462bcd){_0x462bcd=_0x462bcd||0x1f4;return function(_0x1e2f6d){logger['error'](_0x1e2f6d[_0x665f('0x28')]);if(_0x1e2f6d['name']){delete _0x1e2f6d[_0x665f('0x29')];}_0x4d685c['status'](_0x462bcd)['send'](_0x1e2f6d);};}exports[_0x665f('0x2a')]=function(_0x5bc5a4,_0x2e8ff3){var _0x4b94f4={},_0x2bff02={},_0x3abc91={'count':0x0,'rows':[]};var _0x5b1821=_[_0x665f('0x2b')](db[_0x665f('0x2c')][_0x665f('0x2d')],function(_0x1c2cfc){return{'name':_0x1c2cfc['fieldName'],'type':_0x1c2cfc['type']['key']};});_0x2bff02['model']=_[_0x665f('0x2b')](_0x5b1821,_0x665f('0x29'));_0x2bff02['query']=_[_0x665f('0x2e')](_0x5bc5a4['query']);_0x2bff02[_0x665f('0x2f')]=_[_0x665f('0x30')](_0x2bff02[_0x665f('0x31')],_0x2bff02[_0x665f('0x32')]);_0x4b94f4['attributes']=_['intersection'](_0x2bff02[_0x665f('0x31')],qs[_0x665f('0x33')](_0x5bc5a4['query'][_0x665f('0x33')]));_0x4b94f4['attributes']=_0x4b94f4[_0x665f('0x34')][_0x665f('0x35')]?_0x4b94f4['attributes']:_0x2bff02[_0x665f('0x31')];if(!_0x5bc5a4[_0x665f('0x32')][_0x665f('0x36')](_0x665f('0x37'))){_0x4b94f4[_0x665f('0x1e')]=qs[_0x665f('0x1e')](_0x5bc5a4[_0x665f('0x32')][_0x665f('0x1e')]);_0x4b94f4[_0x665f('0x1c')]=qs[_0x665f('0x1c')](_0x5bc5a4['query'][_0x665f('0x1c')]);}_0x4b94f4['order']=qs[_0x665f('0x38')](_0x5bc5a4[_0x665f('0x32')][_0x665f('0x38')]);_0x4b94f4[_0x665f('0x39')]=qs['filters'](_['pick'](_0x5bc5a4[_0x665f('0x32')],_0x2bff02[_0x665f('0x2f')]),_0x5b1821);if(_0x5bc5a4[_0x665f('0x32')][_0x665f('0x3a')]){_0x4b94f4['where']=_[_0x665f('0x3b')](_0x4b94f4['where'],{'$or':_['map'](_0x5b1821,function(_0x2b2017){if(_0x2b2017[_0x665f('0x3c')]!=='VIRTUAL'){var _0x10b286={};_0x10b286[_0x2b2017['name']]={'$like':'%'+_0x5bc5a4[_0x665f('0x32')][_0x665f('0x3a')]+'%'};return _0x10b286;}})});}_0x4b94f4=_['merge']({},_0x4b94f4,_0x5bc5a4[_0x665f('0x3d')]);var _0x30be9d={'where':_0x4b94f4[_0x665f('0x39')]};return db[_0x665f('0x2c')]['count'](_0x30be9d)[_0x665f('0x26')](function(_0x15aeb5){_0x3abc91[_0x665f('0x1f')]=_0x15aeb5;if(_0x5bc5a4[_0x665f('0x32')]['includeAll']){_0x4b94f4[_0x665f('0x3e')]=[{'all':!![]}];}return db[_0x665f('0x2c')][_0x665f('0x3f')](_0x4b94f4);})[_0x665f('0x26')](function(_0x2232fd){_0x3abc91[_0x665f('0x40')]=_0x2232fd;return _0x3abc91;})['then'](respondWithFilteredResult(_0x2e8ff3,_0x4b94f4))[_0x665f('0x41')](handleError(_0x2e8ff3,null));};exports[_0x665f('0x42')]=function(_0x64ebb4,_0x624023){var _0x4e32b4={'raw':!![],'where':{'id':_0x64ebb4['params']['id']}},_0x576772={};_0x576772[_0x665f('0x31')]=_[_0x665f('0x2e')](db['VtigerField']['rawAttributes']);_0x576772['query']=_[_0x665f('0x2e')](_0x64ebb4['query']);_0x576772[_0x665f('0x2f')]=_['intersection'](_0x576772['model'],_0x576772[_0x665f('0x32')]);_0x4e32b4[_0x665f('0x34')]=_['intersection'](_0x576772[_0x665f('0x31')],qs['fields'](_0x64ebb4[_0x665f('0x32')][_0x665f('0x33')]));_0x4e32b4[_0x665f('0x34')]=_0x4e32b4[_0x665f('0x34')][_0x665f('0x35')]?_0x4e32b4[_0x665f('0x34')]:_0x576772['model'];if(_0x64ebb4[_0x665f('0x32')]['includeAll']){_0x4e32b4[_0x665f('0x3e')]=[{'all':!![]}];}_0x4e32b4=_['merge']({},_0x4e32b4,_0x64ebb4[_0x665f('0x3d')]);return db[_0x665f('0x2c')][_0x665f('0x43')](_0x4e32b4)[_0x665f('0x26')](handleEntityNotFound(_0x624023,null))[_0x665f('0x26')](respondWithResult(_0x624023,null))[_0x665f('0x41')](handleError(_0x624023,null));};exports['create']=function(_0x110527,_0x3df1ca){return db[_0x665f('0x2c')][_0x665f('0x44')](_0x110527['body'],{})[_0x665f('0x26')](respondWithResult(_0x3df1ca,0xc9))['catch'](handleError(_0x3df1ca,null));};exports[_0x665f('0x25')]=function(_0x359bb8,_0x5874d7){if(_0x359bb8[_0x665f('0x45')]['id']){delete _0x359bb8[_0x665f('0x45')]['id'];}return db[_0x665f('0x2c')]['find']({'where':{'id':_0x359bb8[_0x665f('0x46')]['id']}})['then'](handleEntityNotFound(_0x5874d7,null))[_0x665f('0x26')](saveUpdates(_0x359bb8['body'],null))[_0x665f('0x26')](respondWithResult(_0x5874d7,null))[_0x665f('0x41')](handleError(_0x5874d7,null));};exports[_0x665f('0x27')]=function(_0x4714b0,_0x51077b){return db[_0x665f('0x2c')][_0x665f('0x43')]({'where':{'id':_0x4714b0[_0x665f('0x46')]['id']}})[_0x665f('0x26')](handleEntityNotFound(_0x51077b,null))[_0x665f('0x26')](removeEntity(_0x51077b,null))[_0x665f('0x41')](handleError(_0x51077b,null));};
\ No newline at end of file
+var _0xa165=['../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','apply','reject','save','destroy','then','error','name','send','index','VtigerField','rawAttributes','type','model','map','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','catch','show','params','keys','create','body','find','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils'];(function(_0x4f3579,_0x22c620){var _0x166fdc=function(_0x219baf){while(--_0x219baf){_0x4f3579['push'](_0x4f3579['shift']());}};_0x166fdc(++_0x22c620);}(_0xa165,0x15b));var _0x5a16=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xa165[_0x122ef9];return _0x42fba0;};'use strict';var emlformat=require(_0x5a16('0x0'));var rimraf=require(_0x5a16('0x1'));var zipdir=require(_0x5a16('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5a16('0x3'));var moment=require(_0x5a16('0x4'));var BPromise=require(_0x5a16('0x5'));var Mustache=require(_0x5a16('0x6'));var util=require('util');var path=require(_0x5a16('0x7'));var sox=require(_0x5a16('0x8'));var csv=require('to-csv');var ejs=require(_0x5a16('0x9'));var fs=require('fs');var fs_extra=require(_0x5a16('0xa'));var _=require(_0x5a16('0xb'));var squel=require('squel');var crypto=require(_0x5a16('0xc'));var jsforce=require(_0x5a16('0xd'));var deskjs=require(_0x5a16('0xe'));var toCsv=require(_0x5a16('0xf'));var querystring=require('querystring');var Papa=require(_0x5a16('0x10'));var Redis=require(_0x5a16('0x11'));var authService=require(_0x5a16('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x5a16('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5a16('0x14'))(_0x5a16('0x15'));var utils=require(_0x5a16('0x16'));var config=require(_0x5a16('0x17'));var licenseUtil=require(_0x5a16('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4a3fc3,_0x5e90ad){_0x5e90ad=_0x5e90ad||0xcc;return function(_0x29cfbb){if(_0x29cfbb){return _0x4a3fc3[_0x5a16('0x19')](_0x5e90ad);}return _0x4a3fc3[_0x5a16('0x1a')](_0x5e90ad)[_0x5a16('0x1b')]();};}function respondWithResult(_0x3274cf,_0x37d1da){_0x37d1da=_0x37d1da||0xc8;return function(_0x74237c){if(_0x74237c){return _0x3274cf['status'](_0x37d1da)[_0x5a16('0x1c')](_0x74237c);}};}function respondWithFilteredResult(_0x4f2eef,_0xcdc308){return function(_0x353f29){if(_0x353f29){var _0x389295=typeof _0xcdc308[_0x5a16('0x1d')]==='undefined'&&typeof _0xcdc308['limit']===_0x5a16('0x1e');var _0x12088d=_0x353f29[_0x5a16('0x1f')];var _0x1d35e3=_0x389295?0x0:_0xcdc308[_0x5a16('0x1d')];var _0x191bc7=_0x389295?_0x353f29['count']:_0xcdc308[_0x5a16('0x1d')]+_0xcdc308[_0x5a16('0x20')];var _0x25f809;if(_0x191bc7>=_0x12088d){_0x191bc7=_0x12088d;_0x25f809=0xc8;}else{_0x25f809=0xce;}_0x4f2eef[_0x5a16('0x1a')](_0x25f809);return _0x4f2eef[_0x5a16('0x21')]('Content-Range',_0x1d35e3+'-'+_0x191bc7+'/'+_0x12088d)[_0x5a16('0x1c')](_0x353f29);}return null;};}function patchUpdates(_0x535618){return function(_0x364e29){try{jsonpatch[_0x5a16('0x22')](_0x364e29,_0x535618,!![]);}catch(_0x50f481){return BPromise[_0x5a16('0x23')](_0x50f481);}return _0x364e29[_0x5a16('0x24')]();};}function saveUpdates(_0x500167,_0x597670){return function(_0x148300){if(_0x148300){return _0x148300['update'](_0x500167)['then'](function(_0x5146e9){return _0x5146e9;});}return null;};}function removeEntity(_0x52e762,_0x3b98d2){return function(_0x37a28d){if(_0x37a28d){return _0x37a28d[_0x5a16('0x25')]()[_0x5a16('0x26')](function(){_0x52e762[_0x5a16('0x1a')](0xcc)[_0x5a16('0x1b')]();});}};}function handleEntityNotFound(_0x754d35,_0x1b710a){return function(_0x54d22b){if(!_0x54d22b){_0x754d35[_0x5a16('0x19')](0x194);}return _0x54d22b;};}function handleError(_0x588238,_0x460614){_0x460614=_0x460614||0x1f4;return function(_0xc97d71){logger[_0x5a16('0x27')](_0xc97d71['stack']);if(_0xc97d71[_0x5a16('0x28')]){delete _0xc97d71['name'];}_0x588238[_0x5a16('0x1a')](_0x460614)[_0x5a16('0x29')](_0xc97d71);};}exports[_0x5a16('0x2a')]=function(_0xe11b6e,_0x204659){var _0x476dba={},_0xfd1cd8={},_0x2ab5e6={'count':0x0,'rows':[]};var _0x291a59=_['map'](db[_0x5a16('0x2b')][_0x5a16('0x2c')],function(_0x1390b8){return{'name':_0x1390b8['fieldName'],'type':_0x1390b8[_0x5a16('0x2d')]['key']};});_0xfd1cd8[_0x5a16('0x2e')]=_[_0x5a16('0x2f')](_0x291a59,_0x5a16('0x28'));_0xfd1cd8[_0x5a16('0x30')]=_['keys'](_0xe11b6e[_0x5a16('0x30')]);_0xfd1cd8['filters']=_[_0x5a16('0x31')](_0xfd1cd8[_0x5a16('0x2e')],_0xfd1cd8[_0x5a16('0x30')]);_0x476dba[_0x5a16('0x32')]=_[_0x5a16('0x31')](_0xfd1cd8[_0x5a16('0x2e')],qs['fields'](_0xe11b6e[_0x5a16('0x30')][_0x5a16('0x33')]));_0x476dba['attributes']=_0x476dba[_0x5a16('0x32')][_0x5a16('0x34')]?_0x476dba[_0x5a16('0x32')]:_0xfd1cd8[_0x5a16('0x2e')];if(!_0xe11b6e['query'][_0x5a16('0x35')](_0x5a16('0x36'))){_0x476dba['limit']=qs[_0x5a16('0x20')](_0xe11b6e[_0x5a16('0x30')][_0x5a16('0x20')]);_0x476dba[_0x5a16('0x1d')]=qs[_0x5a16('0x1d')](_0xe11b6e[_0x5a16('0x30')][_0x5a16('0x1d')]);}_0x476dba[_0x5a16('0x37')]=qs[_0x5a16('0x38')](_0xe11b6e[_0x5a16('0x30')][_0x5a16('0x38')]);_0x476dba[_0x5a16('0x39')]=qs[_0x5a16('0x3a')](_[_0x5a16('0x3b')](_0xe11b6e[_0x5a16('0x30')],_0xfd1cd8[_0x5a16('0x3a')]),_0x291a59);if(_0xe11b6e['query']['filter']){_0x476dba[_0x5a16('0x39')]=_[_0x5a16('0x3c')](_0x476dba[_0x5a16('0x39')],{'$or':_[_0x5a16('0x2f')](_0x291a59,function(_0x1607fe){if(_0x1607fe[_0x5a16('0x2d')]!==_0x5a16('0x3d')){var _0x2de51c={};_0x2de51c[_0x1607fe[_0x5a16('0x28')]]={'$like':'%'+_0xe11b6e[_0x5a16('0x30')][_0x5a16('0x3e')]+'%'};return _0x2de51c;}})});}_0x476dba=_['merge']({},_0x476dba,_0xe11b6e[_0x5a16('0x3f')]);var _0x5398fc={'where':_0x476dba[_0x5a16('0x39')]};return db['VtigerField'][_0x5a16('0x1f')](_0x5398fc)['then'](function(_0x3a30cf){_0x2ab5e6[_0x5a16('0x1f')]=_0x3a30cf;if(_0xe11b6e['query'][_0x5a16('0x40')]){_0x476dba[_0x5a16('0x41')]=[{'all':!![]}];}return db[_0x5a16('0x2b')][_0x5a16('0x42')](_0x476dba);})['then'](function(_0x31b480){_0x2ab5e6['rows']=_0x31b480;return _0x2ab5e6;})[_0x5a16('0x26')](respondWithFilteredResult(_0x204659,_0x476dba))[_0x5a16('0x43')](handleError(_0x204659,null));};exports[_0x5a16('0x44')]=function(_0x330409,_0x2266de){var _0x5c1094={'raw':!![],'where':{'id':_0x330409[_0x5a16('0x45')]['id']}},_0x7ae04a={};_0x7ae04a['model']=_[_0x5a16('0x46')](db[_0x5a16('0x2b')][_0x5a16('0x2c')]);_0x7ae04a[_0x5a16('0x30')]=_[_0x5a16('0x46')](_0x330409[_0x5a16('0x30')]);_0x7ae04a[_0x5a16('0x3a')]=_[_0x5a16('0x31')](_0x7ae04a[_0x5a16('0x2e')],_0x7ae04a[_0x5a16('0x30')]);_0x5c1094[_0x5a16('0x32')]=_[_0x5a16('0x31')](_0x7ae04a[_0x5a16('0x2e')],qs[_0x5a16('0x33')](_0x330409[_0x5a16('0x30')][_0x5a16('0x33')]));_0x5c1094[_0x5a16('0x32')]=_0x5c1094[_0x5a16('0x32')][_0x5a16('0x34')]?_0x5c1094[_0x5a16('0x32')]:_0x7ae04a[_0x5a16('0x2e')];if(_0x330409[_0x5a16('0x30')][_0x5a16('0x40')]){_0x5c1094['include']=[{'all':!![]}];}_0x5c1094=_[_0x5a16('0x3c')]({},_0x5c1094,_0x330409[_0x5a16('0x3f')]);return db[_0x5a16('0x2b')]['find'](_0x5c1094)[_0x5a16('0x26')](handleEntityNotFound(_0x2266de,null))['then'](respondWithResult(_0x2266de,null))[_0x5a16('0x43')](handleError(_0x2266de,null));};exports[_0x5a16('0x47')]=function(_0x5b546f,_0x1f021d){return db[_0x5a16('0x2b')][_0x5a16('0x47')](_0x5b546f[_0x5a16('0x48')],{})['then'](respondWithResult(_0x1f021d,0xc9))['catch'](handleError(_0x1f021d,null));};exports['update']=function(_0xc2869,_0xc04d30){if(_0xc2869['body']['id']){delete _0xc2869[_0x5a16('0x48')]['id'];}return db[_0x5a16('0x2b')]['find']({'where':{'id':_0xc2869['params']['id']}})[_0x5a16('0x26')](handleEntityNotFound(_0xc04d30,null))[_0x5a16('0x26')](saveUpdates(_0xc2869[_0x5a16('0x48')],null))['then'](respondWithResult(_0xc04d30,null))[_0x5a16('0x43')](handleError(_0xc04d30,null));};exports[_0x5a16('0x25')]=function(_0x18177d,_0x121025){return db[_0x5a16('0x2b')][_0x5a16('0x49')]({'where':{'id':_0x18177d['params']['id']}})[_0x5a16('0x26')](handleEntityNotFound(_0x121025,null))['then'](removeEntity(_0x121025,null))['catch'](handleError(_0x121025,null));};
\ No newline at end of file