@gudhub/core 1.0.53 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,7 +75,11 @@ export class GHConstructor {
75
75
  let returningObject = this.parseModule(module, module_id);
76
76
  if(!returningObject) return false;
77
77
  let obj;
78
- eval('obj = ' + returningObject);
78
+ try {
79
+ eval('obj = ' + returningObject);
80
+ } catch(error) {
81
+ console.log(`Error in ghconstructor (${module_id})`, error);
82
+ }
79
83
 
80
84
  let result = {
81
85
  type: module_id,
@@ -84,14 +88,14 @@ export class GHConstructor {
84
88
 
85
89
  getTemplate: function (ref, changeFieldName, displayFieldName, field_model, appId, itemId) {
86
90
  let displayFieldNameChecked = displayFieldName === 'false' ? false : true;
87
- return obj.getTemplate(ref, changeFieldName, displayFieldNameChecked, field_model, appId, itemId);
91
+ return angularModule.getTemplate(ref, changeFieldName, displayFieldNameChecked, field_model, appId, itemId);
88
92
  },
89
93
 
90
94
  //*************** GET DEFAULT VALUE ****************//
91
95
 
92
96
  getDefaultValue: function (fieldModel, valuesArray, itemsList, currentAppId) {
93
97
  return new Promise(async (resolve) => {
94
- let getValueFunction = obj.getDefaultValue;
98
+ let getValueFunction = angularModule.getDefaultValue;
95
99
  if (getValueFunction) {
96
100
  let value = await getValueFunction(fieldModel, valuesArray, itemsList, currentAppId);
97
101
  resolve(value);
@@ -111,14 +115,14 @@ export class GHConstructor {
111
115
 
112
116
  filter: {
113
117
  getSearchOptions: function (fieldModel) {
114
- let d_type = obj;
118
+ let d_type = angularModule;
115
119
  if (d_type.filter && d_type.filter.getSearchOptions) {
116
- return obj.filter.getSearchOptions(fieldModel);
120
+ return angularModule.filter.getSearchOptions(fieldModel);
117
121
  }
118
122
  return [];
119
123
  },
120
124
  getDropdownValues: function () {
121
- let d_type = obj;
125
+ let d_type = angularModule;
122
126
  if (d_type.filter && d_type.filter.getDropdownValues) {
123
127
  return d_type.filter.getDropdownValues();
124
128
  } else {
@@ -152,7 +156,7 @@ export class GHConstructor {
152
156
 
153
157
  getInterpretatedValue: function (field_value, field_model, appId, itemId) {
154
158
  return new Promise(async (resolve) => {
155
- let getInterpretatedValueFunction = obj.getInterpretatedValue;
159
+ let getInterpretatedValueFunction = angularModule.getInterpretatedValue;
156
160
  if (getInterpretatedValueFunction) {
157
161
  let value = await getInterpretatedValueFunction(field_value, field_model, appId, itemId);
158
162
  resolve(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -167,7 +167,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
167
167
  },{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./interpretation/interpretation.js":"pMyP","./nested_list/nested_list.js":"S7Iy","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW"}],"rK64":[function(require,module,exports) {
168
168
  "use strict";function e(e,t,r,n,u,a,s){try{var i=e[a](s),o=i.value}catch(c){return void r(c)}i.done?t(o):Promise.resolve(o).then(n,u)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(u,a){var s=t.apply(r,n);function i(t){e(s,u,a,i,o,"next",t)}function o(t){e(s,u,a,i,o,"throw",t)}i(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var a=function(){function e(t,n){r(this,e),this.req=t,this.storage=n}return u(e,[{key:"login",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.username,r=e.password;return this.req.simplePost({url:"/auth/login",form:{username:t,password:r}})}},{key:"logout",value:function(e){return this.req.post({url:"/auth/logout",form:{token:e}})}},{key:"signup",value:function(e){return this.req.simplePost({url:"/auth/singup",form:{user:JSON.stringify(e)}})}},{key:"getUsersList",value:function(e){return this.req.get({url:"/auth/userlist",params:{keyword:e}})}},{key:"updateUserApi",value:function(e){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(e)}})}},{key:"updateToken",value:function(e){return this.req.simplePost({url:"/auth/login",form:{auth_key:e}})}},{key:"avatarUploadApi",value:function(e){return this.req.post({url:"/auth/avatar-upload",form:{image:e}})}},{key:"getUserByIdApi",value:function(e){return this.req.get({url:"/auth/getuserbyid",params:{id:e}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(e){return this.storage.getUsersList().find(function(t){return t.user_id==e})}},{key:"saveUserToStorage",value:function(e){var t=this.storage.getUsersList(),r=t.find(function(t){return t.user_id==e.user_id});return r||(t.push(e),e)}},{key:"getUserById",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getUserFromStorage(t)){e.next=9;break}return e.next=4,this.getUserByIdApi(t);case 4:if(n=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:(r=this.getUserFromStorage(t))||(this.saveUserToStorage(n),r=n);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getToken",value:function(){var e=t(regeneratorRuntime.mark(function e(){var t,r,n,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=new Date(this.storage.getUser().expirydate),r=new Date,n=this.storage.getUser().accesstoken,!(t<r)&&n){e.next=9;break}return e.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:u=e.sent,this.storage.updateUser(u),n=u.accesstoken;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateUser",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateUserApi(t);case 2:return r=e.sent,this.storage.updateUser(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.avatarUploadApi(t);case 2:return r=e.sent,this.storage.updateUser(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();exports.Auth=a;
169
169
  },{}],"Htuh":[function(require,module,exports) {
170
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GHConstructor=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function asyncGeneratorStep(e,t,n,r,u,o,a){try{var c=e[o](a),i=c.value}catch(s){return void n(s)}c.done?t(i):Promise.resolve(i).then(r,u)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,u){var o=e.apply(t,n);function a(e){asyncGeneratorStep(o,r,u,a,c,"next",e)}function c(e){asyncGeneratorStep(o,r,u,a,c,"throw",e)}a(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var $q={when:function(e){return new Promise(function(t){t(e)})}},GHConstructor=function(){function GHConstructor(){_classCallCheck(this,GHConstructor),this.cache=[],this.modulesQueue={},this.angularInjector}return _createClass(GHConstructor,[{key:"getInstance",value:function(e){var t=this;return new Promise(function(){var n=_asyncToGenerator(regeneratorRuntime.mark(function n(r){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!t.modulesQueue[e]){n.next=4;break}return n.abrupt("return",t.modulesQueue[e].then(function(){r(t.getCached(e))}));case 4:t.cache.find(function(t){return t.type===e})?r(t.getCached(e)):(t.modulesQueue[e]=t.createInstance(e),t.modulesQueue[e].then(function(){r(t.getCached(e))}));case 5:case"end":return n.stop()}},n)}));return function(e){return n.apply(this,arguments)}}())}},{key:"pupToCache",value:function(e){this.cache.push(e)}},{key:"getCached",value:function(e){return this.cache.find(function(t){return t.type===e})}},{key:"initAngularInjector",value:function(e){this.angularInjector=e}},{key:"createInstance",value:function(){var _createInstance=_asyncToGenerator(regeneratorRuntime.mark(function _callee5(module_id){var module_url,angularModule,module,returningObject,obj,result;return regeneratorRuntime.wrap(function _callee5$(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:return module_url=gudhub.storage.getModuleUrl(module_id),_context5.next=3,this.angularInjector.get(module_id);case 3:return angularModule=_context5.sent,_context5.next=6,_axios.default.get(module_url);case 6:if(module=_context5.sent,module=module.data,returningObject=this.parseModule(module,module_id),returningObject){_context5.next=11;break}return _context5.abrupt("return",!1);case 11:return eval("obj = "+returningObject),result={type:module_id,getTemplate:function(e,t,n,r,u,o){var a="false"!==n;return obj.getTemplate(e,t,a,r,u,o)},getDefaultValue:function(e,t,n,r){return new Promise(function(){var u=_asyncToGenerator(regeneratorRuntime.mark(function u(o){var a,c;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(a=obj.getDefaultValue)){u.next=8;break}return u.next=4,a(e,t,n,r);case 4:c=u.sent,o(c),u.next=9;break;case 8:o(null);case 9:case"end":return u.stop()}},u)}));return function(e){return u.apply(this,arguments)}}())},getSettings:function(e,t,n){return angularModule.getSettings(e,t,n)},filter:{getSearchOptions:function(e){var t=obj;return t.filter&&t.filter.getSearchOptions?obj.filter.getSearchOptions(e):[]},getDropdownValues:function(){var e=obj;return e.filter&&e.filter.getDropdownValues?e.filter.getDropdownValues():[]}},getInterpretation:function(e,t,n,r,u,o){return new Promise(function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(c){var i,s,l;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return i=obj,a.next=3,i.getInterpretation(e,t,n,r,u,o);case 3:(s=a.sent)?(l=s.find(function(e){return e.id==r})||s.find(function(e){return"default"==e.id}),c({html:l.html})):c({html:"<span>error(from constructor)</span>"});case 5:case"end":return a.stop()}},a)}));return function(e){return a.apply(this,arguments)}}())},getInterpretatedValue:function(e,t,n,r){return new Promise(function(){var u=_asyncToGenerator(regeneratorRuntime.mark(function u(o){var a,c,i;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(a=obj.getInterpretatedValue)){u.next=8;break}return u.next=4,a(e,t,n,r);case 4:c=u.sent,o(c),u.next=12;break;case 8:return u.next=10,gudhub.getFieldValue(n,r,t.id);case 10:i=u.sent,o(i);case 12:case"end":return u.stop()}},u)}));return function(e){return u.apply(this,arguments)}}())},extendController:function(e){angularModule.getActionScope(e)},runAction:function(e){try{angularModule.runAction(e)}catch(t){}},getWindowScope:function(e){return angularModule.getWindowScope(e)},getWindowHTML:function(e){return angularModule.getWindowHTML(e)}},this.pupToCache(result),_context5.abrupt("return",result);case 15:case"end":return _context5.stop()}},_callee5,this)}));function createInstance(e){return _createInstance.apply(this,arguments)}return createInstance}()},{key:"parseModule",value:function(e,t){var n=e.indexOf(".factory('".concat(t,"',"));if(-1===n&&(n=e.indexOf('.factory("'.concat(t,'",'))),-1!==n){var r=e.substring(n,e.length),u=r.indexOf("return"),o=r.substring(u,r.length),a=o.indexOf("{");o=o.substring(a,o.length);for(var c=0,i=0,s=0,l=0;l<o.length;l++)if("{"===o[l]&&c++,"}"===o[l]&&i++,c===i&&l>=a){s=l;break}return o=o.substring(0,s+1)}return!1}}]),GHConstructor}();exports.GHConstructor=GHConstructor;
170
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GHConstructor=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function asyncGeneratorStep(e,t,n,r,u,o,a){try{var c=e[o](a),i=c.value}catch(s){return void n(s)}c.done?t(i):Promise.resolve(i).then(r,u)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,u){var o=e.apply(t,n);function a(e){asyncGeneratorStep(o,r,u,a,c,"next",e)}function c(e){asyncGeneratorStep(o,r,u,a,c,"throw",e)}a(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var $q={when:function(e){return new Promise(function(t){t(e)})}},GHConstructor=function(){function GHConstructor(){_classCallCheck(this,GHConstructor),this.cache=[],this.modulesQueue={},this.angularInjector}return _createClass(GHConstructor,[{key:"getInstance",value:function(e){var t=this;return new Promise(function(){var n=_asyncToGenerator(regeneratorRuntime.mark(function n(r){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!t.modulesQueue[e]){n.next=4;break}return n.abrupt("return",t.modulesQueue[e].then(function(){r(t.getCached(e))}));case 4:t.cache.find(function(t){return t.type===e})?r(t.getCached(e)):(t.modulesQueue[e]=t.createInstance(e),t.modulesQueue[e].then(function(){r(t.getCached(e))}));case 5:case"end":return n.stop()}},n)}));return function(e){return n.apply(this,arguments)}}())}},{key:"pupToCache",value:function(e){this.cache.push(e)}},{key:"getCached",value:function(e){return this.cache.find(function(t){return t.type===e})}},{key:"initAngularInjector",value:function(e){this.angularInjector=e}},{key:"createInstance",value:function(){var _createInstance=_asyncToGenerator(regeneratorRuntime.mark(function _callee5(module_id){var module_url,angularModule,module,returningObject,obj,result;return regeneratorRuntime.wrap(function _callee5$(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:return module_url=gudhub.storage.getModuleUrl(module_id),_context5.next=3,this.angularInjector.get(module_id);case 3:return angularModule=_context5.sent,_context5.next=6,_axios.default.get(module_url);case 6:if(module=_context5.sent,module=module.data,returningObject=this.parseModule(module,module_id),returningObject){_context5.next=11;break}return _context5.abrupt("return",!1);case 11:try{eval("obj = "+returningObject)}catch(error){console.log("Error in ghconstructor (".concat(module_id,")"),error)}return result={type:module_id,getTemplate:function(e,t,n,r,u,o){var a="false"!==n;return angularModule.getTemplate(e,t,a,r,u,o)},getDefaultValue:function(e,t,n,r){return new Promise(function(){var u=_asyncToGenerator(regeneratorRuntime.mark(function u(o){var a,c;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(a=angularModule.getDefaultValue)){u.next=8;break}return u.next=4,a(e,t,n,r);case 4:c=u.sent,o(c),u.next=9;break;case 8:o(null);case 9:case"end":return u.stop()}},u)}));return function(e){return u.apply(this,arguments)}}())},getSettings:function(e,t,n){return angularModule.getSettings(e,t,n)},filter:{getSearchOptions:function(e){var t=angularModule;return t.filter&&t.filter.getSearchOptions?angularModule.filter.getSearchOptions(e):[]},getDropdownValues:function(){var e=angularModule;return e.filter&&e.filter.getDropdownValues?e.filter.getDropdownValues():[]}},getInterpretation:function(e,t,n,r,u,o){return new Promise(function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(c){var i,s,l;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return i=obj,a.next=3,i.getInterpretation(e,t,n,r,u,o);case 3:(s=a.sent)?(l=s.find(function(e){return e.id==r})||s.find(function(e){return"default"==e.id}),c({html:l.html})):c({html:"<span>error(from constructor)</span>"});case 5:case"end":return a.stop()}},a)}));return function(e){return a.apply(this,arguments)}}())},getInterpretatedValue:function(e,t,n,r){return new Promise(function(){var u=_asyncToGenerator(regeneratorRuntime.mark(function u(o){var a,c,i;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(a=angularModule.getInterpretatedValue)){u.next=8;break}return u.next=4,a(e,t,n,r);case 4:c=u.sent,o(c),u.next=12;break;case 8:return u.next=10,gudhub.getFieldValue(n,r,t.id);case 10:i=u.sent,o(i);case 12:case"end":return u.stop()}},u)}));return function(e){return u.apply(this,arguments)}}())},extendController:function(e){angularModule.getActionScope(e)},runAction:function(e){try{angularModule.runAction(e)}catch(t){}},getWindowScope:function(e){return angularModule.getWindowScope(e)},getWindowHTML:function(e){return angularModule.getWindowHTML(e)}},this.pupToCache(result),_context5.abrupt("return",result);case 15:case"end":return _context5.stop()}},_callee5,this)}));function createInstance(e){return _createInstance.apply(this,arguments)}return createInstance}()},{key:"parseModule",value:function(e,t){var n=e.indexOf(".factory('".concat(t,"',"));if(-1===n&&(n=e.indexOf('.factory("'.concat(t,'",'))),-1!==n){var r=e.substring(n,e.length),u=r.indexOf("return"),o=r.substring(u,r.length),a=o.indexOf("{");o=o.substring(a,o.length);for(var c=0,i=0,s=0,l=0;l<o.length;l++)if("{"===o[l]&&c++,"}"===o[l]&&i++,c===i&&l>=a){s=l;break}return o=o.substring(0,s+1)}return!1}}]),GHConstructor}();exports.GHConstructor=GHConstructor;
171
171
  },{"axios":"O4Aa"}],"UV2u":[function(require,module,exports) {
172
172
  "use strict";function e(o){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_WEB=void 0;var o=!["undefined"==typeof window?"undefined":e(window),"undefined"==typeof document?"undefined":e(document)].includes("undefined");exports.IS_WEB=o;
173
173
  },{}],"q0my":[function(require,module,exports) {