Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 842317a..59d2b33 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6f58=['length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','VtigerField','includeAll','include','findAll','params','keys','find','catch','create','body','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields'];(function(_0x3851ea,_0x2a2ee9){var _0x58db3c=function(_0x321c83){while(--_0x321c83){_0x3851ea['push'](_0x3851ea['shift']());}};_0x58db3c(++_0x2a2ee9);}(_0x6f58,0xe9));var _0x86f5=function(_0x228eb7,_0x526138){_0x228eb7=_0x228eb7-0x0;var _0x59da7a=_0x6f58[_0x228eb7];return _0x59da7a;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x86f5('0x0'));var zipdir=require(_0x86f5('0x1'));var jsonpatch=require(_0x86f5('0x2'));var rp=require('request-promise');var moment=require(_0x86f5('0x3'));var BPromise=require(_0x86f5('0x4'));var Mustache=require('mustache');var util=require(_0x86f5('0x5'));var path=require(_0x86f5('0x6'));var sox=require('sox');var csv=require(_0x86f5('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x86f5('0x8'));var squel=require('squel');var crypto=require(_0x86f5('0x9'));var jsforce=require(_0x86f5('0xa'));var deskjs=require(_0x86f5('0xb'));var toCsv=require(_0x86f5('0x7'));var querystring=require(_0x86f5('0xc'));var Papa=require(_0x86f5('0xd'));var Redis=require('ioredis');var authService=require(_0x86f5('0xe'));var qs=require(_0x86f5('0xf'));var as=require(_0x86f5('0x10'));var hardwareService=require(_0x86f5('0x11'));var logger=require(_0x86f5('0x12'))(_0x86f5('0x13'));var utils=require(_0x86f5('0x14'));var config=require(_0x86f5('0x15'));var db=require(_0x86f5('0x16'))['db'];function respondWithStatusCode(_0x272129,_0x264cbe){_0x264cbe=_0x264cbe||0xcc;return function(_0x4e2029){if(_0x4e2029){return _0x272129[_0x86f5('0x17')](_0x264cbe);}return _0x272129[_0x86f5('0x18')](_0x264cbe)[_0x86f5('0x19')]();};}function respondWithResult(_0x58ff3c,_0x9dafd){_0x9dafd=_0x9dafd||0xc8;return function(_0x5df6ad){if(_0x5df6ad){return _0x58ff3c[_0x86f5('0x18')](_0x9dafd)[_0x86f5('0x1a')](_0x5df6ad);}};}function respondWithFilteredResult(_0x4fea9f,_0x9b5f10){return function(_0x438619){if(_0x438619){var _0x27c5a5=_0x438619[_0x86f5('0x1b')],_0x8a4c28=_0x9b5f10[_0x86f5('0x1c')],_0xc297d8=_0x9b5f10[_0x86f5('0x1c')]+_0x9b5f10[_0x86f5('0x1d')],_0x5448c3;if(_0xc297d8>=_0x27c5a5){_0xc297d8=_0x27c5a5;_0x5448c3=0xc8;}else{_0x5448c3=0xce;}_0x4fea9f['status'](_0x5448c3);return _0x4fea9f[_0x86f5('0x1e')](_0x86f5('0x1f'),_0x8a4c28+'-'+_0xc297d8+'/'+_0x27c5a5)[_0x86f5('0x1a')](_0x438619);}return null;};}function patchUpdates(_0x48057d){return function(_0x3c8978){try{jsonpatch[_0x86f5('0x20')](_0x3c8978,_0x48057d,!![]);}catch(_0x2e2a01){return BPromise[_0x86f5('0x21')](_0x2e2a01);}return _0x3c8978[_0x86f5('0x22')]();};}function saveUpdates(_0x2dd300,_0x2ae4db){return function(_0x27e93f){if(_0x27e93f){return _0x27e93f['update'](_0x2dd300)[_0x86f5('0x23')](function(_0x4a2f85){return _0x4a2f85;});}return null;};}function removeEntity(_0x36bc77,_0xc77f9b){return function(_0x25887e){if(_0x25887e){return _0x25887e['destroy']()[_0x86f5('0x23')](function(){_0x36bc77[_0x86f5('0x18')](0xcc)[_0x86f5('0x19')]();});}};}function handleEntityNotFound(_0x2e0647,_0x4c4b8b){return function(_0x3fe9e7){if(!_0x3fe9e7){_0x2e0647['sendStatus'](0x194);}return _0x3fe9e7;};}function handleError(_0x46f147,_0x4ee00e){_0x4ee00e=_0x4ee00e||0x1f4;return function(_0x4416f5){logger['error'](_0x4416f5[_0x86f5('0x24')]);if(_0x4416f5['name']){delete _0x4416f5[_0x86f5('0x25')];}_0x46f147[_0x86f5('0x18')](_0x4ee00e)[_0x86f5('0x26')](_0x4416f5);};}exports[_0x86f5('0x27')]=function(_0x3fc3c6,_0xca25d3){var _0x4ab0c={},_0x4e8085={},_0xb9686e={'count':0x0,'rows':[]};var _0x138e46=_[_0x86f5('0x28')](db['VtigerField'][_0x86f5('0x29')],function(_0x54b8e6){return{'name':_0x54b8e6[_0x86f5('0x2a')],'type':_0x54b8e6[_0x86f5('0x2b')][_0x86f5('0x2c')]};});_0x4e8085['model']=_[_0x86f5('0x28')](_0x138e46,_0x86f5('0x25'));_0x4e8085[_0x86f5('0x2d')]=_['keys'](_0x3fc3c6[_0x86f5('0x2d')]);_0x4e8085[_0x86f5('0x2e')]=_[_0x86f5('0x2f')](_0x4e8085[_0x86f5('0x30')],_0x4e8085[_0x86f5('0x2d')]);_0x4ab0c[_0x86f5('0x31')]=_[_0x86f5('0x2f')](_0x4e8085[_0x86f5('0x30')],qs[_0x86f5('0x32')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x32')]));_0x4ab0c[_0x86f5('0x31')]=_0x4ab0c[_0x86f5('0x31')][_0x86f5('0x33')]?_0x4ab0c[_0x86f5('0x31')]:_0x4e8085[_0x86f5('0x30')];if(!_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x34')]('nolimit')){_0x4ab0c['limit']=qs[_0x86f5('0x1d')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x1d')]);_0x4ab0c[_0x86f5('0x1c')]=qs[_0x86f5('0x1c')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x1c')]);}_0x4ab0c[_0x86f5('0x35')]=qs['sort'](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x36')]);_0x4ab0c[_0x86f5('0x37')]=qs[_0x86f5('0x2e')](_[_0x86f5('0x38')](_0x3fc3c6[_0x86f5('0x2d')],_0x4e8085[_0x86f5('0x2e')]),_0x138e46);if(_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x39')]){_0x4ab0c['where']=_[_0x86f5('0x3a')](_0x4ab0c['where'],{'$or':_[_0x86f5('0x28')](_0x138e46,function(_0x1b1ec9){if(_0x1b1ec9[_0x86f5('0x2b')]!==_0x86f5('0x3b')){var _0x13adde={};_0x13adde[_0x1b1ec9['name']]={'$like':'%'+_0x3fc3c6[_0x86f5('0x2d')]['filter']+'%'};return _0x13adde;}})});}_0x4ab0c=_[_0x86f5('0x3a')]({},_0x4ab0c,_0x3fc3c6[_0x86f5('0x3c')]);var _0x507842={'where':_0x4ab0c[_0x86f5('0x37')]};return db[_0x86f5('0x3d')][_0x86f5('0x1b')](_0x507842)[_0x86f5('0x23')](function(_0x5705c9){_0xb9686e['count']=_0x5705c9;if(_0x3fc3c6['query'][_0x86f5('0x3e')]){_0x4ab0c[_0x86f5('0x3f')]=[{'all':!![]}];}return db[_0x86f5('0x3d')][_0x86f5('0x40')](_0x4ab0c);})['then'](function(_0x41c001){_0xb9686e['rows']=_0x41c001;return _0xb9686e;})[_0x86f5('0x23')](respondWithFilteredResult(_0xca25d3,_0x4ab0c))['catch'](handleError(_0xca25d3,null));};exports['show']=function(_0x363d3a,_0x47b842){var _0x2db0c1={'raw':!![],'where':{'id':_0x363d3a[_0x86f5('0x41')]['id']}},_0x31bcda={};_0x31bcda[_0x86f5('0x30')]=_[_0x86f5('0x42')](db[_0x86f5('0x3d')][_0x86f5('0x29')]);_0x31bcda['query']=_[_0x86f5('0x42')](_0x363d3a[_0x86f5('0x2d')]);_0x31bcda[_0x86f5('0x2e')]=_[_0x86f5('0x2f')](_0x31bcda[_0x86f5('0x30')],_0x31bcda[_0x86f5('0x2d')]);_0x2db0c1[_0x86f5('0x31')]=_[_0x86f5('0x2f')](_0x31bcda[_0x86f5('0x30')],qs[_0x86f5('0x32')](_0x363d3a[_0x86f5('0x2d')][_0x86f5('0x32')]));_0x2db0c1[_0x86f5('0x31')]=_0x2db0c1['attributes']['length']?_0x2db0c1[_0x86f5('0x31')]:_0x31bcda[_0x86f5('0x30')];if(_0x363d3a['query'][_0x86f5('0x3e')]){_0x2db0c1[_0x86f5('0x3f')]=[{'all':!![]}];}_0x2db0c1=_[_0x86f5('0x3a')]({},_0x2db0c1,_0x363d3a[_0x86f5('0x3c')]);return db[_0x86f5('0x3d')][_0x86f5('0x43')](_0x2db0c1)['then'](handleEntityNotFound(_0x47b842,null))[_0x86f5('0x23')](respondWithResult(_0x47b842,null))[_0x86f5('0x44')](handleError(_0x47b842,null));};exports[_0x86f5('0x45')]=function(_0x20b958,_0x31a932){return db[_0x86f5('0x3d')][_0x86f5('0x45')](_0x20b958['body'],{})['then'](respondWithResult(_0x31a932,0xc9))[_0x86f5('0x44')](handleError(_0x31a932,null));};exports['update']=function(_0x380184,_0x34232e){if(_0x380184[_0x86f5('0x46')]['id']){delete _0x380184[_0x86f5('0x46')]['id'];}return db['VtigerField']['find']({'where':{'id':_0x380184[_0x86f5('0x41')]['id']}})[_0x86f5('0x23')](handleEntityNotFound(_0x34232e,null))[_0x86f5('0x23')](saveUpdates(_0x380184[_0x86f5('0x46')],null))['then'](respondWithResult(_0x34232e,null))[_0x86f5('0x44')](handleError(_0x34232e,null));};exports['destroy']=function(_0x3cc75a,_0x202e29){return db[_0x86f5('0x3d')]['find']({'where':{'id':_0x3cc75a['params']['id']}})[_0x86f5('0x23')](handleEntityNotFound(_0x202e29,null))['then'](removeEntity(_0x202e29,null))[_0x86f5('0x44')](handleError(_0x202e29,null));};
\ No newline at end of file
+var _0xe765=['model','hasOwnProperty','nolimit','where','pick','filter','type','VIRTUAL','merge','options','include','findAll','rows','catch','show','keys','rawAttributes','includeAll','find','create','body','params','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','undefined','count','limit','set','reject','save','update','destroy','then','error','stack','name','send','map','VtigerField','fieldName','query','filters','intersection','fields','attributes','length'];(function(_0x30b09f,_0x13a909){var _0x421fa2=function(_0x2da770){while(--_0x2da770){_0x30b09f['push'](_0x30b09f['shift']());}};_0x421fa2(++_0x13a909);}(_0xe765,0x12e));var _0x5e76=function(_0x4192be,_0x477983){_0x4192be=_0x4192be-0x0;var _0x4fb1fb=_0xe765[_0x4192be];return _0x4fb1fb;};'use strict';var emlformat=require(_0x5e76('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5e76('0x1'));var jsonpatch=require(_0x5e76('0x2'));var rp=require(_0x5e76('0x3'));var moment=require(_0x5e76('0x4'));var BPromise=require(_0x5e76('0x5'));var Mustache=require(_0x5e76('0x6'));var util=require(_0x5e76('0x7'));var path=require(_0x5e76('0x8'));var sox=require(_0x5e76('0x9'));var csv=require(_0x5e76('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5e76('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x5e76('0xc'));var toCsv=require(_0x5e76('0xa'));var querystring=require(_0x5e76('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x5e76('0xe'));var qs=require(_0x5e76('0xf'));var as=require(_0x5e76('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5e76('0x11'))(_0x5e76('0x12'));var utils=require(_0x5e76('0x13'));var config=require(_0x5e76('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2c636e,_0x9ffadb){_0x9ffadb=_0x9ffadb||0xcc;return function(_0x436386){if(_0x436386){return _0x2c636e[_0x5e76('0x15')](_0x9ffadb);}return _0x2c636e[_0x5e76('0x16')](_0x9ffadb)[_0x5e76('0x17')]();};}function respondWithResult(_0x406f9a,_0x5430f5){_0x5430f5=_0x5430f5||0xc8;return function(_0x141f51){if(_0x141f51){return _0x406f9a[_0x5e76('0x16')](_0x5430f5)[_0x5e76('0x18')](_0x141f51);}};}function respondWithFilteredResult(_0x2b609b,_0x6728bc){return function(_0x4f1ee3){if(_0x4f1ee3){var _0x2f4f63=typeof _0x6728bc[_0x5e76('0x19')]===_0x5e76('0x1a')&&typeof _0x6728bc['limit']===_0x5e76('0x1a');var _0x24a7fa=_0x4f1ee3[_0x5e76('0x1b')];var _0x3ef38e=_0x2f4f63?0x0:_0x6728bc['offset'];var _0xdc22a8=_0x2f4f63?_0x4f1ee3[_0x5e76('0x1b')]:_0x6728bc['offset']+_0x6728bc[_0x5e76('0x1c')];var _0x5d89c1;if(_0xdc22a8>=_0x24a7fa){_0xdc22a8=_0x24a7fa;_0x5d89c1=0xc8;}else{_0x5d89c1=0xce;}_0x2b609b['status'](_0x5d89c1);return _0x2b609b[_0x5e76('0x1d')]('Content-Range',_0x3ef38e+'-'+_0xdc22a8+'/'+_0x24a7fa)[_0x5e76('0x18')](_0x4f1ee3);}return null;};}function patchUpdates(_0x5aceb8){return function(_0x1ed0bc){try{jsonpatch['apply'](_0x1ed0bc,_0x5aceb8,!![]);}catch(_0xbb49ed){return BPromise[_0x5e76('0x1e')](_0xbb49ed);}return _0x1ed0bc[_0x5e76('0x1f')]();};}function saveUpdates(_0x4ee72b,_0x15fa4e){return function(_0x1541de){if(_0x1541de){return _0x1541de[_0x5e76('0x20')](_0x4ee72b)['then'](function(_0x27e4cb){return _0x27e4cb;});}return null;};}function removeEntity(_0xc3deee,_0x5f3ac4){return function(_0xdfb355){if(_0xdfb355){return _0xdfb355[_0x5e76('0x21')]()[_0x5e76('0x22')](function(){_0xc3deee[_0x5e76('0x16')](0xcc)[_0x5e76('0x17')]();});}};}function handleEntityNotFound(_0x2a7ebd,_0x497377){return function(_0x3e45cd){if(!_0x3e45cd){_0x2a7ebd['sendStatus'](0x194);}return _0x3e45cd;};}function handleError(_0x2df37b,_0x4afb4a){_0x4afb4a=_0x4afb4a||0x1f4;return function(_0x2ec87d){logger[_0x5e76('0x23')](_0x2ec87d[_0x5e76('0x24')]);if(_0x2ec87d[_0x5e76('0x25')]){delete _0x2ec87d['name'];}_0x2df37b[_0x5e76('0x16')](_0x4afb4a)[_0x5e76('0x26')](_0x2ec87d);};}exports['index']=function(_0x2b0345,_0x575715){var _0x1e6b36={},_0x160239={},_0x23a2a5={'count':0x0,'rows':[]};var _0x4c2e4c=_[_0x5e76('0x27')](db[_0x5e76('0x28')]['rawAttributes'],function(_0x1c8db6){return{'name':_0x1c8db6[_0x5e76('0x29')],'type':_0x1c8db6['type']['key']};});_0x160239['model']=_[_0x5e76('0x27')](_0x4c2e4c,_0x5e76('0x25'));_0x160239[_0x5e76('0x2a')]=_['keys'](_0x2b0345[_0x5e76('0x2a')]);_0x160239[_0x5e76('0x2b')]=_[_0x5e76('0x2c')](_0x160239['model'],_0x160239[_0x5e76('0x2a')]);_0x1e6b36['attributes']=_[_0x5e76('0x2c')](_0x160239['model'],qs[_0x5e76('0x2d')](_0x2b0345[_0x5e76('0x2a')][_0x5e76('0x2d')]));_0x1e6b36['attributes']=_0x1e6b36[_0x5e76('0x2e')][_0x5e76('0x2f')]?_0x1e6b36[_0x5e76('0x2e')]:_0x160239[_0x5e76('0x30')];if(!_0x2b0345[_0x5e76('0x2a')][_0x5e76('0x31')](_0x5e76('0x32'))){_0x1e6b36['limit']=qs['limit'](_0x2b0345[_0x5e76('0x2a')][_0x5e76('0x1c')]);_0x1e6b36[_0x5e76('0x19')]=qs['offset'](_0x2b0345[_0x5e76('0x2a')]['offset']);}_0x1e6b36['order']=qs['sort'](_0x2b0345[_0x5e76('0x2a')]['sort']);_0x1e6b36[_0x5e76('0x33')]=qs['filters'](_[_0x5e76('0x34')](_0x2b0345['query'],_0x160239[_0x5e76('0x2b')]),_0x4c2e4c);if(_0x2b0345[_0x5e76('0x2a')][_0x5e76('0x35')]){_0x1e6b36['where']=_['merge'](_0x1e6b36[_0x5e76('0x33')],{'$or':_[_0x5e76('0x27')](_0x4c2e4c,function(_0x46ca62){if(_0x46ca62[_0x5e76('0x36')]!==_0x5e76('0x37')){var _0x428881={};_0x428881[_0x46ca62['name']]={'$like':'%'+_0x2b0345[_0x5e76('0x2a')][_0x5e76('0x35')]+'%'};return _0x428881;}})});}_0x1e6b36=_[_0x5e76('0x38')]({},_0x1e6b36,_0x2b0345[_0x5e76('0x39')]);var _0x5254ac={'where':_0x1e6b36[_0x5e76('0x33')]};return db[_0x5e76('0x28')]['count'](_0x5254ac)[_0x5e76('0x22')](function(_0x2f3a1b){_0x23a2a5[_0x5e76('0x1b')]=_0x2f3a1b;if(_0x2b0345[_0x5e76('0x2a')]['includeAll']){_0x1e6b36[_0x5e76('0x3a')]=[{'all':!![]}];}return db[_0x5e76('0x28')][_0x5e76('0x3b')](_0x1e6b36);})[_0x5e76('0x22')](function(_0x5129b0){_0x23a2a5[_0x5e76('0x3c')]=_0x5129b0;return _0x23a2a5;})[_0x5e76('0x22')](respondWithFilteredResult(_0x575715,_0x1e6b36))[_0x5e76('0x3d')](handleError(_0x575715,null));};exports[_0x5e76('0x3e')]=function(_0x30e28c,_0x4bc410){var _0x3b44ce={'raw':!![],'where':{'id':_0x30e28c['params']['id']}},_0x17e2bd={};_0x17e2bd[_0x5e76('0x30')]=_[_0x5e76('0x3f')](db[_0x5e76('0x28')][_0x5e76('0x40')]);_0x17e2bd[_0x5e76('0x2a')]=_[_0x5e76('0x3f')](_0x30e28c[_0x5e76('0x2a')]);_0x17e2bd[_0x5e76('0x2b')]=_[_0x5e76('0x2c')](_0x17e2bd[_0x5e76('0x30')],_0x17e2bd['query']);_0x3b44ce[_0x5e76('0x2e')]=_[_0x5e76('0x2c')](_0x17e2bd[_0x5e76('0x30')],qs[_0x5e76('0x2d')](_0x30e28c[_0x5e76('0x2a')][_0x5e76('0x2d')]));_0x3b44ce['attributes']=_0x3b44ce['attributes'][_0x5e76('0x2f')]?_0x3b44ce['attributes']:_0x17e2bd['model'];if(_0x30e28c[_0x5e76('0x2a')][_0x5e76('0x41')]){_0x3b44ce[_0x5e76('0x3a')]=[{'all':!![]}];}_0x3b44ce=_['merge']({},_0x3b44ce,_0x30e28c['options']);return db[_0x5e76('0x28')][_0x5e76('0x42')](_0x3b44ce)[_0x5e76('0x22')](handleEntityNotFound(_0x4bc410,null))[_0x5e76('0x22')](respondWithResult(_0x4bc410,null))[_0x5e76('0x3d')](handleError(_0x4bc410,null));};exports[_0x5e76('0x43')]=function(_0x3d8598,_0xdca54f){return db[_0x5e76('0x28')][_0x5e76('0x43')](_0x3d8598[_0x5e76('0x44')],{})[_0x5e76('0x22')](respondWithResult(_0xdca54f,0xc9))[_0x5e76('0x3d')](handleError(_0xdca54f,null));};exports['update']=function(_0x5e7ada,_0x1489d7){if(_0x5e7ada[_0x5e76('0x44')]['id']){delete _0x5e7ada[_0x5e76('0x44')]['id'];}return db[_0x5e76('0x28')][_0x5e76('0x42')]({'where':{'id':_0x5e7ada[_0x5e76('0x45')]['id']}})[_0x5e76('0x22')](handleEntityNotFound(_0x1489d7,null))[_0x5e76('0x22')](saveUpdates(_0x5e7ada['body'],null))[_0x5e76('0x22')](respondWithResult(_0x1489d7,null))['catch'](handleError(_0x1489d7,null));};exports[_0x5e76('0x21')]=function(_0x55365c,_0x233ab5){return db['VtigerField']['find']({'where':{'id':_0x55365c['params']['id']}})[_0x5e76('0x22')](handleEntityNotFound(_0x233ab5,null))[_0x5e76('0x22')](removeEntity(_0x233ab5,null))['catch'](handleError(_0x233ab5,null));};
\ No newline at end of file