Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / intZohoField / intZohoField.controller.js
index 89612d8..dad2a71 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x16f0=['rows','catch','show','params','rawAttributes','fields','options','create','update','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','save','then','destroy','error','stack','name','send','index','ZohoField','type','key','model','map','query','keys','filters','intersection','attributes','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x16f0,0xa3));var _0x016f=function(_0x3d85be,_0x382b11){_0x3d85be=_0x3d85be-0x0;var _0x3fa27c=_0x16f0[_0x3d85be];return _0x3fa27c;};'use strict';var emlformat=require(_0x016f('0x0'));var rimraf=require(_0x016f('0x1'));var zipdir=require(_0x016f('0x2'));var jsonpatch=require(_0x016f('0x3'));var rp=require(_0x016f('0x4'));var moment=require(_0x016f('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x016f('0x6'));var sox=require(_0x016f('0x7'));var csv=require(_0x016f('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x016f('0x9'));var _=require(_0x016f('0xa'));var squel=require(_0x016f('0xb'));var crypto=require(_0x016f('0xc'));var jsforce=require(_0x016f('0xd'));var deskjs=require(_0x016f('0xe'));var toCsv=require(_0x016f('0x8'));var querystring=require(_0x016f('0xf'));var Papa=require(_0x016f('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x016f('0x11'));var as=require(_0x016f('0x12'));var hardwareService=require(_0x016f('0x13'));var logger=require(_0x016f('0x14'))(_0x016f('0x15'));var utils=require(_0x016f('0x16'));var config=require(_0x016f('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x016f('0x18'))['db'];function respondWithStatusCode(_0x1833cd,_0xe11ac1){_0xe11ac1=_0xe11ac1||0xcc;return function(_0x5ca254){if(_0x5ca254){return _0x1833cd[_0x016f('0x19')](_0xe11ac1);}return _0x1833cd[_0x016f('0x1a')](_0xe11ac1)[_0x016f('0x1b')]();};}function respondWithResult(_0x42eb54,_0x5ae182){_0x5ae182=_0x5ae182||0xc8;return function(_0x3e08fe){if(_0x3e08fe){return _0x42eb54[_0x016f('0x1a')](_0x5ae182)[_0x016f('0x1c')](_0x3e08fe);}};}function respondWithFilteredResult(_0x153ec2,_0x1ff9eb){return function(_0x5a668d){if(_0x5a668d){var _0x1656b9=typeof _0x1ff9eb[_0x016f('0x1d')]===_0x016f('0x1e')&&typeof _0x1ff9eb[_0x016f('0x1f')]===_0x016f('0x1e');var _0x42ef2b=_0x5a668d[_0x016f('0x20')];var _0x4de5f9=_0x1656b9?0x0:_0x1ff9eb[_0x016f('0x1d')];var _0x16497f=_0x1656b9?_0x5a668d['count']:_0x1ff9eb[_0x016f('0x1d')]+_0x1ff9eb[_0x016f('0x1f')];var _0x84d4f1;if(_0x16497f>=_0x42ef2b){_0x16497f=_0x42ef2b;_0x84d4f1=0xc8;}else{_0x84d4f1=0xce;}_0x153ec2[_0x016f('0x1a')](_0x84d4f1);return _0x153ec2['set'](_0x016f('0x21'),_0x4de5f9+'-'+_0x16497f+'/'+_0x42ef2b)[_0x016f('0x1c')](_0x5a668d);}return null;};}function patchUpdates(_0x2b4707){return function(_0x391ce7){try{jsonpatch[_0x016f('0x22')](_0x391ce7,_0x2b4707,!![]);}catch(_0x113c31){return BPromise['reject'](_0x113c31);}return _0x391ce7[_0x016f('0x23')]();};}function saveUpdates(_0x4196b7,_0x42f5b4){return function(_0x1352dd){if(_0x1352dd){return _0x1352dd['update'](_0x4196b7)[_0x016f('0x24')](function(_0x14b69c){return _0x14b69c;});}return null;};}function removeEntity(_0x4da27b,_0x1ec2a6){return function(_0x167a09){if(_0x167a09){return _0x167a09[_0x016f('0x25')]()[_0x016f('0x24')](function(){_0x4da27b['status'](0xcc)[_0x016f('0x1b')]();});}};}function handleEntityNotFound(_0xf0636,_0x534aa3){return function(_0x19aff2){if(!_0x19aff2){_0xf0636[_0x016f('0x19')](0x194);}return _0x19aff2;};}function handleError(_0x368c62,_0x2b654f){_0x2b654f=_0x2b654f||0x1f4;return function(_0x33a53a){logger[_0x016f('0x26')](_0x33a53a[_0x016f('0x27')]);if(_0x33a53a[_0x016f('0x28')]){delete _0x33a53a[_0x016f('0x28')];}_0x368c62[_0x016f('0x1a')](_0x2b654f)[_0x016f('0x29')](_0x33a53a);};}exports[_0x016f('0x2a')]=function(_0x407125,_0x23109c){var _0x454c85={},_0x24434d={},_0x2f04fd={'count':0x0,'rows':[]};var _0x44f2c3=_['map'](db[_0x016f('0x2b')]['rawAttributes'],function(_0x363dac){return{'name':_0x363dac['fieldName'],'type':_0x363dac[_0x016f('0x2c')][_0x016f('0x2d')]};});_0x24434d[_0x016f('0x2e')]=_[_0x016f('0x2f')](_0x44f2c3,_0x016f('0x28'));_0x24434d[_0x016f('0x30')]=_[_0x016f('0x31')](_0x407125[_0x016f('0x30')]);_0x24434d[_0x016f('0x32')]=_[_0x016f('0x33')](_0x24434d[_0x016f('0x2e')],_0x24434d[_0x016f('0x30')]);_0x454c85['attributes']=_['intersection'](_0x24434d[_0x016f('0x2e')],qs['fields'](_0x407125[_0x016f('0x30')]['fields']));_0x454c85[_0x016f('0x34')]=_0x454c85[_0x016f('0x34')][_0x016f('0x35')]?_0x454c85[_0x016f('0x34')]:_0x24434d[_0x016f('0x2e')];if(!_0x407125[_0x016f('0x30')]['hasOwnProperty'](_0x016f('0x36'))){_0x454c85[_0x016f('0x1f')]=qs[_0x016f('0x1f')](_0x407125[_0x016f('0x30')][_0x016f('0x1f')]);_0x454c85[_0x016f('0x1d')]=qs[_0x016f('0x1d')](_0x407125[_0x016f('0x30')][_0x016f('0x1d')]);}_0x454c85[_0x016f('0x37')]=qs['sort'](_0x407125[_0x016f('0x30')][_0x016f('0x38')]);_0x454c85[_0x016f('0x39')]=qs[_0x016f('0x32')](_[_0x016f('0x3a')](_0x407125['query'],_0x24434d[_0x016f('0x32')]),_0x44f2c3);if(_0x407125[_0x016f('0x30')][_0x016f('0x3b')]){_0x454c85[_0x016f('0x39')]=_[_0x016f('0x3c')](_0x454c85[_0x016f('0x39')],{'$or':_[_0x016f('0x2f')](_0x44f2c3,function(_0x2701ab){if(_0x2701ab[_0x016f('0x2c')]!==_0x016f('0x3d')){var _0x2833e0={};_0x2833e0[_0x2701ab[_0x016f('0x28')]]={'$like':'%'+_0x407125[_0x016f('0x30')][_0x016f('0x3b')]+'%'};return _0x2833e0;}})});}_0x454c85=_['merge']({},_0x454c85,_0x407125['options']);var _0x31b42c={'where':_0x454c85[_0x016f('0x39')]};return db[_0x016f('0x2b')]['count'](_0x31b42c)['then'](function(_0x4bd180){_0x2f04fd[_0x016f('0x20')]=_0x4bd180;if(_0x407125[_0x016f('0x30')][_0x016f('0x3e')]){_0x454c85[_0x016f('0x3f')]=[{'all':!![]}];}return db[_0x016f('0x2b')][_0x016f('0x40')](_0x454c85);})[_0x016f('0x24')](function(_0x41ce27){_0x2f04fd[_0x016f('0x41')]=_0x41ce27;return _0x2f04fd;})[_0x016f('0x24')](respondWithFilteredResult(_0x23109c,_0x454c85))[_0x016f('0x42')](handleError(_0x23109c,null));};exports[_0x016f('0x43')]=function(_0x128fe1,_0x246e00){var _0x5eec75={'raw':!![],'where':{'id':_0x128fe1[_0x016f('0x44')]['id']}},_0x180a48={};_0x180a48['model']=_[_0x016f('0x31')](db[_0x016f('0x2b')][_0x016f('0x45')]);_0x180a48[_0x016f('0x30')]=_['keys'](_0x128fe1['query']);_0x180a48[_0x016f('0x32')]=_['intersection'](_0x180a48[_0x016f('0x2e')],_0x180a48[_0x016f('0x30')]);_0x5eec75['attributes']=_['intersection'](_0x180a48[_0x016f('0x2e')],qs[_0x016f('0x46')](_0x128fe1[_0x016f('0x30')]['fields']));_0x5eec75[_0x016f('0x34')]=_0x5eec75[_0x016f('0x34')][_0x016f('0x35')]?_0x5eec75[_0x016f('0x34')]:_0x180a48[_0x016f('0x2e')];if(_0x128fe1[_0x016f('0x30')][_0x016f('0x3e')]){_0x5eec75[_0x016f('0x3f')]=[{'all':!![]}];}_0x5eec75=_[_0x016f('0x3c')]({},_0x5eec75,_0x128fe1[_0x016f('0x47')]);return db[_0x016f('0x2b')]['find'](_0x5eec75)[_0x016f('0x24')](handleEntityNotFound(_0x246e00,null))['then'](respondWithResult(_0x246e00,null))[_0x016f('0x42')](handleError(_0x246e00,null));};exports[_0x016f('0x48')]=function(_0x4f6f73,_0x33fac3){return db['ZohoField']['create'](_0x4f6f73['body'],{})[_0x016f('0x24')](respondWithResult(_0x33fac3,0xc9))[_0x016f('0x42')](handleError(_0x33fac3,null));};exports[_0x016f('0x49')]=function(_0x41b785,_0x71b31b){if(_0x41b785[_0x016f('0x4a')]['id']){delete _0x41b785[_0x016f('0x4a')]['id'];}return db['ZohoField'][_0x016f('0x4b')]({'where':{'id':_0x41b785[_0x016f('0x44')]['id']}})[_0x016f('0x24')](handleEntityNotFound(_0x71b31b,null))['then'](saveUpdates(_0x41b785[_0x016f('0x4a')],null))['then'](respondWithResult(_0x71b31b,null))[_0x016f('0x42')](handleError(_0x71b31b,null));};exports['destroy']=function(_0x2c99df,_0x40e636){return db[_0x016f('0x2b')]['find']({'where':{'id':_0x2c99df[_0x016f('0x44')]['id']}})[_0x016f('0x24')](handleEntityNotFound(_0x40e636,null))[_0x016f('0x24')](removeEntity(_0x40e636,null))['catch'](handleError(_0x40e636,null));};
\ No newline at end of file
+var _0xb37e=['update','then','destroy','stack','name','send','map','ZohoField','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','where','filters','pick','filter','merge','VIRTUAL','options','catch','show','keys','includeAll','include','find','create','body','params','eml-format','rimraf','fast-json-patch','moment','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save'];(function(_0x26bf29,_0x45087c){var _0x369601=function(_0x374fe4){while(--_0x374fe4){_0x26bf29['push'](_0x26bf29['shift']());}};_0x369601(++_0x45087c);}(_0xb37e,0x6f));var _0xeb37=function(_0x1866ea,_0x4e81e4){_0x1866ea=_0x1866ea-0x0;var _0x3f8830=_0xb37e[_0x1866ea];return _0x3f8830;};'use strict';var emlformat=require(_0xeb37('0x0'));var rimraf=require(_0xeb37('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xeb37('0x2'));var rp=require('request-promise');var moment=require(_0xeb37('0x3'));var BPromise=require(_0xeb37('0x4'));var Mustache=require('mustache');var util=require(_0xeb37('0x5'));var path=require(_0xeb37('0x6'));var sox=require(_0xeb37('0x7'));var csv=require(_0xeb37('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xeb37('0x9'));var _=require(_0xeb37('0xa'));var squel=require(_0xeb37('0xb'));var crypto=require('crypto');var jsforce=require(_0xeb37('0xc'));var deskjs=require(_0xeb37('0xd'));var toCsv=require('to-csv');var querystring=require(_0xeb37('0xe'));var Papa=require(_0xeb37('0xf'));var Redis=require(_0xeb37('0x10'));var authService=require(_0xeb37('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xeb37('0x12'));var hardwareService=require(_0xeb37('0x13'));var logger=require(_0xeb37('0x14'))(_0xeb37('0x15'));var utils=require(_0xeb37('0x16'));var config=require(_0xeb37('0x17'));var licenseUtil=require(_0xeb37('0x18'));var db=require(_0xeb37('0x19'))['db'];function respondWithStatusCode(_0x53204a,_0x1c44a8){_0x1c44a8=_0x1c44a8||0xcc;return function(_0x157e65){if(_0x157e65){return _0x53204a[_0xeb37('0x1a')](_0x1c44a8);}return _0x53204a[_0xeb37('0x1b')](_0x1c44a8)[_0xeb37('0x1c')]();};}function respondWithResult(_0x480ccd,_0x59b1c4){_0x59b1c4=_0x59b1c4||0xc8;return function(_0x3403de){if(_0x3403de){return _0x480ccd[_0xeb37('0x1b')](_0x59b1c4)[_0xeb37('0x1d')](_0x3403de);}};}function respondWithFilteredResult(_0x440a17,_0x430eb7){return function(_0x3853ec){if(_0x3853ec){var _0x2508a6=typeof _0x430eb7[_0xeb37('0x1e')]===_0xeb37('0x1f')&&typeof _0x430eb7[_0xeb37('0x20')]===_0xeb37('0x1f');var _0x376cab=_0x3853ec[_0xeb37('0x21')];var _0x4efa54=_0x2508a6?0x0:_0x430eb7[_0xeb37('0x1e')];var _0x739f0=_0x2508a6?_0x3853ec[_0xeb37('0x21')]:_0x430eb7[_0xeb37('0x1e')]+_0x430eb7['limit'];var _0x1490d6;if(_0x739f0>=_0x376cab){_0x739f0=_0x376cab;_0x1490d6=0xc8;}else{_0x1490d6=0xce;}_0x440a17[_0xeb37('0x1b')](_0x1490d6);return _0x440a17[_0xeb37('0x22')](_0xeb37('0x23'),_0x4efa54+'-'+_0x739f0+'/'+_0x376cab)[_0xeb37('0x1d')](_0x3853ec);}return null;};}function patchUpdates(_0x271928){return function(_0x23ba6c){try{jsonpatch[_0xeb37('0x24')](_0x23ba6c,_0x271928,!![]);}catch(_0x3b02f6){return BPromise[_0xeb37('0x25')](_0x3b02f6);}return _0x23ba6c[_0xeb37('0x26')]();};}function saveUpdates(_0x32e467,_0x2b5a91){return function(_0x13d12a){if(_0x13d12a){return _0x13d12a[_0xeb37('0x27')](_0x32e467)[_0xeb37('0x28')](function(_0xf34550){return _0xf34550;});}return null;};}function removeEntity(_0x12a6c9,_0x5d2dca){return function(_0x390584){if(_0x390584){return _0x390584[_0xeb37('0x29')]()[_0xeb37('0x28')](function(){_0x12a6c9['status'](0xcc)[_0xeb37('0x1c')]();});}};}function handleEntityNotFound(_0x4ff01f,_0x4041d8){return function(_0x2a1aa4){if(!_0x2a1aa4){_0x4ff01f['sendStatus'](0x194);}return _0x2a1aa4;};}function handleError(_0x2ee640,_0xdcd3d){_0xdcd3d=_0xdcd3d||0x1f4;return function(_0x5a207e){logger['error'](_0x5a207e[_0xeb37('0x2a')]);if(_0x5a207e['name']){delete _0x5a207e[_0xeb37('0x2b')];}_0x2ee640[_0xeb37('0x1b')](_0xdcd3d)[_0xeb37('0x2c')](_0x5a207e);};}exports['index']=function(_0x347835,_0x3b8613){var _0x416fac={},_0x2f51ea={},_0x2978ff={'count':0x0,'rows':[]};var _0x29b2b2=_[_0xeb37('0x2d')](db[_0xeb37('0x2e')][_0xeb37('0x2f')],function(_0x1c519e){return{'name':_0x1c519e[_0xeb37('0x30')],'type':_0x1c519e[_0xeb37('0x31')][_0xeb37('0x32')]};});_0x2f51ea[_0xeb37('0x33')]=_[_0xeb37('0x2d')](_0x29b2b2,_0xeb37('0x2b'));_0x2f51ea[_0xeb37('0x34')]=_['keys'](_0x347835[_0xeb37('0x34')]);_0x2f51ea['filters']=_['intersection'](_0x2f51ea[_0xeb37('0x33')],_0x2f51ea[_0xeb37('0x34')]);_0x416fac['attributes']=_[_0xeb37('0x35')](_0x2f51ea[_0xeb37('0x33')],qs['fields'](_0x347835['query'][_0xeb37('0x36')]));_0x416fac[_0xeb37('0x37')]=_0x416fac[_0xeb37('0x37')]['length']?_0x416fac[_0xeb37('0x37')]:_0x2f51ea[_0xeb37('0x33')];if(!_0x347835[_0xeb37('0x34')][_0xeb37('0x38')](_0xeb37('0x39'))){_0x416fac[_0xeb37('0x20')]=qs[_0xeb37('0x20')](_0x347835['query'][_0xeb37('0x20')]);_0x416fac['offset']=qs[_0xeb37('0x1e')](_0x347835[_0xeb37('0x34')][_0xeb37('0x1e')]);}_0x416fac[_0xeb37('0x3a')]=qs['sort'](_0x347835[_0xeb37('0x34')]['sort']);_0x416fac[_0xeb37('0x3b')]=qs[_0xeb37('0x3c')](_[_0xeb37('0x3d')](_0x347835[_0xeb37('0x34')],_0x2f51ea[_0xeb37('0x3c')]),_0x29b2b2);if(_0x347835[_0xeb37('0x34')][_0xeb37('0x3e')]){_0x416fac['where']=_[_0xeb37('0x3f')](_0x416fac[_0xeb37('0x3b')],{'$or':_[_0xeb37('0x2d')](_0x29b2b2,function(_0x120b49){if(_0x120b49['type']!==_0xeb37('0x40')){var _0x41f982={};_0x41f982[_0x120b49[_0xeb37('0x2b')]]={'$like':'%'+_0x347835[_0xeb37('0x34')][_0xeb37('0x3e')]+'%'};return _0x41f982;}})});}_0x416fac=_['merge']({},_0x416fac,_0x347835[_0xeb37('0x41')]);var _0x57b79a={'where':_0x416fac[_0xeb37('0x3b')]};return db[_0xeb37('0x2e')][_0xeb37('0x21')](_0x57b79a)[_0xeb37('0x28')](function(_0x101ddb){_0x2978ff[_0xeb37('0x21')]=_0x101ddb;if(_0x347835['query']['includeAll']){_0x416fac['include']=[{'all':!![]}];}return db[_0xeb37('0x2e')]['findAll'](_0x416fac);})[_0xeb37('0x28')](function(_0x3c9829){_0x2978ff['rows']=_0x3c9829;return _0x2978ff;})[_0xeb37('0x28')](respondWithFilteredResult(_0x3b8613,_0x416fac))[_0xeb37('0x42')](handleError(_0x3b8613,null));};exports[_0xeb37('0x43')]=function(_0x2000be,_0x175d8c){var _0x109bc3={'raw':!![],'where':{'id':_0x2000be['params']['id']}},_0x231afb={};_0x231afb['model']=_[_0xeb37('0x44')](db['ZohoField']['rawAttributes']);_0x231afb[_0xeb37('0x34')]=_[_0xeb37('0x44')](_0x2000be['query']);_0x231afb[_0xeb37('0x3c')]=_[_0xeb37('0x35')](_0x231afb[_0xeb37('0x33')],_0x231afb[_0xeb37('0x34')]);_0x109bc3['attributes']=_[_0xeb37('0x35')](_0x231afb[_0xeb37('0x33')],qs[_0xeb37('0x36')](_0x2000be[_0xeb37('0x34')][_0xeb37('0x36')]));_0x109bc3[_0xeb37('0x37')]=_0x109bc3[_0xeb37('0x37')]['length']?_0x109bc3[_0xeb37('0x37')]:_0x231afb[_0xeb37('0x33')];if(_0x2000be[_0xeb37('0x34')][_0xeb37('0x45')]){_0x109bc3[_0xeb37('0x46')]=[{'all':!![]}];}_0x109bc3=_['merge']({},_0x109bc3,_0x2000be['options']);return db['ZohoField'][_0xeb37('0x47')](_0x109bc3)[_0xeb37('0x28')](handleEntityNotFound(_0x175d8c,null))[_0xeb37('0x28')](respondWithResult(_0x175d8c,null))[_0xeb37('0x42')](handleError(_0x175d8c,null));};exports[_0xeb37('0x48')]=function(_0x5d9b49,_0x20e02e){return db['ZohoField'][_0xeb37('0x48')](_0x5d9b49[_0xeb37('0x49')],{})[_0xeb37('0x28')](respondWithResult(_0x20e02e,0xc9))[_0xeb37('0x42')](handleError(_0x20e02e,null));};exports['update']=function(_0x3f53c8,_0xe901f1){if(_0x3f53c8[_0xeb37('0x49')]['id']){delete _0x3f53c8[_0xeb37('0x49')]['id'];}return db[_0xeb37('0x2e')][_0xeb37('0x47')]({'where':{'id':_0x3f53c8[_0xeb37('0x4a')]['id']}})[_0xeb37('0x28')](handleEntityNotFound(_0xe901f1,null))[_0xeb37('0x28')](saveUpdates(_0x3f53c8[_0xeb37('0x49')],null))[_0xeb37('0x28')](respondWithResult(_0xe901f1,null))['catch'](handleError(_0xe901f1,null));};exports['destroy']=function(_0x3d4a7f,_0x32b798){return db['ZohoField']['find']({'where':{'id':_0x3d4a7f[_0xeb37('0x4a')]['id']}})['then'](handleEntityNotFound(_0x32b798,null))[_0xeb37('0x28')](removeEntity(_0x32b798,null))[_0xeb37('0x42')](handleError(_0x32b798,null));};
\ No newline at end of file