Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index b200896..d49ef7a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0184=['crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','sendStatus','status','offset','undefined','limit','count','set','Content-Range','json','save','update','then','destroy','stack','name','send','index','map','ZendeskField','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','includeAll','findAll','rows','show','params','options','catch','create','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs'];(function(_0x12ec8a,_0x3174d8){var _0x326d69=function(_0x2e09bb){while(--_0x2e09bb){_0x12ec8a['push'](_0x12ec8a['shift']());}};_0x326d69(++_0x3174d8);}(_0x0184,0x14e));var _0x4018=function(_0x40220a,_0x22feb1){_0x40220a=_0x40220a-0x0;var _0x3903cc=_0x0184[_0x40220a];return _0x3903cc;};'use strict';var emlformat=require(_0x4018('0x0'));var rimraf=require(_0x4018('0x1'));var zipdir=require(_0x4018('0x2'));var jsonpatch=require(_0x4018('0x3'));var rp=require('request-promise');var moment=require(_0x4018('0x4'));var BPromise=require(_0x4018('0x5'));var Mustache=require('mustache');var util=require(_0x4018('0x6'));var path=require(_0x4018('0x7'));var sox=require(_0x4018('0x8'));var csv=require(_0x4018('0x9'));var ejs=require(_0x4018('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x4018('0xb'));var jsforce=require(_0x4018('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x4018('0x9'));var querystring=require(_0x4018('0xd'));var Papa=require(_0x4018('0xe'));var Redis=require('ioredis');var authService=require(_0x4018('0xf'));var qs=require(_0x4018('0x10'));var as=require(_0x4018('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x4018('0x12'));var utils=require(_0x4018('0x13'));var config=require(_0x4018('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x414176,_0x25aeb7){_0x25aeb7=_0x25aeb7||0xcc;return function(_0x2ddbc0){if(_0x2ddbc0){return _0x414176[_0x4018('0x15')](_0x25aeb7);}return _0x414176[_0x4018('0x16')](_0x25aeb7)['end']();};}function respondWithResult(_0x476b6a,_0x1da1bb){_0x1da1bb=_0x1da1bb||0xc8;return function(_0xe46ed0){if(_0xe46ed0){return _0x476b6a[_0x4018('0x16')](_0x1da1bb)['json'](_0xe46ed0);}};}function respondWithFilteredResult(_0x407fef,_0x54b07a){return function(_0x4f50e6){if(_0x4f50e6){var _0x20ecfd=typeof _0x54b07a[_0x4018('0x17')]===_0x4018('0x18')&&typeof _0x54b07a[_0x4018('0x19')]===_0x4018('0x18');var _0x1578fb=_0x4f50e6[_0x4018('0x1a')];var _0x3412dd=_0x20ecfd?0x0:_0x54b07a['offset'];var _0x1b3e95=_0x20ecfd?_0x4f50e6[_0x4018('0x1a')]:_0x54b07a[_0x4018('0x17')]+_0x54b07a[_0x4018('0x19')];var _0x4ba52e;if(_0x1b3e95>=_0x1578fb){_0x1b3e95=_0x1578fb;_0x4ba52e=0xc8;}else{_0x4ba52e=0xce;}_0x407fef[_0x4018('0x16')](_0x4ba52e);return _0x407fef[_0x4018('0x1b')](_0x4018('0x1c'),_0x3412dd+'-'+_0x1b3e95+'/'+_0x1578fb)[_0x4018('0x1d')](_0x4f50e6);}return null;};}function patchUpdates(_0x3e055f){return function(_0x2c0fe6){try{jsonpatch['apply'](_0x2c0fe6,_0x3e055f,!![]);}catch(_0x4f4ab1){return BPromise['reject'](_0x4f4ab1);}return _0x2c0fe6[_0x4018('0x1e')]();};}function saveUpdates(_0x5ec84b,_0x328a23){return function(_0x263222){if(_0x263222){return _0x263222[_0x4018('0x1f')](_0x5ec84b)[_0x4018('0x20')](function(_0x117efe){return _0x117efe;});}return null;};}function removeEntity(_0x5620df,_0x1835e2){return function(_0xb9b4ce){if(_0xb9b4ce){return _0xb9b4ce[_0x4018('0x21')]()[_0x4018('0x20')](function(){_0x5620df[_0x4018('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0xa093d2,_0x5a4bb1){return function(_0x4b3265){if(!_0x4b3265){_0xa093d2[_0x4018('0x15')](0x194);}return _0x4b3265;};}function handleError(_0x3c9187,_0xa97734){_0xa97734=_0xa97734||0x1f4;return function(_0x3fcb5e){logger['error'](_0x3fcb5e[_0x4018('0x22')]);if(_0x3fcb5e[_0x4018('0x23')]){delete _0x3fcb5e[_0x4018('0x23')];}_0x3c9187[_0x4018('0x16')](_0xa97734)[_0x4018('0x24')](_0x3fcb5e);};}exports[_0x4018('0x25')]=function(_0x5de8cc,_0x4afd88){var _0x592f6f={},_0x2e9ab5={},_0x4782d7={'count':0x0,'rows':[]};var _0x2dc0d5=_[_0x4018('0x26')](db[_0x4018('0x27')][_0x4018('0x28')],function(_0x190f0f){return{'name':_0x190f0f[_0x4018('0x29')],'type':_0x190f0f[_0x4018('0x2a')][_0x4018('0x2b')]};});_0x2e9ab5[_0x4018('0x2c')]=_[_0x4018('0x26')](_0x2dc0d5,_0x4018('0x23'));_0x2e9ab5['query']=_[_0x4018('0x2d')](_0x5de8cc[_0x4018('0x2e')]);_0x2e9ab5[_0x4018('0x2f')]=_['intersection'](_0x2e9ab5[_0x4018('0x2c')],_0x2e9ab5[_0x4018('0x2e')]);_0x592f6f[_0x4018('0x30')]=_[_0x4018('0x31')](_0x2e9ab5[_0x4018('0x2c')],qs['fields'](_0x5de8cc['query'][_0x4018('0x32')]));_0x592f6f[_0x4018('0x30')]=_0x592f6f[_0x4018('0x30')][_0x4018('0x33')]?_0x592f6f[_0x4018('0x30')]:_0x2e9ab5['model'];if(!_0x5de8cc[_0x4018('0x2e')][_0x4018('0x34')](_0x4018('0x35'))){_0x592f6f['limit']=qs[_0x4018('0x19')](_0x5de8cc[_0x4018('0x2e')][_0x4018('0x19')]);_0x592f6f[_0x4018('0x17')]=qs[_0x4018('0x17')](_0x5de8cc[_0x4018('0x2e')][_0x4018('0x17')]);}_0x592f6f['order']=qs[_0x4018('0x36')](_0x5de8cc[_0x4018('0x2e')]['sort']);_0x592f6f[_0x4018('0x37')]=qs['filters'](_[_0x4018('0x38')](_0x5de8cc['query'],_0x2e9ab5[_0x4018('0x2f')]),_0x2dc0d5);if(_0x5de8cc['query'][_0x4018('0x39')]){_0x592f6f['where']=_[_0x4018('0x3a')](_0x592f6f[_0x4018('0x37')],{'$or':_[_0x4018('0x26')](_0x2dc0d5,function(_0x4fbb10){if(_0x4fbb10[_0x4018('0x2a')]!==_0x4018('0x3b')){var _0x350a22={};_0x350a22[_0x4fbb10[_0x4018('0x23')]]={'$like':'%'+_0x5de8cc[_0x4018('0x2e')]['filter']+'%'};return _0x350a22;}})});}_0x592f6f=_[_0x4018('0x3a')]({},_0x592f6f,_0x5de8cc['options']);var _0x3bafb1={'where':_0x592f6f[_0x4018('0x37')]};return db[_0x4018('0x27')]['count'](_0x3bafb1)[_0x4018('0x20')](function(_0x60f44c){_0x4782d7[_0x4018('0x1a')]=_0x60f44c;if(_0x5de8cc[_0x4018('0x2e')][_0x4018('0x3c')]){_0x592f6f['include']=[{'all':!![]}];}return db[_0x4018('0x27')][_0x4018('0x3d')](_0x592f6f);})[_0x4018('0x20')](function(_0xb7b464){_0x4782d7[_0x4018('0x3e')]=_0xb7b464;return _0x4782d7;})[_0x4018('0x20')](respondWithFilteredResult(_0x4afd88,_0x592f6f))['catch'](handleError(_0x4afd88,null));};exports[_0x4018('0x3f')]=function(_0x2b34bb,_0x3fd9aa){var _0x5a357a={'raw':!![],'where':{'id':_0x2b34bb[_0x4018('0x40')]['id']}},_0x2e08ae={};_0x2e08ae[_0x4018('0x2c')]=_[_0x4018('0x2d')](db['ZendeskField']['rawAttributes']);_0x2e08ae['query']=_[_0x4018('0x2d')](_0x2b34bb[_0x4018('0x2e')]);_0x2e08ae[_0x4018('0x2f')]=_['intersection'](_0x2e08ae['model'],_0x2e08ae['query']);_0x5a357a[_0x4018('0x30')]=_[_0x4018('0x31')](_0x2e08ae[_0x4018('0x2c')],qs[_0x4018('0x32')](_0x2b34bb[_0x4018('0x2e')][_0x4018('0x32')]));_0x5a357a[_0x4018('0x30')]=_0x5a357a[_0x4018('0x30')][_0x4018('0x33')]?_0x5a357a['attributes']:_0x2e08ae[_0x4018('0x2c')];if(_0x2b34bb[_0x4018('0x2e')][_0x4018('0x3c')]){_0x5a357a['include']=[{'all':!![]}];}_0x5a357a=_['merge']({},_0x5a357a,_0x2b34bb[_0x4018('0x41')]);return db[_0x4018('0x27')]['find'](_0x5a357a)[_0x4018('0x20')](handleEntityNotFound(_0x3fd9aa,null))['then'](respondWithResult(_0x3fd9aa,null))[_0x4018('0x42')](handleError(_0x3fd9aa,null));};exports[_0x4018('0x43')]=function(_0x25bb5e,_0x401789){return db[_0x4018('0x27')][_0x4018('0x43')](_0x25bb5e[_0x4018('0x44')],{})[_0x4018('0x20')](respondWithResult(_0x401789,0xc9))['catch'](handleError(_0x401789,null));};exports[_0x4018('0x1f')]=function(_0x4d624d,_0x20b05b){if(_0x4d624d[_0x4018('0x44')]['id']){delete _0x4d624d['body']['id'];}return db['ZendeskField']['find']({'where':{'id':_0x4d624d[_0x4018('0x40')]['id']}})['then'](handleEntityNotFound(_0x20b05b,null))[_0x4018('0x20')](saveUpdates(_0x4d624d[_0x4018('0x44')],null))[_0x4018('0x20')](respondWithResult(_0x20b05b,null))[_0x4018('0x42')](handleError(_0x20b05b,null));};exports[_0x4018('0x21')]=function(_0x5ed700,_0x521be3){return db[_0x4018('0x27')]['find']({'where':{'id':_0x5ed700[_0x4018('0x40')]['id']}})['then'](handleEntityNotFound(_0x521be3,null))[_0x4018('0x20')](removeEntity(_0x521be3,null))[_0x4018('0x42')](handleError(_0x521be3,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