Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index 8fdc74d..3c9329c 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 _0x1138=['params','find','create','body','catch','rimraf','zip-dir','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','sendStatus','status','end','limit','undefined','count','offset','set','reject','save','update','then','destroy','error','stack','name','send','index','map','ZendeskField','rawAttributes','fieldName','key','model','query','keys','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','VIRTUAL','options','includeAll','include','rows'];(function(_0xc1af5b,_0x396ee0){var _0x2a5d00=function(_0x52db0f){while(--_0x52db0f){_0xc1af5b['push'](_0xc1af5b['shift']());}};_0x2a5d00(++_0x396ee0);}(_0x1138,0x8f));var _0x8113=function(_0x53125e,_0x11c6a5){_0x53125e=_0x53125e-0x0;var _0x3dfd9a=_0x1138[_0x53125e];return _0x3dfd9a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8113('0x0'));var zipdir=require(_0x8113('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x8113('0x2'));var BPromise=require(_0x8113('0x3'));var Mustache=require(_0x8113('0x4'));var util=require('util');var path=require(_0x8113('0x5'));var sox=require(_0x8113('0x6'));var csv=require('to-csv');var ejs=require(_0x8113('0x7'));var fs=require('fs');var fs_extra=require(_0x8113('0x8'));var _=require(_0x8113('0x9'));var squel=require('squel');var crypto=require(_0x8113('0xa'));var jsforce=require(_0x8113('0xb'));var deskjs=require(_0x8113('0xc'));var toCsv=require('to-csv');var querystring=require(_0x8113('0xd'));var Papa=require(_0x8113('0xe'));var Redis=require(_0x8113('0xf'));var authService=require(_0x8113('0x10'));var qs=require(_0x8113('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x8113('0x12'))(_0x8113('0x13'));var utils=require('../../config/utils');var config=require(_0x8113('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x502920,_0x2b7d0f){_0x2b7d0f=_0x2b7d0f||0xcc;return function(_0x4ab197){if(_0x4ab197){return _0x502920[_0x8113('0x15')](_0x2b7d0f);}return _0x502920[_0x8113('0x16')](_0x2b7d0f)[_0x8113('0x17')]();};}function respondWithResult(_0x563852,_0x39d246){_0x39d246=_0x39d246||0xc8;return function(_0x4ed7ef){if(_0x4ed7ef){return _0x563852[_0x8113('0x16')](_0x39d246)['json'](_0x4ed7ef);}};}function respondWithFilteredResult(_0x5010d2,_0x26471c){return function(_0x4180aa){if(_0x4180aa){var _0x2e3088=typeof _0x26471c['offset']==='undefined'&&typeof _0x26471c[_0x8113('0x18')]===_0x8113('0x19');var _0x299efe=_0x4180aa[_0x8113('0x1a')];var _0x575992=_0x2e3088?0x0:_0x26471c['offset'];var _0x32653f=_0x2e3088?_0x4180aa[_0x8113('0x1a')]:_0x26471c[_0x8113('0x1b')]+_0x26471c[_0x8113('0x18')];var _0x270d0b;if(_0x32653f>=_0x299efe){_0x32653f=_0x299efe;_0x270d0b=0xc8;}else{_0x270d0b=0xce;}_0x5010d2['status'](_0x270d0b);return _0x5010d2[_0x8113('0x1c')]('Content-Range',_0x575992+'-'+_0x32653f+'/'+_0x299efe)['json'](_0x4180aa);}return null;};}function patchUpdates(_0x3caa8e){return function(_0x48a3cd){try{jsonpatch['apply'](_0x48a3cd,_0x3caa8e,!![]);}catch(_0xbbc665){return BPromise[_0x8113('0x1d')](_0xbbc665);}return _0x48a3cd[_0x8113('0x1e')]();};}function saveUpdates(_0x626e17,_0x3577c9){return function(_0x5ba7e1){if(_0x5ba7e1){return _0x5ba7e1[_0x8113('0x1f')](_0x626e17)[_0x8113('0x20')](function(_0x65c511){return _0x65c511;});}return null;};}function removeEntity(_0x21e664,_0x4e3ddb){return function(_0x36ec0d){if(_0x36ec0d){return _0x36ec0d[_0x8113('0x21')]()[_0x8113('0x20')](function(){_0x21e664[_0x8113('0x16')](0xcc)[_0x8113('0x17')]();});}};}function handleEntityNotFound(_0x47292f,_0x55b4e0){return function(_0x304cd0){if(!_0x304cd0){_0x47292f[_0x8113('0x15')](0x194);}return _0x304cd0;};}function handleError(_0x4c526a,_0x533f0f){_0x533f0f=_0x533f0f||0x1f4;return function(_0x5c6fed){logger[_0x8113('0x22')](_0x5c6fed[_0x8113('0x23')]);if(_0x5c6fed['name']){delete _0x5c6fed[_0x8113('0x24')];}_0x4c526a[_0x8113('0x16')](_0x533f0f)[_0x8113('0x25')](_0x5c6fed);};}exports[_0x8113('0x26')]=function(_0x2b5e3b,_0xe8f83d){var _0x12d6e2={},_0x5b72a2={},_0x16506b={'count':0x0,'rows':[]};var _0x178dcd=_[_0x8113('0x27')](db[_0x8113('0x28')][_0x8113('0x29')],function(_0x3a3eba){return{'name':_0x3a3eba[_0x8113('0x2a')],'type':_0x3a3eba['type'][_0x8113('0x2b')]};});_0x5b72a2[_0x8113('0x2c')]=_[_0x8113('0x27')](_0x178dcd,'name');_0x5b72a2[_0x8113('0x2d')]=_[_0x8113('0x2e')](_0x2b5e3b[_0x8113('0x2d')]);_0x5b72a2['filters']=_[_0x8113('0x2f')](_0x5b72a2[_0x8113('0x2c')],_0x5b72a2[_0x8113('0x2d')]);_0x12d6e2['attributes']=_[_0x8113('0x2f')](_0x5b72a2[_0x8113('0x2c')],qs[_0x8113('0x30')](_0x2b5e3b[_0x8113('0x2d')]['fields']));_0x12d6e2[_0x8113('0x31')]=_0x12d6e2[_0x8113('0x31')]['length']?_0x12d6e2['attributes']:_0x5b72a2[_0x8113('0x2c')];if(!_0x2b5e3b[_0x8113('0x2d')][_0x8113('0x32')](_0x8113('0x33'))){_0x12d6e2[_0x8113('0x18')]=qs[_0x8113('0x18')](_0x2b5e3b['query'][_0x8113('0x18')]);_0x12d6e2[_0x8113('0x1b')]=qs[_0x8113('0x1b')](_0x2b5e3b[_0x8113('0x2d')][_0x8113('0x1b')]);}_0x12d6e2[_0x8113('0x34')]=qs[_0x8113('0x35')](_0x2b5e3b['query'][_0x8113('0x35')]);_0x12d6e2['where']=qs[_0x8113('0x36')](_[_0x8113('0x37')](_0x2b5e3b[_0x8113('0x2d')],_0x5b72a2[_0x8113('0x36')]),_0x178dcd);if(_0x2b5e3b[_0x8113('0x2d')][_0x8113('0x38')]){_0x12d6e2[_0x8113('0x39')]=_[_0x8113('0x3a')](_0x12d6e2['where'],{'$or':_['map'](_0x178dcd,function(_0x562b99){if(_0x562b99['type']!==_0x8113('0x3b')){var _0x116823={};_0x116823[_0x562b99[_0x8113('0x24')]]={'$like':'%'+_0x2b5e3b[_0x8113('0x2d')][_0x8113('0x38')]+'%'};return _0x116823;}})});}_0x12d6e2=_[_0x8113('0x3a')]({},_0x12d6e2,_0x2b5e3b[_0x8113('0x3c')]);var _0x343eec={'where':_0x12d6e2['where']};return db[_0x8113('0x28')][_0x8113('0x1a')](_0x343eec)[_0x8113('0x20')](function(_0x145ad6){_0x16506b['count']=_0x145ad6;if(_0x2b5e3b['query'][_0x8113('0x3d')]){_0x12d6e2[_0x8113('0x3e')]=[{'all':!![]}];}return db['ZendeskField']['findAll'](_0x12d6e2);})[_0x8113('0x20')](function(_0x4a00b3){_0x16506b[_0x8113('0x3f')]=_0x4a00b3;return _0x16506b;})[_0x8113('0x20')](respondWithFilteredResult(_0xe8f83d,_0x12d6e2))['catch'](handleError(_0xe8f83d,null));};exports['show']=function(_0x5131e5,_0x4af25b){var _0x2fb3cb={'raw':!![],'where':{'id':_0x5131e5[_0x8113('0x40')]['id']}},_0x130050={};_0x130050['model']=_[_0x8113('0x2e')](db[_0x8113('0x28')]['rawAttributes']);_0x130050[_0x8113('0x2d')]=_[_0x8113('0x2e')](_0x5131e5[_0x8113('0x2d')]);_0x130050[_0x8113('0x36')]=_[_0x8113('0x2f')](_0x130050[_0x8113('0x2c')],_0x130050[_0x8113('0x2d')]);_0x2fb3cb[_0x8113('0x31')]=_['intersection'](_0x130050[_0x8113('0x2c')],qs['fields'](_0x5131e5[_0x8113('0x2d')]['fields']));_0x2fb3cb['attributes']=_0x2fb3cb['attributes']['length']?_0x2fb3cb['attributes']:_0x130050[_0x8113('0x2c')];if(_0x5131e5['query'][_0x8113('0x3d')]){_0x2fb3cb[_0x8113('0x3e')]=[{'all':!![]}];}_0x2fb3cb=_['merge']({},_0x2fb3cb,_0x5131e5[_0x8113('0x3c')]);return db[_0x8113('0x28')][_0x8113('0x41')](_0x2fb3cb)[_0x8113('0x20')](handleEntityNotFound(_0x4af25b,null))[_0x8113('0x20')](respondWithResult(_0x4af25b,null))['catch'](handleError(_0x4af25b,null));};exports[_0x8113('0x42')]=function(_0x1940bc,_0xb46a6){return db[_0x8113('0x28')][_0x8113('0x42')](_0x1940bc['body'],{})['then'](respondWithResult(_0xb46a6,0xc9))['catch'](handleError(_0xb46a6,null));};exports['update']=function(_0x21173a,_0x906bcb){if(_0x21173a[_0x8113('0x43')]['id']){delete _0x21173a[_0x8113('0x43')]['id'];}return db[_0x8113('0x28')][_0x8113('0x41')]({'where':{'id':_0x21173a[_0x8113('0x40')]['id']}})['then'](handleEntityNotFound(_0x906bcb,null))['then'](saveUpdates(_0x21173a[_0x8113('0x43')],null))['then'](respondWithResult(_0x906bcb,null))[_0x8113('0x44')](handleError(_0x906bcb,null));};exports['destroy']=function(_0x5156bf,_0x3749f2){return db[_0x8113('0x28')][_0x8113('0x41')]({'where':{'id':_0x5156bf[_0x8113('0x40')]['id']}})[_0x8113('0x20')](handleEntityNotFound(_0x3749f2,null))[_0x8113('0x20')](removeEntity(_0x3749f2,null))[_0x8113('0x44')](handleError(_0x3749f2,null));};
\ No newline at end of file