Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 55d4581..cb6bcd6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x612f=['squel','crypto','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','limit','count','Content-Range','apply','reject','update','destroy','error','stack','name','send','index','map','VtigerField','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','then','rows','catch','show','params','keys','find','create','body','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra'];(function(_0x403ce1,_0xc1b506){var _0x223831=function(_0x4e5f95){while(--_0x4e5f95){_0x403ce1['push'](_0x403ce1['shift']());}};_0x223831(++_0xc1b506);}(_0x612f,0x19f));var _0xf612=function(_0x45df64,_0x537b7f){_0x45df64=_0x45df64-0x0;var _0x4a0c99=_0x612f[_0x45df64];return _0x4a0c99;};'use strict';var emlformat=require(_0xf612('0x0'));var rimraf=require(_0xf612('0x1'));var zipdir=require(_0xf612('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf612('0x3'));var moment=require(_0xf612('0x4'));var BPromise=require(_0xf612('0x5'));var Mustache=require('mustache');var util=require(_0xf612('0x6'));var path=require(_0xf612('0x7'));var sox=require(_0xf612('0x8'));var csv=require(_0xf612('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf612('0xa'));var _=require('lodash');var squel=require(_0xf612('0xb'));var crypto=require(_0xf612('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xf612('0x9'));var querystring=require(_0xf612('0xd'));var Papa=require('papaparse');var Redis=require(_0xf612('0xe'));var authService=require(_0xf612('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xf612('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf612('0x11'))('api');var utils=require('../../config/utils');var config=require(_0xf612('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0xf612('0x13'))['db'];function respondWithStatusCode(_0x4b38ce,_0xbbe539){_0xbbe539=_0xbbe539||0xcc;return function(_0x393184){if(_0x393184){return _0x4b38ce[_0xf612('0x14')](_0xbbe539);}return _0x4b38ce[_0xf612('0x15')](_0xbbe539)[_0xf612('0x16')]();};}function respondWithResult(_0x224535,_0x1c6b1f){_0x1c6b1f=_0x1c6b1f||0xc8;return function(_0x4758fb){if(_0x4758fb){return _0x224535[_0xf612('0x15')](_0x1c6b1f)[_0xf612('0x17')](_0x4758fb);}};}function respondWithFilteredResult(_0x305c85,_0x34b6e0){return function(_0x2ead7f){if(_0x2ead7f){var _0x56c6e6=typeof _0x34b6e0[_0xf612('0x18')]==='undefined'&&typeof _0x34b6e0[_0xf612('0x19')]==='undefined';var _0x5399b9=_0x2ead7f[_0xf612('0x1a')];var _0x4d330a=_0x56c6e6?0x0:_0x34b6e0['offset'];var _0xf47b1d=_0x56c6e6?_0x2ead7f[_0xf612('0x1a')]:_0x34b6e0[_0xf612('0x18')]+_0x34b6e0['limit'];var _0x243ec1;if(_0xf47b1d>=_0x5399b9){_0xf47b1d=_0x5399b9;_0x243ec1=0xc8;}else{_0x243ec1=0xce;}_0x305c85[_0xf612('0x15')](_0x243ec1);return _0x305c85['set'](_0xf612('0x1b'),_0x4d330a+'-'+_0xf47b1d+'/'+_0x5399b9)[_0xf612('0x17')](_0x2ead7f);}return null;};}function patchUpdates(_0x401688){return function(_0x3a6162){try{jsonpatch[_0xf612('0x1c')](_0x3a6162,_0x401688,!![]);}catch(_0x4feeeb){return BPromise[_0xf612('0x1d')](_0x4feeeb);}return _0x3a6162['save']();};}function saveUpdates(_0x4b00b9,_0x3150e6){return function(_0x2b8de4){if(_0x2b8de4){return _0x2b8de4[_0xf612('0x1e')](_0x4b00b9)['then'](function(_0xf78433){return _0xf78433;});}return null;};}function removeEntity(_0x26e1bd,_0x24f6d9){return function(_0x138409){if(_0x138409){return _0x138409[_0xf612('0x1f')]()['then'](function(){_0x26e1bd[_0xf612('0x15')](0xcc)[_0xf612('0x16')]();});}};}function handleEntityNotFound(_0x478560,_0x3e9d9e){return function(_0x117d23){if(!_0x117d23){_0x478560['sendStatus'](0x194);}return _0x117d23;};}function handleError(_0x24f621,_0x449e5c){_0x449e5c=_0x449e5c||0x1f4;return function(_0x50aa00){logger[_0xf612('0x20')](_0x50aa00[_0xf612('0x21')]);if(_0x50aa00[_0xf612('0x22')]){delete _0x50aa00['name'];}_0x24f621[_0xf612('0x15')](_0x449e5c)[_0xf612('0x23')](_0x50aa00);};}exports[_0xf612('0x24')]=function(_0x203161,_0xdefdaa){var _0x1d8432={},_0x235bf4={},_0x2a772c={'count':0x0,'rows':[]};var _0x193a54=_[_0xf612('0x25')](db[_0xf612('0x26')][_0xf612('0x27')],function(_0x1a7062){return{'name':_0x1a7062[_0xf612('0x28')],'type':_0x1a7062[_0xf612('0x29')][_0xf612('0x2a')]};});_0x235bf4[_0xf612('0x2b')]=_[_0xf612('0x25')](_0x193a54,_0xf612('0x22'));_0x235bf4[_0xf612('0x2c')]=_['keys'](_0x203161[_0xf612('0x2c')]);_0x235bf4['filters']=_[_0xf612('0x2d')](_0x235bf4[_0xf612('0x2b')],_0x235bf4[_0xf612('0x2c')]);_0x1d8432['attributes']=_[_0xf612('0x2d')](_0x235bf4[_0xf612('0x2b')],qs[_0xf612('0x2e')](_0x203161[_0xf612('0x2c')]['fields']));_0x1d8432[_0xf612('0x2f')]=_0x1d8432['attributes'][_0xf612('0x30')]?_0x1d8432[_0xf612('0x2f')]:_0x235bf4[_0xf612('0x2b')];if(!_0x203161[_0xf612('0x2c')][_0xf612('0x31')]('nolimit')){_0x1d8432[_0xf612('0x19')]=qs[_0xf612('0x19')](_0x203161['query'][_0xf612('0x19')]);_0x1d8432[_0xf612('0x18')]=qs['offset'](_0x203161[_0xf612('0x2c')][_0xf612('0x18')]);}_0x1d8432[_0xf612('0x32')]=qs[_0xf612('0x33')](_0x203161['query'][_0xf612('0x33')]);_0x1d8432[_0xf612('0x34')]=qs[_0xf612('0x35')](_[_0xf612('0x36')](_0x203161['query'],_0x235bf4[_0xf612('0x35')]),_0x193a54);if(_0x203161[_0xf612('0x2c')]['filter']){_0x1d8432[_0xf612('0x34')]=_[_0xf612('0x37')](_0x1d8432[_0xf612('0x34')],{'$or':_[_0xf612('0x25')](_0x193a54,function(_0x3294ea){if(_0x3294ea[_0xf612('0x29')]!==_0xf612('0x38')){var _0x5f31e2={};_0x5f31e2[_0x3294ea[_0xf612('0x22')]]={'$like':'%'+_0x203161[_0xf612('0x2c')][_0xf612('0x39')]+'%'};return _0x5f31e2;}})});}_0x1d8432=_['merge']({},_0x1d8432,_0x203161[_0xf612('0x3a')]);var _0x5cc17a={'where':_0x1d8432['where']};return db[_0xf612('0x26')][_0xf612('0x1a')](_0x5cc17a)['then'](function(_0x5af55b){_0x2a772c[_0xf612('0x1a')]=_0x5af55b;if(_0x203161['query'][_0xf612('0x3b')]){_0x1d8432[_0xf612('0x3c')]=[{'all':!![]}];}return db[_0xf612('0x26')][_0xf612('0x3d')](_0x1d8432);})[_0xf612('0x3e')](function(_0x16ef22){_0x2a772c[_0xf612('0x3f')]=_0x16ef22;return _0x2a772c;})[_0xf612('0x3e')](respondWithFilteredResult(_0xdefdaa,_0x1d8432))[_0xf612('0x40')](handleError(_0xdefdaa,null));};exports[_0xf612('0x41')]=function(_0xcc1075,_0x768a1d){var _0x4c7d76={'raw':!![],'where':{'id':_0xcc1075[_0xf612('0x42')]['id']}},_0x4a1f26={};_0x4a1f26[_0xf612('0x2b')]=_[_0xf612('0x43')](db[_0xf612('0x26')][_0xf612('0x27')]);_0x4a1f26[_0xf612('0x2c')]=_[_0xf612('0x43')](_0xcc1075[_0xf612('0x2c')]);_0x4a1f26['filters']=_[_0xf612('0x2d')](_0x4a1f26[_0xf612('0x2b')],_0x4a1f26[_0xf612('0x2c')]);_0x4c7d76[_0xf612('0x2f')]=_[_0xf612('0x2d')](_0x4a1f26[_0xf612('0x2b')],qs['fields'](_0xcc1075[_0xf612('0x2c')][_0xf612('0x2e')]));_0x4c7d76[_0xf612('0x2f')]=_0x4c7d76[_0xf612('0x2f')][_0xf612('0x30')]?_0x4c7d76[_0xf612('0x2f')]:_0x4a1f26['model'];if(_0xcc1075[_0xf612('0x2c')]['includeAll']){_0x4c7d76[_0xf612('0x3c')]=[{'all':!![]}];}_0x4c7d76=_['merge']({},_0x4c7d76,_0xcc1075[_0xf612('0x3a')]);return db[_0xf612('0x26')][_0xf612('0x44')](_0x4c7d76)['then'](handleEntityNotFound(_0x768a1d,null))['then'](respondWithResult(_0x768a1d,null))[_0xf612('0x40')](handleError(_0x768a1d,null));};exports[_0xf612('0x45')]=function(_0x3b3009,_0x3bbda4){return db[_0xf612('0x26')][_0xf612('0x45')](_0x3b3009[_0xf612('0x46')],{})[_0xf612('0x3e')](respondWithResult(_0x3bbda4,0xc9))[_0xf612('0x40')](handleError(_0x3bbda4,null));};exports['update']=function(_0x5373b5,_0x2350ff){if(_0x5373b5['body']['id']){delete _0x5373b5[_0xf612('0x46')]['id'];}return db[_0xf612('0x26')][_0xf612('0x44')]({'where':{'id':_0x5373b5[_0xf612('0x42')]['id']}})[_0xf612('0x3e')](handleEntityNotFound(_0x2350ff,null))[_0xf612('0x3e')](saveUpdates(_0x5373b5['body'],null))['then'](respondWithResult(_0x2350ff,null))[_0xf612('0x40')](handleError(_0x2350ff,null));};exports[_0xf612('0x1f')]=function(_0x18ca6e,_0x1d7a9e){return db[_0xf612('0x26')][_0xf612('0x44')]({'where':{'id':_0x18ca6e[_0xf612('0x42')]['id']}})[_0xf612('0x3e')](handleEntityNotFound(_0x1d7a9e,null))[_0xf612('0x3e')](removeEntity(_0x1d7a9e,null))[_0xf612('0x40')](handleError(_0x1d7a9e,null));};
\ No newline at end of file
+var _0x5d82=['create','destroy','rimraf','fast-json-patch','moment','util','path','sox','ejs','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','save','update','then','error','name','send','VtigerField','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','map','VIRTUAL','options','includeAll','include','findAll','catch','show','params','find'];(function(_0xb4e2df,_0x1cbb7c){var _0x5e95ba=function(_0x79d317){while(--_0x79d317){_0xb4e2df['push'](_0xb4e2df['shift']());}};_0x5e95ba(++_0x1cbb7c);}(_0x5d82,0xd4));var _0x25d8=function(_0x1f0498,_0x4eb36a){_0x1f0498=_0x1f0498-0x0;var _0x36221a=_0x5d82[_0x1f0498];return _0x36221a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x25d8('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x25d8('0x1'));var rp=require('request-promise');var moment=require(_0x25d8('0x2'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x25d8('0x3'));var path=require(_0x25d8('0x4'));var sox=require(_0x25d8('0x5'));var csv=require('to-csv');var ejs=require(_0x25d8('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x25d8('0x7'));var crypto=require(_0x25d8('0x8'));var jsforce=require(_0x25d8('0x9'));var deskjs=require(_0x25d8('0xa'));var toCsv=require(_0x25d8('0xb'));var querystring=require('querystring');var Papa=require(_0x25d8('0xc'));var Redis=require(_0x25d8('0xd'));var authService=require(_0x25d8('0xe'));var qs=require(_0x25d8('0xf'));var as=require(_0x25d8('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x25d8('0x11'))(_0x25d8('0x12'));var utils=require(_0x25d8('0x13'));var config=require(_0x25d8('0x14'));var licenseUtil=require(_0x25d8('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3af3d3,_0x1b1abe){_0x1b1abe=_0x1b1abe||0xcc;return function(_0x544961){if(_0x544961){return _0x3af3d3[_0x25d8('0x16')](_0x1b1abe);}return _0x3af3d3[_0x25d8('0x17')](_0x1b1abe)[_0x25d8('0x18')]();};}function respondWithResult(_0x5f3098,_0x17b9ba){_0x17b9ba=_0x17b9ba||0xc8;return function(_0x623915){if(_0x623915){return _0x5f3098[_0x25d8('0x17')](_0x17b9ba)['json'](_0x623915);}};}function respondWithFilteredResult(_0x60b04a,_0x35e08b){return function(_0x94c33a){if(_0x94c33a){var _0x5e6a83=typeof _0x35e08b[_0x25d8('0x19')]===_0x25d8('0x1a')&&typeof _0x35e08b[_0x25d8('0x1b')]===_0x25d8('0x1a');var _0x336ca1=_0x94c33a[_0x25d8('0x1c')];var _0x54f626=_0x5e6a83?0x0:_0x35e08b[_0x25d8('0x19')];var _0x1ba261=_0x5e6a83?_0x94c33a['count']:_0x35e08b[_0x25d8('0x19')]+_0x35e08b['limit'];var _0x21cda0;if(_0x1ba261>=_0x336ca1){_0x1ba261=_0x336ca1;_0x21cda0=0xc8;}else{_0x21cda0=0xce;}_0x60b04a[_0x25d8('0x17')](_0x21cda0);return _0x60b04a[_0x25d8('0x1d')](_0x25d8('0x1e'),_0x54f626+'-'+_0x1ba261+'/'+_0x336ca1)[_0x25d8('0x1f')](_0x94c33a);}return null;};}function patchUpdates(_0x12629c){return function(_0x3a0215){try{jsonpatch[_0x25d8('0x20')](_0x3a0215,_0x12629c,!![]);}catch(_0x9781cc){return BPromise['reject'](_0x9781cc);}return _0x3a0215[_0x25d8('0x21')]();};}function saveUpdates(_0x583d8d,_0x49857e){return function(_0x25ad47){if(_0x25ad47){return _0x25ad47[_0x25d8('0x22')](_0x583d8d)[_0x25d8('0x23')](function(_0xa1eb15){return _0xa1eb15;});}return null;};}function removeEntity(_0x2ed6ae,_0x3c7973){return function(_0x30aa8b){if(_0x30aa8b){return _0x30aa8b['destroy']()[_0x25d8('0x23')](function(){_0x2ed6ae['status'](0xcc)[_0x25d8('0x18')]();});}};}function handleEntityNotFound(_0x32cea7,_0x2fc0db){return function(_0x320dd8){if(!_0x320dd8){_0x32cea7[_0x25d8('0x16')](0x194);}return _0x320dd8;};}function handleError(_0x37dd02,_0x311da3){_0x311da3=_0x311da3||0x1f4;return function(_0x2f295d){logger[_0x25d8('0x24')](_0x2f295d['stack']);if(_0x2f295d[_0x25d8('0x25')]){delete _0x2f295d[_0x25d8('0x25')];}_0x37dd02[_0x25d8('0x17')](_0x311da3)[_0x25d8('0x26')](_0x2f295d);};}exports['index']=function(_0x5af26c,_0x4e87d3){var _0x57c331={},_0x221f37={},_0x305c11={'count':0x0,'rows':[]};var _0x4b3c2f=_['map'](db[_0x25d8('0x27')][_0x25d8('0x28')],function(_0x5112a8){return{'name':_0x5112a8[_0x25d8('0x29')],'type':_0x5112a8[_0x25d8('0x2a')]['key']};});_0x221f37[_0x25d8('0x2b')]=_['map'](_0x4b3c2f,'name');_0x221f37[_0x25d8('0x2c')]=_[_0x25d8('0x2d')](_0x5af26c[_0x25d8('0x2c')]);_0x221f37[_0x25d8('0x2e')]=_[_0x25d8('0x2f')](_0x221f37[_0x25d8('0x2b')],_0x221f37[_0x25d8('0x2c')]);_0x57c331['attributes']=_[_0x25d8('0x2f')](_0x221f37['model'],qs[_0x25d8('0x30')](_0x5af26c[_0x25d8('0x2c')][_0x25d8('0x30')]));_0x57c331[_0x25d8('0x31')]=_0x57c331[_0x25d8('0x31')][_0x25d8('0x32')]?_0x57c331[_0x25d8('0x31')]:_0x221f37[_0x25d8('0x2b')];if(!_0x5af26c['query'][_0x25d8('0x33')](_0x25d8('0x34'))){_0x57c331[_0x25d8('0x1b')]=qs[_0x25d8('0x1b')](_0x5af26c[_0x25d8('0x2c')]['limit']);_0x57c331[_0x25d8('0x19')]=qs[_0x25d8('0x19')](_0x5af26c['query']['offset']);}_0x57c331[_0x25d8('0x35')]=qs[_0x25d8('0x36')](_0x5af26c[_0x25d8('0x2c')]['sort']);_0x57c331[_0x25d8('0x37')]=qs[_0x25d8('0x2e')](_['pick'](_0x5af26c['query'],_0x221f37[_0x25d8('0x2e')]),_0x4b3c2f);if(_0x5af26c['query'][_0x25d8('0x38')]){_0x57c331[_0x25d8('0x37')]=_[_0x25d8('0x39')](_0x57c331[_0x25d8('0x37')],{'$or':_[_0x25d8('0x3a')](_0x4b3c2f,function(_0x4eb4d6){if(_0x4eb4d6['type']!==_0x25d8('0x3b')){var _0x3b00c8={};_0x3b00c8[_0x4eb4d6[_0x25d8('0x25')]]={'$like':'%'+_0x5af26c[_0x25d8('0x2c')][_0x25d8('0x38')]+'%'};return _0x3b00c8;}})});}_0x57c331=_[_0x25d8('0x39')]({},_0x57c331,_0x5af26c[_0x25d8('0x3c')]);var _0x3c7287={'where':_0x57c331[_0x25d8('0x37')]};return db[_0x25d8('0x27')]['count'](_0x3c7287)[_0x25d8('0x23')](function(_0x5b3df2){_0x305c11[_0x25d8('0x1c')]=_0x5b3df2;if(_0x5af26c[_0x25d8('0x2c')][_0x25d8('0x3d')]){_0x57c331[_0x25d8('0x3e')]=[{'all':!![]}];}return db[_0x25d8('0x27')][_0x25d8('0x3f')](_0x57c331);})[_0x25d8('0x23')](function(_0x36cb13){_0x305c11['rows']=_0x36cb13;return _0x305c11;})[_0x25d8('0x23')](respondWithFilteredResult(_0x4e87d3,_0x57c331))[_0x25d8('0x40')](handleError(_0x4e87d3,null));};exports[_0x25d8('0x41')]=function(_0x3e9f82,_0x30a3f0){var _0x2b0903={'raw':!![],'where':{'id':_0x3e9f82[_0x25d8('0x42')]['id']}},_0x3fab03={};_0x3fab03['model']=_[_0x25d8('0x2d')](db[_0x25d8('0x27')][_0x25d8('0x28')]);_0x3fab03[_0x25d8('0x2c')]=_['keys'](_0x3e9f82[_0x25d8('0x2c')]);_0x3fab03[_0x25d8('0x2e')]=_[_0x25d8('0x2f')](_0x3fab03['model'],_0x3fab03['query']);_0x2b0903[_0x25d8('0x31')]=_[_0x25d8('0x2f')](_0x3fab03['model'],qs['fields'](_0x3e9f82['query'][_0x25d8('0x30')]));_0x2b0903[_0x25d8('0x31')]=_0x2b0903[_0x25d8('0x31')][_0x25d8('0x32')]?_0x2b0903[_0x25d8('0x31')]:_0x3fab03['model'];if(_0x3e9f82[_0x25d8('0x2c')][_0x25d8('0x3d')]){_0x2b0903['include']=[{'all':!![]}];}_0x2b0903=_[_0x25d8('0x39')]({},_0x2b0903,_0x3e9f82[_0x25d8('0x3c')]);return db[_0x25d8('0x27')][_0x25d8('0x43')](_0x2b0903)[_0x25d8('0x23')](handleEntityNotFound(_0x30a3f0,null))[_0x25d8('0x23')](respondWithResult(_0x30a3f0,null))[_0x25d8('0x40')](handleError(_0x30a3f0,null));};exports[_0x25d8('0x44')]=function(_0x480085,_0x37664d){return db[_0x25d8('0x27')]['create'](_0x480085['body'],{})[_0x25d8('0x23')](respondWithResult(_0x37664d,0xc9))['catch'](handleError(_0x37664d,null));};exports['update']=function(_0x326f12,_0x368e4f){if(_0x326f12['body']['id']){delete _0x326f12['body']['id'];}return db[_0x25d8('0x27')][_0x25d8('0x43')]({'where':{'id':_0x326f12[_0x25d8('0x42')]['id']}})[_0x25d8('0x23')](handleEntityNotFound(_0x368e4f,null))[_0x25d8('0x23')](saveUpdates(_0x326f12['body'],null))[_0x25d8('0x23')](respondWithResult(_0x368e4f,null))[_0x25d8('0x40')](handleError(_0x368e4f,null));};exports[_0x25d8('0x45')]=function(_0x33ea21,_0x32ad25){return db['VtigerField'][_0x25d8('0x43')]({'where':{'id':_0x33ea21[_0x25d8('0x42')]['id']}})['then'](handleEntityNotFound(_0x32ad25,null))[_0x25d8('0x23')](removeEntity(_0x32ad25,null))[_0x25d8('0x40')](handleError(_0x32ad25,null));};
\ No newline at end of file