Built motion from commit e0fa946e.|2.6.5
[motion2.git] / server / api / intZendeskField / intZendeskField.controller.js
index da44e03..268474a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x82f4=['filters','filter','merge','VIRTUAL','options','ZendeskField','include','findAll','rows','catch','params','keys','length','includeAll','create','body','find','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','undefined','limit','count','offset','Content-Range','reject','save','update','then','end','name','send','index','map','rawAttributes','type','key','model','query','intersection','attributes','fields','hasOwnProperty','order','where','pick'];(function(_0x590b63,_0x14debb){var _0x3c9380=function(_0x58fc67){while(--_0x58fc67){_0x590b63['push'](_0x590b63['shift']());}};_0x3c9380(++_0x14debb);}(_0x82f4,0xed));var _0x482f=function(_0x1e2ccf,_0x367b8b){_0x1e2ccf=_0x1e2ccf-0x0;var _0x1c4080=_0x82f4[_0x1e2ccf];return _0x1c4080;};'use strict';var emlformat=require(_0x482f('0x0'));var rimraf=require(_0x482f('0x1'));var zipdir=require(_0x482f('0x2'));var jsonpatch=require(_0x482f('0x3'));var rp=require(_0x482f('0x4'));var moment=require(_0x482f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x482f('0x6'));var util=require('util');var path=require('path');var sox=require(_0x482f('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x482f('0x8'));var _=require(_0x482f('0x9'));var squel=require('squel');var crypto=require(_0x482f('0xa'));var jsforce=require(_0x482f('0xb'));var deskjs=require(_0x482f('0xc'));var toCsv=require(_0x482f('0xd'));var querystring=require(_0x482f('0xe'));var Papa=require(_0x482f('0xf'));var Redis=require(_0x482f('0x10'));var authService=require(_0x482f('0x11'));var qs=require(_0x482f('0x12'));var as=require(_0x482f('0x13'));var hardwareService=require(_0x482f('0x14'));var logger=require(_0x482f('0x15'))(_0x482f('0x16'));var utils=require(_0x482f('0x17'));var config=require(_0x482f('0x18'));var licenseUtil=require(_0x482f('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4d9807,_0x16a04b){_0x16a04b=_0x16a04b||0xcc;return function(_0x296d99){if(_0x296d99){return _0x4d9807[_0x482f('0x1a')](_0x16a04b);}return _0x4d9807[_0x482f('0x1b')](_0x16a04b)['end']();};}function respondWithResult(_0x4a9714,_0x189f6c){_0x189f6c=_0x189f6c||0xc8;return function(_0x1de64a){if(_0x1de64a){return _0x4a9714[_0x482f('0x1b')](_0x189f6c)[_0x482f('0x1c')](_0x1de64a);}};}function respondWithFilteredResult(_0x3d1564,_0x477de9){return function(_0x2c7048){if(_0x2c7048){var _0x1343f8=typeof _0x477de9['offset']===_0x482f('0x1d')&&typeof _0x477de9[_0x482f('0x1e')]===_0x482f('0x1d');var _0x517986=_0x2c7048[_0x482f('0x1f')];var _0x1147e0=_0x1343f8?0x0:_0x477de9[_0x482f('0x20')];var _0x1e9182=_0x1343f8?_0x2c7048['count']:_0x477de9[_0x482f('0x20')]+_0x477de9['limit'];var _0x2c5980;if(_0x1e9182>=_0x517986){_0x1e9182=_0x517986;_0x2c5980=0xc8;}else{_0x2c5980=0xce;}_0x3d1564['status'](_0x2c5980);return _0x3d1564['set'](_0x482f('0x21'),_0x1147e0+'-'+_0x1e9182+'/'+_0x517986)[_0x482f('0x1c')](_0x2c7048);}return null;};}function patchUpdates(_0x4d5366){return function(_0x9b65ad){try{jsonpatch['apply'](_0x9b65ad,_0x4d5366,!![]);}catch(_0x28d09a){return BPromise[_0x482f('0x22')](_0x28d09a);}return _0x9b65ad[_0x482f('0x23')]();};}function saveUpdates(_0x2ecdde,_0x4c0d00){return function(_0x348b13){if(_0x348b13){return _0x348b13[_0x482f('0x24')](_0x2ecdde)[_0x482f('0x25')](function(_0x17cb7e){return _0x17cb7e;});}return null;};}function removeEntity(_0x3f3c38,_0x2364a6){return function(_0x11b6bb){if(_0x11b6bb){return _0x11b6bb['destroy']()[_0x482f('0x25')](function(){_0x3f3c38[_0x482f('0x1b')](0xcc)[_0x482f('0x26')]();});}};}function handleEntityNotFound(_0x571e2b,_0x316a38){return function(_0x5a21cf){if(!_0x5a21cf){_0x571e2b['sendStatus'](0x194);}return _0x5a21cf;};}function handleError(_0x121a1a,_0x1aea32){_0x1aea32=_0x1aea32||0x1f4;return function(_0x1affa5){logger['error'](_0x1affa5['stack']);if(_0x1affa5[_0x482f('0x27')]){delete _0x1affa5[_0x482f('0x27')];}_0x121a1a['status'](_0x1aea32)[_0x482f('0x28')](_0x1affa5);};}exports[_0x482f('0x29')]=function(_0x388cbb,_0x41583e){var _0x804982={},_0x355c04={},_0x2c9e3b={'count':0x0,'rows':[]};var _0x95e166=_[_0x482f('0x2a')](db['ZendeskField'][_0x482f('0x2b')],function(_0x1984d2){return{'name':_0x1984d2['fieldName'],'type':_0x1984d2[_0x482f('0x2c')][_0x482f('0x2d')]};});_0x355c04[_0x482f('0x2e')]=_[_0x482f('0x2a')](_0x95e166,'name');_0x355c04[_0x482f('0x2f')]=_['keys'](_0x388cbb[_0x482f('0x2f')]);_0x355c04['filters']=_[_0x482f('0x30')](_0x355c04['model'],_0x355c04[_0x482f('0x2f')]);_0x804982[_0x482f('0x31')]=_['intersection'](_0x355c04[_0x482f('0x2e')],qs[_0x482f('0x32')](_0x388cbb[_0x482f('0x2f')][_0x482f('0x32')]));_0x804982[_0x482f('0x31')]=_0x804982['attributes']['length']?_0x804982[_0x482f('0x31')]:_0x355c04[_0x482f('0x2e')];if(!_0x388cbb[_0x482f('0x2f')][_0x482f('0x33')]('nolimit')){_0x804982['limit']=qs[_0x482f('0x1e')](_0x388cbb[_0x482f('0x2f')][_0x482f('0x1e')]);_0x804982[_0x482f('0x20')]=qs[_0x482f('0x20')](_0x388cbb[_0x482f('0x2f')][_0x482f('0x20')]);}_0x804982[_0x482f('0x34')]=qs['sort'](_0x388cbb[_0x482f('0x2f')]['sort']);_0x804982[_0x482f('0x35')]=qs['filters'](_[_0x482f('0x36')](_0x388cbb[_0x482f('0x2f')],_0x355c04[_0x482f('0x37')]),_0x95e166);if(_0x388cbb[_0x482f('0x2f')][_0x482f('0x38')]){_0x804982[_0x482f('0x35')]=_[_0x482f('0x39')](_0x804982[_0x482f('0x35')],{'$or':_['map'](_0x95e166,function(_0x446e97){if(_0x446e97['type']!==_0x482f('0x3a')){var _0x42b7dd={};_0x42b7dd[_0x446e97['name']]={'$like':'%'+_0x388cbb[_0x482f('0x2f')][_0x482f('0x38')]+'%'};return _0x42b7dd;}})});}_0x804982=_[_0x482f('0x39')]({},_0x804982,_0x388cbb[_0x482f('0x3b')]);var _0x1091f7={'where':_0x804982['where']};return db[_0x482f('0x3c')]['count'](_0x1091f7)[_0x482f('0x25')](function(_0x2478bf){_0x2c9e3b[_0x482f('0x1f')]=_0x2478bf;if(_0x388cbb['query']['includeAll']){_0x804982[_0x482f('0x3d')]=[{'all':!![]}];}return db[_0x482f('0x3c')][_0x482f('0x3e')](_0x804982);})[_0x482f('0x25')](function(_0x14f3ec){_0x2c9e3b[_0x482f('0x3f')]=_0x14f3ec;return _0x2c9e3b;})[_0x482f('0x25')](respondWithFilteredResult(_0x41583e,_0x804982))[_0x482f('0x40')](handleError(_0x41583e,null));};exports['show']=function(_0x2d691e,_0x1e2601){var _0x2aa307={'raw':!![],'where':{'id':_0x2d691e[_0x482f('0x41')]['id']}},_0x5a3192={};_0x5a3192[_0x482f('0x2e')]=_[_0x482f('0x42')](db[_0x482f('0x3c')]['rawAttributes']);_0x5a3192[_0x482f('0x2f')]=_[_0x482f('0x42')](_0x2d691e['query']);_0x5a3192[_0x482f('0x37')]=_['intersection'](_0x5a3192['model'],_0x5a3192[_0x482f('0x2f')]);_0x2aa307[_0x482f('0x31')]=_[_0x482f('0x30')](_0x5a3192[_0x482f('0x2e')],qs['fields'](_0x2d691e[_0x482f('0x2f')][_0x482f('0x32')]));_0x2aa307[_0x482f('0x31')]=_0x2aa307[_0x482f('0x31')][_0x482f('0x43')]?_0x2aa307[_0x482f('0x31')]:_0x5a3192[_0x482f('0x2e')];if(_0x2d691e[_0x482f('0x2f')][_0x482f('0x44')]){_0x2aa307[_0x482f('0x3d')]=[{'all':!![]}];}_0x2aa307=_[_0x482f('0x39')]({},_0x2aa307,_0x2d691e['options']);return db[_0x482f('0x3c')]['find'](_0x2aa307)[_0x482f('0x25')](handleEntityNotFound(_0x1e2601,null))['then'](respondWithResult(_0x1e2601,null))['catch'](handleError(_0x1e2601,null));};exports[_0x482f('0x45')]=function(_0x4b4432,_0x5475bb){return db[_0x482f('0x3c')]['create'](_0x4b4432[_0x482f('0x46')],{})[_0x482f('0x25')](respondWithResult(_0x5475bb,0xc9))[_0x482f('0x40')](handleError(_0x5475bb,null));};exports['update']=function(_0x2ca748,_0x5370d7){if(_0x2ca748[_0x482f('0x46')]['id']){delete _0x2ca748[_0x482f('0x46')]['id'];}return db['ZendeskField'][_0x482f('0x47')]({'where':{'id':_0x2ca748[_0x482f('0x41')]['id']}})[_0x482f('0x25')](handleEntityNotFound(_0x5370d7,null))[_0x482f('0x25')](saveUpdates(_0x2ca748[_0x482f('0x46')],null))[_0x482f('0x25')](respondWithResult(_0x5370d7,null))[_0x482f('0x40')](handleError(_0x5370d7,null));};exports[_0x482f('0x48')]=function(_0x4fb828,_0x5527cf){return db[_0x482f('0x3c')][_0x482f('0x47')]({'where':{'id':_0x4fb828[_0x482f('0x41')]['id']}})[_0x482f('0x25')](handleEntityNotFound(_0x5527cf,null))[_0x482f('0x25')](removeEntity(_0x5527cf,null))['catch'](handleError(_0x5527cf,null));};
\ No newline at end of file
+var _0x43b1=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','name','index','map','ZendeskField','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','merge','type','VIRTUAL','options','then','includeAll','findAll','rows','catch','params','rawAttributes','length','find','create','body','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service'];(function(_0x39839f,_0x48cec4){var _0x533ea2=function(_0x4a1700){while(--_0x4a1700){_0x39839f['push'](_0x39839f['shift']());}};_0x533ea2(++_0x48cec4);}(_0x43b1,0x7d));var _0x143b=function(_0x1368d9,_0x33038d){_0x1368d9=_0x1368d9-0x0;var _0x269bc8=_0x43b1[_0x1368d9];return _0x269bc8;};'use strict';var emlformat=require(_0x143b('0x0'));var rimraf=require(_0x143b('0x1'));var zipdir=require(_0x143b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x143b('0x3'));var moment=require('moment');var BPromise=require(_0x143b('0x4'));var Mustache=require(_0x143b('0x5'));var util=require(_0x143b('0x6'));var path=require(_0x143b('0x7'));var sox=require(_0x143b('0x8'));var csv=require(_0x143b('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x143b('0xa'));var _=require(_0x143b('0xb'));var squel=require(_0x143b('0xc'));var crypto=require('crypto');var jsforce=require(_0x143b('0xd'));var deskjs=require(_0x143b('0xe'));var toCsv=require(_0x143b('0x9'));var querystring=require(_0x143b('0xf'));var Papa=require(_0x143b('0x10'));var Redis=require(_0x143b('0x11'));var authService=require(_0x143b('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x143b('0x13'));var hardwareService=require(_0x143b('0x14'));var logger=require('../../config/logger')('api');var utils=require(_0x143b('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x143b('0x16'));var db=require(_0x143b('0x17'))['db'];function respondWithStatusCode(_0x52429f,_0x2d6c07){_0x2d6c07=_0x2d6c07||0xcc;return function(_0x1ef389){if(_0x1ef389){return _0x52429f[_0x143b('0x18')](_0x2d6c07);}return _0x52429f[_0x143b('0x19')](_0x2d6c07)[_0x143b('0x1a')]();};}function respondWithResult(_0x34cd9b,_0x1325c3){_0x1325c3=_0x1325c3||0xc8;return function(_0x40ce06){if(_0x40ce06){return _0x34cd9b[_0x143b('0x19')](_0x1325c3)[_0x143b('0x1b')](_0x40ce06);}};}function respondWithFilteredResult(_0x2bca2c,_0x3cc649){return function(_0x2d746a){if(_0x2d746a){var _0x133603=typeof _0x3cc649[_0x143b('0x1c')]===_0x143b('0x1d')&&typeof _0x3cc649[_0x143b('0x1e')]==='undefined';var _0x520197=_0x2d746a[_0x143b('0x1f')];var _0x244ba8=_0x133603?0x0:_0x3cc649[_0x143b('0x1c')];var _0x139aa9=_0x133603?_0x2d746a[_0x143b('0x1f')]:_0x3cc649[_0x143b('0x1c')]+_0x3cc649[_0x143b('0x1e')];var _0x1ca6d2;if(_0x139aa9>=_0x520197){_0x139aa9=_0x520197;_0x1ca6d2=0xc8;}else{_0x1ca6d2=0xce;}_0x2bca2c[_0x143b('0x19')](_0x1ca6d2);return _0x2bca2c[_0x143b('0x20')](_0x143b('0x21'),_0x244ba8+'-'+_0x139aa9+'/'+_0x520197)['json'](_0x2d746a);}return null;};}function patchUpdates(_0x1dd05b){return function(_0x35df37){try{jsonpatch[_0x143b('0x22')](_0x35df37,_0x1dd05b,!![]);}catch(_0xfd9194){return BPromise[_0x143b('0x23')](_0xfd9194);}return _0x35df37[_0x143b('0x24')]();};}function saveUpdates(_0x159ef6,_0x1d5b5b){return function(_0x5d0684){if(_0x5d0684){return _0x5d0684[_0x143b('0x25')](_0x159ef6)['then'](function(_0x2a55fe){return _0x2a55fe;});}return null;};}function removeEntity(_0x5bdebc,_0x549638){return function(_0x56717f){if(_0x56717f){return _0x56717f[_0x143b('0x26')]()['then'](function(){_0x5bdebc['status'](0xcc)[_0x143b('0x1a')]();});}};}function handleEntityNotFound(_0x53c102,_0x35e097){return function(_0x54eca6){if(!_0x54eca6){_0x53c102[_0x143b('0x18')](0x194);}return _0x54eca6;};}function handleError(_0xd30b1,_0x1adf50){_0x1adf50=_0x1adf50||0x1f4;return function(_0x4f5a17){logger['error'](_0x4f5a17['stack']);if(_0x4f5a17['name']){delete _0x4f5a17[_0x143b('0x27')];}_0xd30b1['status'](_0x1adf50)['send'](_0x4f5a17);};}exports[_0x143b('0x28')]=function(_0x37611b,_0x6174a3){var _0x5535b5={},_0xd1aa12={},_0x45ef09={'count':0x0,'rows':[]};var _0x42e136=_[_0x143b('0x29')](db[_0x143b('0x2a')]['rawAttributes'],function(_0x5d4da6){return{'name':_0x5d4da6['fieldName'],'type':_0x5d4da6['type'][_0x143b('0x2b')]};});_0xd1aa12[_0x143b('0x2c')]=_[_0x143b('0x29')](_0x42e136,_0x143b('0x27'));_0xd1aa12[_0x143b('0x2d')]=_[_0x143b('0x2e')](_0x37611b[_0x143b('0x2d')]);_0xd1aa12[_0x143b('0x2f')]=_[_0x143b('0x30')](_0xd1aa12[_0x143b('0x2c')],_0xd1aa12['query']);_0x5535b5[_0x143b('0x31')]=_[_0x143b('0x30')](_0xd1aa12['model'],qs['fields'](_0x37611b[_0x143b('0x2d')][_0x143b('0x32')]));_0x5535b5[_0x143b('0x31')]=_0x5535b5[_0x143b('0x31')]['length']?_0x5535b5['attributes']:_0xd1aa12['model'];if(!_0x37611b['query'][_0x143b('0x33')](_0x143b('0x34'))){_0x5535b5[_0x143b('0x1e')]=qs['limit'](_0x37611b[_0x143b('0x2d')][_0x143b('0x1e')]);_0x5535b5[_0x143b('0x1c')]=qs['offset'](_0x37611b[_0x143b('0x2d')][_0x143b('0x1c')]);}_0x5535b5[_0x143b('0x35')]=qs['sort'](_0x37611b[_0x143b('0x2d')][_0x143b('0x36')]);_0x5535b5['where']=qs['filters'](_['pick'](_0x37611b[_0x143b('0x2d')],_0xd1aa12[_0x143b('0x2f')]),_0x42e136);if(_0x37611b['query'][_0x143b('0x37')]){_0x5535b5[_0x143b('0x38')]=_[_0x143b('0x39')](_0x5535b5[_0x143b('0x38')],{'$or':_['map'](_0x42e136,function(_0x21ec5f){if(_0x21ec5f[_0x143b('0x3a')]!==_0x143b('0x3b')){var _0x1ee264={};_0x1ee264[_0x21ec5f[_0x143b('0x27')]]={'$like':'%'+_0x37611b['query'][_0x143b('0x37')]+'%'};return _0x1ee264;}})});}_0x5535b5=_[_0x143b('0x39')]({},_0x5535b5,_0x37611b[_0x143b('0x3c')]);var _0x5cd618={'where':_0x5535b5[_0x143b('0x38')]};return db[_0x143b('0x2a')]['count'](_0x5cd618)[_0x143b('0x3d')](function(_0x374eaf){_0x45ef09[_0x143b('0x1f')]=_0x374eaf;if(_0x37611b[_0x143b('0x2d')][_0x143b('0x3e')]){_0x5535b5['include']=[{'all':!![]}];}return db[_0x143b('0x2a')][_0x143b('0x3f')](_0x5535b5);})[_0x143b('0x3d')](function(_0x4166aa){_0x45ef09[_0x143b('0x40')]=_0x4166aa;return _0x45ef09;})[_0x143b('0x3d')](respondWithFilteredResult(_0x6174a3,_0x5535b5))[_0x143b('0x41')](handleError(_0x6174a3,null));};exports['show']=function(_0xe2a7c5,_0x19a1c1){var _0x5a20e4={'raw':!![],'where':{'id':_0xe2a7c5[_0x143b('0x42')]['id']}},_0x2f3816={};_0x2f3816['model']=_[_0x143b('0x2e')](db[_0x143b('0x2a')][_0x143b('0x43')]);_0x2f3816['query']=_[_0x143b('0x2e')](_0xe2a7c5[_0x143b('0x2d')]);_0x2f3816[_0x143b('0x2f')]=_[_0x143b('0x30')](_0x2f3816[_0x143b('0x2c')],_0x2f3816[_0x143b('0x2d')]);_0x5a20e4['attributes']=_[_0x143b('0x30')](_0x2f3816[_0x143b('0x2c')],qs[_0x143b('0x32')](_0xe2a7c5[_0x143b('0x2d')]['fields']));_0x5a20e4[_0x143b('0x31')]=_0x5a20e4[_0x143b('0x31')][_0x143b('0x44')]?_0x5a20e4[_0x143b('0x31')]:_0x2f3816[_0x143b('0x2c')];if(_0xe2a7c5[_0x143b('0x2d')][_0x143b('0x3e')]){_0x5a20e4['include']=[{'all':!![]}];}_0x5a20e4=_['merge']({},_0x5a20e4,_0xe2a7c5['options']);return db[_0x143b('0x2a')][_0x143b('0x45')](_0x5a20e4)[_0x143b('0x3d')](handleEntityNotFound(_0x19a1c1,null))[_0x143b('0x3d')](respondWithResult(_0x19a1c1,null))[_0x143b('0x41')](handleError(_0x19a1c1,null));};exports[_0x143b('0x46')]=function(_0xaf64ca,_0x3fd640){return db[_0x143b('0x2a')][_0x143b('0x46')](_0xaf64ca['body'],{})[_0x143b('0x3d')](respondWithResult(_0x3fd640,0xc9))[_0x143b('0x41')](handleError(_0x3fd640,null));};exports[_0x143b('0x25')]=function(_0x42a5d9,_0x48e3e5){if(_0x42a5d9[_0x143b('0x47')]['id']){delete _0x42a5d9['body']['id'];}return db[_0x143b('0x2a')][_0x143b('0x45')]({'where':{'id':_0x42a5d9['params']['id']}})['then'](handleEntityNotFound(_0x48e3e5,null))[_0x143b('0x3d')](saveUpdates(_0x42a5d9[_0x143b('0x47')],null))[_0x143b('0x3d')](respondWithResult(_0x48e3e5,null))['catch'](handleError(_0x48e3e5,null));};exports[_0x143b('0x26')]=function(_0x503b1f,_0x409a65){return db['ZendeskField'][_0x143b('0x45')]({'where':{'id':_0x503b1f[_0x143b('0x42')]['id']}})['then'](handleEntityNotFound(_0x409a65,null))[_0x143b('0x3d')](removeEntity(_0x409a65,null))[_0x143b('0x41')](handleError(_0x409a65,null));};
\ No newline at end of file