Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index 9426f1f..74745cc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x63f1=['nolimit','order','sort','where','pick','filter','merge','includeAll','include','findAll','rows','catch','params','options','find','create','body','update','eml-format','rimraf','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','index','map','DeskField','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length'];(function(_0x64b210,_0x301877){var _0x232a2b=function(_0x1056fd){while(--_0x1056fd){_0x64b210['push'](_0x64b210['shift']());}};_0x232a2b(++_0x301877);}(_0x63f1,0x1da));var _0x163f=function(_0x599f41,_0x4db732){_0x599f41=_0x599f41-0x0;var _0x2e4d58=_0x63f1[_0x599f41];return _0x2e4d58;};'use strict';var emlformat=require(_0x163f('0x0'));var rimraf=require(_0x163f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x163f('0x2'));var rp=require('request-promise');var moment=require(_0x163f('0x3'));var BPromise=require(_0x163f('0x4'));var Mustache=require('mustache');var util=require(_0x163f('0x5'));var path=require(_0x163f('0x6'));var sox=require(_0x163f('0x7'));var csv=require(_0x163f('0x8'));var ejs=require(_0x163f('0x9'));var fs=require('fs');var fs_extra=require(_0x163f('0xa'));var _=require(_0x163f('0xb'));var squel=require(_0x163f('0xc'));var crypto=require('crypto');var jsforce=require(_0x163f('0xd'));var deskjs=require(_0x163f('0xe'));var toCsv=require(_0x163f('0x8'));var querystring=require(_0x163f('0xf'));var Papa=require('papaparse');var Redis=require(_0x163f('0x10'));var authService=require(_0x163f('0x11'));var qs=require(_0x163f('0x12'));var as=require(_0x163f('0x13'));var hardwareService=require(_0x163f('0x14'));var logger=require('../../config/logger')(_0x163f('0x15'));var utils=require(_0x163f('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x163f('0x17'));var db=require(_0x163f('0x18'))['db'];function respondWithStatusCode(_0x331cde,_0xe8fc1c){_0xe8fc1c=_0xe8fc1c||0xcc;return function(_0x4bd756){if(_0x4bd756){return _0x331cde[_0x163f('0x19')](_0xe8fc1c);}return _0x331cde[_0x163f('0x1a')](_0xe8fc1c)[_0x163f('0x1b')]();};}function respondWithResult(_0x26635d,_0x151fa8){_0x151fa8=_0x151fa8||0xc8;return function(_0x42a2e0){if(_0x42a2e0){return _0x26635d[_0x163f('0x1a')](_0x151fa8)[_0x163f('0x1c')](_0x42a2e0);}};}function respondWithFilteredResult(_0x1603af,_0x57da99){return function(_0x2a9811){if(_0x2a9811){var _0x261d7b=typeof _0x57da99[_0x163f('0x1d')]===_0x163f('0x1e')&&typeof _0x57da99[_0x163f('0x1f')]==='undefined';var _0x37dacc=_0x2a9811[_0x163f('0x20')];var _0x558191=_0x261d7b?0x0:_0x57da99[_0x163f('0x1d')];var _0x44e0e3=_0x261d7b?_0x2a9811[_0x163f('0x20')]:_0x57da99[_0x163f('0x1d')]+_0x57da99[_0x163f('0x1f')];var _0x352b6b;if(_0x44e0e3>=_0x37dacc){_0x44e0e3=_0x37dacc;_0x352b6b=0xc8;}else{_0x352b6b=0xce;}_0x1603af['status'](_0x352b6b);return _0x1603af[_0x163f('0x21')](_0x163f('0x22'),_0x558191+'-'+_0x44e0e3+'/'+_0x37dacc)['json'](_0x2a9811);}return null;};}function patchUpdates(_0x1d8a9d){return function(_0x4b54a2){try{jsonpatch[_0x163f('0x23')](_0x4b54a2,_0x1d8a9d,!![]);}catch(_0x16fece){return BPromise[_0x163f('0x24')](_0x16fece);}return _0x4b54a2[_0x163f('0x25')]();};}function saveUpdates(_0x18f1a2,_0x169d66){return function(_0x30da66){if(_0x30da66){return _0x30da66['update'](_0x18f1a2)[_0x163f('0x26')](function(_0x55a1ff){return _0x55a1ff;});}return null;};}function removeEntity(_0x49b838,_0x371c22){return function(_0x4becf8){if(_0x4becf8){return _0x4becf8[_0x163f('0x27')]()[_0x163f('0x26')](function(){_0x49b838[_0x163f('0x1a')](0xcc)[_0x163f('0x1b')]();});}};}function handleEntityNotFound(_0x380124,_0x3b479d){return function(_0x9f17a0){if(!_0x9f17a0){_0x380124[_0x163f('0x19')](0x194);}return _0x9f17a0;};}function handleError(_0x4512a2,_0x498b5c){_0x498b5c=_0x498b5c||0x1f4;return function(_0xf03f21){logger[_0x163f('0x28')](_0xf03f21[_0x163f('0x29')]);if(_0xf03f21['name']){delete _0xf03f21[_0x163f('0x2a')];}_0x4512a2[_0x163f('0x1a')](_0x498b5c)[_0x163f('0x2b')](_0xf03f21);};}exports[_0x163f('0x2c')]=function(_0x1f723d,_0x24268d){var _0x16b3e2={},_0x45e7f9={},_0x58b932={'count':0x0,'rows':[]};var _0x5b11d5=_[_0x163f('0x2d')](db[_0x163f('0x2e')][_0x163f('0x2f')],function(_0xe89ef7){return{'name':_0xe89ef7['fieldName'],'type':_0xe89ef7[_0x163f('0x30')][_0x163f('0x31')]};});_0x45e7f9[_0x163f('0x32')]=_[_0x163f('0x2d')](_0x5b11d5,_0x163f('0x2a'));_0x45e7f9[_0x163f('0x33')]=_[_0x163f('0x34')](_0x1f723d['query']);_0x45e7f9[_0x163f('0x35')]=_[_0x163f('0x36')](_0x45e7f9['model'],_0x45e7f9['query']);_0x16b3e2[_0x163f('0x37')]=_[_0x163f('0x36')](_0x45e7f9[_0x163f('0x32')],qs[_0x163f('0x38')](_0x1f723d['query'][_0x163f('0x38')]));_0x16b3e2[_0x163f('0x37')]=_0x16b3e2[_0x163f('0x37')][_0x163f('0x39')]?_0x16b3e2[_0x163f('0x37')]:_0x45e7f9['model'];if(!_0x1f723d[_0x163f('0x33')]['hasOwnProperty'](_0x163f('0x3a'))){_0x16b3e2[_0x163f('0x1f')]=qs['limit'](_0x1f723d[_0x163f('0x33')][_0x163f('0x1f')]);_0x16b3e2['offset']=qs[_0x163f('0x1d')](_0x1f723d['query']['offset']);}_0x16b3e2[_0x163f('0x3b')]=qs[_0x163f('0x3c')](_0x1f723d[_0x163f('0x33')][_0x163f('0x3c')]);_0x16b3e2[_0x163f('0x3d')]=qs[_0x163f('0x35')](_[_0x163f('0x3e')](_0x1f723d[_0x163f('0x33')],_0x45e7f9[_0x163f('0x35')]),_0x5b11d5);if(_0x1f723d[_0x163f('0x33')][_0x163f('0x3f')]){_0x16b3e2['where']=_[_0x163f('0x40')](_0x16b3e2['where'],{'$or':_[_0x163f('0x2d')](_0x5b11d5,function(_0x39c923){if(_0x39c923['type']!=='VIRTUAL'){var _0x46db8a={};_0x46db8a[_0x39c923['name']]={'$like':'%'+_0x1f723d['query'][_0x163f('0x3f')]+'%'};return _0x46db8a;}})});}_0x16b3e2=_[_0x163f('0x40')]({},_0x16b3e2,_0x1f723d['options']);var _0x234416={'where':_0x16b3e2[_0x163f('0x3d')]};return db['DeskField']['count'](_0x234416)[_0x163f('0x26')](function(_0x34bbd8){_0x58b932['count']=_0x34bbd8;if(_0x1f723d['query'][_0x163f('0x41')]){_0x16b3e2[_0x163f('0x42')]=[{'all':!![]}];}return db[_0x163f('0x2e')][_0x163f('0x43')](_0x16b3e2);})[_0x163f('0x26')](function(_0x1a44bd){_0x58b932[_0x163f('0x44')]=_0x1a44bd;return _0x58b932;})[_0x163f('0x26')](respondWithFilteredResult(_0x24268d,_0x16b3e2))[_0x163f('0x45')](handleError(_0x24268d,null));};exports['show']=function(_0x5b6125,_0x2777d6){var _0xe8c203={'raw':!![],'where':{'id':_0x5b6125[_0x163f('0x46')]['id']}},_0x51337e={};_0x51337e[_0x163f('0x32')]=_[_0x163f('0x34')](db[_0x163f('0x2e')]['rawAttributes']);_0x51337e[_0x163f('0x33')]=_[_0x163f('0x34')](_0x5b6125[_0x163f('0x33')]);_0x51337e[_0x163f('0x35')]=_[_0x163f('0x36')](_0x51337e['model'],_0x51337e[_0x163f('0x33')]);_0xe8c203[_0x163f('0x37')]=_['intersection'](_0x51337e[_0x163f('0x32')],qs[_0x163f('0x38')](_0x5b6125[_0x163f('0x33')][_0x163f('0x38')]));_0xe8c203[_0x163f('0x37')]=_0xe8c203[_0x163f('0x37')][_0x163f('0x39')]?_0xe8c203['attributes']:_0x51337e[_0x163f('0x32')];if(_0x5b6125[_0x163f('0x33')][_0x163f('0x41')]){_0xe8c203['include']=[{'all':!![]}];}_0xe8c203=_['merge']({},_0xe8c203,_0x5b6125[_0x163f('0x47')]);return db[_0x163f('0x2e')][_0x163f('0x48')](_0xe8c203)[_0x163f('0x26')](handleEntityNotFound(_0x2777d6,null))[_0x163f('0x26')](respondWithResult(_0x2777d6,null))[_0x163f('0x45')](handleError(_0x2777d6,null));};exports[_0x163f('0x49')]=function(_0x727841,_0x56b9ee){return db[_0x163f('0x2e')][_0x163f('0x49')](_0x727841[_0x163f('0x4a')],{})[_0x163f('0x26')](respondWithResult(_0x56b9ee,0xc9))['catch'](handleError(_0x56b9ee,null));};exports[_0x163f('0x4b')]=function(_0x291aad,_0x5db7fe){if(_0x291aad[_0x163f('0x4a')]['id']){delete _0x291aad['body']['id'];}return db[_0x163f('0x2e')]['find']({'where':{'id':_0x291aad['params']['id']}})['then'](handleEntityNotFound(_0x5db7fe,null))[_0x163f('0x26')](saveUpdates(_0x291aad[_0x163f('0x4a')],null))['then'](respondWithResult(_0x5db7fe,null))[_0x163f('0x45')](handleError(_0x5db7fe,null));};exports[_0x163f('0x27')]=function(_0x3b0db7,_0x251c78){return db['DeskField'][_0x163f('0x48')]({'where':{'id':_0x3b0db7[_0x163f('0x46')]['id']}})['then'](handleEntityNotFound(_0x251c78,null))[_0x163f('0x26')](removeEntity(_0x251c78,null))[_0x163f('0x45')](handleError(_0x251c78,null));};
\ No newline at end of file
+var _0xc8ba=['filters','intersection','fields','attributes','length','nolimit','order','pick','filter','where','type','VIRTUAL','merge','options','includeAll','findAll','then','catch','show','params','keys','include','find','create','body','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','sox','to-csv','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','offset','undefined','count','limit','set','Content-Range','json','apply','update','destroy','stack','name','send','map','DeskField','rawAttributes','fieldName','key','model','query'];(function(_0x5e7e55,_0x4dadc0){var _0x332810=function(_0x532641){while(--_0x532641){_0x5e7e55['push'](_0x5e7e55['shift']());}};_0x332810(++_0x4dadc0);}(_0xc8ba,0x186));var _0xac8b=function(_0x13992d,_0x3029ea){_0x13992d=_0x13992d-0x0;var _0x3d15bf=_0xc8ba[_0x13992d];return _0x3d15bf;};'use strict';var emlformat=require(_0xac8b('0x0'));var rimraf=require(_0xac8b('0x1'));var zipdir=require(_0xac8b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xac8b('0x3'));var BPromise=require(_0xac8b('0x4'));var Mustache=require(_0xac8b('0x5'));var util=require(_0xac8b('0x6'));var path=require('path');var sox=require(_0xac8b('0x7'));var csv=require(_0xac8b('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xac8b('0x9'));var _=require('lodash');var squel=require(_0xac8b('0xa'));var crypto=require(_0xac8b('0xb'));var jsforce=require(_0xac8b('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xac8b('0x8'));var querystring=require(_0xac8b('0xd'));var Papa=require(_0xac8b('0xe'));var Redis=require(_0xac8b('0xf'));var authService=require(_0xac8b('0x10'));var qs=require(_0xac8b('0x11'));var as=require(_0xac8b('0x12'));var hardwareService=require(_0xac8b('0x13'));var logger=require(_0xac8b('0x14'))(_0xac8b('0x15'));var utils=require(_0xac8b('0x16'));var config=require(_0xac8b('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xac8b('0x18'))['db'];function respondWithStatusCode(_0x2c1729,_0x2874dd){_0x2874dd=_0x2874dd||0xcc;return function(_0xc91ef9){if(_0xc91ef9){return _0x2c1729[_0xac8b('0x19')](_0x2874dd);}return _0x2c1729['status'](_0x2874dd)[_0xac8b('0x1a')]();};}function respondWithResult(_0x5ae845,_0x50f036){_0x50f036=_0x50f036||0xc8;return function(_0x347e16){if(_0x347e16){return _0x5ae845[_0xac8b('0x1b')](_0x50f036)['json'](_0x347e16);}};}function respondWithFilteredResult(_0x2d1de4,_0x27dc56){return function(_0x28f8e9){if(_0x28f8e9){var _0x406618=typeof _0x27dc56[_0xac8b('0x1c')]===_0xac8b('0x1d')&&typeof _0x27dc56['limit']==='undefined';var _0x4640dc=_0x28f8e9[_0xac8b('0x1e')];var _0x5e1b9d=_0x406618?0x0:_0x27dc56[_0xac8b('0x1c')];var _0x3974e4=_0x406618?_0x28f8e9[_0xac8b('0x1e')]:_0x27dc56['offset']+_0x27dc56[_0xac8b('0x1f')];var _0x88b80f;if(_0x3974e4>=_0x4640dc){_0x3974e4=_0x4640dc;_0x88b80f=0xc8;}else{_0x88b80f=0xce;}_0x2d1de4[_0xac8b('0x1b')](_0x88b80f);return _0x2d1de4[_0xac8b('0x20')](_0xac8b('0x21'),_0x5e1b9d+'-'+_0x3974e4+'/'+_0x4640dc)[_0xac8b('0x22')](_0x28f8e9);}return null;};}function patchUpdates(_0x1dbbce){return function(_0x1ea7b8){try{jsonpatch[_0xac8b('0x23')](_0x1ea7b8,_0x1dbbce,!![]);}catch(_0x433813){return BPromise['reject'](_0x433813);}return _0x1ea7b8['save']();};}function saveUpdates(_0x35c211,_0x5419f2){return function(_0x5bed0a){if(_0x5bed0a){return _0x5bed0a[_0xac8b('0x24')](_0x35c211)['then'](function(_0x479d7e){return _0x479d7e;});}return null;};}function removeEntity(_0x18f98c,_0x28a730){return function(_0xe51f65){if(_0xe51f65){return _0xe51f65[_0xac8b('0x25')]()['then'](function(){_0x18f98c[_0xac8b('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x8d0eda,_0x447c97){return function(_0xaebbfd){if(!_0xaebbfd){_0x8d0eda[_0xac8b('0x19')](0x194);}return _0xaebbfd;};}function handleError(_0x4b7287,_0x1e7c33){_0x1e7c33=_0x1e7c33||0x1f4;return function(_0x4fac73){logger['error'](_0x4fac73[_0xac8b('0x26')]);if(_0x4fac73[_0xac8b('0x27')]){delete _0x4fac73['name'];}_0x4b7287[_0xac8b('0x1b')](_0x1e7c33)[_0xac8b('0x28')](_0x4fac73);};}exports['index']=function(_0x26ac33,_0x31bf50){var _0xab0bfc={},_0x329511={},_0x209390={'count':0x0,'rows':[]};var _0x11b1a1=_[_0xac8b('0x29')](db[_0xac8b('0x2a')][_0xac8b('0x2b')],function(_0x517524){return{'name':_0x517524[_0xac8b('0x2c')],'type':_0x517524['type'][_0xac8b('0x2d')]};});_0x329511[_0xac8b('0x2e')]=_[_0xac8b('0x29')](_0x11b1a1,_0xac8b('0x27'));_0x329511[_0xac8b('0x2f')]=_['keys'](_0x26ac33[_0xac8b('0x2f')]);_0x329511[_0xac8b('0x30')]=_['intersection'](_0x329511[_0xac8b('0x2e')],_0x329511[_0xac8b('0x2f')]);_0xab0bfc['attributes']=_[_0xac8b('0x31')](_0x329511[_0xac8b('0x2e')],qs[_0xac8b('0x32')](_0x26ac33['query'][_0xac8b('0x32')]));_0xab0bfc[_0xac8b('0x33')]=_0xab0bfc['attributes'][_0xac8b('0x34')]?_0xab0bfc[_0xac8b('0x33')]:_0x329511['model'];if(!_0x26ac33[_0xac8b('0x2f')]['hasOwnProperty'](_0xac8b('0x35'))){_0xab0bfc[_0xac8b('0x1f')]=qs['limit'](_0x26ac33[_0xac8b('0x2f')][_0xac8b('0x1f')]);_0xab0bfc[_0xac8b('0x1c')]=qs[_0xac8b('0x1c')](_0x26ac33[_0xac8b('0x2f')][_0xac8b('0x1c')]);}_0xab0bfc[_0xac8b('0x36')]=qs['sort'](_0x26ac33[_0xac8b('0x2f')]['sort']);_0xab0bfc['where']=qs[_0xac8b('0x30')](_[_0xac8b('0x37')](_0x26ac33[_0xac8b('0x2f')],_0x329511[_0xac8b('0x30')]),_0x11b1a1);if(_0x26ac33[_0xac8b('0x2f')][_0xac8b('0x38')]){_0xab0bfc[_0xac8b('0x39')]=_['merge'](_0xab0bfc[_0xac8b('0x39')],{'$or':_[_0xac8b('0x29')](_0x11b1a1,function(_0x3c5e6e){if(_0x3c5e6e[_0xac8b('0x3a')]!==_0xac8b('0x3b')){var _0x257012={};_0x257012[_0x3c5e6e[_0xac8b('0x27')]]={'$like':'%'+_0x26ac33[_0xac8b('0x2f')]['filter']+'%'};return _0x257012;}})});}_0xab0bfc=_[_0xac8b('0x3c')]({},_0xab0bfc,_0x26ac33[_0xac8b('0x3d')]);var _0x2d9ef6={'where':_0xab0bfc[_0xac8b('0x39')]};return db[_0xac8b('0x2a')][_0xac8b('0x1e')](_0x2d9ef6)['then'](function(_0xed3e99){_0x209390['count']=_0xed3e99;if(_0x26ac33[_0xac8b('0x2f')][_0xac8b('0x3e')]){_0xab0bfc['include']=[{'all':!![]}];}return db[_0xac8b('0x2a')][_0xac8b('0x3f')](_0xab0bfc);})[_0xac8b('0x40')](function(_0x44671f){_0x209390['rows']=_0x44671f;return _0x209390;})[_0xac8b('0x40')](respondWithFilteredResult(_0x31bf50,_0xab0bfc))[_0xac8b('0x41')](handleError(_0x31bf50,null));};exports[_0xac8b('0x42')]=function(_0x4471ca,_0x1960d7){var _0x54f5b7={'raw':!![],'where':{'id':_0x4471ca[_0xac8b('0x43')]['id']}},_0x20c65b={};_0x20c65b[_0xac8b('0x2e')]=_[_0xac8b('0x44')](db[_0xac8b('0x2a')][_0xac8b('0x2b')]);_0x20c65b[_0xac8b('0x2f')]=_[_0xac8b('0x44')](_0x4471ca[_0xac8b('0x2f')]);_0x20c65b[_0xac8b('0x30')]=_[_0xac8b('0x31')](_0x20c65b['model'],_0x20c65b[_0xac8b('0x2f')]);_0x54f5b7[_0xac8b('0x33')]=_[_0xac8b('0x31')](_0x20c65b['model'],qs['fields'](_0x4471ca['query'][_0xac8b('0x32')]));_0x54f5b7[_0xac8b('0x33')]=_0x54f5b7[_0xac8b('0x33')]['length']?_0x54f5b7[_0xac8b('0x33')]:_0x20c65b[_0xac8b('0x2e')];if(_0x4471ca['query'][_0xac8b('0x3e')]){_0x54f5b7[_0xac8b('0x45')]=[{'all':!![]}];}_0x54f5b7=_[_0xac8b('0x3c')]({},_0x54f5b7,_0x4471ca['options']);return db[_0xac8b('0x2a')][_0xac8b('0x46')](_0x54f5b7)[_0xac8b('0x40')](handleEntityNotFound(_0x1960d7,null))[_0xac8b('0x40')](respondWithResult(_0x1960d7,null))['catch'](handleError(_0x1960d7,null));};exports['create']=function(_0x3a978c,_0x39f64c){return db[_0xac8b('0x2a')][_0xac8b('0x47')](_0x3a978c[_0xac8b('0x48')],{})[_0xac8b('0x40')](respondWithResult(_0x39f64c,0xc9))[_0xac8b('0x41')](handleError(_0x39f64c,null));};exports['update']=function(_0x5796c2,_0x27a02f){if(_0x5796c2[_0xac8b('0x48')]['id']){delete _0x5796c2[_0xac8b('0x48')]['id'];}return db[_0xac8b('0x2a')][_0xac8b('0x46')]({'where':{'id':_0x5796c2[_0xac8b('0x43')]['id']}})[_0xac8b('0x40')](handleEntityNotFound(_0x27a02f,null))['then'](saveUpdates(_0x5796c2[_0xac8b('0x48')],null))[_0xac8b('0x40')](respondWithResult(_0x27a02f,null))['catch'](handleError(_0x27a02f,null));};exports['destroy']=function(_0x22f176,_0x22947e){return db[_0xac8b('0x2a')][_0xac8b('0x46')]({'where':{'id':_0x22f176[_0xac8b('0x43')]['id']}})['then'](handleEntityNotFound(_0x22947e,null))[_0xac8b('0x40')](removeEntity(_0x22947e,null))[_0xac8b('0x41')](handleError(_0x22947e,null));};
\ No newline at end of file