Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index 8fdc74d..6a22379 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf2a=['moment','bluebird','mustache','util','sox','to-csv','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','update','then','destroy','stack','name','send','index','map','ZendeskField','rawAttributes','fieldName','type','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','eml-format','fast-json-patch','request-promise'];(function(_0x2d3d0d,_0x67ac82){var _0xca35b6=function(_0x483979){while(--_0x483979){_0x2d3d0d['push'](_0x2d3d0d['shift']());}};_0xca35b6(++_0x67ac82);}(_0xbf2a,0x165));var _0xabf2=function(_0xc905bf,_0x3fb45d){_0xc905bf=_0xc905bf-0x0;var _0x3ffd14=_0xbf2a[_0xc905bf];return _0x3ffd14;};'use strict';var emlformat=require(_0xabf2('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xabf2('0x1'));var rp=require(_0xabf2('0x2'));var moment=require(_0xabf2('0x3'));var BPromise=require(_0xabf2('0x4'));var Mustache=require(_0xabf2('0x5'));var util=require(_0xabf2('0x6'));var path=require('path');var sox=require(_0xabf2('0x7'));var csv=require(_0xabf2('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xabf2('0x9'));var squel=require('squel');var crypto=require(_0xabf2('0xa'));var jsforce=require(_0xabf2('0xb'));var deskjs=require(_0xabf2('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xabf2('0xd'));var Redis=require(_0xabf2('0xe'));var authService=require(_0xabf2('0xf'));var qs=require(_0xabf2('0x10'));var as=require(_0xabf2('0x11'));var hardwareService=require(_0xabf2('0x12'));var logger=require('../../config/logger')('api');var utils=require(_0xabf2('0x13'));var config=require(_0xabf2('0x14'));var licenseUtil=require(_0xabf2('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x63964a,_0x2e54d9){_0x2e54d9=_0x2e54d9||0xcc;return function(_0x8aa3d8){if(_0x8aa3d8){return _0x63964a['sendStatus'](_0x2e54d9);}return _0x63964a[_0xabf2('0x16')](_0x2e54d9)[_0xabf2('0x17')]();};}function respondWithResult(_0xea348e,_0x3b16f4){_0x3b16f4=_0x3b16f4||0xc8;return function(_0x4aa1c2){if(_0x4aa1c2){return _0xea348e[_0xabf2('0x16')](_0x3b16f4)['json'](_0x4aa1c2);}};}function respondWithFilteredResult(_0x425a36,_0x3fbff0){return function(_0x1b9f54){if(_0x1b9f54){var _0x11e650=typeof _0x3fbff0[_0xabf2('0x18')]===_0xabf2('0x19')&&typeof _0x3fbff0[_0xabf2('0x1a')]===_0xabf2('0x19');var _0x209dd3=_0x1b9f54[_0xabf2('0x1b')];var _0x30eeab=_0x11e650?0x0:_0x3fbff0[_0xabf2('0x18')];var _0x4933e8=_0x11e650?_0x1b9f54[_0xabf2('0x1b')]:_0x3fbff0[_0xabf2('0x18')]+_0x3fbff0[_0xabf2('0x1a')];var _0x3a89ab;if(_0x4933e8>=_0x209dd3){_0x4933e8=_0x209dd3;_0x3a89ab=0xc8;}else{_0x3a89ab=0xce;}_0x425a36[_0xabf2('0x16')](_0x3a89ab);return _0x425a36['set'](_0xabf2('0x1c'),_0x30eeab+'-'+_0x4933e8+'/'+_0x209dd3)[_0xabf2('0x1d')](_0x1b9f54);}return null;};}function patchUpdates(_0x533e1a){return function(_0x2eee0f){try{jsonpatch[_0xabf2('0x1e')](_0x2eee0f,_0x533e1a,!![]);}catch(_0xabb431){return BPromise[_0xabf2('0x1f')](_0xabb431);}return _0x2eee0f[_0xabf2('0x20')]();};}function saveUpdates(_0x12984a,_0x4f1012){return function(_0x212ad7){if(_0x212ad7){return _0x212ad7[_0xabf2('0x21')](_0x12984a)[_0xabf2('0x22')](function(_0x391099){return _0x391099;});}return null;};}function removeEntity(_0x2f7ffa,_0x252f3e){return function(_0x54a033){if(_0x54a033){return _0x54a033[_0xabf2('0x23')]()[_0xabf2('0x22')](function(){_0x2f7ffa[_0xabf2('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x309466,_0x2016e6){return function(_0x16994f){if(!_0x16994f){_0x309466['sendStatus'](0x194);}return _0x16994f;};}function handleError(_0x567c14,_0x25e173){_0x25e173=_0x25e173||0x1f4;return function(_0x4eed34){logger['error'](_0x4eed34[_0xabf2('0x24')]);if(_0x4eed34['name']){delete _0x4eed34[_0xabf2('0x25')];}_0x567c14[_0xabf2('0x16')](_0x25e173)[_0xabf2('0x26')](_0x4eed34);};}exports[_0xabf2('0x27')]=function(_0x345f92,_0x53fa8d){var _0x48ba8f={},_0x7dc999={},_0x2038bb={'count':0x0,'rows':[]};var _0x56bda7=_[_0xabf2('0x28')](db[_0xabf2('0x29')][_0xabf2('0x2a')],function(_0x40d577){return{'name':_0x40d577[_0xabf2('0x2b')],'type':_0x40d577[_0xabf2('0x2c')]['key']};});_0x7dc999['model']=_[_0xabf2('0x28')](_0x56bda7,_0xabf2('0x25'));_0x7dc999['query']=_[_0xabf2('0x2d')](_0x345f92[_0xabf2('0x2e')]);_0x7dc999['filters']=_[_0xabf2('0x2f')](_0x7dc999[_0xabf2('0x30')],_0x7dc999[_0xabf2('0x2e')]);_0x48ba8f[_0xabf2('0x31')]=_['intersection'](_0x7dc999[_0xabf2('0x30')],qs[_0xabf2('0x32')](_0x345f92[_0xabf2('0x2e')][_0xabf2('0x32')]));_0x48ba8f[_0xabf2('0x31')]=_0x48ba8f[_0xabf2('0x31')][_0xabf2('0x33')]?_0x48ba8f[_0xabf2('0x31')]:_0x7dc999[_0xabf2('0x30')];if(!_0x345f92[_0xabf2('0x2e')][_0xabf2('0x34')](_0xabf2('0x35'))){_0x48ba8f[_0xabf2('0x1a')]=qs[_0xabf2('0x1a')](_0x345f92[_0xabf2('0x2e')]['limit']);_0x48ba8f['offset']=qs[_0xabf2('0x18')](_0x345f92[_0xabf2('0x2e')][_0xabf2('0x18')]);}_0x48ba8f[_0xabf2('0x36')]=qs['sort'](_0x345f92[_0xabf2('0x2e')][_0xabf2('0x37')]);_0x48ba8f[_0xabf2('0x38')]=qs[_0xabf2('0x39')](_['pick'](_0x345f92[_0xabf2('0x2e')],_0x7dc999[_0xabf2('0x39')]),_0x56bda7);if(_0x345f92[_0xabf2('0x2e')][_0xabf2('0x3a')]){_0x48ba8f[_0xabf2('0x38')]=_[_0xabf2('0x3b')](_0x48ba8f[_0xabf2('0x38')],{'$or':_['map'](_0x56bda7,function(_0x210585){if(_0x210585[_0xabf2('0x2c')]!==_0xabf2('0x3c')){var _0x467b87={};_0x467b87[_0x210585[_0xabf2('0x25')]]={'$like':'%'+_0x345f92[_0xabf2('0x2e')][_0xabf2('0x3a')]+'%'};return _0x467b87;}})});}_0x48ba8f=_[_0xabf2('0x3b')]({},_0x48ba8f,_0x345f92[_0xabf2('0x3d')]);var _0x92c259={'where':_0x48ba8f[_0xabf2('0x38')]};return db[_0xabf2('0x29')][_0xabf2('0x1b')](_0x92c259)[_0xabf2('0x22')](function(_0x543e68){_0x2038bb[_0xabf2('0x1b')]=_0x543e68;if(_0x345f92['query'][_0xabf2('0x3e')]){_0x48ba8f[_0xabf2('0x3f')]=[{'all':!![]}];}return db['ZendeskField'][_0xabf2('0x40')](_0x48ba8f);})[_0xabf2('0x22')](function(_0x2e483f){_0x2038bb[_0xabf2('0x41')]=_0x2e483f;return _0x2038bb;})['then'](respondWithFilteredResult(_0x53fa8d,_0x48ba8f))['catch'](handleError(_0x53fa8d,null));};exports[_0xabf2('0x42')]=function(_0x32f226,_0x3c84ec){var _0x54b705={'raw':!![],'where':{'id':_0x32f226[_0xabf2('0x43')]['id']}},_0x30f92b={};_0x30f92b[_0xabf2('0x30')]=_['keys'](db[_0xabf2('0x29')][_0xabf2('0x2a')]);_0x30f92b[_0xabf2('0x2e')]=_['keys'](_0x32f226[_0xabf2('0x2e')]);_0x30f92b[_0xabf2('0x39')]=_['intersection'](_0x30f92b[_0xabf2('0x30')],_0x30f92b['query']);_0x54b705[_0xabf2('0x31')]=_[_0xabf2('0x2f')](_0x30f92b['model'],qs['fields'](_0x32f226[_0xabf2('0x2e')][_0xabf2('0x32')]));_0x54b705[_0xabf2('0x31')]=_0x54b705[_0xabf2('0x31')][_0xabf2('0x33')]?_0x54b705[_0xabf2('0x31')]:_0x30f92b[_0xabf2('0x30')];if(_0x32f226[_0xabf2('0x2e')]['includeAll']){_0x54b705['include']=[{'all':!![]}];}_0x54b705=_[_0xabf2('0x3b')]({},_0x54b705,_0x32f226[_0xabf2('0x3d')]);return db[_0xabf2('0x29')][_0xabf2('0x44')](_0x54b705)[_0xabf2('0x22')](handleEntityNotFound(_0x3c84ec,null))[_0xabf2('0x22')](respondWithResult(_0x3c84ec,null))[_0xabf2('0x45')](handleError(_0x3c84ec,null));};exports['create']=function(_0x46c3e5,_0x42978f){return db[_0xabf2('0x29')][_0xabf2('0x46')](_0x46c3e5['body'],{})['then'](respondWithResult(_0x42978f,0xc9))['catch'](handleError(_0x42978f,null));};exports['update']=function(_0x58a446,_0x5f2666){if(_0x58a446[_0xabf2('0x47')]['id']){delete _0x58a446[_0xabf2('0x47')]['id'];}return db['ZendeskField'][_0xabf2('0x44')]({'where':{'id':_0x58a446[_0xabf2('0x43')]['id']}})[_0xabf2('0x22')](handleEntityNotFound(_0x5f2666,null))['then'](saveUpdates(_0x58a446[_0xabf2('0x47')],null))[_0xabf2('0x22')](respondWithResult(_0x5f2666,null))[_0xabf2('0x45')](handleError(_0x5f2666,null));};exports[_0xabf2('0x23')]=function(_0x2f9a58,_0x288990){return db[_0xabf2('0x29')][_0xabf2('0x44')]({'where':{'id':_0x2f9a58[_0xabf2('0x43')]['id']}})[_0xabf2('0x22')](handleEntityNotFound(_0x288990,null))['then'](removeEntity(_0x288990,null))['catch'](handleError(_0x288990,null));};
\ No newline at end of file
+var _0x7834=['json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','stack','map','ZendeskField','fieldName','key','model','name','keys','filters','intersection','query','attributes','fields','hasOwnProperty','nolimit','order','sort','where','type','merge','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','body','eml-format','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','status','end'];(function(_0x4ffca4,_0x1dfad4){var _0xc7336e=function(_0x436f5d){while(--_0x436f5d){_0x4ffca4['push'](_0x4ffca4['shift']());}};_0xc7336e(++_0x1dfad4);}(_0x7834,0x13f));var _0x4783=function(_0x99250c,_0x4603c0){_0x99250c=_0x99250c-0x0;var _0x3927d5=_0x7834[_0x99250c];return _0x3927d5;};'use strict';var emlformat=require(_0x4783('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x4783('0x1'));var rp=require('request-promise');var moment=require(_0x4783('0x2'));var BPromise=require(_0x4783('0x3'));var Mustache=require(_0x4783('0x4'));var util=require(_0x4783('0x5'));var path=require(_0x4783('0x6'));var sox=require(_0x4783('0x7'));var csv=require(_0x4783('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4783('0x9'));var _=require(_0x4783('0xa'));var squel=require('squel');var crypto=require(_0x4783('0xb'));var jsforce=require(_0x4783('0xc'));var deskjs=require(_0x4783('0xd'));var toCsv=require(_0x4783('0x8'));var querystring=require(_0x4783('0xe'));var Papa=require(_0x4783('0xf'));var Redis=require('ioredis');var authService=require(_0x4783('0x10'));var qs=require(_0x4783('0x11'));var as=require(_0x4783('0x12'));var hardwareService=require(_0x4783('0x13'));var logger=require(_0x4783('0x14'))(_0x4783('0x15'));var utils=require(_0x4783('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4783('0x17'))['db'];function respondWithStatusCode(_0x85087d,_0x4ce944){_0x4ce944=_0x4ce944||0xcc;return function(_0x2afbdc){if(_0x2afbdc){return _0x85087d['sendStatus'](_0x4ce944);}return _0x85087d[_0x4783('0x18')](_0x4ce944)[_0x4783('0x19')]();};}function respondWithResult(_0x41d853,_0xecb9f9){_0xecb9f9=_0xecb9f9||0xc8;return function(_0x230ae6){if(_0x230ae6){return _0x41d853['status'](_0xecb9f9)[_0x4783('0x1a')](_0x230ae6);}};}function respondWithFilteredResult(_0x225443,_0x11e996){return function(_0x20788f){if(_0x20788f){var _0x3cb485=typeof _0x11e996[_0x4783('0x1b')]===_0x4783('0x1c')&&typeof _0x11e996[_0x4783('0x1d')]===_0x4783('0x1c');var _0x28c979=_0x20788f[_0x4783('0x1e')];var _0x323a90=_0x3cb485?0x0:_0x11e996['offset'];var _0x465ed7=_0x3cb485?_0x20788f[_0x4783('0x1e')]:_0x11e996['offset']+_0x11e996[_0x4783('0x1d')];var _0x4a9dc8;if(_0x465ed7>=_0x28c979){_0x465ed7=_0x28c979;_0x4a9dc8=0xc8;}else{_0x4a9dc8=0xce;}_0x225443[_0x4783('0x18')](_0x4a9dc8);return _0x225443[_0x4783('0x1f')](_0x4783('0x20'),_0x323a90+'-'+_0x465ed7+'/'+_0x28c979)[_0x4783('0x1a')](_0x20788f);}return null;};}function patchUpdates(_0x1b5e90){return function(_0x2772b3){try{jsonpatch[_0x4783('0x21')](_0x2772b3,_0x1b5e90,!![]);}catch(_0x4e15d7){return BPromise[_0x4783('0x22')](_0x4e15d7);}return _0x2772b3['save']();};}function saveUpdates(_0x429801,_0x2d592f){return function(_0x46ada4){if(_0x46ada4){return _0x46ada4[_0x4783('0x23')](_0x429801)[_0x4783('0x24')](function(_0x54529d){return _0x54529d;});}return null;};}function removeEntity(_0x2633e6,_0x16ee3a){return function(_0xba686e){if(_0xba686e){return _0xba686e[_0x4783('0x25')]()[_0x4783('0x24')](function(){_0x2633e6[_0x4783('0x18')](0xcc)[_0x4783('0x19')]();});}};}function handleEntityNotFound(_0x48da76,_0x22d276){return function(_0x3e45d2){if(!_0x3e45d2){_0x48da76['sendStatus'](0x194);}return _0x3e45d2;};}function handleError(_0x5f2ed1,_0x1d3e22){_0x1d3e22=_0x1d3e22||0x1f4;return function(_0xb5f71c){logger['error'](_0xb5f71c[_0x4783('0x26')]);if(_0xb5f71c['name']){delete _0xb5f71c['name'];}_0x5f2ed1['status'](_0x1d3e22)['send'](_0xb5f71c);};}exports['index']=function(_0x59e49b,_0x250b9d){var _0x589082={},_0x3a996c={},_0x455559={'count':0x0,'rows':[]};var _0x424806=_[_0x4783('0x27')](db[_0x4783('0x28')]['rawAttributes'],function(_0x1e23f4){return{'name':_0x1e23f4[_0x4783('0x29')],'type':_0x1e23f4['type'][_0x4783('0x2a')]};});_0x3a996c[_0x4783('0x2b')]=_['map'](_0x424806,_0x4783('0x2c'));_0x3a996c['query']=_[_0x4783('0x2d')](_0x59e49b['query']);_0x3a996c[_0x4783('0x2e')]=_[_0x4783('0x2f')](_0x3a996c['model'],_0x3a996c[_0x4783('0x30')]);_0x589082[_0x4783('0x31')]=_[_0x4783('0x2f')](_0x3a996c[_0x4783('0x2b')],qs['fields'](_0x59e49b[_0x4783('0x30')][_0x4783('0x32')]));_0x589082[_0x4783('0x31')]=_0x589082[_0x4783('0x31')]['length']?_0x589082[_0x4783('0x31')]:_0x3a996c[_0x4783('0x2b')];if(!_0x59e49b['query'][_0x4783('0x33')](_0x4783('0x34'))){_0x589082[_0x4783('0x1d')]=qs[_0x4783('0x1d')](_0x59e49b[_0x4783('0x30')]['limit']);_0x589082[_0x4783('0x1b')]=qs['offset'](_0x59e49b['query'][_0x4783('0x1b')]);}_0x589082[_0x4783('0x35')]=qs[_0x4783('0x36')](_0x59e49b['query'][_0x4783('0x36')]);_0x589082['where']=qs[_0x4783('0x2e')](_['pick'](_0x59e49b[_0x4783('0x30')],_0x3a996c[_0x4783('0x2e')]),_0x424806);if(_0x59e49b[_0x4783('0x30')]['filter']){_0x589082[_0x4783('0x37')]=_['merge'](_0x589082[_0x4783('0x37')],{'$or':_[_0x4783('0x27')](_0x424806,function(_0x85209b){if(_0x85209b[_0x4783('0x38')]!=='VIRTUAL'){var _0x172958={};_0x172958[_0x85209b[_0x4783('0x2c')]]={'$like':'%'+_0x59e49b[_0x4783('0x30')]['filter']+'%'};return _0x172958;}})});}_0x589082=_[_0x4783('0x39')]({},_0x589082,_0x59e49b[_0x4783('0x3a')]);var _0x1ebdc8={'where':_0x589082['where']};return db['ZendeskField'][_0x4783('0x1e')](_0x1ebdc8)[_0x4783('0x24')](function(_0x373208){_0x455559[_0x4783('0x1e')]=_0x373208;if(_0x59e49b[_0x4783('0x30')][_0x4783('0x3b')]){_0x589082[_0x4783('0x3c')]=[{'all':!![]}];}return db[_0x4783('0x28')][_0x4783('0x3d')](_0x589082);})['then'](function(_0x49e41a){_0x455559[_0x4783('0x3e')]=_0x49e41a;return _0x455559;})['then'](respondWithFilteredResult(_0x250b9d,_0x589082))[_0x4783('0x3f')](handleError(_0x250b9d,null));};exports[_0x4783('0x40')]=function(_0x4708be,_0x3df302){var _0x5e5bc7={'raw':!![],'where':{'id':_0x4708be[_0x4783('0x41')]['id']}},_0x409ac6={};_0x409ac6[_0x4783('0x2b')]=_['keys'](db['ZendeskField'][_0x4783('0x42')]);_0x409ac6[_0x4783('0x30')]=_['keys'](_0x4708be[_0x4783('0x30')]);_0x409ac6['filters']=_[_0x4783('0x2f')](_0x409ac6[_0x4783('0x2b')],_0x409ac6[_0x4783('0x30')]);_0x5e5bc7[_0x4783('0x31')]=_[_0x4783('0x2f')](_0x409ac6[_0x4783('0x2b')],qs[_0x4783('0x32')](_0x4708be[_0x4783('0x30')]['fields']));_0x5e5bc7['attributes']=_0x5e5bc7[_0x4783('0x31')]['length']?_0x5e5bc7[_0x4783('0x31')]:_0x409ac6[_0x4783('0x2b')];if(_0x4708be[_0x4783('0x30')][_0x4783('0x3b')]){_0x5e5bc7[_0x4783('0x3c')]=[{'all':!![]}];}_0x5e5bc7=_[_0x4783('0x39')]({},_0x5e5bc7,_0x4708be[_0x4783('0x3a')]);return db[_0x4783('0x28')][_0x4783('0x43')](_0x5e5bc7)[_0x4783('0x24')](handleEntityNotFound(_0x3df302,null))[_0x4783('0x24')](respondWithResult(_0x3df302,null))[_0x4783('0x3f')](handleError(_0x3df302,null));};exports['create']=function(_0x5f44f9,_0xb416de){return db[_0x4783('0x28')]['create'](_0x5f44f9['body'],{})[_0x4783('0x24')](respondWithResult(_0xb416de,0xc9))[_0x4783('0x3f')](handleError(_0xb416de,null));};exports[_0x4783('0x23')]=function(_0x5b248f,_0x3dbd65){if(_0x5b248f['body']['id']){delete _0x5b248f[_0x4783('0x44')]['id'];}return db[_0x4783('0x28')]['find']({'where':{'id':_0x5b248f['params']['id']}})['then'](handleEntityNotFound(_0x3dbd65,null))[_0x4783('0x24')](saveUpdates(_0x5b248f[_0x4783('0x44')],null))['then'](respondWithResult(_0x3dbd65,null))[_0x4783('0x3f')](handleError(_0x3dbd65,null));};exports[_0x4783('0x25')]=function(_0x51a14f,_0x447ab9){return db['ZendeskField'][_0x4783('0x43')]({'where':{'id':_0x51a14f['params']['id']}})[_0x4783('0x24')](handleEntityNotFound(_0x447ab9,null))['then'](removeEntity(_0x447ab9,null))[_0x4783('0x3f')](handleError(_0x447ab9,null));};
\ No newline at end of file