Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index dd9ce48..4070fbb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x483f=['util','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','end','status','offset','undefined','limit','count','set','Content-Range','save','update','then','destroy','error','stack','name','index','map','DeskField','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','rows','catch','show','params','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache'];(function(_0x302a4d,_0x24d3a3){var _0x873686=function(_0x5f2bff){while(--_0x5f2bff){_0x302a4d['push'](_0x302a4d['shift']());}};_0x873686(++_0x24d3a3);}(_0x483f,0x11c));var _0xf483=function(_0x307ece,_0x17e0b5){_0x307ece=_0x307ece-0x0;var _0x5cd5fd=_0x483f[_0x307ece];return _0x5cd5fd;};'use strict';var emlformat=require(_0xf483('0x0'));var rimraf=require(_0xf483('0x1'));var zipdir=require(_0xf483('0x2'));var jsonpatch=require(_0xf483('0x3'));var rp=require(_0xf483('0x4'));var moment=require(_0xf483('0x5'));var BPromise=require(_0xf483('0x6'));var Mustache=require(_0xf483('0x7'));var util=require(_0xf483('0x8'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xf483('0x9'));var fs=require('fs');var fs_extra=require(_0xf483('0xa'));var _=require(_0xf483('0xb'));var squel=require(_0xf483('0xc'));var crypto=require(_0xf483('0xd'));var jsforce=require(_0xf483('0xe'));var deskjs=require(_0xf483('0xf'));var toCsv=require(_0xf483('0x10'));var querystring=require('querystring');var Papa=require(_0xf483('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xf483('0x12'));var as=require(_0xf483('0x13'));var hardwareService=require(_0xf483('0x14'));var logger=require(_0xf483('0x15'))('api');var utils=require(_0xf483('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf483('0x17'));var db=require(_0xf483('0x18'))['db'];function respondWithStatusCode(_0x51a917,_0x181540){_0x181540=_0x181540||0xcc;return function(_0x1d882f){if(_0x1d882f){return _0x51a917['sendStatus'](_0x181540);}return _0x51a917['status'](_0x181540)[_0xf483('0x19')]();};}function respondWithResult(_0x387c23,_0x19aca0){_0x19aca0=_0x19aca0||0xc8;return function(_0x14dc5f){if(_0x14dc5f){return _0x387c23[_0xf483('0x1a')](_0x19aca0)['json'](_0x14dc5f);}};}function respondWithFilteredResult(_0x39f306,_0x2561b2){return function(_0x48ee49){if(_0x48ee49){var _0x14811d=typeof _0x2561b2[_0xf483('0x1b')]===_0xf483('0x1c')&&typeof _0x2561b2[_0xf483('0x1d')]===_0xf483('0x1c');var _0x355f6a=_0x48ee49[_0xf483('0x1e')];var _0x1523eb=_0x14811d?0x0:_0x2561b2['offset'];var _0x78412c=_0x14811d?_0x48ee49[_0xf483('0x1e')]:_0x2561b2[_0xf483('0x1b')]+_0x2561b2['limit'];var _0x4c62fd;if(_0x78412c>=_0x355f6a){_0x78412c=_0x355f6a;_0x4c62fd=0xc8;}else{_0x4c62fd=0xce;}_0x39f306[_0xf483('0x1a')](_0x4c62fd);return _0x39f306[_0xf483('0x1f')](_0xf483('0x20'),_0x1523eb+'-'+_0x78412c+'/'+_0x355f6a)['json'](_0x48ee49);}return null;};}function patchUpdates(_0x390fbd){return function(_0x138d31){try{jsonpatch['apply'](_0x138d31,_0x390fbd,!![]);}catch(_0x22923a){return BPromise['reject'](_0x22923a);}return _0x138d31[_0xf483('0x21')]();};}function saveUpdates(_0x4eec1c,_0x1729e2){return function(_0x4a4489){if(_0x4a4489){return _0x4a4489[_0xf483('0x22')](_0x4eec1c)[_0xf483('0x23')](function(_0x2e3ae2){return _0x2e3ae2;});}return null;};}function removeEntity(_0x25f833,_0x5cee0c){return function(_0x40ea74){if(_0x40ea74){return _0x40ea74[_0xf483('0x24')]()['then'](function(){_0x25f833[_0xf483('0x1a')](0xcc)[_0xf483('0x19')]();});}};}function handleEntityNotFound(_0x50932d,_0xa2f9fd){return function(_0x3b1692){if(!_0x3b1692){_0x50932d['sendStatus'](0x194);}return _0x3b1692;};}function handleError(_0x2188ff,_0xfb138e){_0xfb138e=_0xfb138e||0x1f4;return function(_0x58fd5b){logger[_0xf483('0x25')](_0x58fd5b[_0xf483('0x26')]);if(_0x58fd5b[_0xf483('0x27')]){delete _0x58fd5b['name'];}_0x2188ff[_0xf483('0x1a')](_0xfb138e)['send'](_0x58fd5b);};}exports[_0xf483('0x28')]=function(_0x202eab,_0x38d1eb){var _0x2c00d6={},_0x2afaf6={},_0x5b3f9a={'count':0x0,'rows':[]};var _0x238fcc=_[_0xf483('0x29')](db[_0xf483('0x2a')][_0xf483('0x2b')],function(_0x207f6f){return{'name':_0x207f6f[_0xf483('0x2c')],'type':_0x207f6f[_0xf483('0x2d')][_0xf483('0x2e')]};});_0x2afaf6[_0xf483('0x2f')]=_[_0xf483('0x29')](_0x238fcc,_0xf483('0x27'));_0x2afaf6[_0xf483('0x30')]=_[_0xf483('0x31')](_0x202eab['query']);_0x2afaf6[_0xf483('0x32')]=_[_0xf483('0x33')](_0x2afaf6[_0xf483('0x2f')],_0x2afaf6[_0xf483('0x30')]);_0x2c00d6[_0xf483('0x34')]=_[_0xf483('0x33')](_0x2afaf6['model'],qs[_0xf483('0x35')](_0x202eab[_0xf483('0x30')][_0xf483('0x35')]));_0x2c00d6[_0xf483('0x34')]=_0x2c00d6[_0xf483('0x34')][_0xf483('0x36')]?_0x2c00d6[_0xf483('0x34')]:_0x2afaf6['model'];if(!_0x202eab[_0xf483('0x30')][_0xf483('0x37')]('nolimit')){_0x2c00d6[_0xf483('0x1d')]=qs[_0xf483('0x1d')](_0x202eab['query']['limit']);_0x2c00d6['offset']=qs[_0xf483('0x1b')](_0x202eab[_0xf483('0x30')][_0xf483('0x1b')]);}_0x2c00d6[_0xf483('0x38')]=qs[_0xf483('0x39')](_0x202eab['query'][_0xf483('0x39')]);_0x2c00d6['where']=qs['filters'](_[_0xf483('0x3a')](_0x202eab[_0xf483('0x30')],_0x2afaf6['filters']),_0x238fcc);if(_0x202eab['query'][_0xf483('0x3b')]){_0x2c00d6[_0xf483('0x3c')]=_[_0xf483('0x3d')](_0x2c00d6['where'],{'$or':_['map'](_0x238fcc,function(_0xacfb96){if(_0xacfb96[_0xf483('0x2d')]!==_0xf483('0x3e')){var _0x28649b={};_0x28649b[_0xacfb96[_0xf483('0x27')]]={'$like':'%'+_0x202eab['query'][_0xf483('0x3b')]+'%'};return _0x28649b;}})});}_0x2c00d6=_[_0xf483('0x3d')]({},_0x2c00d6,_0x202eab[_0xf483('0x3f')]);var _0x42fd62={'where':_0x2c00d6['where']};return db[_0xf483('0x2a')][_0xf483('0x1e')](_0x42fd62)[_0xf483('0x23')](function(_0xbb63d7){_0x5b3f9a[_0xf483('0x1e')]=_0xbb63d7;if(_0x202eab[_0xf483('0x30')][_0xf483('0x40')]){_0x2c00d6[_0xf483('0x41')]=[{'all':!![]}];}return db[_0xf483('0x2a')]['findAll'](_0x2c00d6);})[_0xf483('0x23')](function(_0x4727d6){_0x5b3f9a[_0xf483('0x42')]=_0x4727d6;return _0x5b3f9a;})[_0xf483('0x23')](respondWithFilteredResult(_0x38d1eb,_0x2c00d6))[_0xf483('0x43')](handleError(_0x38d1eb,null));};exports[_0xf483('0x44')]=function(_0x31cfef,_0x451125){var _0x3bf955={'raw':!![],'where':{'id':_0x31cfef[_0xf483('0x45')]['id']}},_0x4e4020={};_0x4e4020[_0xf483('0x2f')]=_['keys'](db[_0xf483('0x2a')][_0xf483('0x2b')]);_0x4e4020[_0xf483('0x30')]=_[_0xf483('0x31')](_0x31cfef[_0xf483('0x30')]);_0x4e4020['filters']=_[_0xf483('0x33')](_0x4e4020[_0xf483('0x2f')],_0x4e4020['query']);_0x3bf955[_0xf483('0x34')]=_['intersection'](_0x4e4020[_0xf483('0x2f')],qs[_0xf483('0x35')](_0x31cfef[_0xf483('0x30')]['fields']));_0x3bf955[_0xf483('0x34')]=_0x3bf955['attributes']['length']?_0x3bf955[_0xf483('0x34')]:_0x4e4020['model'];if(_0x31cfef[_0xf483('0x30')][_0xf483('0x40')]){_0x3bf955[_0xf483('0x41')]=[{'all':!![]}];}_0x3bf955=_[_0xf483('0x3d')]({},_0x3bf955,_0x31cfef[_0xf483('0x3f')]);return db[_0xf483('0x2a')]['find'](_0x3bf955)['then'](handleEntityNotFound(_0x451125,null))['then'](respondWithResult(_0x451125,null))[_0xf483('0x43')](handleError(_0x451125,null));};exports[_0xf483('0x46')]=function(_0x380cab,_0x3385ea){return db['DeskField'][_0xf483('0x46')](_0x380cab[_0xf483('0x47')],{})[_0xf483('0x23')](respondWithResult(_0x3385ea,0xc9))['catch'](handleError(_0x3385ea,null));};exports[_0xf483('0x22')]=function(_0x588f53,_0x274fd2){if(_0x588f53[_0xf483('0x47')]['id']){delete _0x588f53[_0xf483('0x47')]['id'];}return db[_0xf483('0x2a')][_0xf483('0x48')]({'where':{'id':_0x588f53[_0xf483('0x45')]['id']}})[_0xf483('0x23')](handleEntityNotFound(_0x274fd2,null))[_0xf483('0x23')](saveUpdates(_0x588f53['body'],null))[_0xf483('0x23')](respondWithResult(_0x274fd2,null))[_0xf483('0x43')](handleError(_0x274fd2,null));};exports[_0xf483('0x24')]=function(_0x11b1b6,_0x3ccded){return db[_0xf483('0x2a')][_0xf483('0x48')]({'where':{'id':_0x11b1b6['params']['id']}})[_0xf483('0x23')](handleEntityNotFound(_0x3ccded,null))['then'](removeEntity(_0x3ccded,null))[_0xf483('0x43')](handleError(_0x3ccded,null));};
\ No newline at end of file
+var _0x553f=['create','body','update','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','count','set','apply','reject','save','then','destroy','error','stack','name','send','map','DeskField','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','include'];(function(_0x575d3b,_0x5a65ce){var _0x5905ea=function(_0x3f631c){while(--_0x3f631c){_0x575d3b['push'](_0x575d3b['shift']());}};_0x5905ea(++_0x5a65ce);}(_0x553f,0x1c0));var _0xf553=function(_0x455d91,_0x22b41a){_0x455d91=_0x455d91-0x0;var _0x41eedb=_0x553f[_0x455d91];return _0x41eedb;};'use strict';var emlformat=require(_0xf553('0x0'));var rimraf=require(_0xf553('0x1'));var zipdir=require(_0xf553('0x2'));var jsonpatch=require(_0xf553('0x3'));var rp=require(_0xf553('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xf553('0x5'));var util=require('util');var path=require(_0xf553('0x6'));var sox=require(_0xf553('0x7'));var csv=require(_0xf553('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf553('0x9'));var _=require(_0xf553('0xa'));var squel=require(_0xf553('0xb'));var crypto=require('crypto');var jsforce=require(_0xf553('0xc'));var deskjs=require(_0xf553('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xf553('0xe'));var authService=require(_0xf553('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xf553('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf553('0x11'))(_0xf553('0x12'));var utils=require('../../config/utils');var config=require(_0xf553('0x13'));var licenseUtil=require(_0xf553('0x14'));var db=require(_0xf553('0x15'))['db'];function respondWithStatusCode(_0x3a296c,_0x16be09){_0x16be09=_0x16be09||0xcc;return function(_0x15231e){if(_0x15231e){return _0x3a296c[_0xf553('0x16')](_0x16be09);}return _0x3a296c[_0xf553('0x17')](_0x16be09)[_0xf553('0x18')]();};}function respondWithResult(_0x154752,_0x49dc14){_0x49dc14=_0x49dc14||0xc8;return function(_0x275d32){if(_0x275d32){return _0x154752[_0xf553('0x17')](_0x49dc14)['json'](_0x275d32);}};}function respondWithFilteredResult(_0x32a01b,_0x12968c){return function(_0x2cef54){if(_0x2cef54){var _0x3197ea=typeof _0x12968c[_0xf553('0x19')]===_0xf553('0x1a')&&typeof _0x12968c['limit']===_0xf553('0x1a');var _0x264bc1=_0x2cef54[_0xf553('0x1b')];var _0x14ae9c=_0x3197ea?0x0:_0x12968c[_0xf553('0x19')];var _0x53aae0=_0x3197ea?_0x2cef54[_0xf553('0x1b')]:_0x12968c[_0xf553('0x19')]+_0x12968c['limit'];var _0x58bd9d;if(_0x53aae0>=_0x264bc1){_0x53aae0=_0x264bc1;_0x58bd9d=0xc8;}else{_0x58bd9d=0xce;}_0x32a01b[_0xf553('0x17')](_0x58bd9d);return _0x32a01b[_0xf553('0x1c')]('Content-Range',_0x14ae9c+'-'+_0x53aae0+'/'+_0x264bc1)['json'](_0x2cef54);}return null;};}function patchUpdates(_0x21c395){return function(_0x560033){try{jsonpatch[_0xf553('0x1d')](_0x560033,_0x21c395,!![]);}catch(_0x2b6f93){return BPromise[_0xf553('0x1e')](_0x2b6f93);}return _0x560033[_0xf553('0x1f')]();};}function saveUpdates(_0x2ad893,_0x242b60){return function(_0x487cdb){if(_0x487cdb){return _0x487cdb['update'](_0x2ad893)[_0xf553('0x20')](function(_0x12e0d1){return _0x12e0d1;});}return null;};}function removeEntity(_0x5d967c,_0x1921cf){return function(_0x585dfa){if(_0x585dfa){return _0x585dfa[_0xf553('0x21')]()[_0xf553('0x20')](function(){_0x5d967c[_0xf553('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1b9a57,_0x501be2){return function(_0x3a58b3){if(!_0x3a58b3){_0x1b9a57[_0xf553('0x16')](0x194);}return _0x3a58b3;};}function handleError(_0x5c4dd2,_0x466be4){_0x466be4=_0x466be4||0x1f4;return function(_0x532fa5){logger[_0xf553('0x22')](_0x532fa5[_0xf553('0x23')]);if(_0x532fa5['name']){delete _0x532fa5[_0xf553('0x24')];}_0x5c4dd2[_0xf553('0x17')](_0x466be4)[_0xf553('0x25')](_0x532fa5);};}exports['index']=function(_0x4749d0,_0x3e06e0){var _0x13b084={},_0x12075e={},_0x53145b={'count':0x0,'rows':[]};var _0x268e0e=_[_0xf553('0x26')](db[_0xf553('0x27')][_0xf553('0x28')],function(_0x31cafc){return{'name':_0x31cafc[_0xf553('0x29')],'type':_0x31cafc[_0xf553('0x2a')][_0xf553('0x2b')]};});_0x12075e['model']=_[_0xf553('0x26')](_0x268e0e,_0xf553('0x24'));_0x12075e['query']=_[_0xf553('0x2c')](_0x4749d0[_0xf553('0x2d')]);_0x12075e[_0xf553('0x2e')]=_[_0xf553('0x2f')](_0x12075e[_0xf553('0x30')],_0x12075e['query']);_0x13b084[_0xf553('0x31')]=_[_0xf553('0x2f')](_0x12075e[_0xf553('0x30')],qs[_0xf553('0x32')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x32')]));_0x13b084[_0xf553('0x31')]=_0x13b084[_0xf553('0x31')][_0xf553('0x33')]?_0x13b084[_0xf553('0x31')]:_0x12075e[_0xf553('0x30')];if(!_0x4749d0['query'][_0xf553('0x34')](_0xf553('0x35'))){_0x13b084[_0xf553('0x36')]=qs[_0xf553('0x36')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x36')]);_0x13b084[_0xf553('0x19')]=qs[_0xf553('0x19')](_0x4749d0[_0xf553('0x2d')]['offset']);}_0x13b084[_0xf553('0x37')]=qs[_0xf553('0x38')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x38')]);_0x13b084['where']=qs[_0xf553('0x2e')](_[_0xf553('0x39')](_0x4749d0[_0xf553('0x2d')],_0x12075e[_0xf553('0x2e')]),_0x268e0e);if(_0x4749d0[_0xf553('0x2d')][_0xf553('0x3a')]){_0x13b084[_0xf553('0x3b')]=_[_0xf553('0x3c')](_0x13b084[_0xf553('0x3b')],{'$or':_[_0xf553('0x26')](_0x268e0e,function(_0x5a721c){if(_0x5a721c[_0xf553('0x2a')]!==_0xf553('0x3d')){var _0x266b9d={};_0x266b9d[_0x5a721c['name']]={'$like':'%'+_0x4749d0[_0xf553('0x2d')]['filter']+'%'};return _0x266b9d;}})});}_0x13b084=_[_0xf553('0x3c')]({},_0x13b084,_0x4749d0[_0xf553('0x3e')]);var _0x582931={'where':_0x13b084[_0xf553('0x3b')]};return db['DeskField'][_0xf553('0x1b')](_0x582931)[_0xf553('0x20')](function(_0x3ecc5d){_0x53145b[_0xf553('0x1b')]=_0x3ecc5d;if(_0x4749d0[_0xf553('0x2d')][_0xf553('0x3f')]){_0x13b084['include']=[{'all':!![]}];}return db[_0xf553('0x27')][_0xf553('0x40')](_0x13b084);})[_0xf553('0x20')](function(_0x294a60){_0x53145b[_0xf553('0x41')]=_0x294a60;return _0x53145b;})[_0xf553('0x20')](respondWithFilteredResult(_0x3e06e0,_0x13b084))[_0xf553('0x42')](handleError(_0x3e06e0,null));};exports[_0xf553('0x43')]=function(_0x5ab801,_0x222666){var _0x37480d={'raw':!![],'where':{'id':_0x5ab801[_0xf553('0x44')]['id']}},_0x28aaa4={};_0x28aaa4[_0xf553('0x30')]=_[_0xf553('0x2c')](db[_0xf553('0x27')]['rawAttributes']);_0x28aaa4[_0xf553('0x2d')]=_[_0xf553('0x2c')](_0x5ab801['query']);_0x28aaa4[_0xf553('0x2e')]=_['intersection'](_0x28aaa4[_0xf553('0x30')],_0x28aaa4[_0xf553('0x2d')]);_0x37480d[_0xf553('0x31')]=_[_0xf553('0x2f')](_0x28aaa4[_0xf553('0x30')],qs[_0xf553('0x32')](_0x5ab801[_0xf553('0x2d')][_0xf553('0x32')]));_0x37480d[_0xf553('0x31')]=_0x37480d[_0xf553('0x31')][_0xf553('0x33')]?_0x37480d[_0xf553('0x31')]:_0x28aaa4['model'];if(_0x5ab801[_0xf553('0x2d')][_0xf553('0x3f')]){_0x37480d[_0xf553('0x45')]=[{'all':!![]}];}_0x37480d=_[_0xf553('0x3c')]({},_0x37480d,_0x5ab801['options']);return db[_0xf553('0x27')]['find'](_0x37480d)[_0xf553('0x20')](handleEntityNotFound(_0x222666,null))[_0xf553('0x20')](respondWithResult(_0x222666,null))['catch'](handleError(_0x222666,null));};exports[_0xf553('0x46')]=function(_0x4d2e2e,_0x556d4e){return db[_0xf553('0x27')][_0xf553('0x46')](_0x4d2e2e[_0xf553('0x47')],{})[_0xf553('0x20')](respondWithResult(_0x556d4e,0xc9))['catch'](handleError(_0x556d4e,null));};exports[_0xf553('0x48')]=function(_0x2adae9,_0x41bbc5){if(_0x2adae9[_0xf553('0x47')]['id']){delete _0x2adae9['body']['id'];}return db[_0xf553('0x27')]['find']({'where':{'id':_0x2adae9[_0xf553('0x44')]['id']}})[_0xf553('0x20')](handleEntityNotFound(_0x41bbc5,null))['then'](saveUpdates(_0x2adae9['body'],null))['then'](respondWithResult(_0x41bbc5,null))[_0xf553('0x42')](handleError(_0x41bbc5,null));};exports[_0xf553('0x21')]=function(_0x1f04a5,_0x17a7e3){return db[_0xf553('0x27')][_0xf553('0x49')]({'where':{'id':_0x1f04a5['params']['id']}})[_0xf553('0x20')](handleEntityNotFound(_0x17a7e3,null))[_0xf553('0x20')](removeEntity(_0x17a7e3,null))['catch'](handleError(_0x17a7e3,null));};
\ No newline at end of file