Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 22f6e6d..2ba8bc4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8a7b=['../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','end','status','json','offset','limit','set','Content-Range','apply','reject','save','destroy','then','get','SquareProjects','name','index','map','SquareProject','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','count','includeAll','include','findAll','rows','show','options','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','create','catch','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','addUsers','ids','omit','removeUsers','isArray','userSquareProject:remove','emit','findOne','User','getUsers','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch'];(function(_0x28ecea,_0x4c98f8){var _0x2326df=function(_0x48c69a){while(--_0x48c69a){_0x28ecea['push'](_0x28ecea['shift']());}};_0x2326df(++_0x4c98f8);}(_0x8a7b,0x17e));var _0xb8a7=function(_0xd20f56,_0x4289bf){_0xd20f56=_0xd20f56-0x0;var _0x366917=_0x8a7b[_0xd20f56];return _0x366917;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xb8a7('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb8a7('0x1'));var rp=require(_0xb8a7('0x2'));var moment=require(_0xb8a7('0x3'));var BPromise=require(_0xb8a7('0x4'));var Mustache=require(_0xb8a7('0x5'));var util=require(_0xb8a7('0x6'));var path=require(_0xb8a7('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xb8a7('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xb8a7('0x9'));var crypto=require(_0xb8a7('0xa'));var jsforce=require(_0xb8a7('0xb'));var deskjs=require(_0xb8a7('0xc'));var toCsv=require(_0xb8a7('0xd'));var querystring=require('querystring');var Papa=require(_0xb8a7('0xe'));var Redis=require(_0xb8a7('0xf'));var authService=require(_0xb8a7('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xb8a7('0x11'));var hardwareService=require(_0xb8a7('0x12'));var logger=require(_0xb8a7('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xb8a7('0x14'));var licenseUtil=require(_0xb8a7('0x15'));var db=require(_0xb8a7('0x16'))['db'];config[_0xb8a7('0x17')]=_[_0xb8a7('0x18')](config[_0xb8a7('0x17')],{'host':_0xb8a7('0x19'),'port':0x18eb});var socket=require(_0xb8a7('0x1a'))(new Redis(config[_0xb8a7('0x17')]));require(_0xb8a7('0x1b'))[_0xb8a7('0x1c')](socket);function respondWithStatusCode(_0x2e35fd,_0x1776db){_0x1776db=_0x1776db||0xcc;return function(_0x4f6fc1){if(_0x4f6fc1){return _0x2e35fd[_0xb8a7('0x1d')](_0x1776db);}return _0x2e35fd['status'](_0x1776db)[_0xb8a7('0x1e')]();};}function respondWithResult(_0x3656c8,_0x120d77){_0x120d77=_0x120d77||0xc8;return function(_0x4e205f){if(_0x4e205f){return _0x3656c8[_0xb8a7('0x1f')](_0x120d77)[_0xb8a7('0x20')](_0x4e205f);}};}function respondWithFilteredResult(_0x6f6dae,_0x63c1d2){return function(_0x2b7599){if(_0x2b7599){var _0x25a067=_0x2b7599['count'],_0x35fd7c=_0x63c1d2[_0xb8a7('0x21')],_0xdae36c=_0x63c1d2['offset']+_0x63c1d2[_0xb8a7('0x22')],_0x7ffbf6;if(_0xdae36c>=_0x25a067){_0xdae36c=_0x25a067;_0x7ffbf6=0xc8;}else{_0x7ffbf6=0xce;}_0x6f6dae[_0xb8a7('0x1f')](_0x7ffbf6);return _0x6f6dae[_0xb8a7('0x23')](_0xb8a7('0x24'),_0x35fd7c+'-'+_0xdae36c+'/'+_0x25a067)[_0xb8a7('0x20')](_0x2b7599);}return null;};}function patchUpdates(_0x5497d6){return function(_0x178273){try{jsonpatch[_0xb8a7('0x25')](_0x178273,_0x5497d6,!![]);}catch(_0x1e3dc2){return BPromise[_0xb8a7('0x26')](_0x1e3dc2);}return _0x178273[_0xb8a7('0x27')]();};}function saveUpdates(_0x41e906,_0x2887b3){return function(_0x463b7e){if(_0x463b7e){return _0x463b7e['update'](_0x41e906)['then'](function(_0x545c17){return _0x545c17;});}return null;};}function removeEntity(_0x3937c8,_0x3a709c){return function(_0x568e67){if(_0x568e67){return _0x568e67[_0xb8a7('0x28')]()[_0xb8a7('0x29')](function(){var _0x2164b7=_0x568e67[_0xb8a7('0x2a')]({'plain':!![]});var _0x220083=_0xb8a7('0x2b');return db['UserProfileResource'][_0xb8a7('0x28')]({'where':{'type':_0x220083,'resourceId':_0x2164b7['id']}})[_0xb8a7('0x29')](function(){return _0x568e67;});})[_0xb8a7('0x29')](function(){_0x3937c8[_0xb8a7('0x1f')](0xcc)[_0xb8a7('0x1e')]();});}};}function handleEntityNotFound(_0x44f3b1,_0x2ac200){return function(_0x5bf0cf){if(!_0x5bf0cf){_0x44f3b1[_0xb8a7('0x1d')](0x194);}return _0x5bf0cf;};}function handleError(_0x154587,_0x11ef36){_0x11ef36=_0x11ef36||0x1f4;return function(_0xc897bd){logger['error'](_0xc897bd['stack']);if(_0xc897bd[_0xb8a7('0x2c')]){delete _0xc897bd[_0xb8a7('0x2c')];}_0x154587[_0xb8a7('0x1f')](_0x11ef36)['send'](_0xc897bd);};}exports[_0xb8a7('0x2d')]=function(_0x5516b5,_0x1e399d){var _0x2f6cfb={},_0xeb0798={},_0x18633a={'count':0x0,'rows':[]};var _0x31d485=_[_0xb8a7('0x2e')](db[_0xb8a7('0x2f')][_0xb8a7('0x30')],function(_0xb5e1ff){return{'name':_0xb5e1ff[_0xb8a7('0x31')],'type':_0xb5e1ff[_0xb8a7('0x32')][_0xb8a7('0x33')]};});_0xeb0798['model']=_[_0xb8a7('0x2e')](_0x31d485,_0xb8a7('0x2c'));_0xeb0798[_0xb8a7('0x34')]=_[_0xb8a7('0x35')](_0x5516b5[_0xb8a7('0x34')]);_0xeb0798[_0xb8a7('0x36')]=_[_0xb8a7('0x37')](_0xeb0798[_0xb8a7('0x38')],_0xeb0798['query']);_0x2f6cfb[_0xb8a7('0x39')]=_[_0xb8a7('0x37')](_0xeb0798[_0xb8a7('0x38')],qs['fields'](_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x3a')]));_0x2f6cfb[_0xb8a7('0x39')]=_0x2f6cfb[_0xb8a7('0x39')][_0xb8a7('0x3b')]?_0x2f6cfb[_0xb8a7('0x39')]:_0xeb0798['model'];if(!_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x3c')](_0xb8a7('0x3d'))){_0x2f6cfb[_0xb8a7('0x22')]=qs[_0xb8a7('0x22')](_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x22')]);_0x2f6cfb[_0xb8a7('0x21')]=qs[_0xb8a7('0x21')](_0x5516b5[_0xb8a7('0x34')]['offset']);}_0x2f6cfb[_0xb8a7('0x3e')]=qs[_0xb8a7('0x3f')](_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x3f')]);_0x2f6cfb['where']=qs[_0xb8a7('0x36')](_[_0xb8a7('0x40')](_0x5516b5[_0xb8a7('0x34')],_0xeb0798[_0xb8a7('0x36')]),_0x31d485);if(_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x41')]){_0x2f6cfb[_0xb8a7('0x42')]=_[_0xb8a7('0x43')](_0x2f6cfb[_0xb8a7('0x42')],{'$or':_[_0xb8a7('0x2e')](_0x31d485,function(_0xe65d24){if(_0xe65d24[_0xb8a7('0x32')]!=='VIRTUAL'){var _0x2a3631={};_0x2a3631[_0xe65d24['name']]={'$like':'%'+_0x5516b5[_0xb8a7('0x34')]['filter']+'%'};return _0x2a3631;}})});}_0x2f6cfb=_[_0xb8a7('0x43')]({},_0x2f6cfb,_0x5516b5['options']);var _0x389b87={'where':_0x2f6cfb[_0xb8a7('0x42')]};return db[_0xb8a7('0x2f')]['count'](_0x389b87)[_0xb8a7('0x29')](function(_0x23208c){_0x18633a[_0xb8a7('0x44')]=_0x23208c;if(_0x5516b5[_0xb8a7('0x34')][_0xb8a7('0x45')]){_0x2f6cfb[_0xb8a7('0x46')]=[{'all':!![]}];}return db[_0xb8a7('0x2f')][_0xb8a7('0x47')](_0x2f6cfb);})[_0xb8a7('0x29')](function(_0x247eac){_0x18633a[_0xb8a7('0x48')]=_0x247eac;return _0x18633a;})['then'](respondWithFilteredResult(_0x1e399d,_0x2f6cfb))['catch'](handleError(_0x1e399d,null));};exports[_0xb8a7('0x49')]=function(_0x52ad30,_0x491f55){var _0x5d9e75={'raw':![],'where':{'id':_0x52ad30['params']['id']}},_0x3243d4={};_0x3243d4[_0xb8a7('0x38')]=_['keys'](db[_0xb8a7('0x2f')][_0xb8a7('0x30')]);_0x3243d4[_0xb8a7('0x34')]=_[_0xb8a7('0x35')](_0x52ad30[_0xb8a7('0x34')]);_0x3243d4[_0xb8a7('0x36')]=_[_0xb8a7('0x37')](_0x3243d4['model'],_0x3243d4[_0xb8a7('0x34')]);_0x5d9e75[_0xb8a7('0x39')]=_[_0xb8a7('0x37')](_0x3243d4[_0xb8a7('0x38')],qs[_0xb8a7('0x3a')](_0x52ad30[_0xb8a7('0x34')][_0xb8a7('0x3a')]));_0x5d9e75[_0xb8a7('0x39')]=_0x5d9e75[_0xb8a7('0x39')]['length']?_0x5d9e75['attributes']:_0x3243d4[_0xb8a7('0x38')];if(_0x52ad30[_0xb8a7('0x34')][_0xb8a7('0x45')]){_0x5d9e75[_0xb8a7('0x46')]=[{'all':!![]}];}_0x5d9e75=_[_0xb8a7('0x43')]({},_0x5d9e75,_0x52ad30[_0xb8a7('0x4a')]);return db[_0xb8a7('0x2f')]['find'](_0x5d9e75)[_0xb8a7('0x29')](handleEntityNotFound(_0x491f55,null))[_0xb8a7('0x29')](respondWithResult(_0x491f55,null))['catch'](handleError(_0x491f55,null));};exports['create']=function(_0x1376cb,_0xffd3f5){return db[_0xb8a7('0x2f')]['create'](_0x1376cb[_0xb8a7('0x4b')],{})['then'](function(_0x358e59){var _0x396d7f=_0x1376cb[_0xb8a7('0x4c')][_0xb8a7('0x2a')]({'plain':!![]});if(!_0x396d7f)throw new Error(_0xb8a7('0x4d'));if(_0x396d7f[_0xb8a7('0x4e')]===_0xb8a7('0x4c')){var _0x931b6=_0x358e59[_0xb8a7('0x2a')]({'plain':!![]});var _0x2d0ed3=_0xb8a7('0x2b');return db[_0xb8a7('0x4f')][_0xb8a7('0x50')]({'where':{'name':_0x2d0ed3,'userProfileId':_0x396d7f[_0xb8a7('0x51')]},'raw':!![]})['then'](function(_0x548643){if(_0x548643&&_0x548643[_0xb8a7('0x52')]===0x0){return db[_0xb8a7('0x53')][_0xb8a7('0x54')]({'name':_0x931b6[_0xb8a7('0x2c')],'resourceId':_0x931b6['id'],'type':_0x548643[_0xb8a7('0x2c')],'sectionId':_0x548643['id']},{})[_0xb8a7('0x29')](function(){return _0x358e59;});}else{return _0x358e59;}})[_0xb8a7('0x55')](function(_0x32e4ec){logger[_0xb8a7('0x56')](_0xb8a7('0x57'),_0x32e4ec);throw _0x32e4ec;});}return _0x358e59;})['then'](respondWithResult(_0xffd3f5,0xc9))[_0xb8a7('0x55')](handleError(_0xffd3f5,null));};exports[_0xb8a7('0x58')]=function(_0x43af10,_0x3b3fea){if(_0x43af10['body']['id']){delete _0x43af10[_0xb8a7('0x4b')]['id'];}return db[_0xb8a7('0x2f')][_0xb8a7('0x50')]({'where':{'id':_0x43af10[_0xb8a7('0x59')]['id']}})[_0xb8a7('0x29')](handleEntityNotFound(_0x3b3fea,null))[_0xb8a7('0x29')](saveUpdates(_0x43af10['body'],null))['then'](respondWithResult(_0x3b3fea,null))[_0xb8a7('0x55')](handleError(_0x3b3fea,null));};exports[_0xb8a7('0x28')]=function(_0x36be47,_0x562519){return db['SquareProject'][_0xb8a7('0x50')]({'where':{'id':_0x36be47['params']['id']}})[_0xb8a7('0x29')](handleEntityNotFound(_0x562519,null))['then'](removeEntity(_0x562519,null))[_0xb8a7('0x55')](handleError(_0x562519,null));};exports[_0xb8a7('0x5a')]=function(_0x246de3,_0x574a60,_0x3fdd25){return db[_0xb8a7('0x2f')]['find']({'where':{'id':_0x246de3[_0xb8a7('0x59')]['id']}})[_0xb8a7('0x29')](handleEntityNotFound(_0x574a60,null))[_0xb8a7('0x29')](function(_0x2d654c){if(_0x2d654c){return _0x2d654c[_0xb8a7('0x5a')](_0x246de3[_0xb8a7('0x4b')][_0xb8a7('0x5b')],_[_0xb8a7('0x5c')](_0x246de3['body'],[_0xb8a7('0x5b'),'id'])||{});}})[_0xb8a7('0x29')](respondWithResult(_0x574a60,null))[_0xb8a7('0x55')](handleError(_0x574a60,null));};exports[_0xb8a7('0x5d')]=function(_0x3641fe,_0x17439d,_0x5683b7){return db['SquareProject'][_0xb8a7('0x50')]({'where':{'id':_0x3641fe[_0xb8a7('0x59')]['id']}})[_0xb8a7('0x29')](handleEntityNotFound(_0x17439d,null))[_0xb8a7('0x29')](function(_0x2d1be2){if(_0x2d1be2){return _0x2d1be2[_0xb8a7('0x5d')](_0x3641fe['query'][_0xb8a7('0x5b')])[_0xb8a7('0x29')](function(){if(_[_0xb8a7('0x5e')](_0x3641fe['query']['ids'])){for(var _0x1bc5f1=0x0;_0x1bc5f1<_0x3641fe['query'][_0xb8a7('0x5b')]['length'];_0x1bc5f1+=0x1){socket['emit'](_0xb8a7('0x5f'),{'UserId':Number(_0x3641fe[_0xb8a7('0x34')][_0xb8a7('0x5b')][_0x1bc5f1]),'SquareProjectId':Number(_0x3641fe[_0xb8a7('0x59')]['id'])});}}else{socket[_0xb8a7('0x60')]('userSquareProject:remove',{'UserId':Number(_0x3641fe[_0xb8a7('0x34')][_0xb8a7('0x5b')]),'SquareProjectId':Number(_0x3641fe[_0xb8a7('0x59')]['id'])});}});}})[_0xb8a7('0x29')](respondWithStatusCode(_0x17439d,null))[_0xb8a7('0x55')](handleError(_0x17439d,null));};exports['getUsers']=function(_0x568587,_0x1e8e50,_0x42dc31){var _0x210861={};var _0x4a1f79={};var _0x3e2b2e;var _0x529ae3;return db[_0xb8a7('0x2f')][_0xb8a7('0x61')]({'where':{'id':_0x568587[_0xb8a7('0x59')]['id']}})[_0xb8a7('0x29')](handleEntityNotFound(_0x1e8e50,null))[_0xb8a7('0x29')](function(_0x335c55){if(_0x335c55){_0x3e2b2e=_0x335c55;_0x4a1f79[_0xb8a7('0x38')]=_[_0xb8a7('0x35')](db[_0xb8a7('0x62')][_0xb8a7('0x30')]);_0x4a1f79[_0xb8a7('0x34')]=_[_0xb8a7('0x35')](_0x568587['query']);_0x4a1f79['filters']=_[_0xb8a7('0x37')](_0x4a1f79[_0xb8a7('0x38')],_0x4a1f79[_0xb8a7('0x34')]);_0x210861[_0xb8a7('0x39')]=_[_0xb8a7('0x37')](_0x4a1f79[_0xb8a7('0x38')],qs[_0xb8a7('0x3a')](_0x568587[_0xb8a7('0x34')][_0xb8a7('0x3a')]));_0x210861[_0xb8a7('0x39')]=_0x210861[_0xb8a7('0x39')][_0xb8a7('0x3b')]?_0x210861['attributes']:_0x4a1f79['model'];_0x210861[_0xb8a7('0x3e')]=qs['sort'](_0x568587[_0xb8a7('0x34')][_0xb8a7('0x3f')]);_0x210861[_0xb8a7('0x42')]=qs['filters'](_[_0xb8a7('0x40')](_0x568587[_0xb8a7('0x34')],_0x4a1f79[_0xb8a7('0x36')]));if(_0x568587[_0xb8a7('0x34')][_0xb8a7('0x41')]){_0x210861[_0xb8a7('0x42')]=_[_0xb8a7('0x43')](_0x210861[_0xb8a7('0x42')],{'$or':_[_0xb8a7('0x2e')](_0x210861['attributes'],function(_0x2507f8){var _0x342e0f={};_0x342e0f[_0x2507f8]={'$like':'%'+_0x568587[_0xb8a7('0x34')][_0xb8a7('0x41')]+'%'};return _0x342e0f;})});}_0x210861=_[_0xb8a7('0x43')]({},_0x210861,_0x568587[_0xb8a7('0x4a')]);return _0x3e2b2e['getUsers'](_0x210861);}})['then'](function(_0x139e10){if(_0x139e10){_0x529ae3=_0x139e10[_0xb8a7('0x3b')];if(!_0x568587[_0xb8a7('0x34')]['hasOwnProperty'](_0xb8a7('0x3d'))){_0x210861[_0xb8a7('0x22')]=qs[_0xb8a7('0x22')](_0x568587[_0xb8a7('0x34')]['limit']);_0x210861['offset']=qs[_0xb8a7('0x21')](_0x568587['query'][_0xb8a7('0x21')]);}return _0x3e2b2e[_0xb8a7('0x63')](_0x210861);}})[_0xb8a7('0x29')](function(_0x391baa){if(_0x391baa){return _0x391baa?{'count':_0x529ae3,'rows':_0x391baa}:null;}})[_0xb8a7('0x29')](respondWithResult(_0x1e8e50,null))[_0xb8a7('0x55')](handleError(_0x1e8e50,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