Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / squareProject / squareProject.controller.js
index cc3882c..2ba8bc4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1fbf=['mustache','util','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','offset','undefined','limit','count','set','json','update','then','destroy','get','SquareProjects','UserProfileResource','error','stack','name','send','index','map','rawAttributes','type','key','query','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','show','keys','length','SquareProject','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addUsers','body','ids','removeUsers','isArray','emit','userSquareProject:remove','getUsers','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment'];(function(_0x7eac77,_0x83fc1b){var _0x31c17c=function(_0x5384b7){while(--_0x5384b7){_0x7eac77['push'](_0x7eac77['shift']());}};_0x31c17c(++_0x83fc1b);}(_0x1fbf,0x17a));var _0xf1fb=function(_0x385895,_0xf937a){_0x385895=_0x385895-0x0;var _0xc01ec5=_0x1fbf[_0x385895];return _0xc01ec5;};'use strict';var emlformat=require(_0xf1fb('0x0'));var rimraf=require(_0xf1fb('0x1'));var zipdir=require(_0xf1fb('0x2'));var jsonpatch=require(_0xf1fb('0x3'));var rp=require(_0xf1fb('0x4'));var moment=require(_0xf1fb('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xf1fb('0x6'));var util=require(_0xf1fb('0x7'));var path=require(_0xf1fb('0x8'));var sox=require(_0xf1fb('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf1fb('0xa'));var squel=require(_0xf1fb('0xb'));var crypto=require(_0xf1fb('0xc'));var jsforce=require(_0xf1fb('0xd'));var deskjs=require(_0xf1fb('0xe'));var toCsv=require(_0xf1fb('0xf'));var querystring=require(_0xf1fb('0x10'));var Papa=require(_0xf1fb('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xf1fb('0x12'));var as=require(_0xf1fb('0x13'));var hardwareService=require(_0xf1fb('0x14'));var logger=require(_0xf1fb('0x15'))(_0xf1fb('0x16'));var utils=require(_0xf1fb('0x17'));var config=require(_0xf1fb('0x18'));var licenseUtil=require(_0xf1fb('0x19'));var db=require(_0xf1fb('0x1a'))['db'];config[_0xf1fb('0x1b')]=_[_0xf1fb('0x1c')](config[_0xf1fb('0x1b')],{'host':_0xf1fb('0x1d'),'port':0x18eb});var socket=require(_0xf1fb('0x1e'))(new Redis(config[_0xf1fb('0x1b')]));require('./squareProject.socket')[_0xf1fb('0x1f')](socket);function respondWithStatusCode(_0x31d5ac,_0xe6a40c){_0xe6a40c=_0xe6a40c||0xcc;return function(_0xbb8cc9){if(_0xbb8cc9){return _0x31d5ac[_0xf1fb('0x20')](_0xe6a40c);}return _0x31d5ac[_0xf1fb('0x21')](_0xe6a40c)['end']();};}function respondWithResult(_0x335bb8,_0x17851f){_0x17851f=_0x17851f||0xc8;return function(_0x31411a){if(_0x31411a){return _0x335bb8[_0xf1fb('0x21')](_0x17851f)['json'](_0x31411a);}};}function respondWithFilteredResult(_0x223d1f,_0xb5e5d1){return function(_0x570108){if(_0x570108){var _0x582746=typeof _0xb5e5d1[_0xf1fb('0x22')]===_0xf1fb('0x23')&&typeof _0xb5e5d1[_0xf1fb('0x24')]===_0xf1fb('0x23');var _0x220d5e=_0x570108[_0xf1fb('0x25')];var _0x5e1471=_0x582746?0x0:_0xb5e5d1['offset'];var _0x4861d7=_0x582746?_0x570108[_0xf1fb('0x25')]:_0xb5e5d1[_0xf1fb('0x22')]+_0xb5e5d1[_0xf1fb('0x24')];var _0x452a2f;if(_0x4861d7>=_0x220d5e){_0x4861d7=_0x220d5e;_0x452a2f=0xc8;}else{_0x452a2f=0xce;}_0x223d1f['status'](_0x452a2f);return _0x223d1f[_0xf1fb('0x26')]('Content-Range',_0x5e1471+'-'+_0x4861d7+'/'+_0x220d5e)[_0xf1fb('0x27')](_0x570108);}return null;};}function patchUpdates(_0x4daac6){return function(_0x453b71){try{jsonpatch['apply'](_0x453b71,_0x4daac6,!![]);}catch(_0x52edaa){return BPromise['reject'](_0x52edaa);}return _0x453b71['save']();};}function saveUpdates(_0x5ad158,_0x52fa63){return function(_0x339446){if(_0x339446){return _0x339446[_0xf1fb('0x28')](_0x5ad158)[_0xf1fb('0x29')](function(_0x57edb5){return _0x57edb5;});}return null;};}function removeEntity(_0x45fb0b,_0x5e6521){return function(_0x67dd81){if(_0x67dd81){return _0x67dd81[_0xf1fb('0x2a')]()['then'](function(){var _0x10b15d=_0x67dd81[_0xf1fb('0x2b')]({'plain':!![]});var _0x32799f=_0xf1fb('0x2c');return db[_0xf1fb('0x2d')][_0xf1fb('0x2a')]({'where':{'type':_0x32799f,'resourceId':_0x10b15d['id']}})['then'](function(){return _0x67dd81;});})['then'](function(){_0x45fb0b[_0xf1fb('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x423d91,_0x3ecfb2){return function(_0x31fc23){if(!_0x31fc23){_0x423d91[_0xf1fb('0x20')](0x194);}return _0x31fc23;};}function handleError(_0x262513,_0xa01cc1){_0xa01cc1=_0xa01cc1||0x1f4;return function(_0x6fc305){logger[_0xf1fb('0x2e')](_0x6fc305[_0xf1fb('0x2f')]);if(_0x6fc305[_0xf1fb('0x30')]){delete _0x6fc305[_0xf1fb('0x30')];}_0x262513[_0xf1fb('0x21')](_0xa01cc1)[_0xf1fb('0x31')](_0x6fc305);};}exports[_0xf1fb('0x32')]=function(_0x414b50,_0x3f43ca){var _0x29cb23={},_0x407828={},_0x44c8cf={'count':0x0,'rows':[]};var _0x40d56=_[_0xf1fb('0x33')](db['SquareProject'][_0xf1fb('0x34')],function(_0xc357da){return{'name':_0xc357da['fieldName'],'type':_0xc357da[_0xf1fb('0x35')][_0xf1fb('0x36')]};});_0x407828['model']=_[_0xf1fb('0x33')](_0x40d56,'name');_0x407828[_0xf1fb('0x37')]=_['keys'](_0x414b50[_0xf1fb('0x37')]);_0x407828[_0xf1fb('0x38')]=_[_0xf1fb('0x39')](_0x407828['model'],_0x407828[_0xf1fb('0x37')]);_0x29cb23['attributes']=_['intersection'](_0x407828[_0xf1fb('0x3a')],qs[_0xf1fb('0x3b')](_0x414b50[_0xf1fb('0x37')][_0xf1fb('0x3b')]));_0x29cb23['attributes']=_0x29cb23[_0xf1fb('0x3c')]['length']?_0x29cb23[_0xf1fb('0x3c')]:_0x407828[_0xf1fb('0x3a')];if(!_0x414b50[_0xf1fb('0x37')][_0xf1fb('0x3d')](_0xf1fb('0x3e'))){_0x29cb23[_0xf1fb('0x24')]=qs[_0xf1fb('0x24')](_0x414b50['query'][_0xf1fb('0x24')]);_0x29cb23[_0xf1fb('0x22')]=qs['offset'](_0x414b50['query'][_0xf1fb('0x22')]);}_0x29cb23[_0xf1fb('0x3f')]=qs['sort'](_0x414b50[_0xf1fb('0x37')][_0xf1fb('0x40')]);_0x29cb23[_0xf1fb('0x41')]=qs[_0xf1fb('0x38')](_[_0xf1fb('0x42')](_0x414b50[_0xf1fb('0x37')],_0x407828['filters']),_0x40d56);if(_0x414b50[_0xf1fb('0x37')][_0xf1fb('0x43')]){_0x29cb23['where']=_[_0xf1fb('0x44')](_0x29cb23[_0xf1fb('0x41')],{'$or':_[_0xf1fb('0x33')](_0x40d56,function(_0x1d48ed){if(_0x1d48ed[_0xf1fb('0x35')]!=='VIRTUAL'){var _0x5fa0f8={};_0x5fa0f8[_0x1d48ed[_0xf1fb('0x30')]]={'$like':'%'+_0x414b50['query'][_0xf1fb('0x43')]+'%'};return _0x5fa0f8;}})});}_0x29cb23=_['merge']({},_0x29cb23,_0x414b50[_0xf1fb('0x45')]);var _0x30b266={'where':_0x29cb23[_0xf1fb('0x41')]};return db['SquareProject'][_0xf1fb('0x25')](_0x30b266)[_0xf1fb('0x29')](function(_0x412b83){_0x44c8cf[_0xf1fb('0x25')]=_0x412b83;if(_0x414b50[_0xf1fb('0x37')][_0xf1fb('0x46')]){_0x29cb23[_0xf1fb('0x47')]=[{'all':!![]}];}return db['SquareProject'][_0xf1fb('0x48')](_0x29cb23);})[_0xf1fb('0x29')](function(_0x224bf7){_0x44c8cf[_0xf1fb('0x49')]=_0x224bf7;return _0x44c8cf;})[_0xf1fb('0x29')](respondWithFilteredResult(_0x3f43ca,_0x29cb23))[_0xf1fb('0x4a')](handleError(_0x3f43ca,null));};exports[_0xf1fb('0x4b')]=function(_0x23a2fb,_0x328ffb){var _0x3ea056={'raw':![],'where':{'id':_0x23a2fb['params']['id']}},_0x1dd13a={};_0x1dd13a[_0xf1fb('0x3a')]=_[_0xf1fb('0x4c')](db['SquareProject'][_0xf1fb('0x34')]);_0x1dd13a['query']=_['keys'](_0x23a2fb['query']);_0x1dd13a[_0xf1fb('0x38')]=_['intersection'](_0x1dd13a['model'],_0x1dd13a[_0xf1fb('0x37')]);_0x3ea056[_0xf1fb('0x3c')]=_[_0xf1fb('0x39')](_0x1dd13a[_0xf1fb('0x3a')],qs[_0xf1fb('0x3b')](_0x23a2fb['query'][_0xf1fb('0x3b')]));_0x3ea056[_0xf1fb('0x3c')]=_0x3ea056[_0xf1fb('0x3c')][_0xf1fb('0x4d')]?_0x3ea056[_0xf1fb('0x3c')]:_0x1dd13a[_0xf1fb('0x3a')];if(_0x23a2fb[_0xf1fb('0x37')][_0xf1fb('0x46')]){_0x3ea056[_0xf1fb('0x47')]=[{'all':!![]}];}_0x3ea056=_[_0xf1fb('0x44')]({},_0x3ea056,_0x23a2fb[_0xf1fb('0x45')]);return db[_0xf1fb('0x4e')][_0xf1fb('0x4f')](_0x3ea056)['then'](handleEntityNotFound(_0x328ffb,null))[_0xf1fb('0x29')](respondWithResult(_0x328ffb,null))['catch'](handleError(_0x328ffb,null));};exports[_0xf1fb('0x50')]=function(_0x4b9532,_0x51821b){return db[_0xf1fb('0x4e')]['create'](_0x4b9532['body'],{})['then'](function(_0x2bf0c6){var _0x1c8be7=_0x4b9532[_0xf1fb('0x51')]['get']({'plain':!![]});if(!_0x1c8be7)throw new Error(_0xf1fb('0x52'));if(_0x1c8be7[_0xf1fb('0x53')]===_0xf1fb('0x51')){var _0x1af72b=_0x2bf0c6['get']({'plain':!![]});var _0x359037=_0xf1fb('0x2c');return db[_0xf1fb('0x54')][_0xf1fb('0x4f')]({'where':{'name':_0x359037,'userProfileId':_0x1c8be7['userProfileId']},'raw':!![]})[_0xf1fb('0x29')](function(_0x3e7927){if(_0x3e7927&&_0x3e7927[_0xf1fb('0x55')]===0x0){return db[_0xf1fb('0x2d')][_0xf1fb('0x50')]({'name':_0x1af72b[_0xf1fb('0x30')],'resourceId':_0x1af72b['id'],'type':_0x3e7927[_0xf1fb('0x30')],'sectionId':_0x3e7927['id']},{})[_0xf1fb('0x29')](function(){return _0x2bf0c6;});}else{return _0x2bf0c6;}})[_0xf1fb('0x4a')](function(_0x1cea29){logger[_0xf1fb('0x2e')](_0xf1fb('0x56'),_0x1cea29);throw _0x1cea29;});}return _0x2bf0c6;})[_0xf1fb('0x29')](respondWithResult(_0x51821b,0xc9))[_0xf1fb('0x4a')](handleError(_0x51821b,null));};exports[_0xf1fb('0x28')]=function(_0x440915,_0x4df52d){if(_0x440915['body']['id']){delete _0x440915['body']['id'];}return db[_0xf1fb('0x4e')][_0xf1fb('0x4f')]({'where':{'id':_0x440915[_0xf1fb('0x57')]['id']}})[_0xf1fb('0x29')](handleEntityNotFound(_0x4df52d,null))[_0xf1fb('0x29')](saveUpdates(_0x440915['body'],null))[_0xf1fb('0x29')](respondWithResult(_0x4df52d,null))['catch'](handleError(_0x4df52d,null));};exports[_0xf1fb('0x2a')]=function(_0x2973aa,_0x27e305){return db[_0xf1fb('0x4e')][_0xf1fb('0x4f')]({'where':{'id':_0x2973aa[_0xf1fb('0x57')]['id']}})[_0xf1fb('0x29')](handleEntityNotFound(_0x27e305,null))['then'](removeEntity(_0x27e305,null))[_0xf1fb('0x4a')](handleError(_0x27e305,null));};exports[_0xf1fb('0x58')]=function(_0x17e815,_0x99cbb5,_0x45815c){return db['SquareProject'][_0xf1fb('0x4f')]({'where':{'id':_0x17e815['params']['id']}})['then'](handleEntityNotFound(_0x99cbb5,null))[_0xf1fb('0x29')](function(_0x347b28){if(_0x347b28){return _0x347b28[_0xf1fb('0x58')](_0x17e815[_0xf1fb('0x59')][_0xf1fb('0x5a')],_['omit'](_0x17e815['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x99cbb5,null))['catch'](handleError(_0x99cbb5,null));};exports['removeUsers']=function(_0x2f4168,_0x3a24fe,_0x4f7cbb){return db[_0xf1fb('0x4e')][_0xf1fb('0x4f')]({'where':{'id':_0x2f4168['params']['id']}})[_0xf1fb('0x29')](handleEntityNotFound(_0x3a24fe,null))['then'](function(_0x3bc328){if(_0x3bc328){return _0x3bc328[_0xf1fb('0x5b')](_0x2f4168[_0xf1fb('0x37')]['ids'])[_0xf1fb('0x29')](function(){if(_[_0xf1fb('0x5c')](_0x2f4168[_0xf1fb('0x37')][_0xf1fb('0x5a')])){for(var _0x980e4b=0x0;_0x980e4b<_0x2f4168['query'][_0xf1fb('0x5a')][_0xf1fb('0x4d')];_0x980e4b+=0x1){socket[_0xf1fb('0x5d')](_0xf1fb('0x5e'),{'UserId':Number(_0x2f4168[_0xf1fb('0x37')][_0xf1fb('0x5a')][_0x980e4b]),'SquareProjectId':Number(_0x2f4168[_0xf1fb('0x57')]['id'])});}}else{socket[_0xf1fb('0x5d')](_0xf1fb('0x5e'),{'UserId':Number(_0x2f4168['query'][_0xf1fb('0x5a')]),'SquareProjectId':Number(_0x2f4168['params']['id'])});}});}})[_0xf1fb('0x29')](respondWithStatusCode(_0x3a24fe,null))[_0xf1fb('0x4a')](handleError(_0x3a24fe,null));};exports[_0xf1fb('0x5f')]=function(_0xa01f71,_0x2e1217,_0x3fee2b){var _0x30d135={};var _0x20ab84={};var _0x18c2ff;var _0x489965;return db['SquareProject']['findOne']({'where':{'id':_0xa01f71[_0xf1fb('0x57')]['id']}})[_0xf1fb('0x29')](handleEntityNotFound(_0x2e1217,null))[_0xf1fb('0x29')](function(_0x4d6030){if(_0x4d6030){_0x18c2ff=_0x4d6030;_0x20ab84[_0xf1fb('0x3a')]=_[_0xf1fb('0x4c')](db['User'][_0xf1fb('0x34')]);_0x20ab84[_0xf1fb('0x37')]=_['keys'](_0xa01f71[_0xf1fb('0x37')]);_0x20ab84['filters']=_[_0xf1fb('0x39')](_0x20ab84[_0xf1fb('0x3a')],_0x20ab84[_0xf1fb('0x37')]);_0x30d135['attributes']=_[_0xf1fb('0x39')](_0x20ab84['model'],qs[_0xf1fb('0x3b')](_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x3b')]));_0x30d135[_0xf1fb('0x3c')]=_0x30d135[_0xf1fb('0x3c')][_0xf1fb('0x4d')]?_0x30d135['attributes']:_0x20ab84[_0xf1fb('0x3a')];_0x30d135[_0xf1fb('0x3f')]=qs[_0xf1fb('0x40')](_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x40')]);_0x30d135[_0xf1fb('0x41')]=qs['filters'](_['pick'](_0xa01f71[_0xf1fb('0x37')],_0x20ab84['filters']));if(_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x43')]){_0x30d135[_0xf1fb('0x41')]=_[_0xf1fb('0x44')](_0x30d135[_0xf1fb('0x41')],{'$or':_[_0xf1fb('0x33')](_0x30d135[_0xf1fb('0x3c')],function(_0x57fe17){var _0x145624={};_0x145624[_0x57fe17]={'$like':'%'+_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x43')]+'%'};return _0x145624;})});}_0x30d135=_[_0xf1fb('0x44')]({},_0x30d135,_0xa01f71[_0xf1fb('0x45')]);return _0x18c2ff[_0xf1fb('0x5f')](_0x30d135);}})[_0xf1fb('0x29')](function(_0x3f55cf){if(_0x3f55cf){_0x489965=_0x3f55cf[_0xf1fb('0x4d')];if(!_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x3d')](_0xf1fb('0x3e'))){_0x30d135[_0xf1fb('0x24')]=qs[_0xf1fb('0x24')](_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x24')]);_0x30d135[_0xf1fb('0x22')]=qs['offset'](_0xa01f71[_0xf1fb('0x37')][_0xf1fb('0x22')]);}return _0x18c2ff[_0xf1fb('0x5f')](_0x30d135);}})['then'](function(_0x1f5c92){if(_0x1f5c92){return _0x1f5c92?{'count':_0x489965,'rows':_0x1f5c92}:null;}})[_0xf1fb('0x29')](respondWithResult(_0x2e1217,null))['catch'](handleError(_0x2e1217,null));};
\ No newline at end of file
+var _0xf485=['includeAll','include','findAll','rows','catch','show','keys','rawAttributes','intersection','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','update','body','params','production','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','redis','defaults','localhost','./squareProject.socket','register','status','json','offset','limit','undefined','count','set','Content-Range','then','destroy','get','SquareProjects','UserProfileResource','publish','agi','stringify','sendStatus','error','stack','name','send','index','map','fieldName','key','model','query','filters','fields','attributes','length','nolimit','sort','where','pick','merge','VIRTUAL','options','SquareProject'];(function(_0x4408f6,_0x597ade){var _0x31f8fd=function(_0x384b2a){while(--_0x384b2a){_0x4408f6['push'](_0x4408f6['shift']());}};_0x31f8fd(++_0x597ade);}(_0xf485,0xe7));var _0x5f48=function(_0x3b8597,_0x57ce17){_0x3b8597=_0x3b8597-0x0;var _0x2089dc=_0xf485[_0x3b8597];return _0x2089dc;};'use strict';var _=require(_0x5f48('0x0'));var Redis=require('ioredis');var qs=require(_0x5f48('0x1'));var logger=require(_0x5f48('0x2'))(_0x5f48('0x3'));var config=require(_0x5f48('0x4'));var db=require('../../mysqldb')['db'];config[_0x5f48('0x5')]=_[_0x5f48('0x6')](config[_0x5f48('0x5')],{'host':_0x5f48('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x5f48('0x8'))[_0x5f48('0x9')](socket);function respondWithResult(_0x5ad1f6,_0x3a23ce){_0x3a23ce=_0x3a23ce||0xc8;return function(_0x47e52f){if(_0x47e52f){return _0x5ad1f6[_0x5f48('0xa')](_0x3a23ce)[_0x5f48('0xb')](_0x47e52f);}};}function respondWithFilteredResult(_0x2ae04f,_0x4991e9){return function(_0x20b040){if(_0x20b040){var _0x62d41e=typeof _0x4991e9[_0x5f48('0xc')]==='undefined'&&typeof _0x4991e9[_0x5f48('0xd')]===_0x5f48('0xe');var _0x43cc94=_0x20b040[_0x5f48('0xf')];var _0x586228=_0x62d41e?0x0:_0x4991e9[_0x5f48('0xc')];var _0x149b4c=_0x62d41e?_0x20b040[_0x5f48('0xf')]:_0x4991e9['offset']+_0x4991e9[_0x5f48('0xd')];var _0x1bf082;if(_0x149b4c>=_0x43cc94){_0x149b4c=_0x43cc94;_0x1bf082=0xc8;}else{_0x1bf082=0xce;}_0x2ae04f[_0x5f48('0xa')](_0x1bf082);return _0x2ae04f[_0x5f48('0x10')](_0x5f48('0x11'),_0x586228+'-'+_0x149b4c+'/'+_0x43cc94)[_0x5f48('0xb')](_0x20b040);}return null;};}function saveUpdates(_0x402c29){return function(_0x24fcbc){if(_0x24fcbc){return _0x24fcbc['update'](_0x402c29)[_0x5f48('0x12')](function(_0x545e3c){return _0x545e3c;});}return null;};}function removeEntity(_0x546d78){return function(_0x4d2c10){if(_0x4d2c10){return _0x4d2c10[_0x5f48('0x13')]()['then'](function(){var _0x3a3c54=_0x4d2c10[_0x5f48('0x14')]({'plain':!![]});var _0x3624a4=_0x5f48('0x15');return db[_0x5f48('0x16')][_0x5f48('0x13')]({'where':{'type':_0x3624a4,'resourceId':_0x3a3c54['id']}})[_0x5f48('0x12')](function(){return _0x4d2c10;});})['then'](function(){var _0x58a07f=new Redis(config[_0x5f48('0x5')]);_0x58a07f[_0x5f48('0x17')](_0x5f48('0x18'),JSON[_0x5f48('0x19')]({'id':_0x4d2c10['id'],'deleted':!![]}));})[_0x5f48('0x12')](function(){_0x546d78['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x315393){return function(_0x1c8048){if(!_0x1c8048){_0x315393[_0x5f48('0x1a')](0x194);}return _0x1c8048;};}function handleError(_0x376592,_0x4440e8){_0x4440e8=_0x4440e8||0x1f4;return function(_0x6e307b){logger[_0x5f48('0x1b')](_0x6e307b[_0x5f48('0x1c')]);if(_0x6e307b[_0x5f48('0x1d')]){delete _0x6e307b['name'];}_0x376592[_0x5f48('0xa')](_0x4440e8)[_0x5f48('0x1e')](_0x6e307b);};}exports[_0x5f48('0x1f')]=function(_0x46dd83,_0x192816){var _0x1992a1={},_0x3cb5c7={},_0x1f72d9={'count':0x0,'rows':[]};var _0x45ac33=_[_0x5f48('0x20')](db['SquareProject']['rawAttributes'],function(_0x228f21){return{'name':_0x228f21[_0x5f48('0x21')],'type':_0x228f21['type'][_0x5f48('0x22')]};});_0x3cb5c7[_0x5f48('0x23')]=_[_0x5f48('0x20')](_0x45ac33,_0x5f48('0x1d'));_0x3cb5c7[_0x5f48('0x24')]=_['keys'](_0x46dd83['query']);_0x3cb5c7[_0x5f48('0x25')]=_['intersection'](_0x3cb5c7['model'],_0x3cb5c7[_0x5f48('0x24')]);_0x1992a1['attributes']=_['intersection'](_0x3cb5c7[_0x5f48('0x23')],qs[_0x5f48('0x26')](_0x46dd83[_0x5f48('0x24')][_0x5f48('0x26')]));_0x1992a1[_0x5f48('0x27')]=_0x1992a1['attributes'][_0x5f48('0x28')]?_0x1992a1['attributes']:_0x3cb5c7[_0x5f48('0x23')];if(!_0x46dd83[_0x5f48('0x24')]['hasOwnProperty'](_0x5f48('0x29'))){_0x1992a1[_0x5f48('0xd')]=qs['limit'](_0x46dd83[_0x5f48('0x24')]['limit']);_0x1992a1[_0x5f48('0xc')]=qs[_0x5f48('0xc')](_0x46dd83[_0x5f48('0x24')]['offset']);}_0x1992a1['order']=qs[_0x5f48('0x2a')](_0x46dd83[_0x5f48('0x24')][_0x5f48('0x2a')]);_0x1992a1[_0x5f48('0x2b')]=qs['filters'](_[_0x5f48('0x2c')](_0x46dd83[_0x5f48('0x24')],_0x3cb5c7[_0x5f48('0x25')]),_0x45ac33);if(_0x46dd83[_0x5f48('0x24')]['filter']){_0x1992a1['where']=_[_0x5f48('0x2d')](_0x1992a1['where'],{'$or':_[_0x5f48('0x20')](_0x45ac33,function(_0x3e7345){if(_0x3e7345['type']!==_0x5f48('0x2e')){var _0x5ec385={};_0x5ec385[_0x3e7345[_0x5f48('0x1d')]]={'$like':'%'+_0x46dd83[_0x5f48('0x24')]['filter']+'%'};return _0x5ec385;}})});}_0x1992a1=_[_0x5f48('0x2d')]({},_0x1992a1,_0x46dd83[_0x5f48('0x2f')]);var _0x120084={'where':_0x1992a1[_0x5f48('0x2b')]};return db[_0x5f48('0x30')]['count'](_0x120084)[_0x5f48('0x12')](function(_0x3cfba9){_0x1f72d9['count']=_0x3cfba9;if(_0x46dd83['query'][_0x5f48('0x31')]){_0x1992a1[_0x5f48('0x32')]=[{'all':!![]}];}return db['SquareProject'][_0x5f48('0x33')](_0x1992a1);})[_0x5f48('0x12')](function(_0x3f9ce1){_0x1f72d9[_0x5f48('0x34')]=_0x3f9ce1;return _0x1f72d9;})[_0x5f48('0x12')](respondWithFilteredResult(_0x192816,_0x1992a1))[_0x5f48('0x35')](handleError(_0x192816,null));};exports[_0x5f48('0x36')]=function(_0x444bb8,_0x547a22){var _0xc91b01={'raw':![],'where':{'id':_0x444bb8['params']['id']}},_0x373149={};_0x373149[_0x5f48('0x23')]=_[_0x5f48('0x37')](db[_0x5f48('0x30')][_0x5f48('0x38')]);_0x373149['query']=_[_0x5f48('0x37')](_0x444bb8[_0x5f48('0x24')]);_0x373149[_0x5f48('0x25')]=_[_0x5f48('0x39')](_0x373149[_0x5f48('0x23')],_0x373149[_0x5f48('0x24')]);_0xc91b01[_0x5f48('0x27')]=_[_0x5f48('0x39')](_0x373149[_0x5f48('0x23')],qs['fields'](_0x444bb8[_0x5f48('0x24')][_0x5f48('0x26')]));_0xc91b01[_0x5f48('0x27')]=_0xc91b01[_0x5f48('0x27')][_0x5f48('0x28')]?_0xc91b01[_0x5f48('0x27')]:_0x373149[_0x5f48('0x23')];if(_0x444bb8[_0x5f48('0x24')][_0x5f48('0x31')]){_0xc91b01[_0x5f48('0x32')]=[{'all':!![]}];}_0xc91b01=_[_0x5f48('0x2d')]({},_0xc91b01,_0x444bb8['options']);return db[_0x5f48('0x30')][_0x5f48('0x3a')](_0xc91b01)[_0x5f48('0x12')](handleEntityNotFound(_0x547a22,null))[_0x5f48('0x12')](respondWithResult(_0x547a22,null))[_0x5f48('0x35')](handleError(_0x547a22,null));};exports[_0x5f48('0x3b')]=function(_0x5ae128,_0x338354){return db[_0x5f48('0x30')][_0x5f48('0x3b')](_0x5ae128['body'],{})[_0x5f48('0x12')](function(_0x220e34){var _0x23f6bc=_0x5ae128[_0x5f48('0x3c')]['get']({'plain':!![]});if(!_0x23f6bc)throw new Error(_0x5f48('0x3d'));if(_0x23f6bc[_0x5f48('0x3e')]===_0x5f48('0x3c')){var _0x518efb=_0x220e34[_0x5f48('0x14')]({'plain':!![]});var _0x38c8b4=_0x5f48('0x15');return db[_0x5f48('0x3f')]['find']({'where':{'name':_0x38c8b4,'userProfileId':_0x23f6bc[_0x5f48('0x40')]},'raw':!![]})[_0x5f48('0x12')](function(_0x3ebaf2){if(_0x3ebaf2&&_0x3ebaf2[_0x5f48('0x41')]===0x0){return db[_0x5f48('0x16')]['create']({'name':_0x518efb['name'],'resourceId':_0x518efb['id'],'type':_0x3ebaf2[_0x5f48('0x1d')],'sectionId':_0x3ebaf2['id']},{})[_0x5f48('0x12')](function(){return _0x220e34;});}else{return _0x220e34;}})['catch'](function(_0x19953a){logger[_0x5f48('0x1b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x19953a);throw _0x19953a;});}return _0x220e34;})[_0x5f48('0x12')](respondWithResult(_0x338354,0xc9))[_0x5f48('0x35')](handleError(_0x338354,null));};exports[_0x5f48('0x42')]=function(_0x13f9fc,_0x5ab9ed){if(_0x13f9fc['body']['id']){delete _0x13f9fc[_0x5f48('0x43')]['id'];}return db[_0x5f48('0x30')][_0x5f48('0x3a')]({'where':{'id':_0x13f9fc[_0x5f48('0x44')]['id']}})[_0x5f48('0x12')](handleEntityNotFound(_0x5ab9ed,null))[_0x5f48('0x12')](saveUpdates(_0x13f9fc[_0x5f48('0x43')],null))[_0x5f48('0x12')](function(_0x416e59){if(!_0x416e59)return;var _0x9e1f82=_0x416e59['get']({'plain':!![]});return _0x9e1f82;})[_0x5f48('0x12')](function(_0x1dc33c){var _0x4a45d2=new Redis(config[_0x5f48('0x5')]);_0x4a45d2[_0x5f48('0x17')](_0x5f48('0x18'),JSON[_0x5f48('0x19')](_[_0x5f48('0x2c')](_0x1dc33c,['id',_0x5f48('0x1d'),_0x5f48('0x45')])));return _0x1dc33c;})[_0x5f48('0x12')](respondWithResult(_0x5ab9ed,null))[_0x5f48('0x35')](handleError(_0x5ab9ed,null));};exports[_0x5f48('0x13')]=function(_0x58af4c,_0x3d9fb0){return db[_0x5f48('0x30')]['find']({'where':{'id':_0x58af4c[_0x5f48('0x44')]['id']}})[_0x5f48('0x12')](handleEntityNotFound(_0x3d9fb0,null))['then'](removeEntity(_0x3d9fb0,null))[_0x5f48('0x35')](handleError(_0x3d9fb0,null));};
\ No newline at end of file