Built motion from commit de2cb856.|2.0.33
[motion2.git] / server / api / variable / variable.controller.js
1 var _0x5792=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x61\x73\x74\x2D\x6A\x73\x6F\x6E\x2D\x70\x61\x74\x63\x68","\x72\x65\x71\x75\x65\x73\x74\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x6D\x6F\x6D\x65\x6E\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6D\x75\x73\x74\x61\x63\x68\x65","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x73\x6F\x78","\x74\x6F\x2D\x63\x73\x76","\x65\x6A\x73","\x66\x73","\x6C\x6F\x64\x61\x73\x68","\x73\x71\x75\x65\x6C","\x63\x72\x79\x70\x74\x6F","\x6A\x73\x66\x6F\x72\x63\x65","\x64\x65\x73\x6B\x2E\x6A\x73","\x71\x75\x65\x72\x79\x73\x74\x72\x69\x6E\x67","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x70\x61\x72\x73\x65\x72\x73\x2F\x71\x73","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x79\x73\x71\x6C\x64\x62","\x56\x61\x72\x69\x61\x62\x6C\x65\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x6E\x6F\x20\x63\x6F\x6E\x74\x65\x6E\x74","\x69\x6E\x66\x6F","\x56\x61\x72\x69\x61\x62\x6C\x65\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x64\x65\x62\x75\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x65\x6E\x74\x69\x74\x79\x20\x66\x6F\x75\x6E\x64","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6A\x73\x6F\x6E","\x63\x6F\x75\x6E\x74","\x6F\x66\x66\x73\x65\x74","\x6C\x69\x6D\x69\x74","\x65\x6E\x74\x69\x74\x69\x65\x73\x20\x66\x6F\x75\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x52\x61\x6E\x67\x65","\x2D","\x2F","\x73\x65\x74","\x61\x70\x70\x6C\x79","\x72\x65\x6A\x65\x63\x74","\x73\x61\x76\x65","\x65\x6E\x74\x69\x74\x79\x20\x75\x70\x64\x61\x74\x65\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65","\x65\x6E\x74\x69\x74\x79\x20\x72\x65\x6D\x6F\x76\x65\x64","\x64\x65\x73\x74\x72\x6F\x79","\x65\x6E\x74\x69\x74\x79\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x65\x72\x72\x6F\x72","\x69\x6E\x73\x70\x65\x63\x74","\x6E\x61\x6D\x65","\x73\x65\x6E\x64","\x69\x6E\x64\x65\x78","\x6D\x6F\x64\x65\x6C","\x72\x61\x77\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x56\x61\x72\x69\x61\x62\x6C\x65","\x6B\x65\x79\x73","\x71\x75\x65\x72\x79","\x66\x69\x6C\x74\x65\x72\x73","\x69\x6E\x74\x65\x72\x73\x65\x63\x74\x69\x6F\x6E","\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x66\x69\x65\x6C\x64\x73","\x6C\x65\x6E\x67\x74\x68","\x6E\x6F\x6C\x69\x6D\x69\x74","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x6F\x72\x64\x65\x72","\x73\x6F\x72\x74","\x77\x68\x65\x72\x65","\x70\x69\x63\x6B","\x66\x69\x6C\x74\x65\x72","\x25","\x6D\x61\x70","\x6D\x65\x72\x67\x65","\x6F\x70\x74\x69\x6F\x6E\x73","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79"];_0x5792[0];var jsonpatch=require(_0x5792[1]);var rp=require(_0x5792[2]);var moment=require(_0x5792[3]);var BPromise=require(_0x5792[4]);var Mustache=require(_0x5792[5]);var util=require(_0x5792[6]);var path=require(_0x5792[7]);var sox=require(_0x5792[8]);var csv=require(_0x5792[9]);var ejs=require(_0x5792[10]);var fs=require(_0x5792[11]);var _=require(_0x5792[12]);var squel=require(_0x5792[13]);var crypto=require(_0x5792[14]);var jsforce=require(_0x5792[15]);var deskjs=require(_0x5792[16]);var toCsv=require(_0x5792[9]);var querystring=require(_0x5792[17]);var qs=require(_0x5792[18]);var logger=require(_0x5792[20])(_0x5792[19]);var utils=require(_0x5792[21]);var config=require(_0x5792[22]);var db=require(_0x5792[24])[_0x5792[23]];function respondWithStatusCode(_0xbcc1x19,_0xbcc1x1a,_0xbcc1x1b){_0xbcc1x1a= _0xbcc1x1a|| 204;return function(_0xbcc1x1c){if(_0xbcc1x1c){logger[_0x5792[27]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,_0x5792[26]);logger[_0x5792[29]](_0x5792[28],_0xbcc1x1b,_0xbcc1x1a,_0x5792[26]);return _0xbcc1x19[_0x5792[30]](_0xbcc1x1a)};return _0xbcc1x19[_0x5792[32]](_0xbcc1x1a)[_0x5792[31]]()}}function respondWithResult(_0xbcc1x19,_0xbcc1x1a,_0xbcc1x1b){_0xbcc1x1a= _0xbcc1x1a|| 200;return function(_0xbcc1x1c){if(_0xbcc1x1c){logger[_0x5792[27]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,_0x5792[33]);logger[_0x5792[29]](_0x5792[28],_0xbcc1x1b,_0xbcc1x1a,_0x5792[33],JSON[_0x5792[34]](_0xbcc1x1c));return _0xbcc1x19[_0x5792[32]](_0xbcc1x1a)[_0x5792[35]](_0xbcc1x1c)};return _0xbcc1x19[_0x5792[32]](304)[_0x5792[31]]()}}function respondWithFilteredResult(_0xbcc1x19,_0xbcc1x1f,_0xbcc1x1b){return function(_0xbcc1x1c){if(_0xbcc1x1c){var _0xbcc1x20=_0xbcc1x1c[_0x5792[36]],_0xbcc1x21=_0xbcc1x1f[_0x5792[37]],_0xbcc1x22=_0xbcc1x1f[_0x5792[37]]+ _0xbcc1x1f[_0x5792[38]],_0xbcc1x1a;if(_0xbcc1x22>= _0xbcc1x20){_0xbcc1x22= _0xbcc1x20;_0xbcc1x1a= 200}else {_0xbcc1x1a= 206};_0xbcc1x19[_0x5792[32]](_0xbcc1x1a);logger[_0x5792[27]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,_0x5792[39]);logger[_0x5792[29]](_0x5792[28],_0xbcc1x1b,_0xbcc1x1a,_0x5792[33],JSON[_0x5792[34]](_0xbcc1x1c));return _0xbcc1x19[_0x5792[43]](_0x5792[40],_0xbcc1x21+ _0x5792[41]+ _0xbcc1x22+ _0x5792[42]+ _0xbcc1x20)[_0x5792[35]](_0xbcc1x1c)};return null}}function patchUpdates(_0xbcc1x24){return function(_0xbcc1x1c){try{jsonpatch[_0x5792[44]](_0xbcc1x1c,_0xbcc1x24,true)}catch(err){return BPromise[_0x5792[45]](err)};return _0xbcc1x1c[_0x5792[46]]()}}function saveUpdates(_0xbcc1x26,_0xbcc1x1a,_0xbcc1x1b){return function(_0xbcc1x1c){if(_0xbcc1x1c){return _0xbcc1x1c[_0x5792[49]](_0xbcc1x26)[_0x5792[48]](function(_0xbcc1x27){logger[_0x5792[27]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,_0x5792[47]);logger[_0x5792[29]](_0x5792[28],_0xbcc1x1b,_0xbcc1x1a,_0x5792[47],JSON[_0x5792[34]](_0xbcc1x1c));return _0xbcc1x27})};return null}}function removeEntity(_0xbcc1x19,_0xbcc1x1a,_0xbcc1x1b){return function(_0xbcc1x1c){if(_0xbcc1x1c){return _0xbcc1x1c[_0x5792[51]]()[_0x5792[48]](function(){logger[_0x5792[27]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,_0x5792[50]);logger[_0x5792[29]](_0x5792[28],_0xbcc1x1b,_0xbcc1x1a,_0x5792[50],JSON[_0x5792[34]](_0xbcc1x1c));_0xbcc1x19[_0x5792[32]](204)[_0x5792[31]]()})}}}function handleEntityNotFound(_0xbcc1x19,_0xbcc1x1a,_0xbcc1x1b){return function(_0xbcc1x1c){if(!_0xbcc1x1c){logger[_0x5792[53]](_0x5792[25],_0xbcc1x1b,404,_0x5792[52]);return _0xbcc1x19[_0x5792[30]](404)};return _0xbcc1x1c}}function handleError(_0xbcc1x19,_0xbcc1x1a,_0xbcc1x1b){_0xbcc1x1a= _0xbcc1x1a|| 500;return function(_0xbcc1x2b){logger[_0x5792[53]](_0x5792[25],_0xbcc1x1b,_0xbcc1x1a,util[_0x5792[54]](_0xbcc1x2b,{showHidden:false,depth:null}));delete _0xbcc1x2b[_0x5792[55]];_0xbcc1x19[_0x5792[32]](_0xbcc1x1a)[_0x5792[56]](_0xbcc1x2b)}}exports[_0x5792[57]]= function(_0xbcc1x2c,_0xbcc1x19){var _0xbcc1x1f={},_0xbcc1x2d={};_0xbcc1x2d[_0x5792[58]]= _[_0x5792[61]](db[_0x5792[60]][_0x5792[59]]);_0xbcc1x2d[_0x5792[62]]= _[_0x5792[61]](_0xbcc1x2c[_0x5792[62]]);_0xbcc1x2d[_0x5792[63]]= _[_0x5792[64]](_0xbcc1x2d[_0x5792[58]],_0xbcc1x2d[_0x5792[62]]);_0xbcc1x1f[_0x5792[65]]= _[_0x5792[64]](_0xbcc1x2d[_0x5792[58]],qs[_0x5792[66]](_0xbcc1x2c[_0x5792[62]][_0x5792[66]]));_0xbcc1x1f[_0x5792[65]]= (_0xbcc1x1f[_0x5792[65]][_0x5792[67]])?_0xbcc1x1f[_0x5792[65]]:_0xbcc1x2d[_0x5792[58]];if(!_0xbcc1x2c[_0x5792[62]][_0x5792[69]](_0x5792[68])){_0xbcc1x1f[_0x5792[38]]= qs[_0x5792[38]](_0xbcc1x2c[_0x5792[62]][_0x5792[38]]);_0xbcc1x1f[_0x5792[37]]= qs[_0x5792[37]](_0xbcc1x2c[_0x5792[62]][_0x5792[37]])};_0xbcc1x1f[_0x5792[70]]= qs[_0x5792[71]](_0xbcc1x2c[_0x5792[62]][_0x5792[71]]);_0xbcc1x1f[_0x5792[72]]= qs[_0x5792[63]](_[_0x5792[73]](_0xbcc1x2c[_0x5792[62]],_0xbcc1x2d[_0x5792[63]]));if(_0xbcc1x2c[_0x5792[62]][_0x5792[74]]){_0xbcc1x1f[_0x5792[72]]= _[_0x5792[77]](_0xbcc1x1f[_0x5792[72]],{$or:_[_0x5792[76]](_0xbcc1x1f[_0x5792[65]],function(_0xbcc1x2e){var _0xbcc1x2f={};_0xbcc1x2f[_0xbcc1x2e]= {$like:_0x5792[75]+ _0xbcc1x2c[_0x5792[62]][_0x5792[74]]+ _0x5792[75]};return _0xbcc1x2f})})};_0xbcc1x1f= _[_0x5792[77]]({},_0xbcc1x1f,_0xbcc1x2c[_0x5792[78]]);return db[_0x5792[60]][_0x5792[80]](_0xbcc1x1f)[_0x5792[48]](respondWithFilteredResult(_0xbcc1x19,_0xbcc1x1f,_0x5792[57]))[_0x5792[79]](handleError(_0xbcc1x19,null,_0x5792[57]))};exports[_0x5792[81]]= function(_0xbcc1x2c,_0xbcc1x19){var _0xbcc1x1f={raw:true,where:{id:_0xbcc1x2c[_0x5792[83]][_0x5792[82]]}},_0xbcc1x2d={};_0xbcc1x2d[_0x5792[58]]= _[_0x5792[61]](db[_0x5792[60]][_0x5792[59]]);_0xbcc1x2d[_0x5792[62]]= _[_0x5792[61]](_0xbcc1x2c[_0x5792[62]]);_0xbcc1x2d[_0x5792[63]]= _[_0x5792[64]](_0xbcc1x2d[_0x5792[58]],_0xbcc1x2d[_0x5792[62]]);_0xbcc1x1f[_0x5792[65]]= _[_0x5792[64]](_0xbcc1x2d[_0x5792[58]],qs[_0x5792[66]](_0xbcc1x2c[_0x5792[62]][_0x5792[66]]));_0xbcc1x1f[_0x5792[65]]= (_0xbcc1x1f[_0x5792[65]][_0x5792[67]])?_0xbcc1x1f[_0x5792[65]]:_0xbcc1x2d[_0x5792[58]];_0xbcc1x1f= _[_0x5792[77]]({},_0xbcc1x1f,_0xbcc1x2c[_0x5792[78]]);return db[_0x5792[60]][_0x5792[84]](_0xbcc1x1f)[_0x5792[48]](handleEntityNotFound(_0xbcc1x19,null,_0x5792[81]))[_0x5792[48]](respondWithResult(_0xbcc1x19,null,_0x5792[81]))[_0x5792[79]](handleError(_0xbcc1x19,null,_0x5792[81]))};exports[_0x5792[85]]= function(_0xbcc1x2c,_0xbcc1x19){return db[_0x5792[60]][_0x5792[85]](_0xbcc1x2c[_0x5792[86]],{})[_0x5792[48]](respondWithResult(_0xbcc1x19,201,_0x5792[85]))[_0x5792[79]](handleError(_0xbcc1x19,null,_0x5792[85]))};exports[_0x5792[49]]= function(_0xbcc1x2c,_0xbcc1x19){if(_0xbcc1x2c[_0x5792[86]][_0x5792[82]]){delete _0xbcc1x2c[_0x5792[86]][_0x5792[82]]};return db[_0x5792[60]][_0x5792[84]]({where:{id:_0xbcc1x2c[_0x5792[83]][_0x5792[82]]}})[_0x5792[48]](handleEntityNotFound(_0xbcc1x19,null,_0x5792[49]))[_0x5792[48]](saveUpdates(_0xbcc1x2c[_0x5792[86]],null,_0x5792[49]))[_0x5792[48]](respondWithResult(_0xbcc1x19,null,_0x5792[49]))[_0x5792[79]](handleError(_0xbcc1x19,null,_0x5792[49]))};exports[_0x5792[51]]= function(_0xbcc1x2c,_0xbcc1x19){return db[_0x5792[60]][_0x5792[84]]({where:{id:_0xbcc1x2c[_0x5792[83]][_0x5792[82]]}})[_0x5792[48]](handleEntityNotFound(_0xbcc1x19,null,_0x5792[51]))[_0x5792[48]](removeEntity(_0xbcc1x19,null,_0x5792[51]))[_0x5792[79]](handleError(_0xbcc1x19,null,_0x5792[51]))}