Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 790b76e..5c43292 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x19f9=['options','create','body','find','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','sendStatus','end','status','json','undefined','count','set','reject','save','update','then','destroy','error','stack','name','index','map','VtigerField','rawAttributes','fieldName','type','key','model','query','intersection','attributes','fields','hasOwnProperty','nolimit','limit','offset','order','sort','where','filters','filter','merge','VIRTUAL','include','findAll','catch','show','params','keys','length'];(function(_0x1a9ed0,_0x1085fc){var _0x47bbd6=function(_0x27bd1c){while(--_0x27bd1c){_0x1a9ed0['push'](_0x1a9ed0['shift']());}};_0x47bbd6(++_0x1085fc);}(_0x19f9,0x124));var _0x919f=function(_0x46d0c9,_0x526bfa){_0x46d0c9=_0x46d0c9-0x0;var _0x174506=_0x19f9[_0x46d0c9];return _0x174506;};'use strict';var emlformat=require(_0x919f('0x0'));var rimraf=require(_0x919f('0x1'));var zipdir=require(_0x919f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x919f('0x3'));var moment=require(_0x919f('0x4'));var BPromise=require(_0x919f('0x5'));var Mustache=require('mustache');var util=require(_0x919f('0x6'));var path=require(_0x919f('0x7'));var sox=require(_0x919f('0x8'));var csv=require(_0x919f('0x9'));var ejs=require(_0x919f('0xa'));var fs=require('fs');var fs_extra=require(_0x919f('0xb'));var _=require(_0x919f('0xc'));var squel=require(_0x919f('0xd'));var crypto=require(_0x919f('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x919f('0x9'));var querystring=require(_0x919f('0xf'));var Papa=require(_0x919f('0x10'));var Redis=require(_0x919f('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x919f('0x12'));var hardwareService=require(_0x919f('0x13'));var logger=require(_0x919f('0x14'))(_0x919f('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x919f('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x19aac4,_0x1bad6f){_0x1bad6f=_0x1bad6f||0xcc;return function(_0x32fbe8){if(_0x32fbe8){return _0x19aac4[_0x919f('0x17')](_0x1bad6f);}return _0x19aac4['status'](_0x1bad6f)[_0x919f('0x18')]();};}function respondWithResult(_0x5513ca,_0x4d0170){_0x4d0170=_0x4d0170||0xc8;return function(_0x25518a){if(_0x25518a){return _0x5513ca[_0x919f('0x19')](_0x4d0170)[_0x919f('0x1a')](_0x25518a);}};}function respondWithFilteredResult(_0x22cb24,_0x3d1970){return function(_0x470c42){if(_0x470c42){var _0xc69b17=typeof _0x3d1970['offset']===_0x919f('0x1b')&&typeof _0x3d1970['limit']==='undefined';var _0x447cd3=_0x470c42[_0x919f('0x1c')];var _0x5d7522=_0xc69b17?0x0:_0x3d1970['offset'];var _0x18b02c=_0xc69b17?_0x470c42['count']:_0x3d1970['offset']+_0x3d1970['limit'];var _0x16551f;if(_0x18b02c>=_0x447cd3){_0x18b02c=_0x447cd3;_0x16551f=0xc8;}else{_0x16551f=0xce;}_0x22cb24['status'](_0x16551f);return _0x22cb24[_0x919f('0x1d')]('Content-Range',_0x5d7522+'-'+_0x18b02c+'/'+_0x447cd3)[_0x919f('0x1a')](_0x470c42);}return null;};}function patchUpdates(_0x53cb32){return function(_0x330f1e){try{jsonpatch['apply'](_0x330f1e,_0x53cb32,!![]);}catch(_0x164ef9){return BPromise[_0x919f('0x1e')](_0x164ef9);}return _0x330f1e[_0x919f('0x1f')]();};}function saveUpdates(_0x5c9812,_0x225bd5){return function(_0x5c959d){if(_0x5c959d){return _0x5c959d[_0x919f('0x20')](_0x5c9812)[_0x919f('0x21')](function(_0x5203b6){return _0x5203b6;});}return null;};}function removeEntity(_0x410493,_0x40d1b7){return function(_0x5a55eb){if(_0x5a55eb){return _0x5a55eb[_0x919f('0x22')]()[_0x919f('0x21')](function(){_0x410493['status'](0xcc)[_0x919f('0x18')]();});}};}function handleEntityNotFound(_0x3f5d23,_0x287195){return function(_0x3ade2c){if(!_0x3ade2c){_0x3f5d23[_0x919f('0x17')](0x194);}return _0x3ade2c;};}function handleError(_0x56d54c,_0x571f3e){_0x571f3e=_0x571f3e||0x1f4;return function(_0xc7faab){logger[_0x919f('0x23')](_0xc7faab[_0x919f('0x24')]);if(_0xc7faab[_0x919f('0x25')]){delete _0xc7faab['name'];}_0x56d54c[_0x919f('0x19')](_0x571f3e)['send'](_0xc7faab);};}exports[_0x919f('0x26')]=function(_0x2636ea,_0x10563b){var _0x12f20f={},_0x2cf6e7={},_0xff884f={'count':0x0,'rows':[]};var _0x23f34d=_[_0x919f('0x27')](db[_0x919f('0x28')][_0x919f('0x29')],function(_0x2d7167){return{'name':_0x2d7167[_0x919f('0x2a')],'type':_0x2d7167[_0x919f('0x2b')][_0x919f('0x2c')]};});_0x2cf6e7[_0x919f('0x2d')]=_[_0x919f('0x27')](_0x23f34d,_0x919f('0x25'));_0x2cf6e7[_0x919f('0x2e')]=_['keys'](_0x2636ea[_0x919f('0x2e')]);_0x2cf6e7['filters']=_[_0x919f('0x2f')](_0x2cf6e7[_0x919f('0x2d')],_0x2cf6e7[_0x919f('0x2e')]);_0x12f20f[_0x919f('0x30')]=_[_0x919f('0x2f')](_0x2cf6e7[_0x919f('0x2d')],qs[_0x919f('0x31')](_0x2636ea['query'][_0x919f('0x31')]));_0x12f20f[_0x919f('0x30')]=_0x12f20f[_0x919f('0x30')]['length']?_0x12f20f['attributes']:_0x2cf6e7[_0x919f('0x2d')];if(!_0x2636ea[_0x919f('0x2e')][_0x919f('0x32')](_0x919f('0x33'))){_0x12f20f[_0x919f('0x34')]=qs[_0x919f('0x34')](_0x2636ea[_0x919f('0x2e')][_0x919f('0x34')]);_0x12f20f[_0x919f('0x35')]=qs[_0x919f('0x35')](_0x2636ea[_0x919f('0x2e')][_0x919f('0x35')]);}_0x12f20f[_0x919f('0x36')]=qs[_0x919f('0x37')](_0x2636ea[_0x919f('0x2e')][_0x919f('0x37')]);_0x12f20f[_0x919f('0x38')]=qs[_0x919f('0x39')](_['pick'](_0x2636ea['query'],_0x2cf6e7[_0x919f('0x39')]),_0x23f34d);if(_0x2636ea[_0x919f('0x2e')][_0x919f('0x3a')]){_0x12f20f[_0x919f('0x38')]=_[_0x919f('0x3b')](_0x12f20f[_0x919f('0x38')],{'$or':_['map'](_0x23f34d,function(_0x3f9fb3){if(_0x3f9fb3[_0x919f('0x2b')]!==_0x919f('0x3c')){var _0x4ab8c8={};_0x4ab8c8[_0x3f9fb3[_0x919f('0x25')]]={'$like':'%'+_0x2636ea[_0x919f('0x2e')][_0x919f('0x3a')]+'%'};return _0x4ab8c8;}})});}_0x12f20f=_['merge']({},_0x12f20f,_0x2636ea['options']);var _0x188fd5={'where':_0x12f20f['where']};return db[_0x919f('0x28')][_0x919f('0x1c')](_0x188fd5)[_0x919f('0x21')](function(_0x166d03){_0xff884f['count']=_0x166d03;if(_0x2636ea[_0x919f('0x2e')]['includeAll']){_0x12f20f[_0x919f('0x3d')]=[{'all':!![]}];}return db[_0x919f('0x28')][_0x919f('0x3e')](_0x12f20f);})['then'](function(_0x12aa7b){_0xff884f['rows']=_0x12aa7b;return _0xff884f;})['then'](respondWithFilteredResult(_0x10563b,_0x12f20f))[_0x919f('0x3f')](handleError(_0x10563b,null));};exports[_0x919f('0x40')]=function(_0x142781,_0x6859c4){var _0x266a51={'raw':!![],'where':{'id':_0x142781[_0x919f('0x41')]['id']}},_0x1bea67={};_0x1bea67[_0x919f('0x2d')]=_[_0x919f('0x42')](db[_0x919f('0x28')][_0x919f('0x29')]);_0x1bea67[_0x919f('0x2e')]=_['keys'](_0x142781[_0x919f('0x2e')]);_0x1bea67['filters']=_[_0x919f('0x2f')](_0x1bea67[_0x919f('0x2d')],_0x1bea67[_0x919f('0x2e')]);_0x266a51[_0x919f('0x30')]=_[_0x919f('0x2f')](_0x1bea67['model'],qs['fields'](_0x142781[_0x919f('0x2e')]['fields']));_0x266a51[_0x919f('0x30')]=_0x266a51[_0x919f('0x30')][_0x919f('0x43')]?_0x266a51['attributes']:_0x1bea67[_0x919f('0x2d')];if(_0x142781['query']['includeAll']){_0x266a51[_0x919f('0x3d')]=[{'all':!![]}];}_0x266a51=_[_0x919f('0x3b')]({},_0x266a51,_0x142781[_0x919f('0x44')]);return db[_0x919f('0x28')]['find'](_0x266a51)[_0x919f('0x21')](handleEntityNotFound(_0x6859c4,null))[_0x919f('0x21')](respondWithResult(_0x6859c4,null))[_0x919f('0x3f')](handleError(_0x6859c4,null));};exports['create']=function(_0xe5cb7f,_0x3cee0e){return db['VtigerField'][_0x919f('0x45')](_0xe5cb7f[_0x919f('0x46')],{})[_0x919f('0x21')](respondWithResult(_0x3cee0e,0xc9))[_0x919f('0x3f')](handleError(_0x3cee0e,null));};exports[_0x919f('0x20')]=function(_0x293449,_0x9e373b){if(_0x293449[_0x919f('0x46')]['id']){delete _0x293449['body']['id'];}return db[_0x919f('0x28')][_0x919f('0x47')]({'where':{'id':_0x293449['params']['id']}})['then'](handleEntityNotFound(_0x9e373b,null))[_0x919f('0x21')](saveUpdates(_0x293449['body'],null))['then'](respondWithResult(_0x9e373b,null))['catch'](handleError(_0x9e373b,null));};exports[_0x919f('0x22')]=function(_0x243f72,_0x3ca86a){return db[_0x919f('0x28')][_0x919f('0x47')]({'where':{'id':_0x243f72[_0x919f('0x41')]['id']}})[_0x919f('0x21')](handleEntityNotFound(_0x3ca86a,null))['then'](removeEntity(_0x3ca86a,null))['catch'](handleError(_0x3ca86a,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