Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / intSugarcrmField / intSugarcrmField.controller.js
index ed1bb16..7994398 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xac9d=['model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','filter','options','SugarcrmField','includeAll','include','findAll','rows','catch','show','params','rawAttributes','length','find','create','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','status','end','json','count','offset','limit','Content-Range','reject','save','update','then','destroy','sendStatus','stack','name','index','map','fieldName','type','key'];(function(_0x711855,_0x4a5977){var _0x5f0bb7=function(_0x465862){while(--_0x465862){_0x711855['push'](_0x711855['shift']());}};_0x5f0bb7(++_0x4a5977);}(_0xac9d,0x14d));var _0xdac9=function(_0x420282,_0x1f941f){_0x420282=_0x420282-0x0;var _0x535480=_0xac9d[_0x420282];return _0x535480;};'use strict';var pdf=require(_0xdac9('0x0'));var emlformat=require(_0xdac9('0x1'));var rimraf=require(_0xdac9('0x2'));var zipdir=require(_0xdac9('0x3'));var jsonpatch=require(_0xdac9('0x4'));var rp=require(_0xdac9('0x5'));var moment=require(_0xdac9('0x6'));var BPromise=require(_0xdac9('0x7'));var Mustache=require('mustache');var util=require(_0xdac9('0x8'));var path=require('path');var sox=require(_0xdac9('0x9'));var csv=require(_0xdac9('0xa'));var ejs=require(_0xdac9('0xb'));var fs=require('fs');var _=require(_0xdac9('0xc'));var squel=require(_0xdac9('0xd'));var crypto=require(_0xdac9('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xdac9('0xf'));var toCsv=require('to-csv');var querystring=require(_0xdac9('0x10'));var Papa=require(_0xdac9('0x11'));var Redis=require(_0xdac9('0x12'));var authService=require(_0xdac9('0x13'));var qs=require(_0xdac9('0x14'));var as=require(_0xdac9('0x15'));var hardwareService=require(_0xdac9('0x16'));var logger=require(_0xdac9('0x17'))(_0xdac9('0x18'));var utils=require('../../config/utils');var config=require(_0xdac9('0x19'));var licenseUtil=require(_0xdac9('0x1a'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3d8e97,_0xeddbc1){_0xeddbc1=_0xeddbc1||0xcc;return function(_0xbfe6d8){if(_0xbfe6d8){return _0x3d8e97['sendStatus'](_0xeddbc1);}return _0x3d8e97[_0xdac9('0x1b')](_0xeddbc1)[_0xdac9('0x1c')]();};}function respondWithResult(_0x9e1bf6,_0x5f0bbd){_0x5f0bbd=_0x5f0bbd||0xc8;return function(_0x5dd536){if(_0x5dd536){return _0x9e1bf6[_0xdac9('0x1b')](_0x5f0bbd)[_0xdac9('0x1d')](_0x5dd536);}};}function respondWithFilteredResult(_0x50f9fe,_0x76af7a){return function(_0x36cbe4){if(_0x36cbe4){var _0x152ea5=_0x36cbe4[_0xdac9('0x1e')],_0x5b2f1b=_0x76af7a[_0xdac9('0x1f')],_0x2221f8=_0x76af7a['offset']+_0x76af7a[_0xdac9('0x20')],_0x393acc;if(_0x2221f8>=_0x152ea5){_0x2221f8=_0x152ea5;_0x393acc=0xc8;}else{_0x393acc=0xce;}_0x50f9fe[_0xdac9('0x1b')](_0x393acc);return _0x50f9fe['set'](_0xdac9('0x21'),_0x5b2f1b+'-'+_0x2221f8+'/'+_0x152ea5)[_0xdac9('0x1d')](_0x36cbe4);}return null;};}function patchUpdates(_0x171df1){return function(_0x181d11){try{jsonpatch['apply'](_0x181d11,_0x171df1,!![]);}catch(_0x520369){return BPromise[_0xdac9('0x22')](_0x520369);}return _0x181d11[_0xdac9('0x23')]();};}function saveUpdates(_0x2b9d91,_0x395ec7){return function(_0x52fb18){if(_0x52fb18){return _0x52fb18[_0xdac9('0x24')](_0x2b9d91)[_0xdac9('0x25')](function(_0x27f473){return _0x27f473;});}return null;};}function removeEntity(_0xae680a,_0xe7bd10){return function(_0x42317c){if(_0x42317c){return _0x42317c[_0xdac9('0x26')]()[_0xdac9('0x25')](function(){_0xae680a[_0xdac9('0x1b')](0xcc)[_0xdac9('0x1c')]();});}};}function handleEntityNotFound(_0x5a0fa2,_0x2943f5){return function(_0x11f4fd){if(!_0x11f4fd){_0x5a0fa2[_0xdac9('0x27')](0x194);}return _0x11f4fd;};}function handleError(_0x34a255,_0x5ca076){_0x5ca076=_0x5ca076||0x1f4;return function(_0x1e631a){logger['error'](_0x1e631a[_0xdac9('0x28')]);if(_0x1e631a[_0xdac9('0x29')]){delete _0x1e631a['name'];}_0x34a255[_0xdac9('0x1b')](_0x5ca076)['send'](_0x1e631a);};}exports[_0xdac9('0x2a')]=function(_0x3743f7,_0xeff4b2){var _0xfe4468={},_0x57d76a={},_0x4b87bc={'count':0x0,'rows':[]};var _0x13e9de=_[_0xdac9('0x2b')](db['SugarcrmField']['rawAttributes'],function(_0x3eed7a){return{'name':_0x3eed7a[_0xdac9('0x2c')],'type':_0x3eed7a[_0xdac9('0x2d')][_0xdac9('0x2e')]};});_0x57d76a[_0xdac9('0x2f')]=_[_0xdac9('0x2b')](_0x13e9de,_0xdac9('0x29'));_0x57d76a[_0xdac9('0x30')]=_[_0xdac9('0x31')](_0x3743f7[_0xdac9('0x30')]);_0x57d76a[_0xdac9('0x32')]=_[_0xdac9('0x33')](_0x57d76a[_0xdac9('0x2f')],_0x57d76a[_0xdac9('0x30')]);_0xfe4468[_0xdac9('0x34')]=_[_0xdac9('0x33')](_0x57d76a[_0xdac9('0x2f')],qs[_0xdac9('0x35')](_0x3743f7[_0xdac9('0x30')][_0xdac9('0x35')]));_0xfe4468[_0xdac9('0x34')]=_0xfe4468['attributes']['length']?_0xfe4468[_0xdac9('0x34')]:_0x57d76a[_0xdac9('0x2f')];if(!_0x3743f7[_0xdac9('0x30')][_0xdac9('0x36')](_0xdac9('0x37'))){_0xfe4468['limit']=qs[_0xdac9('0x20')](_0x3743f7['query'][_0xdac9('0x20')]);_0xfe4468[_0xdac9('0x1f')]=qs['offset'](_0x3743f7[_0xdac9('0x30')]['offset']);}_0xfe4468['order']=qs[_0xdac9('0x38')](_0x3743f7[_0xdac9('0x30')][_0xdac9('0x38')]);_0xfe4468[_0xdac9('0x39')]=qs[_0xdac9('0x32')](_[_0xdac9('0x3a')](_0x3743f7['query'],_0x57d76a[_0xdac9('0x32')]),_0x13e9de);if(_0x3743f7[_0xdac9('0x30')]['filter']){_0xfe4468[_0xdac9('0x39')]=_[_0xdac9('0x3b')](_0xfe4468[_0xdac9('0x39')],{'$or':_[_0xdac9('0x2b')](_0x13e9de,function(_0x35aa58){if(_0x35aa58[_0xdac9('0x2d')]!==_0xdac9('0x3c')){var _0x561fc7={};_0x561fc7[_0x35aa58[_0xdac9('0x29')]]={'$like':'%'+_0x3743f7[_0xdac9('0x30')][_0xdac9('0x3d')]+'%'};return _0x561fc7;}})});}_0xfe4468=_['merge']({},_0xfe4468,_0x3743f7[_0xdac9('0x3e')]);var _0x338e4a={'where':_0xfe4468[_0xdac9('0x39')]};return db[_0xdac9('0x3f')]['count'](_0x338e4a)['then'](function(_0x1d0243){_0x4b87bc[_0xdac9('0x1e')]=_0x1d0243;if(_0x3743f7[_0xdac9('0x30')][_0xdac9('0x40')]){_0xfe4468[_0xdac9('0x41')]=[{'all':!![]}];}return db['SugarcrmField'][_0xdac9('0x42')](_0xfe4468);})['then'](function(_0xd74baf){_0x4b87bc[_0xdac9('0x43')]=_0xd74baf;return _0x4b87bc;})[_0xdac9('0x25')](respondWithFilteredResult(_0xeff4b2,_0xfe4468))[_0xdac9('0x44')](handleError(_0xeff4b2,null));};exports[_0xdac9('0x45')]=function(_0x386b74,_0x413fb1){var _0xb176e0={'raw':!![],'where':{'id':_0x386b74[_0xdac9('0x46')]['id']}},_0x11362d={};_0x11362d[_0xdac9('0x2f')]=_[_0xdac9('0x31')](db[_0xdac9('0x3f')][_0xdac9('0x47')]);_0x11362d['query']=_[_0xdac9('0x31')](_0x386b74[_0xdac9('0x30')]);_0x11362d['filters']=_[_0xdac9('0x33')](_0x11362d[_0xdac9('0x2f')],_0x11362d[_0xdac9('0x30')]);_0xb176e0[_0xdac9('0x34')]=_[_0xdac9('0x33')](_0x11362d[_0xdac9('0x2f')],qs['fields'](_0x386b74[_0xdac9('0x30')]['fields']));_0xb176e0[_0xdac9('0x34')]=_0xb176e0[_0xdac9('0x34')][_0xdac9('0x48')]?_0xb176e0[_0xdac9('0x34')]:_0x11362d['model'];if(_0x386b74['query']['includeAll']){_0xb176e0[_0xdac9('0x41')]=[{'all':!![]}];}_0xb176e0=_['merge']({},_0xb176e0,_0x386b74['options']);return db[_0xdac9('0x3f')][_0xdac9('0x49')](_0xb176e0)['then'](handleEntityNotFound(_0x413fb1,null))['then'](respondWithResult(_0x413fb1,null))[_0xdac9('0x44')](handleError(_0x413fb1,null));};exports[_0xdac9('0x4a')]=function(_0x2a31e8,_0x470137){return db[_0xdac9('0x3f')][_0xdac9('0x4a')](_0x2a31e8[_0xdac9('0x4b')],{})[_0xdac9('0x25')](respondWithResult(_0x470137,0xc9))['catch'](handleError(_0x470137,null));};exports[_0xdac9('0x24')]=function(_0x3bd946,_0xfa104f){if(_0x3bd946[_0xdac9('0x4b')]['id']){delete _0x3bd946[_0xdac9('0x4b')]['id'];}return db[_0xdac9('0x3f')][_0xdac9('0x49')]({'where':{'id':_0x3bd946[_0xdac9('0x46')]['id']}})[_0xdac9('0x25')](handleEntityNotFound(_0xfa104f,null))[_0xdac9('0x25')](saveUpdates(_0x3bd946[_0xdac9('0x4b')],null))[_0xdac9('0x25')](respondWithResult(_0xfa104f,null))[_0xdac9('0x44')](handleError(_0xfa104f,null));};exports[_0xdac9('0x26')]=function(_0x53b349,_0x5112eb){return db['SugarcrmField'][_0xdac9('0x49')]({'where':{'id':_0x53b349[_0xdac9('0x46')]['id']}})['then'](handleEntityNotFound(_0x5112eb,null))[_0xdac9('0x25')](removeEntity(_0x5112eb,null))[_0xdac9('0x44')](handleError(_0x5112eb,null));};
\ No newline at end of file
+var _0xb98e=['map','query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','include','rows','show','params','fields','includeAll','options','find','catch','create','body','eml-format','fast-json-patch','moment','mustache','util','path','to-csv','ejs','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','set','json','apply','reject','update','then','destroy','error','name','send','SugarcrmField','rawAttributes','fieldName','type','key','model'];(function(_0x4424c8,_0x1ca07f){var _0x8355a2=function(_0x5f093d){while(--_0x5f093d){_0x4424c8['push'](_0x4424c8['shift']());}};_0x8355a2(++_0x1ca07f);}(_0xb98e,0x133));var _0xeb98=function(_0x3b26f6,_0x466858){_0x3b26f6=_0x3b26f6-0x0;var _0x51172e=_0xb98e[_0x3b26f6];return _0x51172e;};'use strict';var emlformat=require(_0xeb98('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xeb98('0x1'));var rp=require('request-promise');var moment=require(_0xeb98('0x2'));var BPromise=require('bluebird');var Mustache=require(_0xeb98('0x3'));var util=require(_0xeb98('0x4'));var path=require(_0xeb98('0x5'));var sox=require('sox');var csv=require(_0xeb98('0x6'));var ejs=require(_0xeb98('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xeb98('0x8'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xeb98('0x9'));var toCsv=require(_0xeb98('0x6'));var querystring=require(_0xeb98('0xa'));var Papa=require(_0xeb98('0xb'));var Redis=require(_0xeb98('0xc'));var authService=require(_0xeb98('0xd'));var qs=require(_0xeb98('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xeb98('0xf'))(_0xeb98('0x10'));var utils=require(_0xeb98('0x11'));var config=require(_0xeb98('0x12'));var licenseUtil=require(_0xeb98('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x39ed9f,_0xb4726){_0xb4726=_0xb4726||0xcc;return function(_0x1e5521){if(_0x1e5521){return _0x39ed9f[_0xeb98('0x14')](_0xb4726);}return _0x39ed9f[_0xeb98('0x15')](_0xb4726)[_0xeb98('0x16')]();};}function respondWithResult(_0x13c3a5,_0x708f8d){_0x708f8d=_0x708f8d||0xc8;return function(_0x2e10fd){if(_0x2e10fd){return _0x13c3a5['status'](_0x708f8d)['json'](_0x2e10fd);}};}function respondWithFilteredResult(_0x4d8554,_0x5862f3){return function(_0x47800f){if(_0x47800f){var _0x24fec7=typeof _0x5862f3[_0xeb98('0x17')]===_0xeb98('0x18')&&typeof _0x5862f3[_0xeb98('0x19')]===_0xeb98('0x18');var _0x5b3ee3=_0x47800f[_0xeb98('0x1a')];var _0x226a9d=_0x24fec7?0x0:_0x5862f3['offset'];var _0x99fc4a=_0x24fec7?_0x47800f['count']:_0x5862f3[_0xeb98('0x17')]+_0x5862f3[_0xeb98('0x19')];var _0xb56b4e;if(_0x99fc4a>=_0x5b3ee3){_0x99fc4a=_0x5b3ee3;_0xb56b4e=0xc8;}else{_0xb56b4e=0xce;}_0x4d8554['status'](_0xb56b4e);return _0x4d8554[_0xeb98('0x1b')]('Content-Range',_0x226a9d+'-'+_0x99fc4a+'/'+_0x5b3ee3)[_0xeb98('0x1c')](_0x47800f);}return null;};}function patchUpdates(_0x539a90){return function(_0x31eccf){try{jsonpatch[_0xeb98('0x1d')](_0x31eccf,_0x539a90,!![]);}catch(_0xae8428){return BPromise[_0xeb98('0x1e')](_0xae8428);}return _0x31eccf['save']();};}function saveUpdates(_0x43c114,_0x56bc5a){return function(_0x1b48d5){if(_0x1b48d5){return _0x1b48d5[_0xeb98('0x1f')](_0x43c114)[_0xeb98('0x20')](function(_0x37398c){return _0x37398c;});}return null;};}function removeEntity(_0x46f961,_0x599407){return function(_0x531f3c){if(_0x531f3c){return _0x531f3c[_0xeb98('0x21')]()[_0xeb98('0x20')](function(){_0x46f961['status'](0xcc)[_0xeb98('0x16')]();});}};}function handleEntityNotFound(_0x321165,_0x5d8db4){return function(_0x88c281){if(!_0x88c281){_0x321165[_0xeb98('0x14')](0x194);}return _0x88c281;};}function handleError(_0x2cb4ea,_0xc55579){_0xc55579=_0xc55579||0x1f4;return function(_0x4133d4){logger[_0xeb98('0x22')](_0x4133d4['stack']);if(_0x4133d4[_0xeb98('0x23')]){delete _0x4133d4[_0xeb98('0x23')];}_0x2cb4ea[_0xeb98('0x15')](_0xc55579)[_0xeb98('0x24')](_0x4133d4);};}exports['index']=function(_0x9bea97,_0x55e1a8){var _0x196634={},_0x46c6ab={},_0x1a79bd={'count':0x0,'rows':[]};var _0x18f525=_['map'](db[_0xeb98('0x25')][_0xeb98('0x26')],function(_0x1b0ab1){return{'name':_0x1b0ab1[_0xeb98('0x27')],'type':_0x1b0ab1[_0xeb98('0x28')][_0xeb98('0x29')]};});_0x46c6ab[_0xeb98('0x2a')]=_[_0xeb98('0x2b')](_0x18f525,'name');_0x46c6ab[_0xeb98('0x2c')]=_[_0xeb98('0x2d')](_0x9bea97[_0xeb98('0x2c')]);_0x46c6ab[_0xeb98('0x2e')]=_[_0xeb98('0x2f')](_0x46c6ab[_0xeb98('0x2a')],_0x46c6ab[_0xeb98('0x2c')]);_0x196634[_0xeb98('0x30')]=_[_0xeb98('0x2f')](_0x46c6ab['model'],qs['fields'](_0x9bea97[_0xeb98('0x2c')]['fields']));_0x196634[_0xeb98('0x30')]=_0x196634[_0xeb98('0x30')][_0xeb98('0x31')]?_0x196634['attributes']:_0x46c6ab[_0xeb98('0x2a')];if(!_0x9bea97[_0xeb98('0x2c')][_0xeb98('0x32')](_0xeb98('0x33'))){_0x196634[_0xeb98('0x19')]=qs['limit'](_0x9bea97[_0xeb98('0x2c')][_0xeb98('0x19')]);_0x196634[_0xeb98('0x17')]=qs[_0xeb98('0x17')](_0x9bea97['query'][_0xeb98('0x17')]);}_0x196634[_0xeb98('0x34')]=qs[_0xeb98('0x35')](_0x9bea97[_0xeb98('0x2c')][_0xeb98('0x35')]);_0x196634[_0xeb98('0x36')]=qs[_0xeb98('0x2e')](_[_0xeb98('0x37')](_0x9bea97[_0xeb98('0x2c')],_0x46c6ab[_0xeb98('0x2e')]),_0x18f525);if(_0x9bea97[_0xeb98('0x2c')][_0xeb98('0x38')]){_0x196634[_0xeb98('0x36')]=_['merge'](_0x196634['where'],{'$or':_['map'](_0x18f525,function(_0x5d5bee){if(_0x5d5bee[_0xeb98('0x28')]!==_0xeb98('0x39')){var _0x5c0274={};_0x5c0274[_0x5d5bee['name']]={'$like':'%'+_0x9bea97[_0xeb98('0x2c')]['filter']+'%'};return _0x5c0274;}})});}_0x196634=_[_0xeb98('0x3a')]({},_0x196634,_0x9bea97['options']);var _0xc53aa2={'where':_0x196634[_0xeb98('0x36')]};return db['SugarcrmField']['count'](_0xc53aa2)['then'](function(_0x4d39a5){_0x1a79bd[_0xeb98('0x1a')]=_0x4d39a5;if(_0x9bea97[_0xeb98('0x2c')]['includeAll']){_0x196634[_0xeb98('0x3b')]=[{'all':!![]}];}return db[_0xeb98('0x25')]['findAll'](_0x196634);})[_0xeb98('0x20')](function(_0x2cb6a6){_0x1a79bd[_0xeb98('0x3c')]=_0x2cb6a6;return _0x1a79bd;})[_0xeb98('0x20')](respondWithFilteredResult(_0x55e1a8,_0x196634))['catch'](handleError(_0x55e1a8,null));};exports[_0xeb98('0x3d')]=function(_0x932260,_0x5cdf30){var _0x3036fc={'raw':!![],'where':{'id':_0x932260[_0xeb98('0x3e')]['id']}},_0x36a8df={};_0x36a8df['model']=_[_0xeb98('0x2d')](db[_0xeb98('0x25')][_0xeb98('0x26')]);_0x36a8df[_0xeb98('0x2c')]=_['keys'](_0x932260[_0xeb98('0x2c')]);_0x36a8df['filters']=_[_0xeb98('0x2f')](_0x36a8df[_0xeb98('0x2a')],_0x36a8df[_0xeb98('0x2c')]);_0x3036fc[_0xeb98('0x30')]=_[_0xeb98('0x2f')](_0x36a8df[_0xeb98('0x2a')],qs[_0xeb98('0x3f')](_0x932260[_0xeb98('0x2c')][_0xeb98('0x3f')]));_0x3036fc[_0xeb98('0x30')]=_0x3036fc[_0xeb98('0x30')]['length']?_0x3036fc[_0xeb98('0x30')]:_0x36a8df[_0xeb98('0x2a')];if(_0x932260[_0xeb98('0x2c')][_0xeb98('0x40')]){_0x3036fc['include']=[{'all':!![]}];}_0x3036fc=_['merge']({},_0x3036fc,_0x932260[_0xeb98('0x41')]);return db[_0xeb98('0x25')][_0xeb98('0x42')](_0x3036fc)[_0xeb98('0x20')](handleEntityNotFound(_0x5cdf30,null))[_0xeb98('0x20')](respondWithResult(_0x5cdf30,null))[_0xeb98('0x43')](handleError(_0x5cdf30,null));};exports[_0xeb98('0x44')]=function(_0xeec5be,_0x52a1ab){return db[_0xeb98('0x25')][_0xeb98('0x44')](_0xeec5be[_0xeb98('0x45')],{})['then'](respondWithResult(_0x52a1ab,0xc9))['catch'](handleError(_0x52a1ab,null));};exports[_0xeb98('0x1f')]=function(_0x3243df,_0x51df72){if(_0x3243df[_0xeb98('0x45')]['id']){delete _0x3243df[_0xeb98('0x45')]['id'];}return db[_0xeb98('0x25')][_0xeb98('0x42')]({'where':{'id':_0x3243df[_0xeb98('0x3e')]['id']}})['then'](handleEntityNotFound(_0x51df72,null))[_0xeb98('0x20')](saveUpdates(_0x3243df['body'],null))['then'](respondWithResult(_0x51df72,null))['catch'](handleError(_0x51df72,null));};exports['destroy']=function(_0x295e5c,_0x2a663b){return db['SugarcrmField'][_0xeb98('0x42')]({'where':{'id':_0x295e5c[_0xeb98('0x3e')]['id']}})[_0xeb98('0x20')](handleEntityNotFound(_0x2a663b,null))[_0xeb98('0x20')](removeEntity(_0x2a663b,null))[_0xeb98('0x43')](handleError(_0x2a663b,null));};
\ No newline at end of file