Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 5732a12..a1b4779 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9062=['../../config/license/util','../../mysqldb','sendStatus','status','json','count','offset','limit','set','apply','reject','save','update','end','error','stack','name','VtigerField','rawAttributes','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','VIRTUAL','merge','options','includeAll','include','rows','catch','show','params','keys','find','then','create','body','destroy','html-pdf','eml-format','zip-dir','request-promise','moment','bluebird','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../config/logger','api','../../config/environment'];(function(_0x1950f9,_0x5aaf55){var _0x27b40c=function(_0x8c070d){while(--_0x8c070d){_0x1950f9['push'](_0x1950f9['shift']());}};_0x27b40c(++_0x5aaf55);}(_0x9062,0xfd));var _0x2906=function(_0x529917,_0x32129c){_0x529917=_0x529917-0x0;var _0x2e6d39=_0x9062[_0x529917];return _0x2e6d39;};'use strict';var pdf=require(_0x2906('0x0'));var emlformat=require(_0x2906('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x2906('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x2906('0x3'));var moment=require(_0x2906('0x4'));var BPromise=require(_0x2906('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x2906('0x6'));var sox=require(_0x2906('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x2906('0x8'));var squel=require(_0x2906('0x9'));var crypto=require(_0x2906('0xa'));var jsforce=require(_0x2906('0xb'));var deskjs=require(_0x2906('0xc'));var toCsv=require(_0x2906('0xd'));var querystring=require(_0x2906('0xe'));var Papa=require(_0x2906('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x2906('0x10'))(_0x2906('0x11'));var utils=require('../../config/utils');var config=require(_0x2906('0x12'));var licenseUtil=require(_0x2906('0x13'));var db=require(_0x2906('0x14'))['db'];function respondWithStatusCode(_0x3c6f0b,_0x5f2f64){_0x5f2f64=_0x5f2f64||0xcc;return function(_0x26d998){if(_0x26d998){return _0x3c6f0b[_0x2906('0x15')](_0x5f2f64);}return _0x3c6f0b[_0x2906('0x16')](_0x5f2f64)['end']();};}function respondWithResult(_0x36df13,_0x6aee97){_0x6aee97=_0x6aee97||0xc8;return function(_0x5dcf28){if(_0x5dcf28){return _0x36df13[_0x2906('0x16')](_0x6aee97)[_0x2906('0x17')](_0x5dcf28);}};}function respondWithFilteredResult(_0x5afa8b,_0x44943f){return function(_0x31c133){if(_0x31c133){var _0x58546d=_0x31c133[_0x2906('0x18')],_0x9ef85e=_0x44943f['offset'],_0x5e83e9=_0x44943f[_0x2906('0x19')]+_0x44943f[_0x2906('0x1a')],_0x4b495e;if(_0x5e83e9>=_0x58546d){_0x5e83e9=_0x58546d;_0x4b495e=0xc8;}else{_0x4b495e=0xce;}_0x5afa8b['status'](_0x4b495e);return _0x5afa8b[_0x2906('0x1b')]('Content-Range',_0x9ef85e+'-'+_0x5e83e9+'/'+_0x58546d)['json'](_0x31c133);}return null;};}function patchUpdates(_0x45c793){return function(_0x2442dc){try{jsonpatch[_0x2906('0x1c')](_0x2442dc,_0x45c793,!![]);}catch(_0x23dd50){return BPromise[_0x2906('0x1d')](_0x23dd50);}return _0x2442dc[_0x2906('0x1e')]();};}function saveUpdates(_0x3e7086,_0x4457cb){return function(_0x5e0671){if(_0x5e0671){return _0x5e0671[_0x2906('0x1f')](_0x3e7086)['then'](function(_0x327266){return _0x327266;});}return null;};}function removeEntity(_0x4f38e7,_0x2987e3){return function(_0x54f2a6){if(_0x54f2a6){return _0x54f2a6['destroy']()['then'](function(){_0x4f38e7[_0x2906('0x16')](0xcc)[_0x2906('0x20')]();});}};}function handleEntityNotFound(_0xbdecbb,_0x478707){return function(_0x2a21bc){if(!_0x2a21bc){_0xbdecbb[_0x2906('0x15')](0x194);}return _0x2a21bc;};}function handleError(_0x1df9b0,_0x42655e){_0x42655e=_0x42655e||0x1f4;return function(_0x3f81cc){logger[_0x2906('0x21')](_0x3f81cc[_0x2906('0x22')]);if(_0x3f81cc[_0x2906('0x23')]){delete _0x3f81cc['name'];}_0x1df9b0[_0x2906('0x16')](_0x42655e)['send'](_0x3f81cc);};}exports['index']=function(_0x41f0da,_0x511861){var _0xef1d77={},_0x53db91={},_0x198a4c={'count':0x0,'rows':[]};var _0x3c31ac=_['map'](db[_0x2906('0x24')][_0x2906('0x25')],function(_0x28e968){return{'name':_0x28e968['fieldName'],'type':_0x28e968['type']['key']};});_0x53db91[_0x2906('0x26')]=_['map'](_0x3c31ac,_0x2906('0x23'));_0x53db91[_0x2906('0x27')]=_['keys'](_0x41f0da[_0x2906('0x27')]);_0x53db91[_0x2906('0x28')]=_[_0x2906('0x29')](_0x53db91[_0x2906('0x26')],_0x53db91[_0x2906('0x27')]);_0xef1d77[_0x2906('0x2a')]=_[_0x2906('0x29')](_0x53db91[_0x2906('0x26')],qs['fields'](_0x41f0da[_0x2906('0x27')][_0x2906('0x2b')]));_0xef1d77[_0x2906('0x2a')]=_0xef1d77['attributes'][_0x2906('0x2c')]?_0xef1d77[_0x2906('0x2a')]:_0x53db91['model'];if(!_0x41f0da[_0x2906('0x27')][_0x2906('0x2d')](_0x2906('0x2e'))){_0xef1d77[_0x2906('0x1a')]=qs[_0x2906('0x1a')](_0x41f0da['query'][_0x2906('0x1a')]);_0xef1d77[_0x2906('0x19')]=qs[_0x2906('0x19')](_0x41f0da['query'][_0x2906('0x19')]);}_0xef1d77[_0x2906('0x2f')]=qs[_0x2906('0x30')](_0x41f0da[_0x2906('0x27')]['sort']);_0xef1d77[_0x2906('0x31')]=qs[_0x2906('0x28')](_[_0x2906('0x32')](_0x41f0da[_0x2906('0x27')],_0x53db91[_0x2906('0x28')]),_0x3c31ac);if(_0x41f0da[_0x2906('0x27')][_0x2906('0x33')]){_0xef1d77['where']=_['merge'](_0xef1d77['where'],{'$or':_['map'](_0x3c31ac,function(_0x26c47b){if(_0x26c47b[_0x2906('0x34')]!==_0x2906('0x35')){var _0x3061b5={};_0x3061b5[_0x26c47b[_0x2906('0x23')]]={'$like':'%'+_0x41f0da[_0x2906('0x27')][_0x2906('0x33')]+'%'};return _0x3061b5;}})});}_0xef1d77=_[_0x2906('0x36')]({},_0xef1d77,_0x41f0da[_0x2906('0x37')]);var _0x1af85b={'where':_0xef1d77[_0x2906('0x31')]};return db[_0x2906('0x24')]['count'](_0x1af85b)['then'](function(_0x43a3f7){_0x198a4c[_0x2906('0x18')]=_0x43a3f7;if(_0x41f0da[_0x2906('0x27')][_0x2906('0x38')]){_0xef1d77[_0x2906('0x39')]=[{'all':!![]}];}return db[_0x2906('0x24')]['findAll'](_0xef1d77);})['then'](function(_0x487035){_0x198a4c[_0x2906('0x3a')]=_0x487035;return _0x198a4c;})['then'](respondWithFilteredResult(_0x511861,_0xef1d77))[_0x2906('0x3b')](handleError(_0x511861,null));};exports[_0x2906('0x3c')]=function(_0x27d458,_0x5c1def){var _0x5cdb05={'raw':!![],'where':{'id':_0x27d458[_0x2906('0x3d')]['id']}},_0x58f75e={};_0x58f75e[_0x2906('0x26')]=_[_0x2906('0x3e')](db[_0x2906('0x24')][_0x2906('0x25')]);_0x58f75e[_0x2906('0x27')]=_['keys'](_0x27d458[_0x2906('0x27')]);_0x58f75e[_0x2906('0x28')]=_[_0x2906('0x29')](_0x58f75e[_0x2906('0x26')],_0x58f75e[_0x2906('0x27')]);_0x5cdb05[_0x2906('0x2a')]=_['intersection'](_0x58f75e[_0x2906('0x26')],qs['fields'](_0x27d458[_0x2906('0x27')]['fields']));_0x5cdb05[_0x2906('0x2a')]=_0x5cdb05['attributes'][_0x2906('0x2c')]?_0x5cdb05[_0x2906('0x2a')]:_0x58f75e['model'];if(_0x27d458[_0x2906('0x27')]['includeAll']){_0x5cdb05[_0x2906('0x39')]=[{'all':!![]}];}_0x5cdb05=_[_0x2906('0x36')]({},_0x5cdb05,_0x27d458['options']);return db[_0x2906('0x24')][_0x2906('0x3f')](_0x5cdb05)[_0x2906('0x40')](handleEntityNotFound(_0x5c1def,null))[_0x2906('0x40')](respondWithResult(_0x5c1def,null))[_0x2906('0x3b')](handleError(_0x5c1def,null));};exports['create']=function(_0x5362bf,_0x50e35b){return db[_0x2906('0x24')][_0x2906('0x41')](_0x5362bf['body'],{})[_0x2906('0x40')](respondWithResult(_0x50e35b,0xc9))['catch'](handleError(_0x50e35b,null));};exports[_0x2906('0x1f')]=function(_0x1177d3,_0x27d8c1){if(_0x1177d3['body']['id']){delete _0x1177d3[_0x2906('0x42')]['id'];}return db[_0x2906('0x24')]['find']({'where':{'id':_0x1177d3[_0x2906('0x3d')]['id']}})[_0x2906('0x40')](handleEntityNotFound(_0x27d8c1,null))[_0x2906('0x40')](saveUpdates(_0x1177d3[_0x2906('0x42')],null))[_0x2906('0x40')](respondWithResult(_0x27d8c1,null))['catch'](handleError(_0x27d8c1,null));};exports[_0x2906('0x43')]=function(_0x2c571d,_0x28ae53){return db[_0x2906('0x24')]['find']({'where':{'id':_0x2c571d[_0x2906('0x3d')]['id']}})['then'](handleEntityNotFound(_0x28ae53,null))['then'](removeEntity(_0x28ae53,null))['catch'](handleError(_0x28ae53,null));};
\ No newline at end of file
+var _0xfd45=['crypto','desk.js','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','count','set','json','apply','save','update','then','error','stack','name','index','map','rawAttributes','fieldName','type','model','query','attributes','intersection','fields','hasOwnProperty','nolimit','limit','order','sort','filters','pick','filter','where','VIRTUAL','options','VtigerField','includeAll','findAll','rows','catch','params','keys','length','merge','create','body','find','destroy','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash'];(function(_0xc0374e,_0x2de1fc){var _0x3cabe1=function(_0x2cfcae){while(--_0x2cfcae){_0xc0374e['push'](_0xc0374e['shift']());}};_0x3cabe1(++_0x2de1fc);}(_0xfd45,0x156));var _0x5fd4=function(_0x1da04e,_0x31024b){_0x1da04e=_0x1da04e-0x0;var _0xdd8c41=_0xfd45[_0x1da04e];return _0xdd8c41;};'use strict';var emlformat=require(_0x5fd4('0x0'));var rimraf=require(_0x5fd4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5fd4('0x2'));var rp=require(_0x5fd4('0x3'));var moment=require(_0x5fd4('0x4'));var BPromise=require(_0x5fd4('0x5'));var Mustache=require(_0x5fd4('0x6'));var util=require(_0x5fd4('0x7'));var path=require(_0x5fd4('0x8'));var sox=require(_0x5fd4('0x9'));var csv=require(_0x5fd4('0xa'));var ejs=require(_0x5fd4('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5fd4('0xc'));var squel=require('squel');var crypto=require(_0x5fd4('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x5fd4('0xe'));var toCsv=require(_0x5fd4('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x5fd4('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x5fd4('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5fd4('0x11'));var logger=require('../../config/logger')(_0x5fd4('0x12'));var utils=require(_0x5fd4('0x13'));var config=require(_0x5fd4('0x14'));var licenseUtil=require(_0x5fd4('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2739a6,_0x52fa31){_0x52fa31=_0x52fa31||0xcc;return function(_0x54ebaf){if(_0x54ebaf){return _0x2739a6[_0x5fd4('0x16')](_0x52fa31);}return _0x2739a6[_0x5fd4('0x17')](_0x52fa31)[_0x5fd4('0x18')]();};}function respondWithResult(_0x2f8488,_0x588b77){_0x588b77=_0x588b77||0xc8;return function(_0x230e5e){if(_0x230e5e){return _0x2f8488['status'](_0x588b77)['json'](_0x230e5e);}};}function respondWithFilteredResult(_0x1a4269,_0x1b6470){return function(_0xd93780){if(_0xd93780){var _0x500110=typeof _0x1b6470[_0x5fd4('0x19')]===_0x5fd4('0x1a')&&typeof _0x1b6470['limit']===_0x5fd4('0x1a');var _0x37362e=_0xd93780[_0x5fd4('0x1b')];var _0x4f1e72=_0x500110?0x0:_0x1b6470[_0x5fd4('0x19')];var _0x4b3eca=_0x500110?_0xd93780['count']:_0x1b6470[_0x5fd4('0x19')]+_0x1b6470['limit'];var _0x31b1c8;if(_0x4b3eca>=_0x37362e){_0x4b3eca=_0x37362e;_0x31b1c8=0xc8;}else{_0x31b1c8=0xce;}_0x1a4269['status'](_0x31b1c8);return _0x1a4269[_0x5fd4('0x1c')]('Content-Range',_0x4f1e72+'-'+_0x4b3eca+'/'+_0x37362e)[_0x5fd4('0x1d')](_0xd93780);}return null;};}function patchUpdates(_0x44c597){return function(_0x29c9ae){try{jsonpatch[_0x5fd4('0x1e')](_0x29c9ae,_0x44c597,!![]);}catch(_0x3e7fd2){return BPromise['reject'](_0x3e7fd2);}return _0x29c9ae[_0x5fd4('0x1f')]();};}function saveUpdates(_0x4c6e1f,_0x149eab){return function(_0x40ce24){if(_0x40ce24){return _0x40ce24[_0x5fd4('0x20')](_0x4c6e1f)[_0x5fd4('0x21')](function(_0x2e71ad){return _0x2e71ad;});}return null;};}function removeEntity(_0x48e017,_0x473d07){return function(_0x48a75b){if(_0x48a75b){return _0x48a75b['destroy']()['then'](function(){_0x48e017[_0x5fd4('0x17')](0xcc)[_0x5fd4('0x18')]();});}};}function handleEntityNotFound(_0xde6714,_0x1e1af5){return function(_0x48a387){if(!_0x48a387){_0xde6714[_0x5fd4('0x16')](0x194);}return _0x48a387;};}function handleError(_0x526df0,_0x5cab07){_0x5cab07=_0x5cab07||0x1f4;return function(_0xeae3d9){logger[_0x5fd4('0x22')](_0xeae3d9[_0x5fd4('0x23')]);if(_0xeae3d9[_0x5fd4('0x24')]){delete _0xeae3d9[_0x5fd4('0x24')];}_0x526df0[_0x5fd4('0x17')](_0x5cab07)['send'](_0xeae3d9);};}exports[_0x5fd4('0x25')]=function(_0x1049b8,_0x5c961f){var _0x35ace0={},_0x138a97={},_0x4fdd3e={'count':0x0,'rows':[]};var _0x3d7699=_[_0x5fd4('0x26')](db['VtigerField'][_0x5fd4('0x27')],function(_0x50215c){return{'name':_0x50215c[_0x5fd4('0x28')],'type':_0x50215c[_0x5fd4('0x29')]['key']};});_0x138a97[_0x5fd4('0x2a')]=_[_0x5fd4('0x26')](_0x3d7699,_0x5fd4('0x24'));_0x138a97['query']=_['keys'](_0x1049b8[_0x5fd4('0x2b')]);_0x138a97['filters']=_['intersection'](_0x138a97[_0x5fd4('0x2a')],_0x138a97[_0x5fd4('0x2b')]);_0x35ace0[_0x5fd4('0x2c')]=_[_0x5fd4('0x2d')](_0x138a97['model'],qs['fields'](_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x2e')]));_0x35ace0['attributes']=_0x35ace0[_0x5fd4('0x2c')]['length']?_0x35ace0[_0x5fd4('0x2c')]:_0x138a97[_0x5fd4('0x2a')];if(!_0x1049b8['query'][_0x5fd4('0x2f')](_0x5fd4('0x30'))){_0x35ace0[_0x5fd4('0x31')]=qs[_0x5fd4('0x31')](_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x31')]);_0x35ace0['offset']=qs[_0x5fd4('0x19')](_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x19')]);}_0x35ace0[_0x5fd4('0x32')]=qs[_0x5fd4('0x33')](_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x33')]);_0x35ace0['where']=qs[_0x5fd4('0x34')](_[_0x5fd4('0x35')](_0x1049b8[_0x5fd4('0x2b')],_0x138a97[_0x5fd4('0x34')]),_0x3d7699);if(_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x36')]){_0x35ace0[_0x5fd4('0x37')]=_['merge'](_0x35ace0[_0x5fd4('0x37')],{'$or':_[_0x5fd4('0x26')](_0x3d7699,function(_0x2cf57f){if(_0x2cf57f['type']!==_0x5fd4('0x38')){var _0x3a8042={};_0x3a8042[_0x2cf57f[_0x5fd4('0x24')]]={'$like':'%'+_0x1049b8[_0x5fd4('0x2b')]['filter']+'%'};return _0x3a8042;}})});}_0x35ace0=_['merge']({},_0x35ace0,_0x1049b8[_0x5fd4('0x39')]);var _0x414176={'where':_0x35ace0['where']};return db[_0x5fd4('0x3a')][_0x5fd4('0x1b')](_0x414176)[_0x5fd4('0x21')](function(_0x5ac00a){_0x4fdd3e['count']=_0x5ac00a;if(_0x1049b8[_0x5fd4('0x2b')][_0x5fd4('0x3b')]){_0x35ace0['include']=[{'all':!![]}];}return db['VtigerField'][_0x5fd4('0x3c')](_0x35ace0);})[_0x5fd4('0x21')](function(_0x1992d9){_0x4fdd3e[_0x5fd4('0x3d')]=_0x1992d9;return _0x4fdd3e;})[_0x5fd4('0x21')](respondWithFilteredResult(_0x5c961f,_0x35ace0))[_0x5fd4('0x3e')](handleError(_0x5c961f,null));};exports['show']=function(_0x32276d,_0x50a1f2){var _0x53ec27={'raw':!![],'where':{'id':_0x32276d[_0x5fd4('0x3f')]['id']}},_0x4b6c13={};_0x4b6c13[_0x5fd4('0x2a')]=_[_0x5fd4('0x40')](db[_0x5fd4('0x3a')][_0x5fd4('0x27')]);_0x4b6c13['query']=_['keys'](_0x32276d[_0x5fd4('0x2b')]);_0x4b6c13['filters']=_[_0x5fd4('0x2d')](_0x4b6c13['model'],_0x4b6c13['query']);_0x53ec27[_0x5fd4('0x2c')]=_[_0x5fd4('0x2d')](_0x4b6c13['model'],qs[_0x5fd4('0x2e')](_0x32276d[_0x5fd4('0x2b')][_0x5fd4('0x2e')]));_0x53ec27[_0x5fd4('0x2c')]=_0x53ec27[_0x5fd4('0x2c')][_0x5fd4('0x41')]?_0x53ec27[_0x5fd4('0x2c')]:_0x4b6c13[_0x5fd4('0x2a')];if(_0x32276d[_0x5fd4('0x2b')][_0x5fd4('0x3b')]){_0x53ec27['include']=[{'all':!![]}];}_0x53ec27=_[_0x5fd4('0x42')]({},_0x53ec27,_0x32276d['options']);return db['VtigerField']['find'](_0x53ec27)[_0x5fd4('0x21')](handleEntityNotFound(_0x50a1f2,null))[_0x5fd4('0x21')](respondWithResult(_0x50a1f2,null))[_0x5fd4('0x3e')](handleError(_0x50a1f2,null));};exports[_0x5fd4('0x43')]=function(_0x2dbb29,_0x39aeb5){return db[_0x5fd4('0x3a')]['create'](_0x2dbb29[_0x5fd4('0x44')],{})[_0x5fd4('0x21')](respondWithResult(_0x39aeb5,0xc9))[_0x5fd4('0x3e')](handleError(_0x39aeb5,null));};exports['update']=function(_0x57b243,_0x445e7a){if(_0x57b243[_0x5fd4('0x44')]['id']){delete _0x57b243[_0x5fd4('0x44')]['id'];}return db['VtigerField'][_0x5fd4('0x45')]({'where':{'id':_0x57b243[_0x5fd4('0x3f')]['id']}})[_0x5fd4('0x21')](handleEntityNotFound(_0x445e7a,null))['then'](saveUpdates(_0x57b243['body'],null))[_0x5fd4('0x21')](respondWithResult(_0x445e7a,null))['catch'](handleError(_0x445e7a,null));};exports[_0x5fd4('0x46')]=function(_0x2dd149,_0x4937a){return db['VtigerField'][_0x5fd4('0x45')]({'where':{'id':_0x2dd149[_0x5fd4('0x3f')]['id']}})[_0x5fd4('0x21')](handleEntityNotFound(_0x4937a,null))['then'](removeEntity(_0x4937a,null))['catch'](handleError(_0x4937a,null));};
\ No newline at end of file