Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / squareProject / squareProject.controller.js
index a13365c..0153ab0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f40=['to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./squareProject.socket','status','end','offset','limit','undefined','count','set','Content-Range','json','apply','save','update','then','SquareProjects','UserProfileResource','sendStatus','error','stack','name','send','index','map','SquareProject','rawAttributes','fieldName','type','key','model','keys','intersection','query','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filters','filter','merge','options','includeAll','findAll','rows','catch','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','destroy','addUsers','omit','ids','removeUsers','emit','userSquareProject:remove','getUsers','findOne','nolimit','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox'];(function(_0x5e211d,_0x26e878){var _0x42e65b=function(_0x487e44){while(--_0x487e44){_0x5e211d['push'](_0x5e211d['shift']());}};_0x42e65b(++_0x26e878);}(_0x8f40,0xbe));var _0x08f4=function(_0x10296b,_0x433da2){_0x10296b=_0x10296b-0x0;var _0x48f880=_0x8f40[_0x10296b];return _0x48f880;};'use strict';var emlformat=require(_0x08f4('0x0'));var rimraf=require(_0x08f4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x08f4('0x2'));var rp=require(_0x08f4('0x3'));var moment=require(_0x08f4('0x4'));var BPromise=require(_0x08f4('0x5'));var Mustache=require(_0x08f4('0x6'));var util=require(_0x08f4('0x7'));var path=require(_0x08f4('0x8'));var sox=require(_0x08f4('0x9'));var csv=require(_0x08f4('0xa'));var ejs=require(_0x08f4('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x08f4('0xc'));var squel=require(_0x08f4('0xd'));var crypto=require(_0x08f4('0xe'));var jsforce=require(_0x08f4('0xf'));var deskjs=require(_0x08f4('0x10'));var toCsv=require(_0x08f4('0xa'));var querystring=require(_0x08f4('0x11'));var Papa=require(_0x08f4('0x12'));var Redis=require(_0x08f4('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x08f4('0x14'));var as=require(_0x08f4('0x15'));var hardwareService=require(_0x08f4('0x16'));var logger=require(_0x08f4('0x17'))(_0x08f4('0x18'));var utils=require('../../config/utils');var config=require(_0x08f4('0x19'));var licenseUtil=require(_0x08f4('0x1a'));var db=require(_0x08f4('0x1b'))['db'];config[_0x08f4('0x1c')]=_[_0x08f4('0x1d')](config[_0x08f4('0x1c')],{'host':_0x08f4('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x08f4('0x1c')]));require(_0x08f4('0x1f'))['register'](socket);function respondWithStatusCode(_0x3b14e4,_0x28a8a0){_0x28a8a0=_0x28a8a0||0xcc;return function(_0x4d5119){if(_0x4d5119){return _0x3b14e4['sendStatus'](_0x28a8a0);}return _0x3b14e4[_0x08f4('0x20')](_0x28a8a0)[_0x08f4('0x21')]();};}function respondWithResult(_0x1aeb20,_0x2c6331){_0x2c6331=_0x2c6331||0xc8;return function(_0x522583){if(_0x522583){return _0x1aeb20[_0x08f4('0x20')](_0x2c6331)['json'](_0x522583);}};}function respondWithFilteredResult(_0x32abd0,_0x5cfd91){return function(_0x46017b){if(_0x46017b){var _0x296636=typeof _0x5cfd91[_0x08f4('0x22')]==='undefined'&&typeof _0x5cfd91[_0x08f4('0x23')]===_0x08f4('0x24');var _0x3dbe7d=_0x46017b['count'];var _0x9671b3=_0x296636?0x0:_0x5cfd91['offset'];var _0x24c23c=_0x296636?_0x46017b[_0x08f4('0x25')]:_0x5cfd91[_0x08f4('0x22')]+_0x5cfd91[_0x08f4('0x23')];var _0x5866c6;if(_0x24c23c>=_0x3dbe7d){_0x24c23c=_0x3dbe7d;_0x5866c6=0xc8;}else{_0x5866c6=0xce;}_0x32abd0[_0x08f4('0x20')](_0x5866c6);return _0x32abd0[_0x08f4('0x26')](_0x08f4('0x27'),_0x9671b3+'-'+_0x24c23c+'/'+_0x3dbe7d)[_0x08f4('0x28')](_0x46017b);}return null;};}function patchUpdates(_0xab26a9){return function(_0x3472a6){try{jsonpatch[_0x08f4('0x29')](_0x3472a6,_0xab26a9,!![]);}catch(_0x26f15f){return BPromise['reject'](_0x26f15f);}return _0x3472a6[_0x08f4('0x2a')]();};}function saveUpdates(_0x363052,_0x5ceebb){return function(_0x8a912d){if(_0x8a912d){return _0x8a912d[_0x08f4('0x2b')](_0x363052)['then'](function(_0x47e548){return _0x47e548;});}return null;};}function removeEntity(_0x414072,_0x43cc11){return function(_0x61e06){if(_0x61e06){return _0x61e06['destroy']()[_0x08f4('0x2c')](function(){var _0x5f4e60=_0x61e06['get']({'plain':!![]});var _0x59c2dd=_0x08f4('0x2d');return db[_0x08f4('0x2e')]['destroy']({'where':{'type':_0x59c2dd,'resourceId':_0x5f4e60['id']}})[_0x08f4('0x2c')](function(){return _0x61e06;});})[_0x08f4('0x2c')](function(){_0x414072[_0x08f4('0x20')](0xcc)[_0x08f4('0x21')]();});}};}function handleEntityNotFound(_0x5b80b8,_0x416093){return function(_0x633e62){if(!_0x633e62){_0x5b80b8[_0x08f4('0x2f')](0x194);}return _0x633e62;};}function handleError(_0x1a40d8,_0x3d464c){_0x3d464c=_0x3d464c||0x1f4;return function(_0x2f58a1){logger[_0x08f4('0x30')](_0x2f58a1[_0x08f4('0x31')]);if(_0x2f58a1[_0x08f4('0x32')]){delete _0x2f58a1[_0x08f4('0x32')];}_0x1a40d8['status'](_0x3d464c)[_0x08f4('0x33')](_0x2f58a1);};}exports[_0x08f4('0x34')]=function(_0x3bc2a5,_0x5816e7){var _0x4e4a2e={},_0x5aeee4={},_0x38fc29={'count':0x0,'rows':[]};var _0x2528fd=_[_0x08f4('0x35')](db[_0x08f4('0x36')][_0x08f4('0x37')],function(_0x3a6cdb){return{'name':_0x3a6cdb[_0x08f4('0x38')],'type':_0x3a6cdb[_0x08f4('0x39')][_0x08f4('0x3a')]};});_0x5aeee4[_0x08f4('0x3b')]=_[_0x08f4('0x35')](_0x2528fd,_0x08f4('0x32'));_0x5aeee4['query']=_[_0x08f4('0x3c')](_0x3bc2a5['query']);_0x5aeee4['filters']=_[_0x08f4('0x3d')](_0x5aeee4[_0x08f4('0x3b')],_0x5aeee4[_0x08f4('0x3e')]);_0x4e4a2e['attributes']=_[_0x08f4('0x3d')](_0x5aeee4['model'],qs[_0x08f4('0x3f')](_0x3bc2a5[_0x08f4('0x3e')][_0x08f4('0x3f')]));_0x4e4a2e[_0x08f4('0x40')]=_0x4e4a2e[_0x08f4('0x40')][_0x08f4('0x41')]?_0x4e4a2e[_0x08f4('0x40')]:_0x5aeee4[_0x08f4('0x3b')];if(!_0x3bc2a5[_0x08f4('0x3e')][_0x08f4('0x42')]('nolimit')){_0x4e4a2e['limit']=qs[_0x08f4('0x23')](_0x3bc2a5[_0x08f4('0x3e')]['limit']);_0x4e4a2e[_0x08f4('0x22')]=qs[_0x08f4('0x22')](_0x3bc2a5[_0x08f4('0x3e')]['offset']);}_0x4e4a2e[_0x08f4('0x43')]=qs[_0x08f4('0x44')](_0x3bc2a5[_0x08f4('0x3e')][_0x08f4('0x44')]);_0x4e4a2e[_0x08f4('0x45')]=qs['filters'](_[_0x08f4('0x46')](_0x3bc2a5[_0x08f4('0x3e')],_0x5aeee4[_0x08f4('0x47')]),_0x2528fd);if(_0x3bc2a5['query'][_0x08f4('0x48')]){_0x4e4a2e[_0x08f4('0x45')]=_[_0x08f4('0x49')](_0x4e4a2e[_0x08f4('0x45')],{'$or':_[_0x08f4('0x35')](_0x2528fd,function(_0x5d7527){if(_0x5d7527[_0x08f4('0x39')]!=='VIRTUAL'){var _0x1e5635={};_0x1e5635[_0x5d7527[_0x08f4('0x32')]]={'$like':'%'+_0x3bc2a5[_0x08f4('0x3e')][_0x08f4('0x48')]+'%'};return _0x1e5635;}})});}_0x4e4a2e=_[_0x08f4('0x49')]({},_0x4e4a2e,_0x3bc2a5[_0x08f4('0x4a')]);var _0x1d8f6f={'where':_0x4e4a2e[_0x08f4('0x45')]};return db['SquareProject']['count'](_0x1d8f6f)[_0x08f4('0x2c')](function(_0x3fae65){_0x38fc29[_0x08f4('0x25')]=_0x3fae65;if(_0x3bc2a5['query'][_0x08f4('0x4b')]){_0x4e4a2e['include']=[{'all':!![]}];}return db[_0x08f4('0x36')][_0x08f4('0x4c')](_0x4e4a2e);})['then'](function(_0x3321f6){_0x38fc29[_0x08f4('0x4d')]=_0x3321f6;return _0x38fc29;})['then'](respondWithFilteredResult(_0x5816e7,_0x4e4a2e))[_0x08f4('0x4e')](handleError(_0x5816e7,null));};exports['show']=function(_0x444f5a,_0x140510){var _0x5ce19d={'raw':![],'where':{'id':_0x444f5a['params']['id']}},_0x103032={};_0x103032[_0x08f4('0x3b')]=_[_0x08f4('0x3c')](db[_0x08f4('0x36')][_0x08f4('0x37')]);_0x103032[_0x08f4('0x3e')]=_[_0x08f4('0x3c')](_0x444f5a[_0x08f4('0x3e')]);_0x103032[_0x08f4('0x47')]=_[_0x08f4('0x3d')](_0x103032[_0x08f4('0x3b')],_0x103032['query']);_0x5ce19d[_0x08f4('0x40')]=_[_0x08f4('0x3d')](_0x103032['model'],qs[_0x08f4('0x3f')](_0x444f5a['query']['fields']));_0x5ce19d[_0x08f4('0x40')]=_0x5ce19d[_0x08f4('0x40')][_0x08f4('0x41')]?_0x5ce19d['attributes']:_0x103032[_0x08f4('0x3b')];if(_0x444f5a['query'][_0x08f4('0x4b')]){_0x5ce19d['include']=[{'all':!![]}];}_0x5ce19d=_[_0x08f4('0x49')]({},_0x5ce19d,_0x444f5a[_0x08f4('0x4a')]);return db[_0x08f4('0x36')]['find'](_0x5ce19d)[_0x08f4('0x2c')](handleEntityNotFound(_0x140510,null))[_0x08f4('0x2c')](respondWithResult(_0x140510,null))['catch'](handleError(_0x140510,null));};exports['create']=function(_0x291d36,_0x469015){return db[_0x08f4('0x36')][_0x08f4('0x4f')](_0x291d36['body'],{})[_0x08f4('0x2c')](function(_0x20b2d7){var _0x1df307=_0x291d36['user'][_0x08f4('0x50')]({'plain':!![]});if(!_0x1df307)throw new Error(_0x08f4('0x51'));if(_0x1df307[_0x08f4('0x52')]===_0x08f4('0x53')){var _0x81ac54=_0x20b2d7[_0x08f4('0x50')]({'plain':!![]});var _0x1b3881=_0x08f4('0x2d');return db[_0x08f4('0x54')][_0x08f4('0x55')]({'where':{'name':_0x1b3881,'userProfileId':_0x1df307[_0x08f4('0x56')]},'raw':!![]})[_0x08f4('0x2c')](function(_0x3adb56){if(_0x3adb56&&_0x3adb56['autoAssociation']===0x0){return db['UserProfileResource'][_0x08f4('0x4f')]({'name':_0x81ac54['name'],'resourceId':_0x81ac54['id'],'type':_0x3adb56[_0x08f4('0x32')],'sectionId':_0x3adb56['id']},{})['then'](function(){return _0x20b2d7;});}else{return _0x20b2d7;}})[_0x08f4('0x4e')](function(_0x1dc4ea){logger['error'](_0x08f4('0x57'),_0x1dc4ea);throw _0x1dc4ea;});}return _0x20b2d7;})[_0x08f4('0x2c')](respondWithResult(_0x469015,0xc9))[_0x08f4('0x4e')](handleError(_0x469015,null));};exports[_0x08f4('0x2b')]=function(_0x368d2e,_0x413cd5){if(_0x368d2e[_0x08f4('0x58')]['id']){delete _0x368d2e[_0x08f4('0x58')]['id'];}return db['SquareProject'][_0x08f4('0x55')]({'where':{'id':_0x368d2e[_0x08f4('0x59')]['id']}})[_0x08f4('0x2c')](handleEntityNotFound(_0x413cd5,null))['then'](saveUpdates(_0x368d2e['body'],null))[_0x08f4('0x2c')](respondWithResult(_0x413cd5,null))[_0x08f4('0x4e')](handleError(_0x413cd5,null));};exports[_0x08f4('0x5a')]=function(_0x241678,_0x34d303){return db[_0x08f4('0x36')][_0x08f4('0x55')]({'where':{'id':_0x241678[_0x08f4('0x59')]['id']}})[_0x08f4('0x2c')](handleEntityNotFound(_0x34d303,null))[_0x08f4('0x2c')](removeEntity(_0x34d303,null))[_0x08f4('0x4e')](handleError(_0x34d303,null));};exports[_0x08f4('0x5b')]=function(_0xef3771,_0x2f5e1b,_0x402a86){return db[_0x08f4('0x36')][_0x08f4('0x55')]({'where':{'id':_0xef3771[_0x08f4('0x59')]['id']}})[_0x08f4('0x2c')](handleEntityNotFound(_0x2f5e1b,null))['then'](function(_0x572312){if(_0x572312){return _0x572312[_0x08f4('0x5b')](_0xef3771[_0x08f4('0x58')]['ids'],_[_0x08f4('0x5c')](_0xef3771['body'],[_0x08f4('0x5d'),'id'])||{});}})['then'](respondWithResult(_0x2f5e1b,null))[_0x08f4('0x4e')](handleError(_0x2f5e1b,null));};exports[_0x08f4('0x5e')]=function(_0x3c1345,_0x51a645,_0x50e166){return db['SquareProject']['find']({'where':{'id':_0x3c1345[_0x08f4('0x59')]['id']}})[_0x08f4('0x2c')](handleEntityNotFound(_0x51a645,null))[_0x08f4('0x2c')](function(_0x2aa2a2){if(_0x2aa2a2){return _0x2aa2a2[_0x08f4('0x5e')](_0x3c1345[_0x08f4('0x3e')][_0x08f4('0x5d')])[_0x08f4('0x2c')](function(){if(_['isArray'](_0x3c1345[_0x08f4('0x3e')][_0x08f4('0x5d')])){for(var _0x4f39dd=0x0;_0x4f39dd<_0x3c1345['query'][_0x08f4('0x5d')][_0x08f4('0x41')];_0x4f39dd+=0x1){socket[_0x08f4('0x5f')](_0x08f4('0x60'),{'UserId':Number(_0x3c1345[_0x08f4('0x3e')][_0x08f4('0x5d')][_0x4f39dd]),'SquareProjectId':Number(_0x3c1345[_0x08f4('0x59')]['id'])});}}else{socket[_0x08f4('0x5f')]('userSquareProject:remove',{'UserId':Number(_0x3c1345['query'][_0x08f4('0x5d')]),'SquareProjectId':Number(_0x3c1345['params']['id'])});}});}})[_0x08f4('0x2c')](respondWithStatusCode(_0x51a645,null))['catch'](handleError(_0x51a645,null));};exports[_0x08f4('0x61')]=function(_0x49f37a,_0x7528f0,_0x225814){var _0x251fcf={};var _0x51c8f2={};var _0x58dcbb;var _0xe268c1;return db[_0x08f4('0x36')][_0x08f4('0x62')]({'where':{'id':_0x49f37a['params']['id']}})[_0x08f4('0x2c')](handleEntityNotFound(_0x7528f0,null))['then'](function(_0x2b73fd){if(_0x2b73fd){_0x58dcbb=_0x2b73fd;_0x51c8f2[_0x08f4('0x3b')]=_['keys'](db['User'][_0x08f4('0x37')]);_0x51c8f2[_0x08f4('0x3e')]=_[_0x08f4('0x3c')](_0x49f37a[_0x08f4('0x3e')]);_0x51c8f2['filters']=_[_0x08f4('0x3d')](_0x51c8f2[_0x08f4('0x3b')],_0x51c8f2[_0x08f4('0x3e')]);_0x251fcf['attributes']=_[_0x08f4('0x3d')](_0x51c8f2[_0x08f4('0x3b')],qs[_0x08f4('0x3f')](_0x49f37a[_0x08f4('0x3e')][_0x08f4('0x3f')]));_0x251fcf[_0x08f4('0x40')]=_0x251fcf[_0x08f4('0x40')][_0x08f4('0x41')]?_0x251fcf[_0x08f4('0x40')]:_0x51c8f2[_0x08f4('0x3b')];_0x251fcf[_0x08f4('0x43')]=qs[_0x08f4('0x44')](_0x49f37a[_0x08f4('0x3e')][_0x08f4('0x44')]);_0x251fcf[_0x08f4('0x45')]=qs['filters'](_[_0x08f4('0x46')](_0x49f37a['query'],_0x51c8f2[_0x08f4('0x47')]));if(_0x49f37a[_0x08f4('0x3e')][_0x08f4('0x48')]){_0x251fcf[_0x08f4('0x45')]=_[_0x08f4('0x49')](_0x251fcf[_0x08f4('0x45')],{'$or':_[_0x08f4('0x35')](_0x251fcf[_0x08f4('0x40')],function(_0x1a413d){var _0x57a88f={};_0x57a88f[_0x1a413d]={'$like':'%'+_0x49f37a['query']['filter']+'%'};return _0x57a88f;})});}_0x251fcf=_[_0x08f4('0x49')]({},_0x251fcf,_0x49f37a['options']);return _0x58dcbb[_0x08f4('0x61')](_0x251fcf);}})[_0x08f4('0x2c')](function(_0x1d7e32){if(_0x1d7e32){_0xe268c1=_0x1d7e32[_0x08f4('0x41')];if(!_0x49f37a[_0x08f4('0x3e')][_0x08f4('0x42')](_0x08f4('0x63'))){_0x251fcf[_0x08f4('0x23')]=qs['limit'](_0x49f37a['query'][_0x08f4('0x23')]);_0x251fcf[_0x08f4('0x22')]=qs['offset'](_0x49f37a[_0x08f4('0x3e')][_0x08f4('0x22')]);}return _0x58dcbb['getUsers'](_0x251fcf);}})['then'](function(_0x1bed05){if(_0x1bed05){return _0x1bed05?{'count':_0xe268c1,'rows':_0x1bed05}:null;}})['then'](respondWithResult(_0x7528f0,null))[_0x08f4('0x4e')](handleError(_0x7528f0,null));};
\ No newline at end of file
+var _0x4a90=['destroy','get','SquareProjects','publish','stringify','end','sendStatus','error','stack','name','send','SquareProject','rawAttributes','type','model','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','merge','map','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','body','agi','production','lodash','ioredis','../../components/parsers/qs','api','redis','socket.io-emitter','./squareProject.socket','register','status','json','offset','undefined','count','limit','set','Content-Range','update','then'];(function(_0x420300,_0x806d9c){var _0x4b464d=function(_0x3738fd){while(--_0x3738fd){_0x420300['push'](_0x420300['shift']());}};_0x4b464d(++_0x806d9c);}(_0x4a90,0x102));var _0x04a9=function(_0x5618be,_0x46c435){_0x5618be=_0x5618be-0x0;var _0x9571f3=_0x4a90[_0x5618be];return _0x9571f3;};'use strict';var _=require(_0x04a9('0x0'));var Redis=require(_0x04a9('0x1'));var qs=require(_0x04a9('0x2'));var logger=require('../../config/logger')(_0x04a9('0x3'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x04a9('0x4')]=_['defaults'](config[_0x04a9('0x4')],{'host':'localhost','port':0x18eb});var socket=require(_0x04a9('0x5'))(new Redis(config['redis']));require(_0x04a9('0x6'))[_0x04a9('0x7')](socket);function respondWithResult(_0x171db1,_0xeb2c83){_0xeb2c83=_0xeb2c83||0xc8;return function(_0x2380b0){if(_0x2380b0){return _0x171db1[_0x04a9('0x8')](_0xeb2c83)[_0x04a9('0x9')](_0x2380b0);}};}function respondWithFilteredResult(_0x417ab9,_0x31f311){return function(_0x57aba3){if(_0x57aba3){var _0x125f68=typeof _0x31f311[_0x04a9('0xa')]===_0x04a9('0xb')&&typeof _0x31f311['limit']===_0x04a9('0xb');var _0x1a1ca9=_0x57aba3[_0x04a9('0xc')];var _0x3774fa=_0x125f68?0x0:_0x31f311[_0x04a9('0xa')];var _0x2e586d=_0x125f68?_0x57aba3[_0x04a9('0xc')]:_0x31f311[_0x04a9('0xa')]+_0x31f311[_0x04a9('0xd')];var _0x423501;if(_0x2e586d>=_0x1a1ca9){_0x2e586d=_0x1a1ca9;_0x423501=0xc8;}else{_0x423501=0xce;}_0x417ab9['status'](_0x423501);return _0x417ab9[_0x04a9('0xe')](_0x04a9('0xf'),_0x3774fa+'-'+_0x2e586d+'/'+_0x1a1ca9)[_0x04a9('0x9')](_0x57aba3);}return null;};}function saveUpdates(_0x9f2237){return function(_0x329555){if(_0x329555){return _0x329555[_0x04a9('0x10')](_0x9f2237)[_0x04a9('0x11')](function(_0x2fe8f8){return _0x2fe8f8;});}return null;};}function removeEntity(_0x4f4f7b){return function(_0x489480){if(_0x489480){return _0x489480[_0x04a9('0x12')]()[_0x04a9('0x11')](function(){var _0x3959c1=_0x489480[_0x04a9('0x13')]({'plain':!![]});var _0x21d78e=_0x04a9('0x14');return db['UserProfileResource']['destroy']({'where':{'type':_0x21d78e,'resourceId':_0x3959c1['id']}})[_0x04a9('0x11')](function(){return _0x489480;});})[_0x04a9('0x11')](function(){var _0x5268ff=new Redis(config[_0x04a9('0x4')]);_0x5268ff[_0x04a9('0x15')]('agi',JSON[_0x04a9('0x16')]({'id':_0x489480['id'],'deleted':!![]}));})[_0x04a9('0x11')](function(){_0x4f4f7b[_0x04a9('0x8')](0xcc)[_0x04a9('0x17')]();});}};}function handleEntityNotFound(_0x54224d){return function(_0x3e8bca){if(!_0x3e8bca){_0x54224d[_0x04a9('0x18')](0x194);}return _0x3e8bca;};}function handleError(_0x1def95,_0x3c2b60){_0x3c2b60=_0x3c2b60||0x1f4;return function(_0x1fda54){logger[_0x04a9('0x19')](_0x1fda54[_0x04a9('0x1a')]);if(_0x1fda54[_0x04a9('0x1b')]){delete _0x1fda54[_0x04a9('0x1b')];}_0x1def95[_0x04a9('0x8')](_0x3c2b60)[_0x04a9('0x1c')](_0x1fda54);};}exports['index']=function(_0x3e33b0,_0x1ea50a){var _0x18febf={},_0x4fbfea={},_0x24d176={'count':0x0,'rows':[]};var _0x575d6b=_['map'](db[_0x04a9('0x1d')][_0x04a9('0x1e')],function(_0x5b7ff7){return{'name':_0x5b7ff7['fieldName'],'type':_0x5b7ff7[_0x04a9('0x1f')]['key']};});_0x4fbfea[_0x04a9('0x20')]=_['map'](_0x575d6b,_0x04a9('0x1b'));_0x4fbfea[_0x04a9('0x21')]=_['keys'](_0x3e33b0[_0x04a9('0x21')]);_0x4fbfea['filters']=_[_0x04a9('0x22')](_0x4fbfea['model'],_0x4fbfea[_0x04a9('0x21')]);_0x18febf[_0x04a9('0x23')]=_[_0x04a9('0x22')](_0x4fbfea[_0x04a9('0x20')],qs[_0x04a9('0x24')](_0x3e33b0[_0x04a9('0x21')][_0x04a9('0x24')]));_0x18febf[_0x04a9('0x23')]=_0x18febf[_0x04a9('0x23')]['length']?_0x18febf[_0x04a9('0x23')]:_0x4fbfea[_0x04a9('0x20')];if(!_0x3e33b0['query'][_0x04a9('0x25')](_0x04a9('0x26'))){_0x18febf[_0x04a9('0xd')]=qs[_0x04a9('0xd')](_0x3e33b0['query']['limit']);_0x18febf[_0x04a9('0xa')]=qs['offset'](_0x3e33b0['query']['offset']);}_0x18febf[_0x04a9('0x27')]=qs[_0x04a9('0x28')](_0x3e33b0[_0x04a9('0x21')]['sort']);_0x18febf[_0x04a9('0x29')]=qs[_0x04a9('0x2a')](_['pick'](_0x3e33b0['query'],_0x4fbfea[_0x04a9('0x2a')]),_0x575d6b);if(_0x3e33b0[_0x04a9('0x21')]['filter']){_0x18febf[_0x04a9('0x29')]=_[_0x04a9('0x2b')](_0x18febf[_0x04a9('0x29')],{'$or':_[_0x04a9('0x2c')](_0x575d6b,function(_0x598c56){if(_0x598c56['type']!==_0x04a9('0x2d')){var _0x2f20e4={};_0x2f20e4[_0x598c56['name']]={'$like':'%'+_0x3e33b0['query'][_0x04a9('0x2e')]+'%'};return _0x2f20e4;}})});}_0x18febf=_[_0x04a9('0x2b')]({},_0x18febf,_0x3e33b0[_0x04a9('0x2f')]);var _0x308de7={'where':_0x18febf['where']};return db[_0x04a9('0x1d')][_0x04a9('0xc')](_0x308de7)['then'](function(_0x4ccee9){_0x24d176[_0x04a9('0xc')]=_0x4ccee9;if(_0x3e33b0['query'][_0x04a9('0x30')]){_0x18febf[_0x04a9('0x31')]=[{'all':!![]}];}return db[_0x04a9('0x1d')][_0x04a9('0x32')](_0x18febf);})['then'](function(_0x79c49b){_0x24d176[_0x04a9('0x33')]=_0x79c49b;return _0x24d176;})[_0x04a9('0x11')](respondWithFilteredResult(_0x1ea50a,_0x18febf))[_0x04a9('0x34')](handleError(_0x1ea50a,null));};exports[_0x04a9('0x35')]=function(_0x55961f,_0x3e4bc6){var _0xd708c9={'raw':![],'where':{'id':_0x55961f[_0x04a9('0x36')]['id']}},_0x29e91f={};_0x29e91f[_0x04a9('0x20')]=_[_0x04a9('0x37')](db[_0x04a9('0x1d')][_0x04a9('0x1e')]);_0x29e91f[_0x04a9('0x21')]=_[_0x04a9('0x37')](_0x55961f[_0x04a9('0x21')]);_0x29e91f[_0x04a9('0x2a')]=_['intersection'](_0x29e91f[_0x04a9('0x20')],_0x29e91f[_0x04a9('0x21')]);_0xd708c9[_0x04a9('0x23')]=_[_0x04a9('0x22')](_0x29e91f[_0x04a9('0x20')],qs[_0x04a9('0x24')](_0x55961f[_0x04a9('0x21')][_0x04a9('0x24')]));_0xd708c9['attributes']=_0xd708c9[_0x04a9('0x23')][_0x04a9('0x38')]?_0xd708c9[_0x04a9('0x23')]:_0x29e91f['model'];if(_0x55961f['query'][_0x04a9('0x30')]){_0xd708c9[_0x04a9('0x31')]=[{'all':!![]}];}_0xd708c9=_['merge']({},_0xd708c9,_0x55961f[_0x04a9('0x2f')]);return db['SquareProject'][_0x04a9('0x39')](_0xd708c9)['then'](handleEntityNotFound(_0x3e4bc6,null))[_0x04a9('0x11')](respondWithResult(_0x3e4bc6,null))[_0x04a9('0x34')](handleError(_0x3e4bc6,null));};exports['create']=function(_0x291ee8,_0x1cc56f){return db['SquareProject'][_0x04a9('0x3a')](_0x291ee8['body'],{})[_0x04a9('0x11')](function(_0xeaec5d){var _0x15339b=_0x291ee8[_0x04a9('0x3b')]['get']({'plain':!![]});if(!_0x15339b)throw new Error(_0x04a9('0x3c'));if(_0x15339b[_0x04a9('0x3d')]==='user'){var _0x8da26f=_0xeaec5d[_0x04a9('0x13')]({'plain':!![]});var _0x2f75ec='SquareProjects';return db[_0x04a9('0x3e')][_0x04a9('0x39')]({'where':{'name':_0x2f75ec,'userProfileId':_0x15339b[_0x04a9('0x3f')]},'raw':!![]})[_0x04a9('0x11')](function(_0x1a08b4){if(_0x1a08b4&&_0x1a08b4[_0x04a9('0x40')]===0x0){return db[_0x04a9('0x41')]['create']({'name':_0x8da26f[_0x04a9('0x1b')],'resourceId':_0x8da26f['id'],'type':_0x1a08b4[_0x04a9('0x1b')],'sectionId':_0x1a08b4['id']},{})['then'](function(){return _0xeaec5d;});}else{return _0xeaec5d;}})['catch'](function(_0x1a8183){logger[_0x04a9('0x19')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1a8183);throw _0x1a8183;});}return _0xeaec5d;})[_0x04a9('0x11')](respondWithResult(_0x1cc56f,0xc9))[_0x04a9('0x34')](handleError(_0x1cc56f,null));};exports['update']=function(_0x1a2804,_0x28696c){if(_0x1a2804[_0x04a9('0x42')]['id']){delete _0x1a2804[_0x04a9('0x42')]['id'];}return db[_0x04a9('0x1d')][_0x04a9('0x39')]({'where':{'id':_0x1a2804['params']['id']}})['then'](handleEntityNotFound(_0x28696c,null))['then'](saveUpdates(_0x1a2804[_0x04a9('0x42')],null))['then'](function(_0x777dfa){if(!_0x777dfa)return;var _0x362e3f=_0x777dfa['get']({'plain':!![]});return _0x362e3f;})[_0x04a9('0x11')](function(_0x57dee9){var _0x12d551=new Redis(config['redis']);_0x12d551[_0x04a9('0x15')](_0x04a9('0x43'),JSON['stringify'](_['pick'](_0x57dee9,['id',_0x04a9('0x1b'),_0x04a9('0x44')])));return _0x57dee9;})[_0x04a9('0x11')](respondWithResult(_0x28696c,null))['catch'](handleError(_0x28696c,null));};exports['destroy']=function(_0x202cf7,_0x368979){return db[_0x04a9('0x1d')][_0x04a9('0x39')]({'where':{'id':_0x202cf7[_0x04a9('0x36')]['id']}})[_0x04a9('0x11')](handleEntityNotFound(_0x368979,null))[_0x04a9('0x11')](removeEntity(_0x368979,null))['catch'](handleError(_0x368979,null));};
\ No newline at end of file