Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index cdc1161..1e7f376 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf036=['request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','jayson/promise','client','http','request','then','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','sendStatus','end','status','count','offset','limit','set','Content-Range','json','apply','reject','save','update','destroy','name','send','index','VtigerConfiguration','rawAttributes','fieldName','type','map','keys','query','filters','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','create','body','find','getFields','findOne','VtigerField','order','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x1837f6,_0x2daff9){var _0x487418=function(_0x1a25ec){while(--_0x1a25ec){_0x1837f6['push'](_0x1837f6['shift']());}};_0x487418(++_0x2daff9);}(_0xf036,0x174));var _0x6f03=function(_0x4065eb,_0x9f4169){_0x4065eb=_0x4065eb-0x0;var _0xe695c1=_0xf036[_0x4065eb];return _0xe695c1;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6f03('0x0'));var rimraf=require(_0x6f03('0x1'));var zipdir=require(_0x6f03('0x2'));var jsonpatch=require(_0x6f03('0x3'));var rp=require(_0x6f03('0x4'));var moment=require('moment');var BPromise=require(_0x6f03('0x5'));var Mustache=require(_0x6f03('0x6'));var util=require(_0x6f03('0x7'));var path=require(_0x6f03('0x8'));var sox=require(_0x6f03('0x9'));var csv=require(_0x6f03('0xa'));var ejs=require(_0x6f03('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6f03('0xc'));var crypto=require('crypto');var jsforce=require(_0x6f03('0xd'));var deskjs=require(_0x6f03('0xe'));var toCsv=require(_0x6f03('0xa'));var querystring=require(_0x6f03('0xf'));var Papa=require(_0x6f03('0x10'));var Redis=require(_0x6f03('0x11'));var authService=require(_0x6f03('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x6f03('0x13'));var hardwareService=require(_0x6f03('0x14'));var logger=require(_0x6f03('0x15'))(_0x6f03('0x16'));var utils=require(_0x6f03('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x6f03('0x18'))['db'];var jayson=require(_0x6f03('0x19'));var client=jayson[_0x6f03('0x1a')][_0x6f03('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x5732bc,_0x3954ed,_0x2d62d8,_0x5c4579){return new BPromise(function(_0xae8102,_0x238c82){var _0xcf65aa=_0x5c4579||client;return _0xcf65aa[_0x6f03('0x1c')](_0x5732bc,_0x2d62d8)[_0x6f03('0x1d')](function(_0x1fac75){logger['info'](_0x6f03('0x1e'),_0x3954ed,_0x6f03('0x1f'));logger[_0x6f03('0x20')](_0x6f03('0x21'),_0x3954ed,_0x6f03('0x1f'),JSON[_0x6f03('0x22')](_0x1fac75));if(_0x1fac75[_0x6f03('0x23')]){if(_0x1fac75[_0x6f03('0x23')][_0x6f03('0x24')]===0x1f4){logger[_0x6f03('0x23')](_0x6f03('0x1e'),_0x3954ed,_0x1fac75[_0x6f03('0x23')][_0x6f03('0x25')]);return _0x238c82(_0x1fac75[_0x6f03('0x23')][_0x6f03('0x25')]);}logger[_0x6f03('0x23')]('VtigerConfiguration,\x20%s,\x20%s',_0x3954ed,_0x1fac75[_0x6f03('0x23')]['message']);return _0xae8102(_0x1fac75[_0x6f03('0x23')]['message']);}else{logger[_0x6f03('0x26')](_0x6f03('0x1e'),_0x3954ed,_0x6f03('0x1f'));_0xae8102(_0x1fac75['result'][_0x6f03('0x25')]);}})[_0x6f03('0x27')](function(_0xa668f2){logger[_0x6f03('0x23')](_0x6f03('0x1e'),_0x3954ed,_0xa668f2);_0x238c82(_0xa668f2);});});}function respondWithStatusCode(_0x458bdc,_0xf4bb55){_0xf4bb55=_0xf4bb55||0xcc;return function(_0x1fa39b){if(_0x1fa39b){return _0x458bdc[_0x6f03('0x28')](_0xf4bb55);}return _0x458bdc['status'](_0xf4bb55)[_0x6f03('0x29')]();};}function respondWithResult(_0x3694c6,_0x12f84a){_0x12f84a=_0x12f84a||0xc8;return function(_0x1c9584){if(_0x1c9584){return _0x3694c6[_0x6f03('0x2a')](_0x12f84a)['json'](_0x1c9584);}};}function respondWithFilteredResult(_0x5a7735,_0x5f071f){return function(_0x92f319){if(_0x92f319){var _0x425dbb=_0x92f319[_0x6f03('0x2b')],_0x1af00b=_0x5f071f[_0x6f03('0x2c')],_0x4ab8b5=_0x5f071f[_0x6f03('0x2c')]+_0x5f071f[_0x6f03('0x2d')],_0x5c0857;if(_0x4ab8b5>=_0x425dbb){_0x4ab8b5=_0x425dbb;_0x5c0857=0xc8;}else{_0x5c0857=0xce;}_0x5a7735[_0x6f03('0x2a')](_0x5c0857);return _0x5a7735[_0x6f03('0x2e')](_0x6f03('0x2f'),_0x1af00b+'-'+_0x4ab8b5+'/'+_0x425dbb)[_0x6f03('0x30')](_0x92f319);}return null;};}function patchUpdates(_0x13361c){return function(_0x309259){try{jsonpatch[_0x6f03('0x31')](_0x309259,_0x13361c,!![]);}catch(_0x2192fa){return BPromise[_0x6f03('0x32')](_0x2192fa);}return _0x309259[_0x6f03('0x33')]();};}function saveUpdates(_0x21811b,_0x5f5c93){return function(_0x1dfea8){if(_0x1dfea8){return _0x1dfea8[_0x6f03('0x34')](_0x21811b)[_0x6f03('0x1d')](function(_0x55d433){return _0x55d433;});}return null;};}function removeEntity(_0x441db0,_0x4d079f){return function(_0xf82f07){if(_0xf82f07){return _0xf82f07[_0x6f03('0x35')]()[_0x6f03('0x1d')](function(){_0x441db0[_0x6f03('0x2a')](0xcc)[_0x6f03('0x29')]();});}};}function handleEntityNotFound(_0x18084e,_0x149782){return function(_0x52915a){if(!_0x52915a){_0x18084e['sendStatus'](0x194);}return _0x52915a;};}function handleError(_0x11ae27,_0x8385c9){_0x8385c9=_0x8385c9||0x1f4;return function(_0x170ef2){logger['error'](_0x170ef2['stack']);if(_0x170ef2[_0x6f03('0x36')]){delete _0x170ef2[_0x6f03('0x36')];}_0x11ae27['status'](_0x8385c9)[_0x6f03('0x37')](_0x170ef2);};}exports[_0x6f03('0x38')]=function(_0x27550a,_0x3bb769){var _0x241207={},_0x161079={},_0x15971d={'count':0x0,'rows':[]};var _0x2729d3=_['map'](db[_0x6f03('0x39')][_0x6f03('0x3a')],function(_0x50ed60){return{'name':_0x50ed60[_0x6f03('0x3b')],'type':_0x50ed60[_0x6f03('0x3c')]['key']};});_0x161079['model']=_[_0x6f03('0x3d')](_0x2729d3,_0x6f03('0x36'));_0x161079['query']=_[_0x6f03('0x3e')](_0x27550a[_0x6f03('0x3f')]);_0x161079[_0x6f03('0x40')]=_['intersection'](_0x161079['model'],_0x161079['query']);_0x241207[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x161079[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x27550a[_0x6f03('0x3f')]['fields']));_0x241207['attributes']=_0x241207[_0x6f03('0x41')][_0x6f03('0x45')]?_0x241207[_0x6f03('0x41')]:_0x161079[_0x6f03('0x43')];if(!_0x27550a[_0x6f03('0x3f')][_0x6f03('0x46')](_0x6f03('0x47'))){_0x241207[_0x6f03('0x2d')]=qs[_0x6f03('0x2d')](_0x27550a[_0x6f03('0x3f')][_0x6f03('0x2d')]);_0x241207[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x27550a[_0x6f03('0x3f')]['offset']);}_0x241207['order']=qs['sort'](_0x27550a[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x241207[_0x6f03('0x49')]=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x27550a[_0x6f03('0x3f')],_0x161079[_0x6f03('0x40')]),_0x2729d3);if(_0x27550a['query'][_0x6f03('0x4b')]){_0x241207[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x241207[_0x6f03('0x49')],{'$or':_[_0x6f03('0x3d')](_0x2729d3,function(_0x2e5e08){if(_0x2e5e08[_0x6f03('0x3c')]!==_0x6f03('0x4d')){var _0x2adab4={};_0x2adab4[_0x2e5e08[_0x6f03('0x36')]]={'$like':'%'+_0x27550a['query'][_0x6f03('0x4b')]+'%'};return _0x2adab4;}})});}_0x241207=_[_0x6f03('0x4c')]({},_0x241207,_0x27550a[_0x6f03('0x4e')]);var _0x5d9a0c={'where':_0x241207[_0x6f03('0x49')]};return db[_0x6f03('0x39')][_0x6f03('0x2b')](_0x5d9a0c)[_0x6f03('0x1d')](function(_0x4144d1){_0x15971d[_0x6f03('0x2b')]=_0x4144d1;if(_0x27550a[_0x6f03('0x3f')][_0x6f03('0x4f')]){_0x241207[_0x6f03('0x50')]=[{'all':!![]}];}return db['VtigerConfiguration'][_0x6f03('0x51')](_0x241207);})['then'](function(_0x2f2a23){_0x15971d[_0x6f03('0x52')]=_0x2f2a23;return _0x15971d;})[_0x6f03('0x1d')](respondWithFilteredResult(_0x3bb769,_0x241207))[_0x6f03('0x27')](handleError(_0x3bb769,null));};exports[_0x6f03('0x53')]=function(_0x103134,_0x212846){var _0x468a75={'raw':![],'where':{'id':_0x103134[_0x6f03('0x54')]['id']}},_0x104c74={};_0x104c74[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x39')][_0x6f03('0x3a')]);_0x104c74[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x103134['query']);_0x104c74[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x104c74[_0x6f03('0x43')],_0x104c74[_0x6f03('0x3f')]);_0x468a75['attributes']=_[_0x6f03('0x42')](_0x104c74[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x103134[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x468a75[_0x6f03('0x41')]=_0x468a75[_0x6f03('0x41')][_0x6f03('0x45')]?_0x468a75[_0x6f03('0x41')]:_0x104c74[_0x6f03('0x43')];if(_0x103134['query'][_0x6f03('0x4f')]){_0x468a75[_0x6f03('0x50')]=[{'all':!![]}];}_0x468a75=_[_0x6f03('0x4c')]({},_0x468a75,_0x103134[_0x6f03('0x4e')]);return db[_0x6f03('0x39')]['find'](_0x468a75)['then'](handleEntityNotFound(_0x212846,null))[_0x6f03('0x1d')](respondWithResult(_0x212846,null))[_0x6f03('0x27')](handleError(_0x212846,null));};exports[_0x6f03('0x55')]=function(_0xccb399,_0x133592){return db[_0x6f03('0x39')][_0x6f03('0x55')](_0xccb399[_0x6f03('0x56')],{})[_0x6f03('0x1d')](respondWithResult(_0x133592,0xc9))[_0x6f03('0x27')](handleError(_0x133592,null));};exports[_0x6f03('0x34')]=function(_0x29a346,_0x438606){if(_0x29a346[_0x6f03('0x56')]['id']){delete _0x29a346[_0x6f03('0x56')]['id'];}return db[_0x6f03('0x39')][_0x6f03('0x57')]({'where':{'id':_0x29a346[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x438606,null))[_0x6f03('0x1d')](saveUpdates(_0x29a346[_0x6f03('0x56')],null))['then'](respondWithResult(_0x438606,null))[_0x6f03('0x27')](handleError(_0x438606,null));};exports['destroy']=function(_0x28f67d,_0x9175d3){return db[_0x6f03('0x39')][_0x6f03('0x57')]({'where':{'id':_0x28f67d[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x9175d3,null))[_0x6f03('0x1d')](removeEntity(_0x9175d3,null))[_0x6f03('0x27')](handleError(_0x9175d3,null));};exports[_0x6f03('0x58')]=function(_0x2308fa,_0x214555,_0x5f5402){var _0x3028e1={};var _0x52532f={};var _0x44b8e1;var _0x1c4243;return db['VtigerConfiguration'][_0x6f03('0x59')]({'where':{'id':_0x2308fa[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x214555,null))['then'](function(_0x4362a0){if(_0x4362a0){_0x44b8e1=_0x4362a0;_0x52532f['model']=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')][_0x6f03('0x3a')]);_0x52532f[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x2308fa[_0x6f03('0x3f')]);_0x52532f[_0x6f03('0x40')]=_['intersection'](_0x52532f['model'],_0x52532f[_0x6f03('0x3f')]);_0x3028e1[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x52532f['model'],qs[_0x6f03('0x44')](_0x2308fa[_0x6f03('0x3f')]['fields']));_0x3028e1[_0x6f03('0x41')]=_0x3028e1[_0x6f03('0x41')][_0x6f03('0x45')]?_0x3028e1[_0x6f03('0x41')]:_0x52532f[_0x6f03('0x43')];_0x3028e1[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x3028e1[_0x6f03('0x49')]=qs['filters'](_[_0x6f03('0x4a')](_0x2308fa[_0x6f03('0x3f')],_0x52532f[_0x6f03('0x40')]));if(_0x2308fa[_0x6f03('0x3f')]['filter']){_0x3028e1[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x3028e1['where'],{'$or':_[_0x6f03('0x3d')](_0x3028e1['attributes'],function(_0x4df7d8){var _0x956210={};_0x956210[_0x4df7d8]={'$like':'%'+_0x2308fa['query'][_0x6f03('0x4b')]+'%'};return _0x956210;})});}_0x3028e1=_[_0x6f03('0x4c')]({},_0x3028e1,_0x2308fa[_0x6f03('0x4e')]);return _0x44b8e1['getFields'](_0x3028e1);}})['then'](function(_0x100dd3){if(_0x100dd3){_0x1c4243=_0x100dd3['length'];if(!_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x46')]('nolimit')){_0x3028e1[_0x6f03('0x2d')]=qs[_0x6f03('0x2d')](_0x2308fa['query'][_0x6f03('0x2d')]);_0x3028e1[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x2c')]);}return _0x44b8e1[_0x6f03('0x58')](_0x3028e1);}})[_0x6f03('0x1d')](function(_0x2040ac){if(_0x2040ac){return _0x2040ac?{'count':_0x1c4243,'rows':_0x2040ac}:null;}})[_0x6f03('0x1d')](respondWithResult(_0x214555,null))[_0x6f03('0x27')](handleError(_0x214555,null));};exports[_0x6f03('0x5c')]=function(_0x134e3e,_0x507096,_0x156b37){var _0x2a8723={};var _0x2b78e4={};var _0x4b5ed8;var _0x3f98f9;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x134e3e[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x507096,null))[_0x6f03('0x1d')](function(_0x4bbbea){if(_0x4bbbea){_0x4b5ed8=_0x4bbbea;_0x2b78e4[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')]['rawAttributes']);_0x2b78e4[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x134e3e[_0x6f03('0x3f')]);_0x2b78e4[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x2b78e4[_0x6f03('0x43')],_0x2b78e4[_0x6f03('0x3f')]);_0x2a8723[_0x6f03('0x41')]=_['intersection'](_0x2b78e4[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x2a8723[_0x6f03('0x41')]=_0x2a8723['attributes']['length']?_0x2a8723['attributes']:_0x2b78e4[_0x6f03('0x43')];_0x2a8723[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x2a8723['where']=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x134e3e[_0x6f03('0x3f')],_0x2b78e4[_0x6f03('0x40')]));if(_0x134e3e[_0x6f03('0x3f')]['filter']){_0x2a8723[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x2a8723[_0x6f03('0x49')],{'$or':_['map'](_0x2a8723[_0x6f03('0x41')],function(_0x33d11a){var _0xf05ddb={};_0xf05ddb[_0x33d11a]={'$like':'%'+_0x134e3e['query']['filter']+'%'};return _0xf05ddb;})});}_0x2a8723=_['merge']({},_0x2a8723,_0x134e3e[_0x6f03('0x4e')]);return _0x4b5ed8[_0x6f03('0x5c')](_0x2a8723);}})[_0x6f03('0x1d')](function(_0x3a6bcf){if(_0x3a6bcf){_0x3f98f9=_0x3a6bcf['length'];if(!_0x134e3e['query']['hasOwnProperty'](_0x6f03('0x47'))){_0x2a8723['limit']=qs['limit'](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x2d')]);_0x2a8723['offset']=qs[_0x6f03('0x2c')](_0x134e3e[_0x6f03('0x3f')]['offset']);}return _0x4b5ed8[_0x6f03('0x5c')](_0x2a8723);}})[_0x6f03('0x1d')](function(_0x1105b6){if(_0x1105b6){return _0x1105b6?{'count':_0x3f98f9,'rows':_0x1105b6}:null;}})[_0x6f03('0x1d')](respondWithResult(_0x507096,null))[_0x6f03('0x27')](handleError(_0x507096,null));};exports[_0x6f03('0x5d')]=function(_0x163fc9,_0xf4b166,_0x1650da){var _0x13ce94={};var _0x273096={};var _0x42a944;var _0x4c09f2;return db[_0x6f03('0x39')][_0x6f03('0x59')]({'where':{'id':_0x163fc9[_0x6f03('0x54')]['id']}})['then'](handleEntityNotFound(_0xf4b166,null))['then'](function(_0x440bac){if(_0x440bac){_0x42a944=_0x440bac;_0x273096[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')][_0x6f03('0x3a')]);_0x273096[_0x6f03('0x3f')]=_['keys'](_0x163fc9[_0x6f03('0x3f')]);_0x273096[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x273096[_0x6f03('0x43')],_0x273096[_0x6f03('0x3f')]);_0x13ce94[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x273096[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x13ce94['attributes']=_0x13ce94['attributes'][_0x6f03('0x45')]?_0x13ce94[_0x6f03('0x41')]:_0x273096['model'];_0x13ce94[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x13ce94[_0x6f03('0x49')]=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x163fc9[_0x6f03('0x3f')],_0x273096[_0x6f03('0x40')]));if(_0x163fc9[_0x6f03('0x3f')]['filter']){_0x13ce94[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x13ce94['where'],{'$or':_[_0x6f03('0x3d')](_0x13ce94[_0x6f03('0x41')],function(_0x75914a){var _0x1e9def={};_0x1e9def[_0x75914a]={'$like':'%'+_0x163fc9[_0x6f03('0x3f')]['filter']+'%'};return _0x1e9def;})});}_0x13ce94=_[_0x6f03('0x4c')]({},_0x13ce94,_0x163fc9[_0x6f03('0x4e')]);return _0x42a944[_0x6f03('0x5d')](_0x13ce94);}})[_0x6f03('0x1d')](function(_0x46af2c){if(_0x46af2c){_0x4c09f2=_0x46af2c[_0x6f03('0x45')];if(!_0x163fc9[_0x6f03('0x3f')]['hasOwnProperty'](_0x6f03('0x47'))){_0x13ce94[_0x6f03('0x2d')]=qs['limit'](_0x163fc9['query'][_0x6f03('0x2d')]);_0x13ce94[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x2c')]);}return _0x42a944['getDescriptions'](_0x13ce94);}})[_0x6f03('0x1d')](function(_0x18a8e5){if(_0x18a8e5){return _0x18a8e5?{'count':_0x4c09f2,'rows':_0x18a8e5}:null;}})['then'](respondWithResult(_0xf4b166,null))[_0x6f03('0x27')](handleError(_0xf4b166,null));};
\ No newline at end of file
+var _0x04cc=['getSubjects','getDescriptions','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','request\x20sent','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','VtigerConfiguration,\x20%s,\x20%s','message','result','catch','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','stack','name','send','index','VtigerConfiguration','rawAttributes','fieldName','type','model','map','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','filter','where','merge','options','includeAll','findAll','rows','show','params','keys','include','create','body','find','getFields','findOne','pick'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0x04cc,0x10d));var _0xc04c=function(_0x1621dd,_0x172229){_0x1621dd=_0x1621dd-0x0;var _0x3b0046=_0x04cc[_0x1621dd];return _0x3b0046;};'use strict';var pdf=require(_0xc04c('0x0'));var emlformat=require(_0xc04c('0x1'));var rimraf=require(_0xc04c('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xc04c('0x3'));var rp=require(_0xc04c('0x4'));var moment=require(_0xc04c('0x5'));var BPromise=require(_0xc04c('0x6'));var Mustache=require(_0xc04c('0x7'));var util=require('util');var path=require(_0xc04c('0x8'));var sox=require('sox');var csv=require(_0xc04c('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xc04c('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xc04c('0xb'));var deskjs=require(_0xc04c('0xc'));var toCsv=require(_0xc04c('0x9'));var querystring=require(_0xc04c('0xd'));var Papa=require(_0xc04c('0xe'));var Redis=require(_0xc04c('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xc04c('0x10'));var as=require(_0xc04c('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc04c('0x12'))('api');var utils=require(_0xc04c('0x13'));var config=require(_0xc04c('0x14'));var licenseUtil=require(_0xc04c('0x15'));var db=require(_0xc04c('0x16'))['db'];var jayson=require(_0xc04c('0x17'));var client=jayson[_0xc04c('0x18')][_0xc04c('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x11adcc,_0x5bbd7f,_0x76eb56,_0x1ab9c5){return new BPromise(function(_0x300305,_0x33e121){var _0x4da4c0=_0x1ab9c5||client;return _0x4da4c0[_0xc04c('0x1a')](_0x11adcc,_0x76eb56)[_0xc04c('0x1b')](function(_0x42c342){logger[_0xc04c('0x1c')]('VtigerConfiguration,\x20%s,\x20%s',_0x5bbd7f,_0xc04c('0x1d'));logger['debug'](_0xc04c('0x1e'),_0x5bbd7f,_0xc04c('0x1d'),JSON[_0xc04c('0x1f')](_0x42c342));if(_0x42c342[_0xc04c('0x20')]){if(_0x42c342[_0xc04c('0x20')]['code']===0x1f4){logger[_0xc04c('0x20')](_0xc04c('0x21'),_0x5bbd7f,_0x42c342[_0xc04c('0x20')][_0xc04c('0x22')]);return _0x33e121(_0x42c342[_0xc04c('0x20')][_0xc04c('0x22')]);}logger['error'](_0xc04c('0x21'),_0x5bbd7f,_0x42c342[_0xc04c('0x20')]['message']);return _0x300305(_0x42c342[_0xc04c('0x20')]['message']);}else{logger[_0xc04c('0x1c')](_0xc04c('0x21'),_0x5bbd7f,_0xc04c('0x1d'));_0x300305(_0x42c342[_0xc04c('0x23')][_0xc04c('0x22')]);}})[_0xc04c('0x24')](function(_0x2c1a78){logger[_0xc04c('0x20')](_0xc04c('0x21'),_0x5bbd7f,_0x2c1a78);_0x33e121(_0x2c1a78);});});}function respondWithStatusCode(_0x2dac80,_0x5a847a){_0x5a847a=_0x5a847a||0xcc;return function(_0x51ad1d){if(_0x51ad1d){return _0x2dac80['sendStatus'](_0x5a847a);}return _0x2dac80[_0xc04c('0x25')](_0x5a847a)[_0xc04c('0x26')]();};}function respondWithResult(_0x28e7b6,_0x2d72c6){_0x2d72c6=_0x2d72c6||0xc8;return function(_0x1bfe35){if(_0x1bfe35){return _0x28e7b6[_0xc04c('0x25')](_0x2d72c6)[_0xc04c('0x27')](_0x1bfe35);}};}function respondWithFilteredResult(_0x5db434,_0x3cf428){return function(_0xa467a0){if(_0xa467a0){var _0x5e67b0=_0xa467a0[_0xc04c('0x28')],_0x432355=_0x3cf428[_0xc04c('0x29')],_0x1ffb21=_0x3cf428[_0xc04c('0x29')]+_0x3cf428[_0xc04c('0x2a')],_0x521067;if(_0x1ffb21>=_0x5e67b0){_0x1ffb21=_0x5e67b0;_0x521067=0xc8;}else{_0x521067=0xce;}_0x5db434[_0xc04c('0x25')](_0x521067);return _0x5db434[_0xc04c('0x2b')](_0xc04c('0x2c'),_0x432355+'-'+_0x1ffb21+'/'+_0x5e67b0)[_0xc04c('0x27')](_0xa467a0);}return null;};}function patchUpdates(_0xefaabb){return function(_0x1b9862){try{jsonpatch[_0xc04c('0x2d')](_0x1b9862,_0xefaabb,!![]);}catch(_0x2023fe){return BPromise[_0xc04c('0x2e')](_0x2023fe);}return _0x1b9862[_0xc04c('0x2f')]();};}function saveUpdates(_0x53607c,_0x575d18){return function(_0x25014e){if(_0x25014e){return _0x25014e[_0xc04c('0x30')](_0x53607c)[_0xc04c('0x1b')](function(_0x2811d1){return _0x2811d1;});}return null;};}function removeEntity(_0x54fc24,_0x4cfc98){return function(_0x52587a){if(_0x52587a){return _0x52587a[_0xc04c('0x31')]()[_0xc04c('0x1b')](function(){_0x54fc24[_0xc04c('0x25')](0xcc)[_0xc04c('0x26')]();});}};}function handleEntityNotFound(_0x1957df,_0x55144d){return function(_0x47b788){if(!_0x47b788){_0x1957df['sendStatus'](0x194);}return _0x47b788;};}function handleError(_0x3d421c,_0x5945f7){_0x5945f7=_0x5945f7||0x1f4;return function(_0x32ddd2){logger[_0xc04c('0x20')](_0x32ddd2[_0xc04c('0x32')]);if(_0x32ddd2['name']){delete _0x32ddd2[_0xc04c('0x33')];}_0x3d421c[_0xc04c('0x25')](_0x5945f7)[_0xc04c('0x34')](_0x32ddd2);};}exports[_0xc04c('0x35')]=function(_0x4a348a,_0x5278e8){var _0x370e0d={},_0x2ac5f2={},_0x34446a={'count':0x0,'rows':[]};var _0x9c7b57=_['map'](db[_0xc04c('0x36')][_0xc04c('0x37')],function(_0x3628b4){return{'name':_0x3628b4[_0xc04c('0x38')],'type':_0x3628b4[_0xc04c('0x39')]['key']};});_0x2ac5f2[_0xc04c('0x3a')]=_[_0xc04c('0x3b')](_0x9c7b57,_0xc04c('0x33'));_0x2ac5f2['query']=_['keys'](_0x4a348a['query']);_0x2ac5f2['filters']=_[_0xc04c('0x3c')](_0x2ac5f2[_0xc04c('0x3a')],_0x2ac5f2[_0xc04c('0x3d')]);_0x370e0d[_0xc04c('0x3e')]=_[_0xc04c('0x3c')](_0x2ac5f2[_0xc04c('0x3a')],qs['fields'](_0x4a348a['query'][_0xc04c('0x3f')]));_0x370e0d[_0xc04c('0x3e')]=_0x370e0d[_0xc04c('0x3e')][_0xc04c('0x40')]?_0x370e0d[_0xc04c('0x3e')]:_0x2ac5f2[_0xc04c('0x3a')];if(!_0x4a348a['query'][_0xc04c('0x41')](_0xc04c('0x42'))){_0x370e0d[_0xc04c('0x2a')]=qs[_0xc04c('0x2a')](_0x4a348a[_0xc04c('0x3d')][_0xc04c('0x2a')]);_0x370e0d[_0xc04c('0x29')]=qs[_0xc04c('0x29')](_0x4a348a[_0xc04c('0x3d')][_0xc04c('0x29')]);}_0x370e0d[_0xc04c('0x43')]=qs['sort'](_0x4a348a[_0xc04c('0x3d')][_0xc04c('0x44')]);_0x370e0d['where']=qs['filters'](_['pick'](_0x4a348a[_0xc04c('0x3d')],_0x2ac5f2[_0xc04c('0x45')]),_0x9c7b57);if(_0x4a348a[_0xc04c('0x3d')][_0xc04c('0x46')]){_0x370e0d[_0xc04c('0x47')]=_[_0xc04c('0x48')](_0x370e0d[_0xc04c('0x47')],{'$or':_[_0xc04c('0x3b')](_0x9c7b57,function(_0x1727ad){if(_0x1727ad[_0xc04c('0x39')]!=='VIRTUAL'){var _0x518915={};_0x518915[_0x1727ad[_0xc04c('0x33')]]={'$like':'%'+_0x4a348a[_0xc04c('0x3d')][_0xc04c('0x46')]+'%'};return _0x518915;}})});}_0x370e0d=_['merge']({},_0x370e0d,_0x4a348a[_0xc04c('0x49')]);var _0x6dd5bf={'where':_0x370e0d[_0xc04c('0x47')]};return db[_0xc04c('0x36')][_0xc04c('0x28')](_0x6dd5bf)[_0xc04c('0x1b')](function(_0x38aa43){_0x34446a[_0xc04c('0x28')]=_0x38aa43;if(_0x4a348a['query'][_0xc04c('0x4a')]){_0x370e0d['include']=[{'all':!![]}];}return db[_0xc04c('0x36')][_0xc04c('0x4b')](_0x370e0d);})[_0xc04c('0x1b')](function(_0x46e010){_0x34446a[_0xc04c('0x4c')]=_0x46e010;return _0x34446a;})[_0xc04c('0x1b')](respondWithFilteredResult(_0x5278e8,_0x370e0d))['catch'](handleError(_0x5278e8,null));};exports[_0xc04c('0x4d')]=function(_0x39d6c5,_0x2e9558){var _0x2a1f32={'raw':![],'where':{'id':_0x39d6c5[_0xc04c('0x4e')]['id']}},_0x464289={};_0x464289['model']=_['keys'](db[_0xc04c('0x36')]['rawAttributes']);_0x464289[_0xc04c('0x3d')]=_[_0xc04c('0x4f')](_0x39d6c5[_0xc04c('0x3d')]);_0x464289[_0xc04c('0x45')]=_[_0xc04c('0x3c')](_0x464289[_0xc04c('0x3a')],_0x464289[_0xc04c('0x3d')]);_0x2a1f32[_0xc04c('0x3e')]=_[_0xc04c('0x3c')](_0x464289[_0xc04c('0x3a')],qs['fields'](_0x39d6c5[_0xc04c('0x3d')]['fields']));_0x2a1f32[_0xc04c('0x3e')]=_0x2a1f32['attributes'][_0xc04c('0x40')]?_0x2a1f32[_0xc04c('0x3e')]:_0x464289['model'];if(_0x39d6c5[_0xc04c('0x3d')][_0xc04c('0x4a')]){_0x2a1f32[_0xc04c('0x50')]=[{'all':!![]}];}_0x2a1f32=_[_0xc04c('0x48')]({},_0x2a1f32,_0x39d6c5[_0xc04c('0x49')]);return db[_0xc04c('0x36')]['find'](_0x2a1f32)[_0xc04c('0x1b')](handleEntityNotFound(_0x2e9558,null))[_0xc04c('0x1b')](respondWithResult(_0x2e9558,null))[_0xc04c('0x24')](handleError(_0x2e9558,null));};exports[_0xc04c('0x51')]=function(_0xf39a39,_0x324724){return db[_0xc04c('0x36')]['create'](_0xf39a39[_0xc04c('0x52')],{})[_0xc04c('0x1b')](respondWithResult(_0x324724,0xc9))['catch'](handleError(_0x324724,null));};exports[_0xc04c('0x30')]=function(_0x32ec6d,_0xff895f){if(_0x32ec6d[_0xc04c('0x52')]['id']){delete _0x32ec6d[_0xc04c('0x52')]['id'];}return db[_0xc04c('0x36')][_0xc04c('0x53')]({'where':{'id':_0x32ec6d[_0xc04c('0x4e')]['id']}})[_0xc04c('0x1b')](handleEntityNotFound(_0xff895f,null))[_0xc04c('0x1b')](saveUpdates(_0x32ec6d['body'],null))['then'](respondWithResult(_0xff895f,null))[_0xc04c('0x24')](handleError(_0xff895f,null));};exports[_0xc04c('0x31')]=function(_0x4f8969,_0x1ced0e){return db[_0xc04c('0x36')][_0xc04c('0x53')]({'where':{'id':_0x4f8969['params']['id']}})[_0xc04c('0x1b')](handleEntityNotFound(_0x1ced0e,null))['then'](removeEntity(_0x1ced0e,null))[_0xc04c('0x24')](handleError(_0x1ced0e,null));};exports[_0xc04c('0x54')]=function(_0x24368e,_0x5caac0,_0x2c207f){var _0x5094ce={};var _0x17ef62={};var _0x3d7a27;var _0x5a53e5;return db[_0xc04c('0x36')][_0xc04c('0x55')]({'where':{'id':_0x24368e['params']['id']}})[_0xc04c('0x1b')](handleEntityNotFound(_0x5caac0,null))[_0xc04c('0x1b')](function(_0x189394){if(_0x189394){_0x3d7a27=_0x189394;_0x17ef62[_0xc04c('0x3a')]=_[_0xc04c('0x4f')](db['VtigerField']['rawAttributes']);_0x17ef62[_0xc04c('0x3d')]=_[_0xc04c('0x4f')](_0x24368e[_0xc04c('0x3d')]);_0x17ef62[_0xc04c('0x45')]=_[_0xc04c('0x3c')](_0x17ef62[_0xc04c('0x3a')],_0x17ef62[_0xc04c('0x3d')]);_0x5094ce['attributes']=_[_0xc04c('0x3c')](_0x17ef62[_0xc04c('0x3a')],qs[_0xc04c('0x3f')](_0x24368e[_0xc04c('0x3d')][_0xc04c('0x3f')]));_0x5094ce[_0xc04c('0x3e')]=_0x5094ce[_0xc04c('0x3e')][_0xc04c('0x40')]?_0x5094ce[_0xc04c('0x3e')]:_0x17ef62[_0xc04c('0x3a')];_0x5094ce[_0xc04c('0x43')]=qs[_0xc04c('0x44')](_0x24368e[_0xc04c('0x3d')][_0xc04c('0x44')]);_0x5094ce[_0xc04c('0x47')]=qs[_0xc04c('0x45')](_[_0xc04c('0x56')](_0x24368e[_0xc04c('0x3d')],_0x17ef62[_0xc04c('0x45')]));if(_0x24368e[_0xc04c('0x3d')]['filter']){_0x5094ce[_0xc04c('0x47')]=_['merge'](_0x5094ce[_0xc04c('0x47')],{'$or':_[_0xc04c('0x3b')](_0x5094ce['attributes'],function(_0x41b88a){var _0x3e6c09={};_0x3e6c09[_0x41b88a]={'$like':'%'+_0x24368e['query'][_0xc04c('0x46')]+'%'};return _0x3e6c09;})});}_0x5094ce=_[_0xc04c('0x48')]({},_0x5094ce,_0x24368e['options']);return _0x3d7a27[_0xc04c('0x54')](_0x5094ce);}})['then'](function(_0x1653a2){if(_0x1653a2){_0x5a53e5=_0x1653a2[_0xc04c('0x40')];if(!_0x24368e[_0xc04c('0x3d')]['hasOwnProperty'](_0xc04c('0x42'))){_0x5094ce[_0xc04c('0x2a')]=qs[_0xc04c('0x2a')](_0x24368e['query'][_0xc04c('0x2a')]);_0x5094ce['offset']=qs[_0xc04c('0x29')](_0x24368e['query']['offset']);}return _0x3d7a27[_0xc04c('0x54')](_0x5094ce);}})[_0xc04c('0x1b')](function(_0x330e2a){if(_0x330e2a){return _0x330e2a?{'count':_0x5a53e5,'rows':_0x330e2a}:null;}})[_0xc04c('0x1b')](respondWithResult(_0x5caac0,null))[_0xc04c('0x24')](handleError(_0x5caac0,null));};exports[_0xc04c('0x57')]=function(_0x39ec0f,_0x5e9435,_0x3174bd){var _0x28c20f={};var _0x3e378f={};var _0x695629;var _0x286a47;return db[_0xc04c('0x36')]['findOne']({'where':{'id':_0x39ec0f['params']['id']}})[_0xc04c('0x1b')](handleEntityNotFound(_0x5e9435,null))['then'](function(_0x43b46e){if(_0x43b46e){_0x695629=_0x43b46e;_0x3e378f[_0xc04c('0x3a')]=_['keys'](db['VtigerField'][_0xc04c('0x37')]);_0x3e378f[_0xc04c('0x3d')]=_[_0xc04c('0x4f')](_0x39ec0f[_0xc04c('0x3d')]);_0x3e378f[_0xc04c('0x45')]=_['intersection'](_0x3e378f[_0xc04c('0x3a')],_0x3e378f['query']);_0x28c20f[_0xc04c('0x3e')]=_[_0xc04c('0x3c')](_0x3e378f[_0xc04c('0x3a')],qs['fields'](_0x39ec0f[_0xc04c('0x3d')][_0xc04c('0x3f')]));_0x28c20f[_0xc04c('0x3e')]=_0x28c20f[_0xc04c('0x3e')]['length']?_0x28c20f[_0xc04c('0x3e')]:_0x3e378f['model'];_0x28c20f['order']=qs['sort'](_0x39ec0f['query'][_0xc04c('0x44')]);_0x28c20f[_0xc04c('0x47')]=qs['filters'](_[_0xc04c('0x56')](_0x39ec0f[_0xc04c('0x3d')],_0x3e378f[_0xc04c('0x45')]));if(_0x39ec0f['query'][_0xc04c('0x46')]){_0x28c20f[_0xc04c('0x47')]=_[_0xc04c('0x48')](_0x28c20f[_0xc04c('0x47')],{'$or':_[_0xc04c('0x3b')](_0x28c20f[_0xc04c('0x3e')],function(_0x3125da){var _0x3c3abf={};_0x3c3abf[_0x3125da]={'$like':'%'+_0x39ec0f['query'][_0xc04c('0x46')]+'%'};return _0x3c3abf;})});}_0x28c20f=_['merge']({},_0x28c20f,_0x39ec0f['options']);return _0x695629[_0xc04c('0x57')](_0x28c20f);}})['then'](function(_0x2c87f3){if(_0x2c87f3){_0x286a47=_0x2c87f3[_0xc04c('0x40')];if(!_0x39ec0f[_0xc04c('0x3d')][_0xc04c('0x41')]('nolimit')){_0x28c20f[_0xc04c('0x2a')]=qs[_0xc04c('0x2a')](_0x39ec0f['query']['limit']);_0x28c20f[_0xc04c('0x29')]=qs['offset'](_0x39ec0f[_0xc04c('0x3d')][_0xc04c('0x29')]);}return _0x695629[_0xc04c('0x57')](_0x28c20f);}})[_0xc04c('0x1b')](function(_0x297910){if(_0x297910){return _0x297910?{'count':_0x286a47,'rows':_0x297910}:null;}})[_0xc04c('0x1b')](respondWithResult(_0x5e9435,null))[_0xc04c('0x24')](handleError(_0x5e9435,null));};exports[_0xc04c('0x58')]=function(_0x359ed4,_0x54b9a2,_0x5e71f7){var _0x40d9ff={};var _0x6302f2={};var _0x8bbcc4;var _0x9b92be;return db[_0xc04c('0x36')][_0xc04c('0x55')]({'where':{'id':_0x359ed4[_0xc04c('0x4e')]['id']}})['then'](handleEntityNotFound(_0x54b9a2,null))[_0xc04c('0x1b')](function(_0x5d350f){if(_0x5d350f){_0x8bbcc4=_0x5d350f;_0x6302f2[_0xc04c('0x3a')]=_[_0xc04c('0x4f')](db['VtigerField'][_0xc04c('0x37')]);_0x6302f2[_0xc04c('0x3d')]=_['keys'](_0x359ed4['query']);_0x6302f2[_0xc04c('0x45')]=_['intersection'](_0x6302f2['model'],_0x6302f2[_0xc04c('0x3d')]);_0x40d9ff[_0xc04c('0x3e')]=_['intersection'](_0x6302f2['model'],qs[_0xc04c('0x3f')](_0x359ed4[_0xc04c('0x3d')][_0xc04c('0x3f')]));_0x40d9ff['attributes']=_0x40d9ff['attributes'][_0xc04c('0x40')]?_0x40d9ff[_0xc04c('0x3e')]:_0x6302f2[_0xc04c('0x3a')];_0x40d9ff[_0xc04c('0x43')]=qs[_0xc04c('0x44')](_0x359ed4['query'][_0xc04c('0x44')]);_0x40d9ff['where']=qs[_0xc04c('0x45')](_[_0xc04c('0x56')](_0x359ed4[_0xc04c('0x3d')],_0x6302f2[_0xc04c('0x45')]));if(_0x359ed4[_0xc04c('0x3d')]['filter']){_0x40d9ff[_0xc04c('0x47')]=_[_0xc04c('0x48')](_0x40d9ff[_0xc04c('0x47')],{'$or':_[_0xc04c('0x3b')](_0x40d9ff[_0xc04c('0x3e')],function(_0x4a7b7a){var _0x17ec23={};_0x17ec23[_0x4a7b7a]={'$like':'%'+_0x359ed4['query'][_0xc04c('0x46')]+'%'};return _0x17ec23;})});}_0x40d9ff=_['merge']({},_0x40d9ff,_0x359ed4[_0xc04c('0x49')]);return _0x8bbcc4[_0xc04c('0x58')](_0x40d9ff);}})['then'](function(_0x4b1dde){if(_0x4b1dde){_0x9b92be=_0x4b1dde[_0xc04c('0x40')];if(!_0x359ed4[_0xc04c('0x3d')][_0xc04c('0x41')](_0xc04c('0x42'))){_0x40d9ff['limit']=qs[_0xc04c('0x2a')](_0x359ed4['query'][_0xc04c('0x2a')]);_0x40d9ff[_0xc04c('0x29')]=qs[_0xc04c('0x29')](_0x359ed4[_0xc04c('0x3d')][_0xc04c('0x29')]);}return _0x8bbcc4[_0xc04c('0x58')](_0x40d9ff);}})[_0xc04c('0x1b')](function(_0x5e94d3){if(_0x5e94d3){return _0x5e94d3?{'count':_0x9b92be,'rows':_0x5e94d3}:null;}})[_0xc04c('0x1b')](respondWithResult(_0x54b9a2,null))['catch'](handleError(_0x54b9a2,null));};
\ No newline at end of file