@gudhub/core 1.1.126 → 1.1.127

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.
@@ -5,6 +5,7 @@
5
5
  import axios from "axios";
6
6
  import { convertObjToUrlParams } from "./utils.js";
7
7
  import qs from "qs";
8
+
8
9
  export class GudHubHttpsService {
9
10
  constructor(server_url) {
10
11
  this.root = server_url;
@@ -34,10 +35,11 @@ export class GudHubHttpsService {
34
35
  if(request.externalResource) {
35
36
  url = request.url;
36
37
  } else {
38
+ const baseSeparator = /\?/.test(url) ? "&" : "?";
39
+ const paramsString = convertObjToUrlParams(request.params);
40
+
37
41
  url = this.root + request.url;
38
- url = `${url}${
39
- /\?/.test(url) ? "&" : "?"
40
- }token=${accessToken}${convertObjToUrlParams(request.params)}`;
42
+ url = `${url}${baseSeparator}${paramsString}${paramsString ? "&" : ""}token=${accessToken}`;
41
43
  }
42
44
  axios.get(url, {
43
45
  validateStatus: function (status) {
@@ -107,42 +109,77 @@ export class GudHubHttpsService {
107
109
  return promise;
108
110
  }
109
111
 
110
- /*************** AXIOS REQUEST ***************/
111
- // It's using to send simple requests to custom urls without token
112
- // If you want to send application/x-www-form-urlencoded, pass data in 'form' property of request
113
- // If you wnt to send any other type of data, just pass it to 'body' property of request
112
+ /*************** AXIOS REQUEST ***************/
113
+ // It's using to send simple requests to custom urls without token
114
+ // If you want to send application/x-www-form-urlencoded, pass data in 'form' property of request
115
+ // If you wnt to send any other type of data, just pass it to 'body' property of request
114
116
 
115
- axiosRequest(request) {
116
- const hesh = this.getHashCodeForAxiosRequest(request);
117
+ axiosRequest(request) {
118
+ const hesh = this.getHashCodeForAxiosRequest(request);
117
119
 
118
- if (this.requestPromises[hesh]) {
119
- return this.requestPromises[hesh].promise;
120
- }
120
+ if (this.requestPromises[hesh]) {
121
+ return this.requestPromises[hesh].promise;
122
+ }
121
123
 
122
- let method = request.method ? request.method.toLowerCase() : 'get';
123
- let url = request.url;
124
- let headers = request.headers || {};
125
- if(request.form) {
126
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
127
- }
124
+ const method = request.method ? request.method.toLowerCase() : "get";
125
+ const url = request.url;
126
+ const headers = { ...(request.headers || {}) };
128
127
 
129
- const promise = new Promise(async (resolve, reject) => {
130
- try {
131
- const { data } = await axios[method](url, method === 'post' ? (qs.stringify(request.form) || request.body) : { headers }, method === 'post' ? {
132
- headers
133
- } : {});
134
- resolve(data);
135
- } catch(error) {
136
- console.log("ERROR -> GUDHUB HTTP SERVICE -> SIMPLE POST :", error.message);
137
- console.log("Request message: ", request);
138
- reject(error);
139
- }
140
- });
128
+ const promise = new Promise(async (resolve, reject) => {
129
+ try {
130
+ let data = request.body;
141
131
 
142
- this.pushPromise(promise, hesh);
132
+ if (request.form instanceof URLSearchParams) {
133
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
134
+ data = request.form;
135
+ } else if (
136
+ typeof FormData !== "undefined" &&
137
+ request.form instanceof FormData
138
+ ) {
139
+ data = request.form;
140
+ delete headers["Content-Type"];
141
+ } else if (request.form) {
142
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
143
+ data = qs.stringify(request.form);
144
+ }
143
145
 
144
- return promise;
145
- }
146
+ const config = {
147
+ url,
148
+ method,
149
+ headers,
150
+ maxBodyLength: Infinity,
151
+ validateStatus(status) {
152
+ return status < 400;
153
+ },
154
+ };
155
+
156
+ if (["post", "put", "patch"].includes(method)) {
157
+ config.data = data;
158
+ }
159
+
160
+ const response = await axios(config);
161
+
162
+ resolve(response.data);
163
+ } catch (error) {
164
+ console.log(
165
+ `ERROR -> GUDHUB HTTP SERVICE -> SIMPLE ${method.toUpperCase()} :`,
166
+ error.message
167
+ );
168
+
169
+ console.log("Request message: ", request);
170
+
171
+ if (error.response) {
172
+ console.log("Error response data:", error.response.data);
173
+ }
174
+
175
+ reject(error);
176
+ }
177
+ });
178
+
179
+ this.pushPromise(promise, hesh);
180
+
181
+ return promise;
182
+ }
146
183
 
147
184
  /*************** PUSH PROMISE ***************/
148
185
  // It push promise object by hash to this.requestPromises
@@ -225,13 +262,14 @@ export class GudHubHttpsService {
225
262
  };
226
263
 
227
264
  const basis = {
228
- url: request.url || "",
229
- method: (request.method || request.request_method || "GET").toUpperCase(),
230
- headers: request.headers || {},
231
- params: request.params || {},
232
- query: request.query || {},
233
- form: request.form || request.body || null,
234
- externalResource: !!request.externalResource
265
+ url: request.url || "",
266
+ method: (request.method || request.request_method || "GET").toUpperCase(),
267
+ headers: request.headers || {},
268
+ params: request.params || {},
269
+ query: request.query || {},
270
+ body: request.body || null,
271
+ form: request.form || null,
272
+ externalResource: !!request.externalResource
235
273
  };
236
274
 
237
275
  const str = stableStringify(basis);
package/GUDHUB/utils.js CHANGED
@@ -21,5 +21,5 @@ export function filterFields(fieldsToFilter = []) {
21
21
  export function convertObjToUrlParams(obj = {}) {
22
22
  const entries = Object.entries(obj);
23
23
  if (!entries.length) return "";
24
- return `&${entries.map(([key, value]) => `${key}=${value}`).join("&")}`;
25
- }
24
+ return entries.map(([key, value]) => `${key}=${value}`).join("&");
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.126",
3
+ "version": "1.1.127",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -119,7 +119,7 @@ var e=require("buffer").Buffer;Object.defineProperty(exports,"__esModule",{value
119
119
  },{"./utils.js":"Feqj","./helpers/bind.js":"hRTX","./core/Axios.js":"trUU","./core/mergeConfig.js":"fBI1","./defaults/index.js":"r0tr","./helpers/formDataToJSON.js":"NTPf","./cancel/CanceledError.js":"lyDU","./cancel/CancelToken.js":"VgQU","./cancel/isCancel.js":"mXc0","./env/data.js":"xOzr","./helpers/toFormData.js":"wxxD","./core/AxiosError.js":"Cb9L","./helpers/spread.js":"yisB","./helpers/isAxiosError.js":"FbOI","./core/AxiosHeaders.js":"sDZl","./adapters/adapters.js":"aHrQ","./helpers/HttpStatusCode.js":"Qnwc"}],"O4Aa":[function(require,module,exports) {
120
120
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.all=exports.VERSION=exports.HttpStatusCode=exports.CanceledError=exports.CancelToken=exports.Cancel=exports.AxiosHeaders=exports.AxiosError=exports.Axios=void 0,Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e.default}}),exports.toFormData=exports.spread=exports.mergeConfig=exports.isCancel=exports.isAxiosError=exports.getAdapter=exports.formToJSON=void 0;var e=r(require("./lib/axios.js"));function r(e){return e&&e.__esModule?e:{default:e}}const{Axios:o,AxiosError:t,CanceledError:s,isCancel:x,CancelToken:p,VERSION:a,all:i,Cancel:n,isAxiosError:l,spread:d,toFormData:c,AxiosHeaders:C,HttpStatusCode:u,formToJSON:A,getAdapter:f,mergeConfig:E}=e.default;exports.mergeConfig=E,exports.getAdapter=f,exports.formToJSON=A,exports.HttpStatusCode=u,exports.AxiosHeaders=C,exports.toFormData=c,exports.spread=d,exports.isAxiosError=l,exports.Cancel=n,exports.all=i,exports.VERSION=a,exports.CancelToken=p,exports.isCancel=x,exports.CanceledError=s,exports.AxiosError=t,exports.Axios=o;
121
121
  },{"./lib/axios.js":"Wzmt"}],"EgeI":[function(require,module,exports) {
122
- "use strict";function r(r,n){return i(r)||o(r,n)||e(r,n)||t()}function t(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(r,t){if(r){if("string"==typeof r)return n(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(r,t):void 0}}function n(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function o(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(r){c=!0,o=r}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}function i(r){if(Array.isArray(r))return r}function a(r){return JSON.stringify(r).replace(/\+|&|%/g,function(r){switch(r){case"+":return"%2B";case"&":return"%26";case"%":return"%25"}})}function l(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(r){return null!=r.field_value})}function u(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.entries(t);return e.length?"&".concat(e.map(function(t){var e=r(t,2),n=e[0],o=e[1];return"".concat(n,"=").concat(o)}).join("&")):""}Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertObjToUrlParams=u,exports.filterFields=l,exports.replaceSpecialCharacters=a;
122
+ "use strict";function r(r,n){return i(r)||o(r,n)||e(r,n)||t()}function t(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(r,t){if(r){if("string"==typeof r)return n(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(r,t):void 0}}function n(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function o(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i,l,u=[],a=!0,c=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;a=!1}else for(;!(a=(n=i.call(e)).done)&&(u.push(n.value),u.length!==t);a=!0);}catch(r){c=!0,o=r}finally{try{if(!a&&null!=e.return&&(l=e.return(),Object(l)!==l))return}finally{if(c)throw o}}return u}}function i(r){if(Array.isArray(r))return r}function l(r){return JSON.stringify(r).replace(/\+|&|%/g,function(r){switch(r){case"+":return"%2B";case"&":return"%26";case"%":return"%25"}})}function u(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(r){return null!=r.field_value})}function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.entries(t);return e.length?e.map(function(t){var e=r(t,2),n=e[0],o=e[1];return"".concat(n,"=").concat(o)}).join("&"):""}Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertObjToUrlParams=a,exports.filterFields=u,exports.replaceSpecialCharacters=l;
123
123
  },{}],"aoYB":[function(require,module,exports) {
124
124
  "use strict";module.exports=TypeError;
125
125
  },{}],"sC8V":[function(require,module,exports) {
@@ -214,7 +214,7 @@ var t=arguments[3],e="function"==typeof Map&&Map.prototype,r=Object.getOwnProper
214
214
  },{"./utils":"Qri1"}],"hIRQ":[function(require,module,exports) {
215
215
  "use strict";var r=require("./stringify"),e=require("./parse"),s=require("./formats");module.exports={formats:s,parse:e,stringify:r};
216
216
  },{"./stringify":"mwZo","./parse":"snX5","./formats":"XaX2"}],"hDvy":[function(require,module,exports) {
217
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHubHttpsService=void 0;var t=n(require("axios")),e=require("./utils.js"),r=n(require("qs"));function n(t){return t&&t.__esModule?t:{default:t}}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=s(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function a(t,e){return l(t)||f(t,e)||s(t,e)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(t,e){if(t){if("string"==typeof t)return c(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function f(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}function l(t){if(Array.isArray(t))return t}function h(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return y(c,"_invoke",function(r,n,o){var i,u,s,c=0,f=o||[],l=!1,h={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,s=t,h.n=r,a}};function y(r,n){for(u=r,s=n,e=0;!l&&c&&!o&&e<f.length;e++){var o,i=f[e],y=h.p,p=i[2];r>3?(o=p===n)&&(s=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,h.v=n,h.n=i[1]):y<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,f,p){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&y(f,p),u=f,s=p;(e=u<2?t:s)||!l;){i||(u?u<3?(u>1&&(h.n=-1),y(u,s)):h.n=s:h.v=s);try{if(c=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(l=h.n<0)?s:r.call(n,h))!==a)break}catch(e){i=t,u=1,s=e}finally{c=1}}return{value:e,done:l}}}(r,o,i),!0),c}var a={};function u(){}function s(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(y(e={},n,function(){return this}),e),l=c.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,y(t,o,"GeneratorFunction")),t.prototype=Object.create(l),t}return s.prototype=c,y(l,"constructor",c),y(c,"constructor",s),s.displayName="GeneratorFunction",y(c,o,"GeneratorFunction"),y(l),y(l,o,"Generator"),y(l,n,function(){return this}),y(l,"toString",function(){return"[object Generator]"}),(h=function(){return{w:i,m:p}})()}function y(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}(y=function(t,e,r,n){function i(e,r){y(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))})(t,e,r,n)}function p(t,e,r,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function m(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){p(i,n,o,a,u,"next",t)}function u(t){p(i,n,o,a,u,"throw",t)}a(void 0)})}}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,g(n.key),n)}}function b(t,e,r){return e&&d(t.prototype,e),r&&d(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t){var e=P(t,"string");return"symbol"==o(e)?e:e+""}function P(t,e){if("object"!=o(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var S=exports.GudHubHttpsService=function(){return b(function t(e){v(this,t),this.root=e,this.requestPromises=[]},[{key:"init",value:function(t){this.getToken=t}},{key:"get",value:function(){var r=m(h().m(function r(n){var o,i,a,u=this;return h().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this.getToken();case 1:if(o=r.v,i=this.getHashCode(n),!this.requestPromises[i]){r.n=2;break}return r.a(2,this.requestPromises[i].promise);case 2:return a=new Promise(function(r,i){var a;n.externalResource?a=n.url:(a=u.root+n.url,a="".concat(a).concat(/\?/.test(a)?"&":"?","token=").concat(o).concat((0,e.convertObjToUrlParams)(n.params))),t.default.get(a,{validateStatus:function(t){return t<400}}).then(function(t){200!=t.status&&console.error("GUDHUB HTTP SERVICE: GET ERROR: ".concat(t.status),t),r(t.data)}).catch(function(t){console.error("GUDHUB HTTP SERVICE: GET ERROR: ".concat(t.response.status,"\n"),t),console.log("Request message: ",n),t.response&&t.response.data&&console.log("Error response data: ",t.response.data),i(t)})}),this.pushPromise(a,i),r.a(2,a)}},r,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"post",value:function(){var e=m(h().m(function e(n){var o,i,a=this;return h().w(function(e){for(;;)switch(e.n){case 0:return o=this.getHashCode(n),e.n=1,this.getToken();case 1:if(n.form.token=e.v,!this.requestPromises[o]){e.n=2;break}return e.a(2,this.requestPromises[o].promise);case 2:return i=new Promise(function(e,o){t.default.post(a.root+n.url,r.default.stringify(n.form),{maxBodyLength:1/0,headers:n.headers||{"Content-Type":"application/x-www-form-urlencoded"},validateStatus:function(t){return t<400}}).then(function(t){200!=t.status&&console.error("GUDHUB HTTP SERVICE: POST ERROR: ".concat(t.status),t),e(t.data)}).catch(function(t){console.error("GUDHUB HTTP SERVICE: POST ERROR: ".concat(t.response.status,"\n"),t),console.log("Request message: ",n),o(t)})}),this.pushPromise(i,o),e.a(2,i)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"axiosRequest",value:function(e){var n=this.getHashCodeForAxiosRequest(e);if(this.requestPromises[n])return this.requestPromises[n].promise;var o=e.method?e.method.toLowerCase():"get",i=e.url,a=e.headers||{};e.form&&(a["Content-Type"]="application/x-www-form-urlencoded");var u=new Promise(function(){var n=m(h().m(function n(u,s){var c,f,l;return h().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t.default[o](i,"post"===o?r.default.stringify(e.form)||e.body:{headers:a},"post"===o?{headers:a}:{});case 1:c=n.v,f=c.data,u(f),n.n=3;break;case 2:n.p=2,l=n.v,console.log("ERROR -> GUDHUB HTTP SERVICE -> SIMPLE POST :",l.message),console.log("Request message: ",e),s(l);case 3:return n.a(2)}},n,null,[[0,2]])}));return function(t,e){return n.apply(this,arguments)}}());return this.pushPromise(u,n),u}},{key:"pushPromise",value:function(t,e){var r=this;this.requestPromises[e]={promise:t,hesh:e,callback:t.then(function(){r.destroyPromise(e)}).catch(function(t){r.destroyPromise(e)})}}},{key:"destroyPromise",value:function(t){this.requestPromises=this.requestPromises.filter(function(e){return e.hesh!==t})}},{key:"getHashCode",value:function(t){var e=0,n=r.default.stringify(t);if(0==n.length)return e;for(var o=0;o<n.length;o++){e=(e<<5)-e+n.charCodeAt(o),e&=e}return"h"+e}},{key:"getHashCodeForAxiosRequest",value:function(t){for(var e=function(t){if(null==t)return"";if(t instanceof URLSearchParams){var r=[];t.forEach(function(t,e){return r.push([e,String(t)])}),r.sort(function(t,e){return t[0]===e[0]?t[1].localeCompare(e[1]):t[0].localeCompare(e[0])});var n=r.filter(function(t){return"token"!==a(t,1)[0]});return JSON.stringify(n)}if("undefined"!=typeof FormData&&t instanceof FormData){var u,s=[],c=i(t.entries());try{for(c.s();!(u=c.n()).done;){var f=a(u.value,2),l=f[0],h=f[1];h&&"object"===o(h)&&"name"in h&&"size"in h?s.push([l,{name:h.name,size:h.size,type:h.type||"",lastModified:h.lastModified||0}]):s.push([l,String(h)])}}catch(b){c.e(b)}finally{c.f()}s.sort(function(t,e){return t[0]===e[0]?JSON.stringify(t[1]).localeCompare(JSON.stringify(e[1])):t[0].localeCompare(e[0])});var y=s.filter(function(t){return"token"!==a(t,1)[0]});return JSON.stringify(y)}if("object"===o(t)){var p,m={},v=i(Object.keys(t).sort());try{for(v.s();!(p=v.n()).done;){var d=p.value;"token"!==d&&(m[d]=e(t[d]))}}catch(b){v.e(b)}finally{v.f()}return JSON.stringify(m)}return String(t)},r={url:t.url||"",method:(t.method||t.request_method||"GET").toUpperCase(),headers:t.headers||{},params:t.params||{},query:t.query||{},form:t.form||t.body||null,externalResource:!!t.externalResource},n=e(r),u=0,s=0;s<n.length;s++){u=(u<<5)-u+n.charCodeAt(s),u|=0}return"h"+u}}])}();
217
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHubHttpsService=void 0;var e=n(require("axios")),t=require("./utils.js"),r=n(require("qs"));function n(e){return e&&e.__esModule?e:{default:e}}function o(e){return(o="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})(e)}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=s(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function a(e,t){return l(e)||f(e,t)||s(e,t)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){if(e){if("string"==typeof e)return c(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}function l(e){if(Array.isArray(e))return e}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){h(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function h(e,t,r){return(t=w(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return d(c,"_invoke",function(r,n,o){var i,u,s,c=0,f=o||[],l=!1,p={p:0,n:0,v:e,a:y,f:y.bind(e,4),d:function(t,r){return i=t,u=0,s=e,p.n=r,a}};function y(r,n){for(u=r,s=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,i=f[t],y=p.p,h=i[2];r>3?(o=h===n)&&(s=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,p.n=h,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&y(f,h),u=f,s=h;(t=u<2?e:s)||!l;){i||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(c=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=p.n<0)?s:r.call(n,p))!==a)break}catch(t){i=e,u=1,s=t}finally{c=1}}return{value:t,done:l}}}(r,o,i),!0),c}var a={};function u(){}function s(){}function c(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(d(t={},n,function(){return this}),t),l=c.prototype=u.prototype=Object.create(f);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,d(e,o,"GeneratorFunction")),e.prototype=Object.create(l),e}return s.prototype=c,d(l,"constructor",c),d(c,"constructor",s),s.displayName="GeneratorFunction",d(c,o,"GeneratorFunction"),d(l),d(l,o,"Generator"),d(l,n,function(){return this}),d(l,"toString",function(){return"[object Generator]"}),(m=function(){return{w:i,m:p}})()}function d(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(d=function(e,t,r,n){function i(t,r){d(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))})(e,t,r,n)}function v(e,t,r,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){v(i,n,o,a,u,"next",e)}function u(e){v(i,n,o,a,u,"throw",e)}a(void 0)})}}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function P(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,w(n.key),n)}}function O(e,t,r){return t&&P(e.prototype,t),r&&P(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function w(e){var t=S(e,"string");return"symbol"==o(t)?t:t+""}function S(e,t){if("object"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var j=exports.GudHubHttpsService=function(){return O(function e(t){g(this,e),this.root=t,this.requestPromises=[]},[{key:"init",value:function(e){this.getToken=e}},{key:"get",value:function(){var r=b(m().m(function r(n){var o,i,a,u=this;return m().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,this.getToken();case 1:if(o=r.v,i=this.getHashCode(n),!this.requestPromises[i]){r.n=2;break}return r.a(2,this.requestPromises[i].promise);case 2:return a=new Promise(function(r,i){var a;if(n.externalResource)a=n.url;else{var s=/\?/.test(a)?"&":"?",c=(0,t.convertObjToUrlParams)(n.params);a=u.root+n.url,a="".concat(a).concat(s).concat(c).concat(c?"&":"","token=").concat(o)}e.default.get(a,{validateStatus:function(e){return e<400}}).then(function(e){200!=e.status&&console.error("GUDHUB HTTP SERVICE: GET ERROR: ".concat(e.status),e),r(e.data)}).catch(function(e){console.error("GUDHUB HTTP SERVICE: GET ERROR: ".concat(e.response.status,"\n"),e),console.log("Request message: ",n),e.response&&e.response.data&&console.log("Error response data: ",e.response.data),i(e)})}),this.pushPromise(a,i),r.a(2,a)}},r,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"post",value:function(){var t=b(m().m(function t(n){var o,i,a=this;return m().w(function(t){for(;;)switch(t.n){case 0:return o=this.getHashCode(n),t.n=1,this.getToken();case 1:if(n.form.token=t.v,!this.requestPromises[o]){t.n=2;break}return t.a(2,this.requestPromises[o].promise);case 2:return i=new Promise(function(t,o){e.default.post(a.root+n.url,r.default.stringify(n.form),{maxBodyLength:1/0,headers:n.headers||{"Content-Type":"application/x-www-form-urlencoded"},validateStatus:function(e){return e<400}}).then(function(e){200!=e.status&&console.error("GUDHUB HTTP SERVICE: POST ERROR: ".concat(e.status),e),t(e.data)}).catch(function(e){console.error("GUDHUB HTTP SERVICE: POST ERROR: ".concat(e.response.status,"\n"),e),console.log("Request message: ",n),o(e)})}),this.pushPromise(i,o),t.a(2,i)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"axiosRequest",value:function(t){var n=this.getHashCodeForAxiosRequest(t);if(this.requestPromises[n])return this.requestPromises[n].promise;var o=t.method?t.method.toLowerCase():"get",i=t.url,a=y({},t.headers||{}),u=new Promise(function(){var n=b(m().m(function n(u,s){var c,f,l,p;return m().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,c=t.body,t.form instanceof URLSearchParams?(a["Content-Type"]="application/x-www-form-urlencoded",c=t.form):"undefined"!=typeof FormData&&t.form instanceof FormData?(c=t.form,delete a["Content-Type"]):t.form&&(a["Content-Type"]="application/x-www-form-urlencoded",c=r.default.stringify(t.form)),f={url:i,method:o,headers:a,maxBodyLength:1/0,validateStatus:function(e){return e<400}},["post","put","patch"].includes(o)&&(f.data=c),n.n=1,(0,e.default)(f);case 1:l=n.v,u(l.data),n.n=3;break;case 2:n.p=2,p=n.v,console.log("ERROR -> GUDHUB HTTP SERVICE -> SIMPLE ".concat(o.toUpperCase()," :"),p.message),console.log("Request message: ",t),p.response&&console.log("Error response data:",p.response.data),s(p);case 3:return n.a(2)}},n,null,[[0,2]])}));return function(e,t){return n.apply(this,arguments)}}());return this.pushPromise(u,n),u}},{key:"pushPromise",value:function(e,t){var r=this;this.requestPromises[t]={promise:e,hesh:t,callback:e.then(function(){r.destroyPromise(t)}).catch(function(e){r.destroyPromise(t)})}}},{key:"destroyPromise",value:function(e){this.requestPromises=this.requestPromises.filter(function(t){return t.hesh!==e})}},{key:"getHashCode",value:function(e){var t=0,n=r.default.stringify(e);if(0==n.length)return t;for(var o=0;o<n.length;o++){t=(t<<5)-t+n.charCodeAt(o),t&=t}return"h"+t}},{key:"getHashCodeForAxiosRequest",value:function(e){for(var t=function(e){if(null==e)return"";if(e instanceof URLSearchParams){var r=[];e.forEach(function(e,t){return r.push([t,String(e)])}),r.sort(function(e,t){return e[0]===t[0]?e[1].localeCompare(t[1]):e[0].localeCompare(t[0])});var n=r.filter(function(e){return"token"!==a(e,1)[0]});return JSON.stringify(n)}if("undefined"!=typeof FormData&&e instanceof FormData){var u,s=[],c=i(e.entries());try{for(c.s();!(u=c.n()).done;){var f=a(u.value,2),l=f[0],p=f[1];p&&"object"===o(p)&&"name"in p&&"size"in p?s.push([l,{name:p.name,size:p.size,type:p.type||"",lastModified:p.lastModified||0}]):s.push([l,String(p)])}}catch(b){c.e(b)}finally{c.f()}s.sort(function(e,t){return e[0]===t[0]?JSON.stringify(e[1]).localeCompare(JSON.stringify(t[1])):e[0].localeCompare(t[0])});var y=s.filter(function(e){return"token"!==a(e,1)[0]});return JSON.stringify(y)}if("object"===o(e)){var h,m={},d=i(Object.keys(e).sort());try{for(d.s();!(h=d.n()).done;){var v=h.value;"token"!==v&&(m[v]=t(e[v]))}}catch(b){d.e(b)}finally{d.f()}return JSON.stringify(m)}return String(e)},r={url:e.url||"",method:(e.method||e.request_method||"GET").toUpperCase(),headers:e.headers||{},params:e.params||{},query:e.query||{},body:e.body||null,form:e.form||null,externalResource:!!e.externalResource},n=t(r),u=0,s=0;s<n.length;s++){u=(u<<5)-u+n.charCodeAt(s),u|=0}return"h"+u}}])}();
218
218
  },{"axios":"O4Aa","./utils.js":"EgeI","qs":"hIRQ"}],"Lc8J":[function(require,module,exports) {
219
219
  "use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(e)}function e(o){var e="";for(var t in o)o.hasOwnProperty(t)&&o[t]&&(e+="."+o[t]);return e?e.substring(1):"any"}function t(e,t,n){return null==e||"string"!=typeof e?(console.log("Listener type is \"undefined\" or not have actual 'type' for subscribe"),!1):null==t||"object"!==o(t)?(console.log("Listener destination is \"undefined\" or not have actual 'type' for subscribe"),!1):"function"==typeof n||(console.log("Listener is not a function for subscribe!"),!1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkParams=t,exports.createId=e;
220
220
  },{}],"E3xI":[function(require,module,exports) {