Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 5e73fde..2f3807b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbee3=['rows','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','SquareProjects','UserProfileSection','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addUsers','ids','omit','isArray','emit','userSquareProject:remove','findOne','User','order','getUsers','hasOwnProperty','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','count','offset','limit','set','reject','save','update','then','get','UserProfileResource','destroy','end','error','name','send','index','rawAttributes','key','model','map','query','keys','filters','intersection','fields','attributes','length','nolimit','sort','where','pick','filter','merge','type','VIRTUAL','options','SquareProject','includeAll','include','findAll'];(function(_0x1435a7,_0x6e5e92){var _0x4595be=function(_0x3499c5){while(--_0x3499c5){_0x1435a7['push'](_0x1435a7['shift']());}};_0x4595be(++_0x6e5e92);}(_0xbee3,0xd5));var _0x3bee=function(_0x3a11bb,_0x2159be){_0x3a11bb=_0x3a11bb-0x0;var _0x45371c=_0xbee3[_0x3a11bb];return _0x45371c;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x3bee('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x3bee('0x1'));var rp=require(_0x3bee('0x2'));var moment=require('moment');var BPromise=require(_0x3bee('0x3'));var Mustache=require(_0x3bee('0x4'));var util=require(_0x3bee('0x5'));var path=require('path');var sox=require(_0x3bee('0x6'));var csv=require(_0x3bee('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x3bee('0x8'));var squel=require(_0x3bee('0x9'));var crypto=require(_0x3bee('0xa'));var jsforce=require(_0x3bee('0xb'));var deskjs=require(_0x3bee('0xc'));var toCsv=require(_0x3bee('0x7'));var querystring=require(_0x3bee('0xd'));var Papa=require('papaparse');var Redis=require(_0x3bee('0xe'));var authService=require(_0x3bee('0xf'));var qs=require(_0x3bee('0x10'));var as=require(_0x3bee('0x11'));var hardwareService=require(_0x3bee('0x12'));var logger=require(_0x3bee('0x13'))('api');var utils=require(_0x3bee('0x14'));var config=require('../../config/environment');var db=require(_0x3bee('0x15'))['db'];config[_0x3bee('0x16')]=_[_0x3bee('0x17')](config[_0x3bee('0x16')],{'host':_0x3bee('0x18'),'port':0x18eb});var socket=require(_0x3bee('0x19'))(new Redis(config[_0x3bee('0x16')]));require('./squareProject.socket')[_0x3bee('0x1a')](socket);function respondWithStatusCode(_0x33504d,_0x31ac52){_0x31ac52=_0x31ac52||0xcc;return function(_0x237110){if(_0x237110){return _0x33504d[_0x3bee('0x1b')](_0x31ac52);}return _0x33504d['status'](_0x31ac52)['end']();};}function respondWithResult(_0x346767,_0x515397){_0x515397=_0x515397||0xc8;return function(_0x2cfba7){if(_0x2cfba7){return _0x346767[_0x3bee('0x1c')](_0x515397)['json'](_0x2cfba7);}};}function respondWithFilteredResult(_0x5c87cf,_0x1582a4){return function(_0x36c5aa){if(_0x36c5aa){var _0xfdba3b=_0x36c5aa[_0x3bee('0x1d')],_0x631ff8=_0x1582a4[_0x3bee('0x1e')],_0x49095a=_0x1582a4[_0x3bee('0x1e')]+_0x1582a4[_0x3bee('0x1f')],_0x30a1de;if(_0x49095a>=_0xfdba3b){_0x49095a=_0xfdba3b;_0x30a1de=0xc8;}else{_0x30a1de=0xce;}_0x5c87cf[_0x3bee('0x1c')](_0x30a1de);return _0x5c87cf[_0x3bee('0x20')]('Content-Range',_0x631ff8+'-'+_0x49095a+'/'+_0xfdba3b)['json'](_0x36c5aa);}return null;};}function patchUpdates(_0x1afd0f){return function(_0x30bba2){try{jsonpatch['apply'](_0x30bba2,_0x1afd0f,!![]);}catch(_0x471027){return BPromise[_0x3bee('0x21')](_0x471027);}return _0x30bba2[_0x3bee('0x22')]();};}function saveUpdates(_0x179e62,_0x28c248){return function(_0x26e92e){if(_0x26e92e){return _0x26e92e[_0x3bee('0x23')](_0x179e62)['then'](function(_0x8ae4ca){return _0x8ae4ca;});}return null;};}function removeEntity(_0x1ed0c1,_0x1fed5a){return function(_0x3bb884){if(_0x3bb884){return _0x3bb884['destroy']()[_0x3bee('0x24')](function(){var _0xdcc781=_0x3bb884[_0x3bee('0x25')]({'plain':!![]});var _0x4b4cd4='SquareProjects';return db[_0x3bee('0x26')][_0x3bee('0x27')]({'where':{'type':_0x4b4cd4,'resourceId':_0xdcc781['id']}})['then'](function(){return _0x3bb884;});})[_0x3bee('0x24')](function(){_0x1ed0c1[_0x3bee('0x1c')](0xcc)[_0x3bee('0x28')]();});}};}function handleEntityNotFound(_0x5b1eec,_0x1984c4){return function(_0x355b64){if(!_0x355b64){_0x5b1eec[_0x3bee('0x1b')](0x194);}return _0x355b64;};}function handleError(_0x4f2066,_0x239fa4){_0x239fa4=_0x239fa4||0x1f4;return function(_0xf08fb3){logger[_0x3bee('0x29')](_0xf08fb3['stack']);if(_0xf08fb3[_0x3bee('0x2a')]){delete _0xf08fb3[_0x3bee('0x2a')];}_0x4f2066[_0x3bee('0x1c')](_0x239fa4)[_0x3bee('0x2b')](_0xf08fb3);};}exports[_0x3bee('0x2c')]=function(_0x559c2b,_0x564e45){var _0x3fbc8c={},_0x1e1529={},_0x10bae0={'count':0x0,'rows':[]};var _0x11e07d=_['map'](db['SquareProject'][_0x3bee('0x2d')],function(_0x42cb58){return{'name':_0x42cb58['fieldName'],'type':_0x42cb58['type'][_0x3bee('0x2e')]};});_0x1e1529[_0x3bee('0x2f')]=_[_0x3bee('0x30')](_0x11e07d,_0x3bee('0x2a'));_0x1e1529[_0x3bee('0x31')]=_[_0x3bee('0x32')](_0x559c2b[_0x3bee('0x31')]);_0x1e1529[_0x3bee('0x33')]=_[_0x3bee('0x34')](_0x1e1529[_0x3bee('0x2f')],_0x1e1529['query']);_0x3fbc8c['attributes']=_[_0x3bee('0x34')](_0x1e1529['model'],qs['fields'](_0x559c2b[_0x3bee('0x31')][_0x3bee('0x35')]));_0x3fbc8c[_0x3bee('0x36')]=_0x3fbc8c[_0x3bee('0x36')][_0x3bee('0x37')]?_0x3fbc8c[_0x3bee('0x36')]:_0x1e1529[_0x3bee('0x2f')];if(!_0x559c2b[_0x3bee('0x31')]['hasOwnProperty'](_0x3bee('0x38'))){_0x3fbc8c[_0x3bee('0x1f')]=qs['limit'](_0x559c2b[_0x3bee('0x31')][_0x3bee('0x1f')]);_0x3fbc8c[_0x3bee('0x1e')]=qs[_0x3bee('0x1e')](_0x559c2b[_0x3bee('0x31')]['offset']);}_0x3fbc8c['order']=qs[_0x3bee('0x39')](_0x559c2b[_0x3bee('0x31')][_0x3bee('0x39')]);_0x3fbc8c[_0x3bee('0x3a')]=qs[_0x3bee('0x33')](_[_0x3bee('0x3b')](_0x559c2b[_0x3bee('0x31')],_0x1e1529[_0x3bee('0x33')]));if(_0x559c2b[_0x3bee('0x31')][_0x3bee('0x3c')]){_0x3fbc8c[_0x3bee('0x3a')]=_[_0x3bee('0x3d')](_0x3fbc8c['where'],{'$or':_[_0x3bee('0x30')](_0x11e07d,function(_0x1b5eca){if(_0x1b5eca[_0x3bee('0x3e')]!==_0x3bee('0x3f')){var _0x268c0e={};_0x268c0e[_0x1b5eca[_0x3bee('0x2a')]]={'$like':'%'+_0x559c2b[_0x3bee('0x31')][_0x3bee('0x3c')]+'%'};return _0x268c0e;}})});}_0x3fbc8c=_[_0x3bee('0x3d')]({},_0x3fbc8c,_0x559c2b[_0x3bee('0x40')]);var _0x2e3740={'where':_0x3fbc8c[_0x3bee('0x3a')]};return db[_0x3bee('0x41')]['count'](_0x2e3740)[_0x3bee('0x24')](function(_0x2f30d7){_0x10bae0[_0x3bee('0x1d')]=_0x2f30d7;if(_0x559c2b[_0x3bee('0x31')][_0x3bee('0x42')]){_0x3fbc8c[_0x3bee('0x43')]=[{'all':!![]}];}return db[_0x3bee('0x41')][_0x3bee('0x44')](_0x3fbc8c);})['then'](function(_0x10a59d){_0x10bae0[_0x3bee('0x45')]=_0x10a59d;return _0x10bae0;})[_0x3bee('0x24')](respondWithFilteredResult(_0x564e45,_0x3fbc8c))['catch'](handleError(_0x564e45,null));};exports[_0x3bee('0x46')]=function(_0x57113b,_0x2b1677){var _0x48325e={'raw':![],'where':{'id':_0x57113b[_0x3bee('0x47')]['id']}},_0x5717d3={};_0x5717d3[_0x3bee('0x2f')]=_[_0x3bee('0x32')](db[_0x3bee('0x41')][_0x3bee('0x2d')]);_0x5717d3['query']=_['keys'](_0x57113b[_0x3bee('0x31')]);_0x5717d3['filters']=_[_0x3bee('0x34')](_0x5717d3['model'],_0x5717d3[_0x3bee('0x31')]);_0x48325e['attributes']=_[_0x3bee('0x34')](_0x5717d3[_0x3bee('0x2f')],qs[_0x3bee('0x35')](_0x57113b[_0x3bee('0x31')]['fields']));_0x48325e['attributes']=_0x48325e[_0x3bee('0x36')]['length']?_0x48325e['attributes']:_0x5717d3['model'];if(_0x57113b[_0x3bee('0x31')]['includeAll']){_0x48325e[_0x3bee('0x43')]=[{'all':!![]}];}_0x48325e=_[_0x3bee('0x3d')]({},_0x48325e,_0x57113b[_0x3bee('0x40')]);return db['SquareProject'][_0x3bee('0x48')](_0x48325e)['then'](handleEntityNotFound(_0x2b1677,null))[_0x3bee('0x24')](respondWithResult(_0x2b1677,null))['catch'](handleError(_0x2b1677,null));};exports[_0x3bee('0x49')]=function(_0x16b096,_0x15a96a){return db['SquareProject'][_0x3bee('0x49')](_0x16b096[_0x3bee('0x4a')],{})[_0x3bee('0x24')](function(_0x504382){var _0x479d7f=_0x16b096[_0x3bee('0x4b')][_0x3bee('0x25')]({'plain':!![]});if(!_0x479d7f)throw new Error(_0x3bee('0x4c'));if(_0x479d7f[_0x3bee('0x4d')]===_0x3bee('0x4b')){var _0x21ab40=_0x504382[_0x3bee('0x25')]({'plain':!![]});var _0x521ceb=_0x3bee('0x4e');return db[_0x3bee('0x4f')]['find']({'where':{'name':_0x521ceb,'userProfileId':_0x479d7f['userProfileId']},'raw':!![]})[_0x3bee('0x24')](function(_0x5d4755){if(_0x5d4755&&_0x5d4755[_0x3bee('0x50')]===0x0){return db[_0x3bee('0x26')][_0x3bee('0x49')]({'name':_0x21ab40['name'],'resourceId':_0x21ab40['id'],'type':_0x5d4755[_0x3bee('0x2a')],'sectionId':_0x5d4755['id']},{})[_0x3bee('0x24')](function(){return _0x504382;});}else{return _0x504382;}})[_0x3bee('0x51')](function(_0x5f5272){logger[_0x3bee('0x29')](_0x3bee('0x52'),_0x5f5272);throw _0x5f5272;});}return _0x504382;})['then'](respondWithResult(_0x15a96a,0xc9))[_0x3bee('0x51')](handleError(_0x15a96a,null));};exports[_0x3bee('0x23')]=function(_0x53c881,_0x432920){if(_0x53c881[_0x3bee('0x4a')]['id']){delete _0x53c881[_0x3bee('0x4a')]['id'];}return db[_0x3bee('0x41')][_0x3bee('0x48')]({'where':{'id':_0x53c881[_0x3bee('0x47')]['id']}})[_0x3bee('0x24')](handleEntityNotFound(_0x432920,null))[_0x3bee('0x24')](saveUpdates(_0x53c881['body'],null))['then'](respondWithResult(_0x432920,null))[_0x3bee('0x51')](handleError(_0x432920,null));};exports['destroy']=function(_0x38b82a,_0x2d3f3f){return db[_0x3bee('0x41')]['find']({'where':{'id':_0x38b82a[_0x3bee('0x47')]['id']}})[_0x3bee('0x24')](handleEntityNotFound(_0x2d3f3f,null))[_0x3bee('0x24')](removeEntity(_0x2d3f3f,null))['catch'](handleError(_0x2d3f3f,null));};exports[_0x3bee('0x53')]=function(_0x52a327,_0x3cb900,_0x2304cd){return db[_0x3bee('0x41')]['find']({'where':{'id':_0x52a327[_0x3bee('0x47')]['id']}})[_0x3bee('0x24')](handleEntityNotFound(_0x3cb900,null))[_0x3bee('0x24')](function(_0x526551){if(_0x526551){return _0x526551['addUsers'](_0x52a327[_0x3bee('0x4a')][_0x3bee('0x54')],_[_0x3bee('0x55')](_0x52a327['body'],['ids','id'])||{});}})[_0x3bee('0x24')](respondWithResult(_0x3cb900,null))['catch'](handleError(_0x3cb900,null));};exports['removeUsers']=function(_0xbae40e,_0x2a8f08,_0x43d3bc){return db['SquareProject']['find']({'where':{'id':_0xbae40e[_0x3bee('0x47')]['id']}})[_0x3bee('0x24')](handleEntityNotFound(_0x2a8f08,null))['then'](function(_0x3bd805){if(_0x3bd805){return _0x3bd805['removeUsers'](_0xbae40e[_0x3bee('0x31')][_0x3bee('0x54')])[_0x3bee('0x24')](function(){if(_[_0x3bee('0x56')](_0xbae40e[_0x3bee('0x31')][_0x3bee('0x54')])){for(var _0x273bc5=0x0;_0x273bc5<_0xbae40e[_0x3bee('0x31')][_0x3bee('0x54')][_0x3bee('0x37')];_0x273bc5+=0x1){socket[_0x3bee('0x57')]('userSquareProject:remove',{'UserId':Number(_0xbae40e['query']['ids'][_0x273bc5]),'SquareProjectId':Number(_0xbae40e[_0x3bee('0x47')]['id'])});}}else{socket[_0x3bee('0x57')](_0x3bee('0x58'),{'UserId':Number(_0xbae40e[_0x3bee('0x31')]['ids']),'SquareProjectId':Number(_0xbae40e[_0x3bee('0x47')]['id'])});}});}})[_0x3bee('0x24')](respondWithStatusCode(_0x2a8f08,null))['catch'](handleError(_0x2a8f08,null));};exports['getUsers']=function(_0x3b223a,_0xf5a4e3,_0x20be01){var _0x5c3b2c={};var _0x44212e={};var _0x1f7b50;var _0x1d9ffa;return db['SquareProject'][_0x3bee('0x59')]({'where':{'id':_0x3b223a[_0x3bee('0x47')]['id']}})[_0x3bee('0x24')](handleEntityNotFound(_0xf5a4e3,null))[_0x3bee('0x24')](function(_0x52df57){if(_0x52df57){_0x1f7b50=_0x52df57;_0x44212e['model']=_[_0x3bee('0x32')](db[_0x3bee('0x5a')][_0x3bee('0x2d')]);_0x44212e[_0x3bee('0x31')]=_[_0x3bee('0x32')](_0x3b223a['query']);_0x44212e[_0x3bee('0x33')]=_['intersection'](_0x44212e[_0x3bee('0x2f')],_0x44212e[_0x3bee('0x31')]);_0x5c3b2c[_0x3bee('0x36')]=_[_0x3bee('0x34')](_0x44212e[_0x3bee('0x2f')],qs[_0x3bee('0x35')](_0x3b223a[_0x3bee('0x31')]['fields']));_0x5c3b2c[_0x3bee('0x36')]=_0x5c3b2c[_0x3bee('0x36')][_0x3bee('0x37')]?_0x5c3b2c[_0x3bee('0x36')]:_0x44212e['model'];_0x5c3b2c[_0x3bee('0x5b')]=qs[_0x3bee('0x39')](_0x3b223a[_0x3bee('0x31')][_0x3bee('0x39')]);_0x5c3b2c[_0x3bee('0x3a')]=qs[_0x3bee('0x33')](_[_0x3bee('0x3b')](_0x3b223a[_0x3bee('0x31')],_0x44212e['filters']));if(_0x3b223a[_0x3bee('0x31')][_0x3bee('0x3c')]){_0x5c3b2c[_0x3bee('0x3a')]=_['merge'](_0x5c3b2c[_0x3bee('0x3a')],{'$or':_[_0x3bee('0x30')](_0x5c3b2c[_0x3bee('0x36')],function(_0x3890cd){var _0x19e26d={};_0x19e26d[_0x3890cd]={'$like':'%'+_0x3b223a[_0x3bee('0x31')][_0x3bee('0x3c')]+'%'};return _0x19e26d;})});}_0x5c3b2c=_[_0x3bee('0x3d')]({},_0x5c3b2c,_0x3b223a[_0x3bee('0x40')]);return _0x1f7b50[_0x3bee('0x5c')](_0x5c3b2c);}})[_0x3bee('0x24')](function(_0x387924){if(_0x387924){_0x1d9ffa=_0x387924[_0x3bee('0x37')];if(!_0x3b223a[_0x3bee('0x31')][_0x3bee('0x5d')](_0x3bee('0x38'))){_0x5c3b2c[_0x3bee('0x1f')]=qs[_0x3bee('0x1f')](_0x3b223a[_0x3bee('0x31')][_0x3bee('0x1f')]);_0x5c3b2c[_0x3bee('0x1e')]=qs[_0x3bee('0x1e')](_0x3b223a[_0x3bee('0x31')][_0x3bee('0x1e')]);}return _0x1f7b50[_0x3bee('0x5c')](_0x5c3b2c);}})['then'](function(_0x35f0fb){if(_0x35f0fb){return _0x35f0fb?{'count':_0x1d9ffa,'rows':_0x35f0fb}:null;}})[_0x3bee('0x24')](respondWithResult(_0xf5a4e3,null))[_0x3bee('0x51')](handleError(_0xf5a4e3,null));};
\ No newline at end of file
+var _0x9e42=['query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','options','includeAll','rows','catch','show','params','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','localhost','redis','register','status','offset','undefined','count','limit','set','json','update','then','destroy','get','SquareProjects','UserProfileResource','publish','stringify','end','error','name','send','index','map','SquareProject','rawAttributes','fieldName','key','model'];(function(_0x14f30b,_0x4ac7ca){var _0x248b2e=function(_0x800f64){while(--_0x800f64){_0x14f30b['push'](_0x14f30b['shift']());}};_0x248b2e(++_0x4ac7ca);}(_0x9e42,0x1dc));var _0x29e4=function(_0x5235a6,_0x680b76){_0x5235a6=_0x5235a6-0x0;var _0x1cf37e=_0x9e42[_0x5235a6];return _0x1cf37e;};'use strict';var _=require(_0x29e4('0x0'));var Redis=require(_0x29e4('0x1'));var qs=require(_0x29e4('0x2'));var logger=require(_0x29e4('0x3'))(_0x29e4('0x4'));var config=require(_0x29e4('0x5'));var db=require(_0x29e4('0x6'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0x29e4('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x29e4('0x8')]));require('./squareProject.socket')[_0x29e4('0x9')](socket);function respondWithResult(_0x38f655,_0x93aaae){_0x93aaae=_0x93aaae||0xc8;return function(_0x332234){if(_0x332234){return _0x38f655[_0x29e4('0xa')](_0x93aaae)['json'](_0x332234);}};}function respondWithFilteredResult(_0x4761d4,_0x473797){return function(_0x50c833){if(_0x50c833){var _0x524714=typeof _0x473797[_0x29e4('0xb')]===_0x29e4('0xc')&&typeof _0x473797['limit']===_0x29e4('0xc');var _0x3409b3=_0x50c833['count'];var _0x2309e6=_0x524714?0x0:_0x473797['offset'];var _0x2d9c52=_0x524714?_0x50c833[_0x29e4('0xd')]:_0x473797['offset']+_0x473797[_0x29e4('0xe')];var _0x12d715;if(_0x2d9c52>=_0x3409b3){_0x2d9c52=_0x3409b3;_0x12d715=0xc8;}else{_0x12d715=0xce;}_0x4761d4[_0x29e4('0xa')](_0x12d715);return _0x4761d4[_0x29e4('0xf')]('Content-Range',_0x2309e6+'-'+_0x2d9c52+'/'+_0x3409b3)[_0x29e4('0x10')](_0x50c833);}return null;};}function saveUpdates(_0x442bec){return function(_0x395162){if(_0x395162){return _0x395162[_0x29e4('0x11')](_0x442bec)[_0x29e4('0x12')](function(_0x73e6f5){return _0x73e6f5;});}return null;};}function removeEntity(_0x36125c){return function(_0x1d3fad){if(_0x1d3fad){return _0x1d3fad[_0x29e4('0x13')]()['then'](function(){var _0x44cf88=_0x1d3fad[_0x29e4('0x14')]({'plain':!![]});var _0x4ccaa4=_0x29e4('0x15');return db[_0x29e4('0x16')][_0x29e4('0x13')]({'where':{'type':_0x4ccaa4,'resourceId':_0x44cf88['id']}})[_0x29e4('0x12')](function(){return _0x1d3fad;});})[_0x29e4('0x12')](function(){var _0x4a26fa=new Redis(config[_0x29e4('0x8')]);_0x4a26fa[_0x29e4('0x17')]('agi',JSON[_0x29e4('0x18')]({'id':_0x1d3fad['id'],'deleted':!![]}));})['then'](function(){_0x36125c[_0x29e4('0xa')](0xcc)[_0x29e4('0x19')]();});}};}function handleEntityNotFound(_0x5d56c7){return function(_0x500230){if(!_0x500230){_0x5d56c7['sendStatus'](0x194);}return _0x500230;};}function handleError(_0xf2a29f,_0x412bd8){_0x412bd8=_0x412bd8||0x1f4;return function(_0x1cf111){logger[_0x29e4('0x1a')](_0x1cf111['stack']);if(_0x1cf111[_0x29e4('0x1b')]){delete _0x1cf111[_0x29e4('0x1b')];}_0xf2a29f[_0x29e4('0xa')](_0x412bd8)[_0x29e4('0x1c')](_0x1cf111);};}exports[_0x29e4('0x1d')]=function(_0x107830,_0x4f9c69){var _0x13a365={},_0x4c6e57={},_0x48d1d3={'count':0x0,'rows':[]};var _0x27b70d=_[_0x29e4('0x1e')](db[_0x29e4('0x1f')][_0x29e4('0x20')],function(_0x12700e){return{'name':_0x12700e[_0x29e4('0x21')],'type':_0x12700e['type'][_0x29e4('0x22')]};});_0x4c6e57[_0x29e4('0x23')]=_[_0x29e4('0x1e')](_0x27b70d,_0x29e4('0x1b'));_0x4c6e57[_0x29e4('0x24')]=_[_0x29e4('0x25')](_0x107830[_0x29e4('0x24')]);_0x4c6e57[_0x29e4('0x26')]=_[_0x29e4('0x27')](_0x4c6e57['model'],_0x4c6e57['query']);_0x13a365[_0x29e4('0x28')]=_['intersection'](_0x4c6e57[_0x29e4('0x23')],qs[_0x29e4('0x29')](_0x107830[_0x29e4('0x24')]['fields']));_0x13a365[_0x29e4('0x28')]=_0x13a365[_0x29e4('0x28')][_0x29e4('0x2a')]?_0x13a365[_0x29e4('0x28')]:_0x4c6e57['model'];if(!_0x107830['query'][_0x29e4('0x2b')](_0x29e4('0x2c'))){_0x13a365[_0x29e4('0xe')]=qs[_0x29e4('0xe')](_0x107830[_0x29e4('0x24')]['limit']);_0x13a365[_0x29e4('0xb')]=qs[_0x29e4('0xb')](_0x107830[_0x29e4('0x24')][_0x29e4('0xb')]);}_0x13a365[_0x29e4('0x2d')]=qs['sort'](_0x107830['query'][_0x29e4('0x2e')]);_0x13a365[_0x29e4('0x2f')]=qs[_0x29e4('0x26')](_[_0x29e4('0x30')](_0x107830[_0x29e4('0x24')],_0x4c6e57[_0x29e4('0x26')]),_0x27b70d);if(_0x107830[_0x29e4('0x24')][_0x29e4('0x31')]){_0x13a365[_0x29e4('0x2f')]=_['merge'](_0x13a365[_0x29e4('0x2f')],{'$or':_[_0x29e4('0x1e')](_0x27b70d,function(_0x527aa5){if(_0x527aa5[_0x29e4('0x32')]!=='VIRTUAL'){var _0x4057f6={};_0x4057f6[_0x527aa5[_0x29e4('0x1b')]]={'$like':'%'+_0x107830['query']['filter']+'%'};return _0x4057f6;}})});}_0x13a365=_['merge']({},_0x13a365,_0x107830[_0x29e4('0x33')]);var _0x2384c6={'where':_0x13a365[_0x29e4('0x2f')]};return db['SquareProject']['count'](_0x2384c6)[_0x29e4('0x12')](function(_0x418d44){_0x48d1d3[_0x29e4('0xd')]=_0x418d44;if(_0x107830[_0x29e4('0x24')][_0x29e4('0x34')]){_0x13a365['include']=[{'all':!![]}];}return db[_0x29e4('0x1f')]['findAll'](_0x13a365);})[_0x29e4('0x12')](function(_0x429f33){_0x48d1d3[_0x29e4('0x35')]=_0x429f33;return _0x48d1d3;})['then'](respondWithFilteredResult(_0x4f9c69,_0x13a365))[_0x29e4('0x36')](handleError(_0x4f9c69,null));};exports[_0x29e4('0x37')]=function(_0x3aaa9c,_0x36e714){var _0x170924={'raw':![],'where':{'id':_0x3aaa9c[_0x29e4('0x38')]['id']}},_0x274ad6={};_0x274ad6['model']=_[_0x29e4('0x25')](db[_0x29e4('0x1f')][_0x29e4('0x20')]);_0x274ad6[_0x29e4('0x24')]=_[_0x29e4('0x25')](_0x3aaa9c[_0x29e4('0x24')]);_0x274ad6[_0x29e4('0x26')]=_[_0x29e4('0x27')](_0x274ad6[_0x29e4('0x23')],_0x274ad6['query']);_0x170924['attributes']=_['intersection'](_0x274ad6[_0x29e4('0x23')],qs[_0x29e4('0x29')](_0x3aaa9c[_0x29e4('0x24')]['fields']));_0x170924[_0x29e4('0x28')]=_0x170924['attributes'][_0x29e4('0x2a')]?_0x170924[_0x29e4('0x28')]:_0x274ad6['model'];if(_0x3aaa9c[_0x29e4('0x24')][_0x29e4('0x34')]){_0x170924['include']=[{'all':!![]}];}_0x170924=_[_0x29e4('0x39')]({},_0x170924,_0x3aaa9c[_0x29e4('0x33')]);return db[_0x29e4('0x1f')][_0x29e4('0x3a')](_0x170924)[_0x29e4('0x12')](handleEntityNotFound(_0x36e714,null))[_0x29e4('0x12')](respondWithResult(_0x36e714,null))['catch'](handleError(_0x36e714,null));};exports[_0x29e4('0x3b')]=function(_0x49ec5e,_0x55e1f5){return db[_0x29e4('0x1f')]['create'](_0x49ec5e[_0x29e4('0x3c')],{})['then'](function(_0x31d40d){var _0x5c2ae2=_0x49ec5e[_0x29e4('0x3d')][_0x29e4('0x14')]({'plain':!![]});if(!_0x5c2ae2)throw new Error(_0x29e4('0x3e'));if(_0x5c2ae2[_0x29e4('0x3f')]===_0x29e4('0x3d')){var _0xee82d5=_0x31d40d[_0x29e4('0x14')]({'plain':!![]});var _0x4e5292=_0x29e4('0x15');return db['UserProfileSection'][_0x29e4('0x3a')]({'where':{'name':_0x4e5292,'userProfileId':_0x5c2ae2['userProfileId']},'raw':!![]})['then'](function(_0x3944f3){if(_0x3944f3&&_0x3944f3['autoAssociation']===0x0){return db[_0x29e4('0x16')][_0x29e4('0x3b')]({'name':_0xee82d5[_0x29e4('0x1b')],'resourceId':_0xee82d5['id'],'type':_0x3944f3[_0x29e4('0x1b')],'sectionId':_0x3944f3['id']},{})[_0x29e4('0x12')](function(){return _0x31d40d;});}else{return _0x31d40d;}})[_0x29e4('0x36')](function(_0x595158){logger[_0x29e4('0x1a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x595158);throw _0x595158;});}return _0x31d40d;})[_0x29e4('0x12')](respondWithResult(_0x55e1f5,0xc9))['catch'](handleError(_0x55e1f5,null));};exports['update']=function(_0x2897d5,_0x1be9f7){if(_0x2897d5[_0x29e4('0x3c')]['id']){delete _0x2897d5[_0x29e4('0x3c')]['id'];}return db[_0x29e4('0x1f')][_0x29e4('0x3a')]({'where':{'id':_0x2897d5['params']['id']}})[_0x29e4('0x12')](handleEntityNotFound(_0x1be9f7,null))[_0x29e4('0x12')](saveUpdates(_0x2897d5[_0x29e4('0x3c')],null))[_0x29e4('0x12')](function(_0x498393){if(!_0x498393)return;var _0x2b107b=_0x498393[_0x29e4('0x14')]({'plain':!![]});return _0x2b107b;})['then'](function(_0x5c9694){var _0x5f43e2=new Redis(config[_0x29e4('0x8')]);_0x5f43e2['publish']('agi',JSON[_0x29e4('0x18')](_[_0x29e4('0x30')](_0x5c9694,['id',_0x29e4('0x1b'),'production'])));return _0x5c9694;})['then'](respondWithResult(_0x1be9f7,null))[_0x29e4('0x36')](handleError(_0x1be9f7,null));};exports[_0x29e4('0x13')]=function(_0x1831bb,_0x43be85){return db['SquareProject']['find']({'where':{'id':_0x1831bb[_0x29e4('0x38')]['id']}})[_0x29e4('0x12')](handleEntityNotFound(_0x43be85,null))[_0x29e4('0x12')](removeEntity(_0x43be85,null))[_0x29e4('0x36')](handleError(_0x43be85,null));};
\ No newline at end of file