Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 6d5a72c..cef30ae 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6db2=['name','send','index','map','VtigerField','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','merge','where','VIRTUAL','options','count','include','rows','show','params','rawAttributes','includeAll','catch','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','offset','undefined','limit','set','Content-Range','apply','reject','save','update','destroy','then','error','stack'];(function(_0x337862,_0x5f3c2e){var _0x3fdeee=function(_0x5c7ce1){while(--_0x5c7ce1){_0x337862['push'](_0x337862['shift']());}};_0x3fdeee(++_0x5f3c2e);}(_0x6db2,0x10a));var _0x26db=function(_0x5acfde,_0x3596d4){_0x5acfde=_0x5acfde-0x0;var _0x123d61=_0x6db2[_0x5acfde];return _0x123d61;};'use strict';var emlformat=require(_0x26db('0x0'));var rimraf=require(_0x26db('0x1'));var zipdir=require(_0x26db('0x2'));var jsonpatch=require(_0x26db('0x3'));var rp=require(_0x26db('0x4'));var moment=require(_0x26db('0x5'));var BPromise=require(_0x26db('0x6'));var Mustache=require(_0x26db('0x7'));var util=require('util');var path=require(_0x26db('0x8'));var sox=require(_0x26db('0x9'));var csv=require(_0x26db('0xa'));var ejs=require(_0x26db('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x26db('0xc'));var crypto=require('crypto');var jsforce=require(_0x26db('0xd'));var deskjs=require(_0x26db('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x26db('0xf'));var Redis=require(_0x26db('0x10'));var authService=require(_0x26db('0x11'));var qs=require(_0x26db('0x12'));var as=require(_0x26db('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x26db('0x14'))(_0x26db('0x15'));var utils=require(_0x26db('0x16'));var config=require(_0x26db('0x17'));var licenseUtil=require(_0x26db('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x548dfc,_0x3f38e0){_0x3f38e0=_0x3f38e0||0xcc;return function(_0x5c371c){if(_0x5c371c){return _0x548dfc[_0x26db('0x19')](_0x3f38e0);}return _0x548dfc['status'](_0x3f38e0)[_0x26db('0x1a')]();};}function respondWithResult(_0x39bd21,_0x10ff6c){_0x10ff6c=_0x10ff6c||0xc8;return function(_0x14dfa9){if(_0x14dfa9){return _0x39bd21[_0x26db('0x1b')](_0x10ff6c)[_0x26db('0x1c')](_0x14dfa9);}};}function respondWithFilteredResult(_0x97a807,_0x44e393){return function(_0x3d7698){if(_0x3d7698){var _0x581f2c=typeof _0x44e393[_0x26db('0x1d')]===_0x26db('0x1e')&&typeof _0x44e393['limit']===_0x26db('0x1e');var _0x4fb798=_0x3d7698['count'];var _0x33bacc=_0x581f2c?0x0:_0x44e393[_0x26db('0x1d')];var _0x41d75d=_0x581f2c?_0x3d7698['count']:_0x44e393[_0x26db('0x1d')]+_0x44e393[_0x26db('0x1f')];var _0x66a040;if(_0x41d75d>=_0x4fb798){_0x41d75d=_0x4fb798;_0x66a040=0xc8;}else{_0x66a040=0xce;}_0x97a807[_0x26db('0x1b')](_0x66a040);return _0x97a807[_0x26db('0x20')](_0x26db('0x21'),_0x33bacc+'-'+_0x41d75d+'/'+_0x4fb798)[_0x26db('0x1c')](_0x3d7698);}return null;};}function patchUpdates(_0x2688e8){return function(_0x9bf587){try{jsonpatch[_0x26db('0x22')](_0x9bf587,_0x2688e8,!![]);}catch(_0x5508d6){return BPromise[_0x26db('0x23')](_0x5508d6);}return _0x9bf587[_0x26db('0x24')]();};}function saveUpdates(_0x4dbc07,_0x4cb93c){return function(_0x11886f){if(_0x11886f){return _0x11886f[_0x26db('0x25')](_0x4dbc07)['then'](function(_0x52ef7b){return _0x52ef7b;});}return null;};}function removeEntity(_0x164581,_0x19dbbb){return function(_0xf843e3){if(_0xf843e3){return _0xf843e3[_0x26db('0x26')]()[_0x26db('0x27')](function(){_0x164581[_0x26db('0x1b')](0xcc)[_0x26db('0x1a')]();});}};}function handleEntityNotFound(_0x42672c,_0x3a64f0){return function(_0x16cda4){if(!_0x16cda4){_0x42672c[_0x26db('0x19')](0x194);}return _0x16cda4;};}function handleError(_0x213ad5,_0x4992d6){_0x4992d6=_0x4992d6||0x1f4;return function(_0x223f7f){logger[_0x26db('0x28')](_0x223f7f[_0x26db('0x29')]);if(_0x223f7f[_0x26db('0x2a')]){delete _0x223f7f[_0x26db('0x2a')];}_0x213ad5[_0x26db('0x1b')](_0x4992d6)[_0x26db('0x2b')](_0x223f7f);};}exports[_0x26db('0x2c')]=function(_0x139fe8,_0x4d523e){var _0x12343c={},_0x266d1b={},_0x421269={'count':0x0,'rows':[]};var _0x5f2e73=_[_0x26db('0x2d')](db[_0x26db('0x2e')]['rawAttributes'],function(_0x494812){return{'name':_0x494812['fieldName'],'type':_0x494812[_0x26db('0x2f')][_0x26db('0x30')]};});_0x266d1b[_0x26db('0x31')]=_[_0x26db('0x2d')](_0x5f2e73,_0x26db('0x2a'));_0x266d1b[_0x26db('0x32')]=_[_0x26db('0x33')](_0x139fe8[_0x26db('0x32')]);_0x266d1b[_0x26db('0x34')]=_[_0x26db('0x35')](_0x266d1b[_0x26db('0x31')],_0x266d1b['query']);_0x12343c[_0x26db('0x36')]=_['intersection'](_0x266d1b[_0x26db('0x31')],qs['fields'](_0x139fe8[_0x26db('0x32')][_0x26db('0x37')]));_0x12343c[_0x26db('0x36')]=_0x12343c[_0x26db('0x36')][_0x26db('0x38')]?_0x12343c[_0x26db('0x36')]:_0x266d1b[_0x26db('0x31')];if(!_0x139fe8[_0x26db('0x32')][_0x26db('0x39')](_0x26db('0x3a'))){_0x12343c[_0x26db('0x1f')]=qs[_0x26db('0x1f')](_0x139fe8[_0x26db('0x32')][_0x26db('0x1f')]);_0x12343c[_0x26db('0x1d')]=qs[_0x26db('0x1d')](_0x139fe8[_0x26db('0x32')][_0x26db('0x1d')]);}_0x12343c[_0x26db('0x3b')]=qs[_0x26db('0x3c')](_0x139fe8[_0x26db('0x32')][_0x26db('0x3c')]);_0x12343c['where']=qs[_0x26db('0x34')](_['pick'](_0x139fe8[_0x26db('0x32')],_0x266d1b['filters']),_0x5f2e73);if(_0x139fe8[_0x26db('0x32')][_0x26db('0x3d')]){_0x12343c['where']=_[_0x26db('0x3e')](_0x12343c[_0x26db('0x3f')],{'$or':_[_0x26db('0x2d')](_0x5f2e73,function(_0x12b171){if(_0x12b171[_0x26db('0x2f')]!==_0x26db('0x40')){var _0x16a3db={};_0x16a3db[_0x12b171[_0x26db('0x2a')]]={'$like':'%'+_0x139fe8[_0x26db('0x32')][_0x26db('0x3d')]+'%'};return _0x16a3db;}})});}_0x12343c=_[_0x26db('0x3e')]({},_0x12343c,_0x139fe8[_0x26db('0x41')]);var _0x4a384b={'where':_0x12343c[_0x26db('0x3f')]};return db[_0x26db('0x2e')][_0x26db('0x42')](_0x4a384b)[_0x26db('0x27')](function(_0x456eea){_0x421269['count']=_0x456eea;if(_0x139fe8['query']['includeAll']){_0x12343c[_0x26db('0x43')]=[{'all':!![]}];}return db[_0x26db('0x2e')]['findAll'](_0x12343c);})[_0x26db('0x27')](function(_0x2f5b12){_0x421269[_0x26db('0x44')]=_0x2f5b12;return _0x421269;})[_0x26db('0x27')](respondWithFilteredResult(_0x4d523e,_0x12343c))['catch'](handleError(_0x4d523e,null));};exports[_0x26db('0x45')]=function(_0x1ea8e7,_0x4f588b){var _0x30f616={'raw':!![],'where':{'id':_0x1ea8e7[_0x26db('0x46')]['id']}},_0x33fa26={};_0x33fa26[_0x26db('0x31')]=_['keys'](db[_0x26db('0x2e')][_0x26db('0x47')]);_0x33fa26[_0x26db('0x32')]=_[_0x26db('0x33')](_0x1ea8e7[_0x26db('0x32')]);_0x33fa26['filters']=_['intersection'](_0x33fa26['model'],_0x33fa26[_0x26db('0x32')]);_0x30f616[_0x26db('0x36')]=_[_0x26db('0x35')](_0x33fa26[_0x26db('0x31')],qs[_0x26db('0x37')](_0x1ea8e7['query'][_0x26db('0x37')]));_0x30f616[_0x26db('0x36')]=_0x30f616[_0x26db('0x36')][_0x26db('0x38')]?_0x30f616['attributes']:_0x33fa26['model'];if(_0x1ea8e7[_0x26db('0x32')][_0x26db('0x48')]){_0x30f616[_0x26db('0x43')]=[{'all':!![]}];}_0x30f616=_[_0x26db('0x3e')]({},_0x30f616,_0x1ea8e7[_0x26db('0x41')]);return db[_0x26db('0x2e')]['find'](_0x30f616)[_0x26db('0x27')](handleEntityNotFound(_0x4f588b,null))['then'](respondWithResult(_0x4f588b,null))[_0x26db('0x49')](handleError(_0x4f588b,null));};exports[_0x26db('0x4a')]=function(_0x3d368b,_0x18f1b7){return db[_0x26db('0x2e')]['create'](_0x3d368b[_0x26db('0x4b')],{})['then'](respondWithResult(_0x18f1b7,0xc9))[_0x26db('0x49')](handleError(_0x18f1b7,null));};exports[_0x26db('0x25')]=function(_0xefb91b,_0x2c9797){if(_0xefb91b['body']['id']){delete _0xefb91b[_0x26db('0x4b')]['id'];}return db[_0x26db('0x2e')][_0x26db('0x4c')]({'where':{'id':_0xefb91b[_0x26db('0x46')]['id']}})['then'](handleEntityNotFound(_0x2c9797,null))[_0x26db('0x27')](saveUpdates(_0xefb91b['body'],null))[_0x26db('0x27')](respondWithResult(_0x2c9797,null))[_0x26db('0x49')](handleError(_0x2c9797,null));};exports[_0x26db('0x26')]=function(_0x28b508,_0x5a1852){return db[_0x26db('0x2e')]['find']({'where':{'id':_0x28b508['params']['id']}})[_0x26db('0x27')](handleEntityNotFound(_0x5a1852,null))['then'](removeEntity(_0x5a1852,null))['catch'](handleError(_0x5a1852,null));};
\ No newline at end of file
+var _0xf853=['findAll','rows','catch','show','intersection','include','merge','find','create','body','params','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','reject','save','update','then','destroy','end','error','stack','send','map','rawAttributes','fieldName','type','key','model','name','query','keys','filters','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','where','VIRTUAL','options','includeAll','VtigerField'];(function(_0x330723,_0x8de382){var _0x60c546=function(_0xd6d3fe){while(--_0xd6d3fe){_0x330723['push'](_0x330723['shift']());}};_0x60c546(++_0x8de382);}(_0xf853,0x1cd));var _0x3f85=function(_0xe896bf,_0x4f8e5e){_0xe896bf=_0xe896bf-0x0;var _0x4c7a8a=_0xf853[_0xe896bf];return _0x4c7a8a;};'use strict';var emlformat=require(_0x3f85('0x0'));var rimraf=require(_0x3f85('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3f85('0x2'));var rp=require(_0x3f85('0x3'));var moment=require(_0x3f85('0x4'));var BPromise=require(_0x3f85('0x5'));var Mustache=require('mustache');var util=require(_0x3f85('0x6'));var path=require('path');var sox=require(_0x3f85('0x7'));var csv=require(_0x3f85('0x8'));var ejs=require(_0x3f85('0x9'));var fs=require('fs');var fs_extra=require(_0x3f85('0xa'));var _=require(_0x3f85('0xb'));var squel=require(_0x3f85('0xc'));var crypto=require(_0x3f85('0xd'));var jsforce=require(_0x3f85('0xe'));var deskjs=require(_0x3f85('0xf'));var toCsv=require(_0x3f85('0x8'));var querystring=require(_0x3f85('0x10'));var Papa=require('papaparse');var Redis=require(_0x3f85('0x11'));var authService=require(_0x3f85('0x12'));var qs=require(_0x3f85('0x13'));var as=require(_0x3f85('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x3f85('0x15'))(_0x3f85('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x3f85('0x17'))['db'];function respondWithStatusCode(_0x3c1cb7,_0x1885ae){_0x1885ae=_0x1885ae||0xcc;return function(_0x1a5474){if(_0x1a5474){return _0x3c1cb7[_0x3f85('0x18')](_0x1885ae);}return _0x3c1cb7[_0x3f85('0x19')](_0x1885ae)['end']();};}function respondWithResult(_0x4b8bc9,_0x478df6){_0x478df6=_0x478df6||0xc8;return function(_0x196a5f){if(_0x196a5f){return _0x4b8bc9[_0x3f85('0x19')](_0x478df6)[_0x3f85('0x1a')](_0x196a5f);}};}function respondWithFilteredResult(_0x274a04,_0x35ed10){return function(_0x53d27d){if(_0x53d27d){var _0x2d8927=typeof _0x35ed10[_0x3f85('0x1b')]===_0x3f85('0x1c')&&typeof _0x35ed10[_0x3f85('0x1d')]===_0x3f85('0x1c');var _0x3f3315=_0x53d27d[_0x3f85('0x1e')];var _0x3bc49a=_0x2d8927?0x0:_0x35ed10[_0x3f85('0x1b')];var _0xcdd71f=_0x2d8927?_0x53d27d[_0x3f85('0x1e')]:_0x35ed10['offset']+_0x35ed10[_0x3f85('0x1d')];var _0x4c664d;if(_0xcdd71f>=_0x3f3315){_0xcdd71f=_0x3f3315;_0x4c664d=0xc8;}else{_0x4c664d=0xce;}_0x274a04[_0x3f85('0x19')](_0x4c664d);return _0x274a04[_0x3f85('0x1f')]('Content-Range',_0x3bc49a+'-'+_0xcdd71f+'/'+_0x3f3315)['json'](_0x53d27d);}return null;};}function patchUpdates(_0x16caed){return function(_0x2bfe6e){try{jsonpatch['apply'](_0x2bfe6e,_0x16caed,!![]);}catch(_0x55fd2b){return BPromise[_0x3f85('0x20')](_0x55fd2b);}return _0x2bfe6e[_0x3f85('0x21')]();};}function saveUpdates(_0x4581dd,_0x50c473){return function(_0x4739f5){if(_0x4739f5){return _0x4739f5[_0x3f85('0x22')](_0x4581dd)[_0x3f85('0x23')](function(_0x121495){return _0x121495;});}return null;};}function removeEntity(_0x3faf6c,_0x298d06){return function(_0x4ca964){if(_0x4ca964){return _0x4ca964[_0x3f85('0x24')]()[_0x3f85('0x23')](function(){_0x3faf6c[_0x3f85('0x19')](0xcc)[_0x3f85('0x25')]();});}};}function handleEntityNotFound(_0x579158,_0xd8e991){return function(_0x21d552){if(!_0x21d552){_0x579158[_0x3f85('0x18')](0x194);}return _0x21d552;};}function handleError(_0x4f3453,_0x1b0f53){_0x1b0f53=_0x1b0f53||0x1f4;return function(_0x5e4b03){logger[_0x3f85('0x26')](_0x5e4b03[_0x3f85('0x27')]);if(_0x5e4b03['name']){delete _0x5e4b03['name'];}_0x4f3453['status'](_0x1b0f53)[_0x3f85('0x28')](_0x5e4b03);};}exports['index']=function(_0xd10ad2,_0x5657f6){var _0x47f05c={},_0x370943={},_0x24eaed={'count':0x0,'rows':[]};var _0x17e6d3=_[_0x3f85('0x29')](db['VtigerField'][_0x3f85('0x2a')],function(_0x21b893){return{'name':_0x21b893[_0x3f85('0x2b')],'type':_0x21b893[_0x3f85('0x2c')][_0x3f85('0x2d')]};});_0x370943[_0x3f85('0x2e')]=_['map'](_0x17e6d3,_0x3f85('0x2f'));_0x370943[_0x3f85('0x30')]=_[_0x3f85('0x31')](_0xd10ad2[_0x3f85('0x30')]);_0x370943[_0x3f85('0x32')]=_['intersection'](_0x370943[_0x3f85('0x2e')],_0x370943[_0x3f85('0x30')]);_0x47f05c[_0x3f85('0x33')]=_['intersection'](_0x370943[_0x3f85('0x2e')],qs[_0x3f85('0x34')](_0xd10ad2[_0x3f85('0x30')][_0x3f85('0x34')]));_0x47f05c[_0x3f85('0x33')]=_0x47f05c[_0x3f85('0x33')][_0x3f85('0x35')]?_0x47f05c[_0x3f85('0x33')]:_0x370943['model'];if(!_0xd10ad2[_0x3f85('0x30')][_0x3f85('0x36')]('nolimit')){_0x47f05c[_0x3f85('0x1d')]=qs[_0x3f85('0x1d')](_0xd10ad2['query'][_0x3f85('0x1d')]);_0x47f05c['offset']=qs[_0x3f85('0x1b')](_0xd10ad2[_0x3f85('0x30')][_0x3f85('0x1b')]);}_0x47f05c[_0x3f85('0x37')]=qs[_0x3f85('0x38')](_0xd10ad2[_0x3f85('0x30')][_0x3f85('0x38')]);_0x47f05c['where']=qs['filters'](_[_0x3f85('0x39')](_0xd10ad2[_0x3f85('0x30')],_0x370943['filters']),_0x17e6d3);if(_0xd10ad2['query'][_0x3f85('0x3a')]){_0x47f05c[_0x3f85('0x3b')]=_['merge'](_0x47f05c[_0x3f85('0x3b')],{'$or':_[_0x3f85('0x29')](_0x17e6d3,function(_0x1d9952){if(_0x1d9952['type']!==_0x3f85('0x3c')){var _0x260110={};_0x260110[_0x1d9952[_0x3f85('0x2f')]]={'$like':'%'+_0xd10ad2[_0x3f85('0x30')][_0x3f85('0x3a')]+'%'};return _0x260110;}})});}_0x47f05c=_['merge']({},_0x47f05c,_0xd10ad2[_0x3f85('0x3d')]);var _0x651768={'where':_0x47f05c[_0x3f85('0x3b')]};return db['VtigerField'][_0x3f85('0x1e')](_0x651768)[_0x3f85('0x23')](function(_0x5dda4b){_0x24eaed['count']=_0x5dda4b;if(_0xd10ad2['query'][_0x3f85('0x3e')]){_0x47f05c['include']=[{'all':!![]}];}return db[_0x3f85('0x3f')][_0x3f85('0x40')](_0x47f05c);})[_0x3f85('0x23')](function(_0x3bf47e){_0x24eaed[_0x3f85('0x41')]=_0x3bf47e;return _0x24eaed;})['then'](respondWithFilteredResult(_0x5657f6,_0x47f05c))[_0x3f85('0x42')](handleError(_0x5657f6,null));};exports[_0x3f85('0x43')]=function(_0x180399,_0xdae88c){var _0x428d21={'raw':!![],'where':{'id':_0x180399['params']['id']}},_0x226bc6={};_0x226bc6[_0x3f85('0x2e')]=_[_0x3f85('0x31')](db['VtigerField'][_0x3f85('0x2a')]);_0x226bc6[_0x3f85('0x30')]=_[_0x3f85('0x31')](_0x180399[_0x3f85('0x30')]);_0x226bc6[_0x3f85('0x32')]=_['intersection'](_0x226bc6['model'],_0x226bc6[_0x3f85('0x30')]);_0x428d21[_0x3f85('0x33')]=_[_0x3f85('0x44')](_0x226bc6[_0x3f85('0x2e')],qs[_0x3f85('0x34')](_0x180399[_0x3f85('0x30')][_0x3f85('0x34')]));_0x428d21[_0x3f85('0x33')]=_0x428d21[_0x3f85('0x33')][_0x3f85('0x35')]?_0x428d21['attributes']:_0x226bc6[_0x3f85('0x2e')];if(_0x180399[_0x3f85('0x30')][_0x3f85('0x3e')]){_0x428d21[_0x3f85('0x45')]=[{'all':!![]}];}_0x428d21=_[_0x3f85('0x46')]({},_0x428d21,_0x180399[_0x3f85('0x3d')]);return db[_0x3f85('0x3f')][_0x3f85('0x47')](_0x428d21)['then'](handleEntityNotFound(_0xdae88c,null))['then'](respondWithResult(_0xdae88c,null))['catch'](handleError(_0xdae88c,null));};exports[_0x3f85('0x48')]=function(_0x55124e,_0x40f374){return db[_0x3f85('0x3f')][_0x3f85('0x48')](_0x55124e[_0x3f85('0x49')],{})[_0x3f85('0x23')](respondWithResult(_0x40f374,0xc9))[_0x3f85('0x42')](handleError(_0x40f374,null));};exports[_0x3f85('0x22')]=function(_0x201cbc,_0x751d9f){if(_0x201cbc[_0x3f85('0x49')]['id']){delete _0x201cbc[_0x3f85('0x49')]['id'];}return db[_0x3f85('0x3f')][_0x3f85('0x47')]({'where':{'id':_0x201cbc[_0x3f85('0x4a')]['id']}})[_0x3f85('0x23')](handleEntityNotFound(_0x751d9f,null))[_0x3f85('0x23')](saveUpdates(_0x201cbc[_0x3f85('0x49')],null))['then'](respondWithResult(_0x751d9f,null))[_0x3f85('0x42')](handleError(_0x751d9f,null));};exports['destroy']=function(_0xcd64a2,_0x3a2e98){return db[_0x3f85('0x3f')][_0x3f85('0x47')]({'where':{'id':_0xcd64a2[_0x3f85('0x4a')]['id']}})[_0x3f85('0x23')](handleEntityNotFound(_0x3a2e98,null))['then'](removeEntity(_0x3a2e98,null))[_0x3f85('0x42')](handleError(_0x3a2e98,null));};
\ No newline at end of file