Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index b19b4f7..d49ef7a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x40ce=['sendStatus','end','status','json','offset','limit','undefined','count','Content-Range','apply','reject','save','update','then','error','stack','name','index','map','ZendeskField','rawAttributes','type','key','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','catch','show','params','find','create','body','destroy','rimraf','zip-dir','fast-json-patch','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb'];(function(_0x3bc5bb,_0x280c54){var _0x13dc9f=function(_0x12472b){while(--_0x12472b){_0x3bc5bb['push'](_0x3bc5bb['shift']());}};_0x13dc9f(++_0x280c54);}(_0x40ce,0x110));var _0xe40c=function(_0x1649f2,_0x13fe1d){_0x1649f2=_0x1649f2-0x0;var _0x1a5626=_0x40ce[_0x1649f2];return _0x1a5626;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe40c('0x0'));var zipdir=require(_0xe40c('0x1'));var jsonpatch=require(_0xe40c('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xe40c('0x3'));var path=require(_0xe40c('0x4'));var sox=require(_0xe40c('0x5'));var csv=require(_0xe40c('0x6'));var ejs=require(_0xe40c('0x7'));var fs=require('fs');var fs_extra=require(_0xe40c('0x8'));var _=require(_0xe40c('0x9'));var squel=require(_0xe40c('0xa'));var crypto=require(_0xe40c('0xb'));var jsforce=require(_0xe40c('0xc'));var deskjs=require(_0xe40c('0xd'));var toCsv=require(_0xe40c('0x6'));var querystring=require(_0xe40c('0xe'));var Papa=require('papaparse');var Redis=require(_0xe40c('0xf'));var authService=require(_0xe40c('0x10'));var qs=require(_0xe40c('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe40c('0x12'));var logger=require(_0xe40c('0x13'))(_0xe40c('0x14'));var utils=require(_0xe40c('0x15'));var config=require(_0xe40c('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xe40c('0x17'))['db'];function respondWithStatusCode(_0x20ea5f,_0x62257f){_0x62257f=_0x62257f||0xcc;return function(_0x21d14c){if(_0x21d14c){return _0x20ea5f[_0xe40c('0x18')](_0x62257f);}return _0x20ea5f['status'](_0x62257f)[_0xe40c('0x19')]();};}function respondWithResult(_0x474c05,_0xa36149){_0xa36149=_0xa36149||0xc8;return function(_0x2f5497){if(_0x2f5497){return _0x474c05[_0xe40c('0x1a')](_0xa36149)[_0xe40c('0x1b')](_0x2f5497);}};}function respondWithFilteredResult(_0x350ff1,_0x5aca04){return function(_0x93d8ca){if(_0x93d8ca){var _0x4cf110=typeof _0x5aca04[_0xe40c('0x1c')]==='undefined'&&typeof _0x5aca04[_0xe40c('0x1d')]===_0xe40c('0x1e');var _0x93f5d3=_0x93d8ca[_0xe40c('0x1f')];var _0x18d05d=_0x4cf110?0x0:_0x5aca04[_0xe40c('0x1c')];var _0x1dbe4b=_0x4cf110?_0x93d8ca[_0xe40c('0x1f')]:_0x5aca04[_0xe40c('0x1c')]+_0x5aca04[_0xe40c('0x1d')];var _0x16c98e;if(_0x1dbe4b>=_0x93f5d3){_0x1dbe4b=_0x93f5d3;_0x16c98e=0xc8;}else{_0x16c98e=0xce;}_0x350ff1['status'](_0x16c98e);return _0x350ff1['set'](_0xe40c('0x20'),_0x18d05d+'-'+_0x1dbe4b+'/'+_0x93f5d3)[_0xe40c('0x1b')](_0x93d8ca);}return null;};}function patchUpdates(_0x3e4f52){return function(_0x392bae){try{jsonpatch[_0xe40c('0x21')](_0x392bae,_0x3e4f52,!![]);}catch(_0x5b54ea){return BPromise[_0xe40c('0x22')](_0x5b54ea);}return _0x392bae[_0xe40c('0x23')]();};}function saveUpdates(_0x3ae56b,_0x5c9ce0){return function(_0x1e7260){if(_0x1e7260){return _0x1e7260[_0xe40c('0x24')](_0x3ae56b)[_0xe40c('0x25')](function(_0x2f649e){return _0x2f649e;});}return null;};}function removeEntity(_0xa6e793,_0x5f0a5d){return function(_0x2573f2){if(_0x2573f2){return _0x2573f2['destroy']()[_0xe40c('0x25')](function(){_0xa6e793[_0xe40c('0x1a')](0xcc)[_0xe40c('0x19')]();});}};}function handleEntityNotFound(_0x501275,_0x9a5746){return function(_0x24ba2d){if(!_0x24ba2d){_0x501275[_0xe40c('0x18')](0x194);}return _0x24ba2d;};}function handleError(_0x4cad58,_0x479601){_0x479601=_0x479601||0x1f4;return function(_0x29f851){logger[_0xe40c('0x26')](_0x29f851[_0xe40c('0x27')]);if(_0x29f851[_0xe40c('0x28')]){delete _0x29f851[_0xe40c('0x28')];}_0x4cad58[_0xe40c('0x1a')](_0x479601)['send'](_0x29f851);};}exports[_0xe40c('0x29')]=function(_0x12ee21,_0x3c99ff){var _0x6e455f={},_0x5de519={},_0x136758={'count':0x0,'rows':[]};var _0x2de4e7=_[_0xe40c('0x2a')](db[_0xe40c('0x2b')][_0xe40c('0x2c')],function(_0xd61afe){return{'name':_0xd61afe['fieldName'],'type':_0xd61afe[_0xe40c('0x2d')][_0xe40c('0x2e')]};});_0x5de519['model']=_[_0xe40c('0x2a')](_0x2de4e7,_0xe40c('0x28'));_0x5de519[_0xe40c('0x2f')]=_[_0xe40c('0x30')](_0x12ee21['query']);_0x5de519[_0xe40c('0x31')]=_['intersection'](_0x5de519[_0xe40c('0x32')],_0x5de519[_0xe40c('0x2f')]);_0x6e455f[_0xe40c('0x33')]=_[_0xe40c('0x34')](_0x5de519[_0xe40c('0x32')],qs[_0xe40c('0x35')](_0x12ee21['query'][_0xe40c('0x35')]));_0x6e455f['attributes']=_0x6e455f[_0xe40c('0x33')][_0xe40c('0x36')]?_0x6e455f[_0xe40c('0x33')]:_0x5de519[_0xe40c('0x32')];if(!_0x12ee21['query'][_0xe40c('0x37')](_0xe40c('0x38'))){_0x6e455f[_0xe40c('0x1d')]=qs[_0xe40c('0x1d')](_0x12ee21['query'][_0xe40c('0x1d')]);_0x6e455f[_0xe40c('0x1c')]=qs[_0xe40c('0x1c')](_0x12ee21['query'][_0xe40c('0x1c')]);}_0x6e455f[_0xe40c('0x39')]=qs['sort'](_0x12ee21[_0xe40c('0x2f')][_0xe40c('0x3a')]);_0x6e455f[_0xe40c('0x3b')]=qs[_0xe40c('0x31')](_[_0xe40c('0x3c')](_0x12ee21['query'],_0x5de519[_0xe40c('0x31')]),_0x2de4e7);if(_0x12ee21[_0xe40c('0x2f')][_0xe40c('0x3d')]){_0x6e455f[_0xe40c('0x3b')]=_[_0xe40c('0x3e')](_0x6e455f['where'],{'$or':_[_0xe40c('0x2a')](_0x2de4e7,function(_0x2a2375){if(_0x2a2375[_0xe40c('0x2d')]!==_0xe40c('0x3f')){var _0x335915={};_0x335915[_0x2a2375['name']]={'$like':'%'+_0x12ee21['query'][_0xe40c('0x3d')]+'%'};return _0x335915;}})});}_0x6e455f=_[_0xe40c('0x3e')]({},_0x6e455f,_0x12ee21[_0xe40c('0x40')]);var _0x1ffc76={'where':_0x6e455f[_0xe40c('0x3b')]};return db['ZendeskField'][_0xe40c('0x1f')](_0x1ffc76)['then'](function(_0x404640){_0x136758[_0xe40c('0x1f')]=_0x404640;if(_0x12ee21['query'][_0xe40c('0x41')]){_0x6e455f[_0xe40c('0x42')]=[{'all':!![]}];}return db[_0xe40c('0x2b')]['findAll'](_0x6e455f);})['then'](function(_0x521cae){_0x136758['rows']=_0x521cae;return _0x136758;})[_0xe40c('0x25')](respondWithFilteredResult(_0x3c99ff,_0x6e455f))[_0xe40c('0x43')](handleError(_0x3c99ff,null));};exports[_0xe40c('0x44')]=function(_0x1568df,_0x2ce377){var _0x460cce={'raw':!![],'where':{'id':_0x1568df[_0xe40c('0x45')]['id']}},_0x27b110={};_0x27b110[_0xe40c('0x32')]=_[_0xe40c('0x30')](db['ZendeskField']['rawAttributes']);_0x27b110[_0xe40c('0x2f')]=_['keys'](_0x1568df['query']);_0x27b110[_0xe40c('0x31')]=_[_0xe40c('0x34')](_0x27b110['model'],_0x27b110[_0xe40c('0x2f')]);_0x460cce[_0xe40c('0x33')]=_[_0xe40c('0x34')](_0x27b110[_0xe40c('0x32')],qs[_0xe40c('0x35')](_0x1568df['query'][_0xe40c('0x35')]));_0x460cce[_0xe40c('0x33')]=_0x460cce[_0xe40c('0x33')][_0xe40c('0x36')]?_0x460cce[_0xe40c('0x33')]:_0x27b110[_0xe40c('0x32')];if(_0x1568df[_0xe40c('0x2f')][_0xe40c('0x41')]){_0x460cce[_0xe40c('0x42')]=[{'all':!![]}];}_0x460cce=_['merge']({},_0x460cce,_0x1568df['options']);return db[_0xe40c('0x2b')][_0xe40c('0x46')](_0x460cce)[_0xe40c('0x25')](handleEntityNotFound(_0x2ce377,null))[_0xe40c('0x25')](respondWithResult(_0x2ce377,null))[_0xe40c('0x43')](handleError(_0x2ce377,null));};exports[_0xe40c('0x47')]=function(_0x5be499,_0x2aa1e6){return db[_0xe40c('0x2b')][_0xe40c('0x47')](_0x5be499['body'],{})[_0xe40c('0x25')](respondWithResult(_0x2aa1e6,0xc9))['catch'](handleError(_0x2aa1e6,null));};exports[_0xe40c('0x24')]=function(_0x499e1b,_0x5b80b7){if(_0x499e1b['body']['id']){delete _0x499e1b['body']['id'];}return db[_0xe40c('0x2b')]['find']({'where':{'id':_0x499e1b[_0xe40c('0x45')]['id']}})[_0xe40c('0x25')](handleEntityNotFound(_0x5b80b7,null))['then'](saveUpdates(_0x499e1b[_0xe40c('0x48')],null))[_0xe40c('0x25')](respondWithResult(_0x5b80b7,null))[_0xe40c('0x43')](handleError(_0x5b80b7,null));};exports[_0xe40c('0x49')]=function(_0x25b078,_0x33960f){return db[_0xe40c('0x2b')][_0xe40c('0x46')]({'where':{'id':_0x25b078[_0xe40c('0x45')]['id']}})['then'](handleEntityNotFound(_0x33960f,null))[_0xe40c('0x25')](removeEntity(_0x33960f,null))[_0xe40c('0x43')](handleError(_0x33960f,null));};
\ No newline at end of file
+var _0x81f5=['undefined','limit','count','set','apply','save','update','destroy','then','stack','name','send','index','map','ZendeskField','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','sort','where','pick','filters','filter','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset'];(function(_0x30797c,_0x4d85f0){var _0x245872=function(_0x841ea0){while(--_0x841ea0){_0x30797c['push'](_0x30797c['shift']());}};_0x245872(++_0x4d85f0);}(_0x81f5,0x77));var _0x581f=function(_0x311c35,_0x534915){_0x311c35=_0x311c35-0x0;var _0x5cc50c=_0x81f5[_0x311c35];return _0x5cc50c;};'use strict';var emlformat=require(_0x581f('0x0'));var rimraf=require(_0x581f('0x1'));var zipdir=require(_0x581f('0x2'));var jsonpatch=require(_0x581f('0x3'));var rp=require(_0x581f('0x4'));var moment=require(_0x581f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x581f('0x6'));var util=require(_0x581f('0x7'));var path=require(_0x581f('0x8'));var sox=require(_0x581f('0x9'));var csv=require(_0x581f('0xa'));var ejs=require(_0x581f('0xb'));var fs=require('fs');var fs_extra=require(_0x581f('0xc'));var _=require(_0x581f('0xd'));var squel=require(_0x581f('0xe'));var crypto=require('crypto');var jsforce=require(_0x581f('0xf'));var deskjs=require(_0x581f('0x10'));var toCsv=require('to-csv');var querystring=require(_0x581f('0x11'));var Papa=require(_0x581f('0x12'));var Redis=require(_0x581f('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x581f('0x14'));var as=require(_0x581f('0x15'));var hardwareService=require(_0x581f('0x16'));var logger=require('../../config/logger')('api');var utils=require(_0x581f('0x17'));var config=require(_0x581f('0x18'));var licenseUtil=require(_0x581f('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4cfe6f,_0x249a79){_0x249a79=_0x249a79||0xcc;return function(_0xf8cfe9){if(_0xf8cfe9){return _0x4cfe6f[_0x581f('0x1a')](_0x249a79);}return _0x4cfe6f[_0x581f('0x1b')](_0x249a79)[_0x581f('0x1c')]();};}function respondWithResult(_0x44c7ec,_0x57fef9){_0x57fef9=_0x57fef9||0xc8;return function(_0x5b90af){if(_0x5b90af){return _0x44c7ec[_0x581f('0x1b')](_0x57fef9)[_0x581f('0x1d')](_0x5b90af);}};}function respondWithFilteredResult(_0x781853,_0x3ce459){return function(_0x12bdc3){if(_0x12bdc3){var _0x7a867e=typeof _0x3ce459[_0x581f('0x1e')]===_0x581f('0x1f')&&typeof _0x3ce459[_0x581f('0x20')]===_0x581f('0x1f');var _0x2564c8=_0x12bdc3[_0x581f('0x21')];var _0x143fe0=_0x7a867e?0x0:_0x3ce459[_0x581f('0x1e')];var _0xb70df6=_0x7a867e?_0x12bdc3['count']:_0x3ce459[_0x581f('0x1e')]+_0x3ce459[_0x581f('0x20')];var _0x345dd7;if(_0xb70df6>=_0x2564c8){_0xb70df6=_0x2564c8;_0x345dd7=0xc8;}else{_0x345dd7=0xce;}_0x781853[_0x581f('0x1b')](_0x345dd7);return _0x781853[_0x581f('0x22')]('Content-Range',_0x143fe0+'-'+_0xb70df6+'/'+_0x2564c8)[_0x581f('0x1d')](_0x12bdc3);}return null;};}function patchUpdates(_0x10f439){return function(_0x25b3b1){try{jsonpatch[_0x581f('0x23')](_0x25b3b1,_0x10f439,!![]);}catch(_0x4163e2){return BPromise['reject'](_0x4163e2);}return _0x25b3b1[_0x581f('0x24')]();};}function saveUpdates(_0x328b74,_0x508933){return function(_0x22dd22){if(_0x22dd22){return _0x22dd22[_0x581f('0x25')](_0x328b74)['then'](function(_0x18ea1d){return _0x18ea1d;});}return null;};}function removeEntity(_0x27e7bf,_0x3d0a62){return function(_0xc8e38a){if(_0xc8e38a){return _0xc8e38a[_0x581f('0x26')]()[_0x581f('0x27')](function(){_0x27e7bf[_0x581f('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x57cc07,_0xd1d380){return function(_0x1d8abb){if(!_0x1d8abb){_0x57cc07[_0x581f('0x1a')](0x194);}return _0x1d8abb;};}function handleError(_0x80a877,_0x1092fb){_0x1092fb=_0x1092fb||0x1f4;return function(_0x3e4b65){logger['error'](_0x3e4b65[_0x581f('0x28')]);if(_0x3e4b65['name']){delete _0x3e4b65[_0x581f('0x29')];}_0x80a877['status'](_0x1092fb)[_0x581f('0x2a')](_0x3e4b65);};}exports[_0x581f('0x2b')]=function(_0x2b4619,_0x3009af){var _0x4fedde={},_0xabbf34={},_0x2dec70={'count':0x0,'rows':[]};var _0x174819=_[_0x581f('0x2c')](db[_0x581f('0x2d')][_0x581f('0x2e')],function(_0x4e383a){return{'name':_0x4e383a[_0x581f('0x2f')],'type':_0x4e383a[_0x581f('0x30')][_0x581f('0x31')]};});_0xabbf34[_0x581f('0x32')]=_[_0x581f('0x2c')](_0x174819,'name');_0xabbf34[_0x581f('0x33')]=_[_0x581f('0x34')](_0x2b4619[_0x581f('0x33')]);_0xabbf34['filters']=_[_0x581f('0x35')](_0xabbf34[_0x581f('0x32')],_0xabbf34['query']);_0x4fedde[_0x581f('0x36')]=_[_0x581f('0x35')](_0xabbf34[_0x581f('0x32')],qs[_0x581f('0x37')](_0x2b4619[_0x581f('0x33')][_0x581f('0x37')]));_0x4fedde[_0x581f('0x36')]=_0x4fedde['attributes'][_0x581f('0x38')]?_0x4fedde[_0x581f('0x36')]:_0xabbf34['model'];if(!_0x2b4619[_0x581f('0x33')]['hasOwnProperty'](_0x581f('0x39'))){_0x4fedde[_0x581f('0x20')]=qs['limit'](_0x2b4619[_0x581f('0x33')][_0x581f('0x20')]);_0x4fedde[_0x581f('0x1e')]=qs[_0x581f('0x1e')](_0x2b4619[_0x581f('0x33')][_0x581f('0x1e')]);}_0x4fedde['order']=qs[_0x581f('0x3a')](_0x2b4619[_0x581f('0x33')][_0x581f('0x3a')]);_0x4fedde[_0x581f('0x3b')]=qs['filters'](_[_0x581f('0x3c')](_0x2b4619[_0x581f('0x33')],_0xabbf34[_0x581f('0x3d')]),_0x174819);if(_0x2b4619[_0x581f('0x33')][_0x581f('0x3e')]){_0x4fedde[_0x581f('0x3b')]=_['merge'](_0x4fedde[_0x581f('0x3b')],{'$or':_[_0x581f('0x2c')](_0x174819,function(_0x4dd253){if(_0x4dd253['type']!==_0x581f('0x3f')){var _0xdaa9f9={};_0xdaa9f9[_0x4dd253[_0x581f('0x29')]]={'$like':'%'+_0x2b4619[_0x581f('0x33')][_0x581f('0x3e')]+'%'};return _0xdaa9f9;}})});}_0x4fedde=_['merge']({},_0x4fedde,_0x2b4619[_0x581f('0x40')]);var _0x2f752a={'where':_0x4fedde[_0x581f('0x3b')]};return db['ZendeskField'][_0x581f('0x21')](_0x2f752a)[_0x581f('0x27')](function(_0x43ecf7){_0x2dec70[_0x581f('0x21')]=_0x43ecf7;if(_0x2b4619['query'][_0x581f('0x41')]){_0x4fedde[_0x581f('0x42')]=[{'all':!![]}];}return db['ZendeskField'][_0x581f('0x43')](_0x4fedde);})[_0x581f('0x27')](function(_0x30d527){_0x2dec70[_0x581f('0x44')]=_0x30d527;return _0x2dec70;})['then'](respondWithFilteredResult(_0x3009af,_0x4fedde))[_0x581f('0x45')](handleError(_0x3009af,null));};exports[_0x581f('0x46')]=function(_0x5a4658,_0x171fa1){var _0x3988ba={'raw':!![],'where':{'id':_0x5a4658[_0x581f('0x47')]['id']}},_0x4216ba={};_0x4216ba[_0x581f('0x32')]=_[_0x581f('0x34')](db[_0x581f('0x2d')][_0x581f('0x2e')]);_0x4216ba['query']=_[_0x581f('0x34')](_0x5a4658[_0x581f('0x33')]);_0x4216ba[_0x581f('0x3d')]=_[_0x581f('0x35')](_0x4216ba[_0x581f('0x32')],_0x4216ba[_0x581f('0x33')]);_0x3988ba[_0x581f('0x36')]=_[_0x581f('0x35')](_0x4216ba[_0x581f('0x32')],qs['fields'](_0x5a4658[_0x581f('0x33')][_0x581f('0x37')]));_0x3988ba[_0x581f('0x36')]=_0x3988ba[_0x581f('0x36')][_0x581f('0x38')]?_0x3988ba['attributes']:_0x4216ba[_0x581f('0x32')];if(_0x5a4658[_0x581f('0x33')]['includeAll']){_0x3988ba[_0x581f('0x42')]=[{'all':!![]}];}_0x3988ba=_['merge']({},_0x3988ba,_0x5a4658[_0x581f('0x40')]);return db[_0x581f('0x2d')][_0x581f('0x48')](_0x3988ba)[_0x581f('0x27')](handleEntityNotFound(_0x171fa1,null))[_0x581f('0x27')](respondWithResult(_0x171fa1,null))[_0x581f('0x45')](handleError(_0x171fa1,null));};exports[_0x581f('0x49')]=function(_0x370384,_0x5be2df){return db[_0x581f('0x2d')]['create'](_0x370384[_0x581f('0x4a')],{})['then'](respondWithResult(_0x5be2df,0xc9))[_0x581f('0x45')](handleError(_0x5be2df,null));};exports[_0x581f('0x25')]=function(_0x4b1f4e,_0x3e9471){if(_0x4b1f4e[_0x581f('0x4a')]['id']){delete _0x4b1f4e['body']['id'];}return db[_0x581f('0x2d')][_0x581f('0x48')]({'where':{'id':_0x4b1f4e[_0x581f('0x47')]['id']}})[_0x581f('0x27')](handleEntityNotFound(_0x3e9471,null))[_0x581f('0x27')](saveUpdates(_0x4b1f4e['body'],null))['then'](respondWithResult(_0x3e9471,null))[_0x581f('0x45')](handleError(_0x3e9471,null));};exports[_0x581f('0x26')]=function(_0x505964,_0x5073cf){return db['ZendeskField']['find']({'where':{'id':_0x505964[_0x581f('0x47')]['id']}})[_0x581f('0x27')](handleEntityNotFound(_0x5073cf,null))[_0x581f('0x27')](removeEntity(_0x5073cf,null))['catch'](handleError(_0x5073cf,null));};
\ No newline at end of file