@gudhub/core 1.1.126 → 1.1.128

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.
@@ -22,7 +22,7 @@ export default class AppsTemplateService {
22
22
  })
23
23
  : null;
24
24
 
25
- const appsList = await remoteServerGudHubInstance.getAppsList();
25
+ const appsList = isInstallFromRemoteServer ? await remoteServerGudHubInstance.getAppsList() : null;
26
26
 
27
27
  const onAppStep = (status) => {
28
28
  currentStep += 1;
@@ -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.128",
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) {
@@ -293,7 +293,7 @@ function o(e){return module.exports=o="function"==typeof Symbol&&"symbol"==typeo
293
293
  },{}],"nKaW":[function(require,module,exports) {
294
294
  "use strict";function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function e(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function r(t){return u(t)||o(t)||i(t)||n()}function n(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(t,e){if(t){if("string"==typeof t)return a(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)?a(t,e):void 0}}function o(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function u(t){if(Array.isArray(t))return a(t)}function a(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 c(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}}function f(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var c=n&&n.prototype instanceof a?n:a,f=Object.create(c.prototype);return s(f,"_invoke",function(r,n,i){var o,a,c,f=0,s=i||[],l=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return o=e,a=0,c=t,p.n=r,u}};function d(r,n){for(a=r,c=n,e=0;!l&&f&&!i&&e<s.length;e++){var i,o=s[e],d=p.p,y=o[2];r>3?(i=y===n)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=r<2&&d<o[1])?(a=0,p.v=n,p.n=o[1]):d<y&&(i=r<3||o[0]>n||n>y)&&(o[4]=r,o[5]=n,p.n=y,a=0))}if(i||r>1)return u;throw l=!0,n}return function(i,s,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&d(s,y),a=s,c=y;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(p.n=-1),d(a,c)):p.n=c:p.v=c);try{if(f=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=p.n<0)?c:r.call(n,p))!==u)break}catch(e){o=t,a=1,c=e}finally{f=1}}return{value:e,done:l}}}(r,i,o),!0),f}var u={};function a(){}function c(){}function l(){}e=Object.getPrototypeOf;var p=[][n]?e(e([][n]())):(s(e={},n,function(){return this}),e),d=l.prototype=a.prototype=Object.create(p);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,s(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,s(d,"constructor",l),s(l,"constructor",c),c.displayName="GeneratorFunction",s(l,i,"GeneratorFunction"),s(d),s(d,i,"Generator"),s(d,n,function(){return this}),s(d,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:y}})()}function s(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}(s=function(t,e,r,n){function o(e,r){s(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(o("next",0),o("throw",1),o("return",2))})(t,e,r,n)}function l(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t){var e=d(t,"string");return"symbol"==y(e)?e:e+""}function d(t,e){if("object"!=y(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function y(t){return(y="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 b(t,e,r,n,i,o,u){try{var a=t[o](u),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,i)}function v(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function u(t){b(o,n,i,u,a,"next",t)}function a(t){b(o,n,i,u,a,"throw",t)}u(void 0)})}}function m(t,n,i,o,u){function a(t,e,r){return s.apply(this,arguments)}function s(){return(s=v(f().m(function t(e,r,n){var i,o,u,s,d,v,m,h,w;return f().w(function(t){for(;;)switch(t.n){case 0:if(i=null,"array"!==e.type){t.n=4;break}if(!Number(e.is_static)){t.n=2;break}return v=Array,t.n=1,_(e.childs,r,n);case 1:m=t.v,i=new v(m),t.n=4;break;case 2:return t.n=3,p(e,r,n);case 3:i=t.v;case 4:if("object"!==e.type){t.n=8;break}if(!Number(e.current_item)){t.n=6;break}return t.n=5,b(e,r);case 5:i=t.v,t.n=8;break;case 6:return t.n=7,_(e.childs,r,n);case 7:i=t.v;case 8:if("property"!==e.type){t.n=10;break}return t.n=9,g(e,r,n);case 9:i=t.v;case 10:if("object"!==y(e)||void 0!==e.type){t.n=15;break}o={},h=c(e);case 11:if((w=h()).done){t.n=14;break}if(u=w.value,!e.hasOwnProperty(u)){t.n=13;break}return s=e[u],t.n=12,a(s,r,n);case 12:d=t.v,o[u]=d[s.property_name];case 13:t.n=11;break;case 14:return t.a(2,o);case 15:return t.a(2,l({},e.property_name,i))}},t)}))).apply(this,arguments)}function p(t,e,r){return d.apply(this,arguments)}function d(){return(d=v(f().m(function t(e,n,u){var a,c,s,l,p,d,y;return f().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,i.gudhub.getApp(Number(e.app_id));case 1:return a=t.v,t.n=2,S(e.filter,a.items_list,u,n);case 2:return c=t.v,e.isSortable&&e.field_id_to_sort&&""!==e.field_id_to_sort&&(s=c.flatMap(function(t){var r=t.fields.find(function(t){return t.field_id==e.field_id_to_sort});return r&&""!=r.field_value?t:[]}),l=c.filter(function(t){if(!s.includes(t))return t}),s=s.sort(function(t,r){return"desc"==e.sortType?r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value:t.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value-r.fields.find(function(t){return t.field_id==e.field_id_to_sort}).field_value}),c=[].concat(r(s),r(l))),e.offset&&(p=e.use_variables_for_limit_and_offset&&o?o[e.offset]:/^[0-9]+$/.test(e.offset)?e.offset:0,c=c.slice(p)),e.limit&&0!==(d=e.use_variables_for_limit_and_offset&&o?o[e.limit]:/^[0-9]+$/.test(e.limit)||0)&&(c=c.slice(0,d)),y=c.map(function(){var t=v(f().m(function t(r){return f().w(function(t){for(;;)switch(t.n){case 0:return t.a(2,_(e.childs,r,a.app_id))}},t)}));return function(e){return t.apply(this,arguments)}}()),t.a(2,Promise.all(y))}},t)}))).apply(this,arguments)}function b(t,e){return m.apply(this,arguments)}function m(){return(m=v(f().m(function t(e,r){var n,o;return f().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,i.gudhub.getApp(e.app_id);case 1:return n=t.v,o=n.items_list||[],t.a(2,_(e.childs,r||o[0],n.app_id))}},t)}))).apply(this,arguments)}function _(t,e,r){return h.apply(this,arguments)}function h(){return(h=v(f().m(function t(r,n,i){var o,u;return f().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r.map(function(){var t=v(f().m(function t(e){return f().w(function(t){for(;;)switch(t.n){case 0:return t.a(2,a(e,n,i))}},t)}));return function(e){return t.apply(this,arguments)}}());case 1:return o=t.v,t.n=2,Promise.all(o);case 2:return u=t.v,t.a(2,u.reduce(function(t,r){return e(e({},t),r)},{}))}},t)}))).apply(this,arguments)}function g(t,e,r){return w.apply(this,arguments)}function w(){return(w=v(f().m(function t(e,n,o){var u,a,c,s,l,p,d;return f().w(function(t){for(;;)switch(t.n){case 0:p=e.property_type,t.n="static"===p?1:"variable"===p?2:"field_id"===p?5:"function"===p?6:9;break;case 1:return t.a(2,e.static_field_value);case 2:d=e.variable_type,t.n="app_id"===d?3:4;break;case 3:return t.a(2,o);case 4:return t.a(2,"".concat(o,".").concat(n.item_id));case 5:return t.a(2,e.field_id);case 6:if("function"!=typeof e.function){t.n=7;break}return u=e.function.apply(e,[n,o,i.gudhub].concat(r(e.args))),t.a(2,u);case 7:return a=new Function("item, appId, gudhub","return (async "+e.function+")(item, appId, gudhub)"),t.n=8,a(n,o,i.gudhub);case 8:return c=t.v,t.a(2,c);case 9:if(e.field_id||!e.name_space){t.n=11;break}return t.n=10,i.gudhub.getFieldIdByNameSpace(o,e.name_space);case 10:e.field_id=t.v;case 11:if(!Boolean(Number(e.interpretation))){t.n=13;break}return t.n=12,i.gudhub.getInterpretationById(Number(o),Number(n.item_id),Number(e.field_id),"value");case 12:return s=t.v,t.a(2,s);case 13:return t.n=14,i.gudhub.getFieldValue(Number(o),Number(n.item_id),Number(e.field_id));case 14:return l=t.v,t.a(2,l);case 15:return t.a(2)}},t)}))).apply(this,arguments)}function O(t,e,r,n,i){return j.apply(this,arguments)}function j(){return(j=v(f().m(function t(n,u,a,c,s){var l;return f().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,i.gudhub.prefilter(JSON.parse(JSON.stringify(n)),e({element_app_id:u,app_id:a,item_id:c},o));case 1:return l=t.v,t.a(2,i.gudhub.filter(s,[].concat(r(l),r(n))))}},t)}))).apply(this,arguments)}function S(){return P.apply(this,arguments)}function P(){return(P=v(f().m(function t(){var e,n,i,o,u=arguments;return f().w(function(t){for(;;)switch(t.n){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:[],n=u.length>1&&void 0!==u[1]?u[1]:[],i=u.length>2&&void 0!==u[2]?u[2]:"",o=u.length>3&&void 0!==u[3]?u[3]:{},t.a(2,e.length?O(e,i,i,o.item_id,n):r(n))}},t)}))).apply(this,arguments)}return a(t,n,u,o)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=m;
295
295
  },{}],"zqOZ":[function(require,module,exports) {
296
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("../../gudhub.js");function n(e){if(null!=e){var n=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(u(e)+" is not iterable")}function t(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=r(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}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 o,u=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){l=!0,o=e},f:function(){try{u||null==t.return||t.return()}finally{if(l)throw o}}}}function r(e,n){if(e){if("string"==typeof e)return i(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,n):void 0}}function i(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function a(){var e,n,t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",i=t.toStringTag||"@@toStringTag";function u(t,r,i,a){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return o(s,"_invoke",function(t,r,i){var a,o,u,c=0,s=i||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(n,t){return a=n,o=0,u=e,p.n=t,l}};function d(t,r){for(o=t,u=r,n=0;!f&&c&&!i&&n<s.length;n++){var i,a=s[n],d=p.p,_=a[2];t>3?(i=_===r)&&(u=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=d&&((i=t<2&&d<a[1])?(o=0,p.v=r,p.n=a[1]):d<_&&(i=t<3||a[0]>r||r>_)&&(a[4]=t,a[5]=r,p.n=_,o=0))}if(i||t>1)return l;throw f=!0,r}return function(i,s,_){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,_),o=s,u=_;(n=o<2?e:u)||!f;){a||(o?o<3?(o>1&&(p.n=-1),d(o,u)):p.n=u:p.v=u);try{if(c=2,a){if(o||(i="next"),n=a[i]){if(!(n=n.call(a,u)))throw TypeError("iterator result is not an object");if(!n.done)return n;u=n.value,o<2&&(o=0)}else 1===o&&(n=a.return)&&n.call(a),o<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),o=1);a=e}else if((n=(f=p.n<0)?u:t.call(r,p))!==l)break}catch(n){a=e,o=1,u=n}finally{c=1}}return{value:n,done:f}}}(t,i,a),!0),s}var l={};function c(){}function s(){}function f(){}n=Object.getPrototypeOf;var p=[][r]?n(n([][r]())):(o(n={},r,function(){return this}),n),d=f.prototype=c.prototype=Object.create(p);function _(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,o(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=f,o(d,"constructor",f),o(f,"constructor",s),s.displayName="GeneratorFunction",o(f,i,"GeneratorFunction"),o(d),o(d,i,"Generator"),o(d,r,function(){return this}),o(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:u,m:_}})()}function o(e,n,t,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}(o=function(e,n,t,r){function a(n,t){o(e,n,function(e){return this._invoke(n,t,e)})}n?i?i(e,n,{value:t,enumerable:!r,configurable:!r,writable:!r}):e[n]=t:(a("next",0),a("throw",1),a("return",2))})(e,n,t,r)}function u(e){return(u="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 l(e,n,t,r,i,a,o){try{var u=e[a](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(r,i)}function c(e){return function(){var n=this,t=arguments;return new Promise(function(r,i){var a=e.apply(n,t);function o(e){l(a,r,i,o,u,"next",e)}function u(e){l(a,r,i,o,u,"throw",e)}o(void 0)})}}function s(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function f(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}function p(e,n,t){return n&&f(e.prototype,n),t&&f(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var n=_(e,"string");return"symbol"==u(n)?n:n+""}function _(e,n){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}var v=exports.default=function(){return p(function e(n){s(this,e),this.gudhub=n,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}},[{key:"createAppsFromTemplate",value:function(){var n=c(a().m(function n(t,r,i,o,l,c){var s,f,p,d,_,v,h;return a().w(function(n){for(;;)switch(n.n){case 0:return s=6*t.apps.length,f=100/s,p=0,d=o?new e.GudHub(i,{server_url:"".concat(r,"/GudHub")}):null,n.n=1,d.getAppsList();case 1:return n.v,_=function(e){p+=1,null==c||c({percent:p*f,status:e})},v=function(e){"string"==typeof e?(p+=1,null==c||c({percent:p*f,status:e})):"object"===u(e)&&(null==c||c({status:"Done",apps:e}))},n.n=2,this._createApps(t,r,i,o,d,_);case 2:return h=n.v,n.n=3,this._createItems(h,r,i,o,d,l,v);case 3:return n.a(2)}},n,this)}));return function(e,t,r,i,a,o){return n.apply(this,arguments)}}()},{key:"_createApps",value:function(){var e=c(a().m(function e(n,r,i,o,u,l){var c,s,f,p,d,_,v,h,y,m,b,w,g,k,A,O,P;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(c={},s=[],f=[],p=null,!o){e.n=2;break}return e.n=1,this.gudhub.req.axiosRequest({method:"POST",url:"".concat(r,"/GudHub/auth/login"),form:{auth_key:i}});case 1:d=e.v,p=d.accesstoken;case 2:_=t(n.apps),e.p=3,_.s();case 4:if((v=_.n()).done){e.n=12;break}if(h=v.value,y=void 0,!o){e.n=6;break}return e.n=5,this.gudhub.req.axiosRequest({url:"".concat(r,"/GudHub/api/app/get?token=").concat(p,"&app_id=").concat(h),method:"GET"});case 5:y=e.v,e.n=8;break;case 6:return e.n=7,this.gudhub.getApp(h);case 7:y=e.v;case 8:if(y){e.n=9;break}throw new Error("Failed to get app: ".concat(h));case 9:return null==l||l("GET APP: ".concat(y.app_name," (App steps)")),m=JSON.parse(JSON.stringify(y)),c[m.app_id]=m,(b=this._prepareAppTemplate(m)).privacy=1,n.data_to_change&&(n.data_to_change.name&&(b.app_name=n.data_to_change.name),n.data_to_change.icon&&(b.icon=n.data_to_change.icon)),this._resetViewsIds(b),e.n=10,this.gudhub.createNewApp(b);case 10:w=e.v,null==l||l("CREATE NEW APP: ".concat(y.app_name," (App steps)")),s.push(w),this._mapApp(m,w,this.appsConnectingMap);case 11:e.n=4;break;case 12:e.n=14;break;case 13:e.p=13,P=e.v,_.e(P);case 14:return e.p=14,_.f(),e.f(14);case 15:this._connectApps(s,this.appsConnectingMap,c),g=0,k=s;case 16:if(!(g<k.length)){e.n=19;break}return A=k[g],e.n=17,this.gudhub.updateApp(A);case 17:O=e.v,null==l||l("UPDATE APP: ".concat(O.app_name," (App steps)")),f.push(O);case 18:g++,e.n=16;break;case 19:return e.a(2,f)}},e,this,[[3,13,14,15]])}));return function(n,t,r,i,a,o){return e.apply(this,arguments)}}()},{key:"_createItems",value:function(){var e=c(a().m(function e(n,r,i,o,u,l,s){var f,p,d,_,v,h,y,m,b,w,g,k,A,O,P,S,j=this;return a().w(function(e){for(;;)switch(e.n){case 0:if(f=null!=l?l:1e5,p=null,!o){e.n=2;break}return e.n=1,this.gudhub.req.axiosRequest({method:"POST",url:"".concat(r,"/GudHub/auth/login"),form:{auth_key:i}});case 1:d=e.v,p=d.accesstoken;case 2:return e.n=3,Promise.all(n.map(function(){var e=c(a().m(function e(n){var t,i,u,l;return a().w(function(e){for(;;)switch(e.n){case 0:if(!o){e.n=2;break}return e.n=1,j.gudhub.req.axiosRequest({url:"".concat(r,"/GudHub/api/app/get?token=").concat(p,"&app_id=").concat(j._searchOldAppId(n.app_id,j.appsConnectingMap.apps)),method:"GET"});case 1:t=e.v,e.n=4;break;case 2:return e.n=3,j.gudhub.getApp(j._searchOldAppId(n.app_id,j.appsConnectingMap.apps));case 3:t=e.v;case 4:if(t){e.n=5;break}throw new Error("Failed to get app in createItems: ".concat(n.app_id));case 5:return null==s||s("GET APP: ".concat(t.app_name," (Items steps)")),i=JSON.parse(JSON.stringify(t)),u=i.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,n){return n<=f}),e.n=6,j.gudhub.addNewItems(n.app_id,u);case 6:return l=e.v,null==s||s("ADD NEW ITEMS: ".concat(t.app_name," (Items steps)")),n.items_list=l,j._updateMap(n.items_list,i.items_list),j._addFieldValue(i.items_list,n.items_list,j.appsConnectingMap),e.a(2,n)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 3:_=e.v,v=t(_);try{for(v.s();!(h=v.n()).done;){y=h.value,m=t(y.items_list);try{for(m.s();!(b=m.n()).done;){w=b.value,g=t(w.fields);try{for(g.s();!(k=g.n()).done;){A=k.value,O=t(this.appsConnectingMap.fields);try{for(O.s();!(P=O.n()).done;)S=P.value,A.field_id===S.old_field_id&&(A.field_id=S.new_field_id,A.element_id=S.new_field_id)}catch(I){O.e(I)}finally{O.f()}}}catch(I){g.e(I)}finally{g.f()}}}catch(I){m.e(I)}finally{m.f()}}}catch(I){v.e(I)}finally{v.f()}return this._deleteField(_),e.n=4,this._replaceValue(_,this.appsConnectingMap,o,u);case 4:return e.n=5,Promise.all(_.map(function(){var e=c(a().m(function e(n){var t;return a().w(function(e){for(;;)switch(e.n){case 0:return t=n.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e}),e.n=1,j.gudhub.updateItems(n.app_id,t);case 1:null==s||s("REPLACE VALUE: ".concat(n.app_name," (Items steps)"));case 2:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 5:null==s||s(_);case 6:return e.a(2)}},e,this)}));return function(n,t,r,i,a,o,u){return e.apply(this,arguments)}}()},{key:"_deleteField",value:function(e){var n,r=t(e);try{var i=function(){var e,r=n.value,i=t(r.items_list);try{for(i.s();!(e=i.n()).done;){var a=e.value;a.fields=a.fields.filter(function(e){return r.field_list.findIndex(function(n){return n.field_id==e.field_id})>-1})}}catch(o){i.e(o)}finally{i.f()}};for(r.s();!(n=r.n()).done;)i()}catch(a){r.e(a)}finally{r.f()}}},{key:"_replaceValue",value:function(){var e=c(a().m(function e(r,i,o,u){var l,s,f,p,d,_,v=this;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:l=[],s=null==i?void 0:i.apps,f=t(r),e.p=1,d=a().m(function e(){var r,f,d,_,h;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:r=p.value,f=t(r.field_list),e.p=1,_=a().m(function e(){var n;return a().w(function(e){for(;;)switch(e.n){case 0:"item_ref"===(n=d.value).data_type&&v._replaceValueItemRef(r,n,i),l.push(v.gudhub.ghconstructor.getInstance(n.data_type).then(function(){var e=c(a().m(function e(t){return a().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,{type:n.data_type});case 1:if("file"!==t.getTemplate().constructor){e.n=2;break}return e.a(2,v.gudhub.util.fileInstallerHelper(s,r.app_id,r.items_list,n.field_id,o,u));case 2:if("document"!==t.getTemplate().constructor){e.n=4;break}return e.n=3,v._documentInstallerHelper(r.app_id,r.items_list,n.field_id);case 3:case 4:return e.a(2,t)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 1:return e.a(2)}},e)}),f.s();case 2:if((d=f.n()).done){e.n=4;break}return e.d(n(_()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,h=e.v,f.e(h);case 6:return e.p=6,f.f(),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])}),f.s();case 2:if((p=f.n()).done){e.n=4;break}return e.d(n(d()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,_=e.v,f.e(_);case 6:return e.p=6,f.f(),e.f(6);case 7:if(!(l.length>0)){e.n=8;break}return e.a(2,Promise.all(l));case 8:return e.a(2)}},e,null,[[1,5,6,7]])}));return function(n,t,r,i){return e.apply(this,arguments)}}()},{key:"_documentInstallerHelper",value:function(){var e=c(a().m(function e(n,r,i){var o,u,l,c,s,f,p,d,_;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:o=[],u=t(r),e.p=1,u.s();case 2:if((l=u.n()).done){e.n=6;break}if(s=l.value,!((null==(f=s.fields.find(function(e){return e.element_id===i}))||null===(c=f.field_value)||void 0===c?void 0:c.length)>0)){e.n=5;break}return e.n=3,this.gudhub.getDocument({_id:f.field_value});case 3:if(null==(p=e.v)||!p.data){e.n=5;break}return e.n=4,this.gudhub.createDocument({app_id:n,item_id:s.item_id,element_id:i,data:p.data});case 4:d=e.v,f.field_value=d._id,o.push(s);case 5:e.n=2;break;case 6:e.n=8;break;case 7:e.p=7,_=e.v,u.e(_);case 8:return e.p=8,u.f(),e.f(8);case 9:return e.a(2,o)}},e,this,[[1,7,8,9]])}));return function(n,t,r){return e.apply(this,arguments)}}()},{key:"_replaceValueItemRef",value:function(e,n,r){var i,a=t(e.items_list);try{for(a.s();!(i=a.n()).done;){var o,u=t(i.value.fields);try{for(u.s();!(o=u.n()).done;){var l=o.value;if(l.field_id===n.field_id&&l.field_value){var c=l.field_value.split(",").map(function(e){var n,i=e.split("."),a=t(r.apps);try{for(a.s();!(n=a.n()).done;){var o=n.value;i[0]==o.old_app_id&&(i[0]=o.new_app_id)}}catch(s){a.e(s)}finally{a.f()}var u,l=t(r.items);try{for(l.s();!(u=l.n()).done;){var c=u.value;i[1]==c.old_item_id&&(i[1]=c.new_item_id)}}catch(s){l.e(s)}finally{l.f()}return i.join(".")});l.field_value=c.join(",")}}}catch(s){u.e(s)}finally{u.f()}}}catch(s){a.e(s)}finally{a.f()}}},{key:"_addFieldValue",value:function(e,n,r){var i,a=t(n);try{for(a.s();!(i=a.n()).done;){var o,u=i.value,l=t(r.items);try{for(l.s();!(o=l.n()).done;){var c=o.value;if(u.item_id===c.new_item_id){var s,f=t(e);try{for(f.s();!(s=f.n()).done;){var p=s.value;c.old_item_id===p.item_id&&(u.fields=p.fields)}}catch(d){f.e(d)}finally{f.f()}}}}catch(d){l.e(d)}finally{l.f()}}}catch(d){a.e(d)}finally{a.f()}}},{key:"_updateMap",value:function(e,n){var r,i=t(n);try{for(i.s();!(r=i.n()).done;){var a,o=r.value,u=t(e);try{for(u.s();!(a=u.n()).done;){var l=a.value;o.index_number===l.index_number&&this.appsConnectingMap.items.push({old_item_id:o.item_id,new_item_id:l.item_id})}}catch(c){u.e(c)}finally{u.f()}}}catch(c){i.e(c)}finally{i.f()}}},{key:"_searchOldAppId",value:function(e,n){var t,r;return null!==(t=null===(r=n.find(function(n){return n.new_app_id===e}))||void 0===r?void 0:r.old_app_id)&&void 0!==t?t:0}},{key:"_mapApp",value:function(e,n,r){r.apps.push({old_app_id:e.app_id,new_app_id:n.app_id,old_view_init:e.view_init,new_view_init:n.view_init});var i,a=t(e.field_list);try{for(a.s();!(i=a.n()).done;){var o,u=i.value,l=t(n.field_list);try{for(l.s();!(o=l.n()).done;){var c=o.value;u.name_space===c.name_space&&r.fields.push({name_space:u.name_space,old_field_id:u.field_id,new_field_id:c.field_id})}}catch(h){l.e(h)}finally{l.f()}}}catch(h){a.e(h)}finally{a.f()}var s,f=t(e.views_list);try{for(f.s();!(s=f.n()).done;){var p,d=s.value,_=t(n.views_list);try{for(_.s();!(p=_.n()).done;){var v=p.value;d.name===v.name&&r.views.push({name:d.name,old_view_id:d.view_id,new_view_id:v.view_id})}}catch(h){_.e(h)}finally{_.f()}}}catch(h){f.e(h)}finally{f.f()}}},{key:"_crawling",value:function(e,n){if(null!==e)for(var t=0,r=Object.keys(e);t<r.length;t++){var i=r[t],a=e[i];void 0!==a&&"string"!=typeof e&&(n(i,a,e),this._crawling(a,n))}}},{key:"_resetViewsIds",value:function(e){e.view_init=0,this._crawling(e.views_list,function(e,n,t){"view_id"!==e&&"container_id"!==e||(t[e]=0)})}},{key:"_connectApps",value:function(e,n,r){var i,a=this,o=function(e,n){return n.some(function(n){return-1!==e.indexOf(n)})},u=t(e);try{var l=function(){var e,u=i.value,l=t(n.apps);try{for(l.s();!(e=l.n()).done;){var c=e.value;if(u.view_init===c.new_view_init){var s,f=t(n.views);try{for(f.s();!(s=f.n()).done;){var p=s.value;c.old_view_init===p.old_view_id&&(u.view_init=p.new_view_id)}}catch(d){f.e(d)}finally{f.f()}}}}catch(d){l.e(d)}finally{l.f()}a._crawling(u.field_list,function(e,i,l){var c;if(o(e,["field_id","FieldId","destination_field","element_id"])){var s,f=String(i).split(","),p=[],_=t(n.fields);try{for(_.s();!(s=_.n()).done;){var v,h=s.value,y=t(f);try{for(y.s();!(v=y.n()).done;){v.value==h.old_field_id&&p.push(h.new_field_id)}}catch(d){y.e(d)}finally{y.f()}}}catch(d){_.e(d)}finally{_.f()}p.length&&(l[e]=p.join(","))}if(o(e,["app_id","AppId","destination_app"])){var m,b=t(n.apps);try{for(b.s();!(m=b.n()).done;){var w=m.value;i==w.old_app_id&&(l[e]=w.new_app_id)}}catch(d){b.e(d)}finally{b.f()}}if(o(e,["view_id"])){var g,k=t(n.views);try{for(k.s();!(g=k.n()).done;){var A=g.value;i==A.old_view_id&&(l[e]=A.new_view_id)}}catch(d){k.e(d)}finally{k.f()}}if(o(e,["src"])&&isFinite(i)){var O=n.apps.find(function(e){return e.new_app_id===u.app_id}).old_app_id,P=a._findPath(r[O].views_list,"container_id",i);l[e]="".concat(a._getValueByPath(u.views_list,P,"container_id"))}if(-1!==e.indexOf("trigger")&&null!==(c=i.model)&&void 0!==c&&c.nodes){var S=i.model.nodes;for(var j in S)for(var I=0,E=["inputs","outputs"];I<E.length;I++){var T,N=E[I],x=S[j],G=t(Object.keys(x[N]).filter(function(e){return""!==e&&!isNaN(e)}));try{var M=function(){var e=T.value,r=n.fields.find(function(n){return n.old_field_id==e});if(null!=r&&r.new_field_id){var i,a=r.new_field_id.toString(),o=x[N][e],u=t(o.connections);try{for(u.s();!(i=u.n()).done;){var l=i.value;l.input==e&&(l.input=a),l.output==e&&(l.output=a)}}catch(d){u.e(d)}finally{u.f()}delete x[N][e],x[N][a]=o}};for(G.s();!(T=G.n()).done;)M()}catch(d){G.e(d)}finally{G.f()}}}})};for(u.s();!(i=u.n()).done;)l()}catch(c){u.e(c)}finally{u.f()}return e}},{key:"_getValueByPath",value:function(e,n,r){var i,a=e,o=t(n.split("."));try{for(o.s();!(i=o.n()).done;){a=a[i.value]}}catch(u){o.e(u)}finally{o.f()}return a[r]}},{key:"_findPath",value:function(e,n,t){var r=!1,i=!1,a=[];return this._crawling(e,function(e,o,l){i&&a.reverse().forEach(function(e){i&&(e.delete=!0,e.parent===l&&(i=!1,(a=a.filter(function(e){return!e.delete})).reverse()))}),r||("object"===u(l[e])&&a.push({prop:e,parent:l}),o==t&&n===e?r=!0:Object.keys(l).pop()===e&&"object"!==u(l[e])&&(i=!0))}),a.map(function(e){return e.prop}).join(".")}},{key:"_prepareAppTemplate",value:function(e){var n=JSON.parse(JSON.stringify(e));this._crawling(n.views_list,function(e,n,t){"element_id"===e&&(t.element_id=-Number(n),t.create_element=-Number(n))});var r,i=t(n.field_list);try{for(i.s();!(r=i.n()).done;){var a=r.value;a.create_field=-Number(a.field_id),a.element_id=-Number(a.field_id),a.field_id=-Number(a.field_id),a.field_value=""}}catch(o){i.e(o)}finally{i.f()}return n.items_list=[],delete n.app_id,delete n.icon.id,delete n.group_id,delete n.trash,delete n.last_update,delete n.file_list,n}}])}();
296
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("../../gudhub.js");function n(e){if(null!=e){var n=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(u(e)+" is not iterable")}function t(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=r(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}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 o,u=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){l=!0,o=e},f:function(){try{u||null==t.return||t.return()}finally{if(l)throw o}}}}function r(e,n){if(e){if("string"==typeof e)return i(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,n):void 0}}function i(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function a(){var e,n,t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",i=t.toStringTag||"@@toStringTag";function u(t,r,i,a){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return o(s,"_invoke",function(t,r,i){var a,o,u,c=0,s=i||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(n,t){return a=n,o=0,u=e,p.n=t,l}};function d(t,r){for(o=t,u=r,n=0;!f&&c&&!i&&n<s.length;n++){var i,a=s[n],d=p.p,_=a[2];t>3?(i=_===r)&&(u=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=d&&((i=t<2&&d<a[1])?(o=0,p.v=r,p.n=a[1]):d<_&&(i=t<3||a[0]>r||r>_)&&(a[4]=t,a[5]=r,p.n=_,o=0))}if(i||t>1)return l;throw f=!0,r}return function(i,s,_){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,_),o=s,u=_;(n=o<2?e:u)||!f;){a||(o?o<3?(o>1&&(p.n=-1),d(o,u)):p.n=u:p.v=u);try{if(c=2,a){if(o||(i="next"),n=a[i]){if(!(n=n.call(a,u)))throw TypeError("iterator result is not an object");if(!n.done)return n;u=n.value,o<2&&(o=0)}else 1===o&&(n=a.return)&&n.call(a),o<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),o=1);a=e}else if((n=(f=p.n<0)?u:t.call(r,p))!==l)break}catch(n){a=e,o=1,u=n}finally{c=1}}return{value:n,done:f}}}(t,i,a),!0),s}var l={};function c(){}function s(){}function f(){}n=Object.getPrototypeOf;var p=[][r]?n(n([][r]())):(o(n={},r,function(){return this}),n),d=f.prototype=c.prototype=Object.create(p);function _(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,o(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=f,o(d,"constructor",f),o(f,"constructor",s),s.displayName="GeneratorFunction",o(f,i,"GeneratorFunction"),o(d),o(d,i,"Generator"),o(d,r,function(){return this}),o(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:u,m:_}})()}function o(e,n,t,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}(o=function(e,n,t,r){function a(n,t){o(e,n,function(e){return this._invoke(n,t,e)})}n?i?i(e,n,{value:t,enumerable:!r,configurable:!r,writable:!r}):e[n]=t:(a("next",0),a("throw",1),a("return",2))})(e,n,t,r)}function u(e){return(u="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 l(e,n,t,r,i,a,o){try{var u=e[a](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(r,i)}function c(e){return function(){var n=this,t=arguments;return new Promise(function(r,i){var a=e.apply(n,t);function o(e){l(a,r,i,o,u,"next",e)}function u(e){l(a,r,i,o,u,"throw",e)}o(void 0)})}}function s(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function f(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}function p(e,n,t){return n&&f(e.prototype,n),t&&f(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var n=_(e,"string");return"symbol"==u(n)?n:n+""}function _(e,n){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}var v=exports.default=function(){return p(function e(n){s(this,e),this.gudhub=n,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}},[{key:"createAppsFromTemplate",value:function(){var n=c(a().m(function n(t,r,i,o,l,c){var s,f,p,d,_,v,h,y;return a().w(function(n){for(;;)switch(n.n){case 0:if(s=6*t.apps.length,f=100/s,p=0,d=o?new e.GudHub(i,{server_url:"".concat(r,"/GudHub")}):null,!o){n.n=2;break}return n.n=1,d.getAppsList();case 1:y=n.v,n.n=3;break;case 2:y=null;case 3:return y,_=function(e){p+=1,null==c||c({percent:p*f,status:e})},v=function(e){"string"==typeof e?(p+=1,null==c||c({percent:p*f,status:e})):"object"===u(e)&&(null==c||c({status:"Done",apps:e}))},n.n=4,this._createApps(t,r,i,o,d,_);case 4:return h=n.v,n.n=5,this._createItems(h,r,i,o,d,l,v);case 5:return n.a(2)}},n,this)}));return function(e,t,r,i,a,o){return n.apply(this,arguments)}}()},{key:"_createApps",value:function(){var e=c(a().m(function e(n,r,i,o,u,l){var c,s,f,p,d,_,v,h,y,m,b,w,g,k,A,O,P;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(c={},s=[],f=[],p=null,!o){e.n=2;break}return e.n=1,this.gudhub.req.axiosRequest({method:"POST",url:"".concat(r,"/GudHub/auth/login"),form:{auth_key:i}});case 1:d=e.v,p=d.accesstoken;case 2:_=t(n.apps),e.p=3,_.s();case 4:if((v=_.n()).done){e.n=12;break}if(h=v.value,y=void 0,!o){e.n=6;break}return e.n=5,this.gudhub.req.axiosRequest({url:"".concat(r,"/GudHub/api/app/get?token=").concat(p,"&app_id=").concat(h),method:"GET"});case 5:y=e.v,e.n=8;break;case 6:return e.n=7,this.gudhub.getApp(h);case 7:y=e.v;case 8:if(y){e.n=9;break}throw new Error("Failed to get app: ".concat(h));case 9:return null==l||l("GET APP: ".concat(y.app_name," (App steps)")),m=JSON.parse(JSON.stringify(y)),c[m.app_id]=m,(b=this._prepareAppTemplate(m)).privacy=1,n.data_to_change&&(n.data_to_change.name&&(b.app_name=n.data_to_change.name),n.data_to_change.icon&&(b.icon=n.data_to_change.icon)),this._resetViewsIds(b),e.n=10,this.gudhub.createNewApp(b);case 10:w=e.v,null==l||l("CREATE NEW APP: ".concat(y.app_name," (App steps)")),s.push(w),this._mapApp(m,w,this.appsConnectingMap);case 11:e.n=4;break;case 12:e.n=14;break;case 13:e.p=13,P=e.v,_.e(P);case 14:return e.p=14,_.f(),e.f(14);case 15:this._connectApps(s,this.appsConnectingMap,c),g=0,k=s;case 16:if(!(g<k.length)){e.n=19;break}return A=k[g],e.n=17,this.gudhub.updateApp(A);case 17:O=e.v,null==l||l("UPDATE APP: ".concat(O.app_name," (App steps)")),f.push(O);case 18:g++,e.n=16;break;case 19:return e.a(2,f)}},e,this,[[3,13,14,15]])}));return function(n,t,r,i,a,o){return e.apply(this,arguments)}}()},{key:"_createItems",value:function(){var e=c(a().m(function e(n,r,i,o,u,l,s){var f,p,d,_,v,h,y,m,b,w,g,k,A,O,P,S,j=this;return a().w(function(e){for(;;)switch(e.n){case 0:if(f=null!=l?l:1e5,p=null,!o){e.n=2;break}return e.n=1,this.gudhub.req.axiosRequest({method:"POST",url:"".concat(r,"/GudHub/auth/login"),form:{auth_key:i}});case 1:d=e.v,p=d.accesstoken;case 2:return e.n=3,Promise.all(n.map(function(){var e=c(a().m(function e(n){var t,i,u,l;return a().w(function(e){for(;;)switch(e.n){case 0:if(!o){e.n=2;break}return e.n=1,j.gudhub.req.axiosRequest({url:"".concat(r,"/GudHub/api/app/get?token=").concat(p,"&app_id=").concat(j._searchOldAppId(n.app_id,j.appsConnectingMap.apps)),method:"GET"});case 1:t=e.v,e.n=4;break;case 2:return e.n=3,j.gudhub.getApp(j._searchOldAppId(n.app_id,j.appsConnectingMap.apps));case 3:t=e.v;case 4:if(t){e.n=5;break}throw new Error("Failed to get app in createItems: ".concat(n.app_id));case 5:return null==s||s("GET APP: ".concat(t.app_name," (Items steps)")),i=JSON.parse(JSON.stringify(t)),u=i.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,n){return n<=f}),e.n=6,j.gudhub.addNewItems(n.app_id,u);case 6:return l=e.v,null==s||s("ADD NEW ITEMS: ".concat(t.app_name," (Items steps)")),n.items_list=l,j._updateMap(n.items_list,i.items_list),j._addFieldValue(i.items_list,n.items_list,j.appsConnectingMap),e.a(2,n)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 3:_=e.v,v=t(_);try{for(v.s();!(h=v.n()).done;){y=h.value,m=t(y.items_list);try{for(m.s();!(b=m.n()).done;){w=b.value,g=t(w.fields);try{for(g.s();!(k=g.n()).done;){A=k.value,O=t(this.appsConnectingMap.fields);try{for(O.s();!(P=O.n()).done;)S=P.value,A.field_id===S.old_field_id&&(A.field_id=S.new_field_id,A.element_id=S.new_field_id)}catch(I){O.e(I)}finally{O.f()}}}catch(I){g.e(I)}finally{g.f()}}}catch(I){m.e(I)}finally{m.f()}}}catch(I){v.e(I)}finally{v.f()}return this._deleteField(_),e.n=4,this._replaceValue(_,this.appsConnectingMap,o,u);case 4:return e.n=5,Promise.all(_.map(function(){var e=c(a().m(function e(n){var t;return a().w(function(e){for(;;)switch(e.n){case 0:return t=n.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e}),e.n=1,j.gudhub.updateItems(n.app_id,t);case 1:null==s||s("REPLACE VALUE: ".concat(n.app_name," (Items steps)"));case 2:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 5:null==s||s(_);case 6:return e.a(2)}},e,this)}));return function(n,t,r,i,a,o,u){return e.apply(this,arguments)}}()},{key:"_deleteField",value:function(e){var n,r=t(e);try{var i=function(){var e,r=n.value,i=t(r.items_list);try{for(i.s();!(e=i.n()).done;){var a=e.value;a.fields=a.fields.filter(function(e){return r.field_list.findIndex(function(n){return n.field_id==e.field_id})>-1})}}catch(o){i.e(o)}finally{i.f()}};for(r.s();!(n=r.n()).done;)i()}catch(a){r.e(a)}finally{r.f()}}},{key:"_replaceValue",value:function(){var e=c(a().m(function e(r,i,o,u){var l,s,f,p,d,_,v=this;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:l=[],s=null==i?void 0:i.apps,f=t(r),e.p=1,d=a().m(function e(){var r,f,d,_,h;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:r=p.value,f=t(r.field_list),e.p=1,_=a().m(function e(){var n;return a().w(function(e){for(;;)switch(e.n){case 0:"item_ref"===(n=d.value).data_type&&v._replaceValueItemRef(r,n,i),l.push(v.gudhub.ghconstructor.getInstance(n.data_type).then(function(){var e=c(a().m(function e(t){return a().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,{type:n.data_type});case 1:if("file"!==t.getTemplate().constructor){e.n=2;break}return e.a(2,v.gudhub.util.fileInstallerHelper(s,r.app_id,r.items_list,n.field_id,o,u));case 2:if("document"!==t.getTemplate().constructor){e.n=4;break}return e.n=3,v._documentInstallerHelper(r.app_id,r.items_list,n.field_id);case 3:case 4:return e.a(2,t)}},e)}));return function(n){return e.apply(this,arguments)}}()));case 1:return e.a(2)}},e)}),f.s();case 2:if((d=f.n()).done){e.n=4;break}return e.d(n(_()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,h=e.v,f.e(h);case 6:return e.p=6,f.f(),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])}),f.s();case 2:if((p=f.n()).done){e.n=4;break}return e.d(n(d()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,_=e.v,f.e(_);case 6:return e.p=6,f.f(),e.f(6);case 7:if(!(l.length>0)){e.n=8;break}return e.a(2,Promise.all(l));case 8:return e.a(2)}},e,null,[[1,5,6,7]])}));return function(n,t,r,i){return e.apply(this,arguments)}}()},{key:"_documentInstallerHelper",value:function(){var e=c(a().m(function e(n,r,i){var o,u,l,c,s,f,p,d,_;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:o=[],u=t(r),e.p=1,u.s();case 2:if((l=u.n()).done){e.n=6;break}if(s=l.value,!((null==(f=s.fields.find(function(e){return e.element_id===i}))||null===(c=f.field_value)||void 0===c?void 0:c.length)>0)){e.n=5;break}return e.n=3,this.gudhub.getDocument({_id:f.field_value});case 3:if(null==(p=e.v)||!p.data){e.n=5;break}return e.n=4,this.gudhub.createDocument({app_id:n,item_id:s.item_id,element_id:i,data:p.data});case 4:d=e.v,f.field_value=d._id,o.push(s);case 5:e.n=2;break;case 6:e.n=8;break;case 7:e.p=7,_=e.v,u.e(_);case 8:return e.p=8,u.f(),e.f(8);case 9:return e.a(2,o)}},e,this,[[1,7,8,9]])}));return function(n,t,r){return e.apply(this,arguments)}}()},{key:"_replaceValueItemRef",value:function(e,n,r){var i,a=t(e.items_list);try{for(a.s();!(i=a.n()).done;){var o,u=t(i.value.fields);try{for(u.s();!(o=u.n()).done;){var l=o.value;if(l.field_id===n.field_id&&l.field_value){var c=l.field_value.split(",").map(function(e){var n,i=e.split("."),a=t(r.apps);try{for(a.s();!(n=a.n()).done;){var o=n.value;i[0]==o.old_app_id&&(i[0]=o.new_app_id)}}catch(s){a.e(s)}finally{a.f()}var u,l=t(r.items);try{for(l.s();!(u=l.n()).done;){var c=u.value;i[1]==c.old_item_id&&(i[1]=c.new_item_id)}}catch(s){l.e(s)}finally{l.f()}return i.join(".")});l.field_value=c.join(",")}}}catch(s){u.e(s)}finally{u.f()}}}catch(s){a.e(s)}finally{a.f()}}},{key:"_addFieldValue",value:function(e,n,r){var i,a=t(n);try{for(a.s();!(i=a.n()).done;){var o,u=i.value,l=t(r.items);try{for(l.s();!(o=l.n()).done;){var c=o.value;if(u.item_id===c.new_item_id){var s,f=t(e);try{for(f.s();!(s=f.n()).done;){var p=s.value;c.old_item_id===p.item_id&&(u.fields=p.fields)}}catch(d){f.e(d)}finally{f.f()}}}}catch(d){l.e(d)}finally{l.f()}}}catch(d){a.e(d)}finally{a.f()}}},{key:"_updateMap",value:function(e,n){var r,i=t(n);try{for(i.s();!(r=i.n()).done;){var a,o=r.value,u=t(e);try{for(u.s();!(a=u.n()).done;){var l=a.value;o.index_number===l.index_number&&this.appsConnectingMap.items.push({old_item_id:o.item_id,new_item_id:l.item_id})}}catch(c){u.e(c)}finally{u.f()}}}catch(c){i.e(c)}finally{i.f()}}},{key:"_searchOldAppId",value:function(e,n){var t,r;return null!==(t=null===(r=n.find(function(n){return n.new_app_id===e}))||void 0===r?void 0:r.old_app_id)&&void 0!==t?t:0}},{key:"_mapApp",value:function(e,n,r){r.apps.push({old_app_id:e.app_id,new_app_id:n.app_id,old_view_init:e.view_init,new_view_init:n.view_init});var i,a=t(e.field_list);try{for(a.s();!(i=a.n()).done;){var o,u=i.value,l=t(n.field_list);try{for(l.s();!(o=l.n()).done;){var c=o.value;u.name_space===c.name_space&&r.fields.push({name_space:u.name_space,old_field_id:u.field_id,new_field_id:c.field_id})}}catch(h){l.e(h)}finally{l.f()}}}catch(h){a.e(h)}finally{a.f()}var s,f=t(e.views_list);try{for(f.s();!(s=f.n()).done;){var p,d=s.value,_=t(n.views_list);try{for(_.s();!(p=_.n()).done;){var v=p.value;d.name===v.name&&r.views.push({name:d.name,old_view_id:d.view_id,new_view_id:v.view_id})}}catch(h){_.e(h)}finally{_.f()}}}catch(h){f.e(h)}finally{f.f()}}},{key:"_crawling",value:function(e,n){if(null!==e)for(var t=0,r=Object.keys(e);t<r.length;t++){var i=r[t],a=e[i];void 0!==a&&"string"!=typeof e&&(n(i,a,e),this._crawling(a,n))}}},{key:"_resetViewsIds",value:function(e){e.view_init=0,this._crawling(e.views_list,function(e,n,t){"view_id"!==e&&"container_id"!==e||(t[e]=0)})}},{key:"_connectApps",value:function(e,n,r){var i,a=this,o=function(e,n){return n.some(function(n){return-1!==e.indexOf(n)})},u=t(e);try{var l=function(){var e,u=i.value,l=t(n.apps);try{for(l.s();!(e=l.n()).done;){var c=e.value;if(u.view_init===c.new_view_init){var s,f=t(n.views);try{for(f.s();!(s=f.n()).done;){var p=s.value;c.old_view_init===p.old_view_id&&(u.view_init=p.new_view_id)}}catch(d){f.e(d)}finally{f.f()}}}}catch(d){l.e(d)}finally{l.f()}a._crawling(u.field_list,function(e,i,l){var c;if(o(e,["field_id","FieldId","destination_field","element_id"])){var s,f=String(i).split(","),p=[],_=t(n.fields);try{for(_.s();!(s=_.n()).done;){var v,h=s.value,y=t(f);try{for(y.s();!(v=y.n()).done;){v.value==h.old_field_id&&p.push(h.new_field_id)}}catch(d){y.e(d)}finally{y.f()}}}catch(d){_.e(d)}finally{_.f()}p.length&&(l[e]=p.join(","))}if(o(e,["app_id","AppId","destination_app"])){var m,b=t(n.apps);try{for(b.s();!(m=b.n()).done;){var w=m.value;i==w.old_app_id&&(l[e]=w.new_app_id)}}catch(d){b.e(d)}finally{b.f()}}if(o(e,["view_id"])){var g,k=t(n.views);try{for(k.s();!(g=k.n()).done;){var A=g.value;i==A.old_view_id&&(l[e]=A.new_view_id)}}catch(d){k.e(d)}finally{k.f()}}if(o(e,["src"])&&isFinite(i)){var O=n.apps.find(function(e){return e.new_app_id===u.app_id}).old_app_id,P=a._findPath(r[O].views_list,"container_id",i);l[e]="".concat(a._getValueByPath(u.views_list,P,"container_id"))}if(-1!==e.indexOf("trigger")&&null!==(c=i.model)&&void 0!==c&&c.nodes){var S=i.model.nodes;for(var j in S)for(var I=0,E=["inputs","outputs"];I<E.length;I++){var T,N=E[I],x=S[j],G=t(Object.keys(x[N]).filter(function(e){return""!==e&&!isNaN(e)}));try{var M=function(){var e=T.value,r=n.fields.find(function(n){return n.old_field_id==e});if(null!=r&&r.new_field_id){var i,a=r.new_field_id.toString(),o=x[N][e],u=t(o.connections);try{for(u.s();!(i=u.n()).done;){var l=i.value;l.input==e&&(l.input=a),l.output==e&&(l.output=a)}}catch(d){u.e(d)}finally{u.f()}delete x[N][e],x[N][a]=o}};for(G.s();!(T=G.n()).done;)M()}catch(d){G.e(d)}finally{G.f()}}}})};for(u.s();!(i=u.n()).done;)l()}catch(c){u.e(c)}finally{u.f()}return e}},{key:"_getValueByPath",value:function(e,n,r){var i,a=e,o=t(n.split("."));try{for(o.s();!(i=o.n()).done;){a=a[i.value]}}catch(u){o.e(u)}finally{o.f()}return a[r]}},{key:"_findPath",value:function(e,n,t){var r=!1,i=!1,a=[];return this._crawling(e,function(e,o,l){i&&a.reverse().forEach(function(e){i&&(e.delete=!0,e.parent===l&&(i=!1,(a=a.filter(function(e){return!e.delete})).reverse()))}),r||("object"===u(l[e])&&a.push({prop:e,parent:l}),o==t&&n===e?r=!0:Object.keys(l).pop()===e&&"object"!==u(l[e])&&(i=!0))}),a.map(function(e){return e.prop}).join(".")}},{key:"_prepareAppTemplate",value:function(e){var n=JSON.parse(JSON.stringify(e));this._crawling(n.views_list,function(e,n,t){"element_id"===e&&(t.element_id=-Number(n),t.create_element=-Number(n))});var r,i=t(n.field_list);try{for(i.s();!(r=i.n()).done;){var a=r.value;a.create_field=-Number(a.field_id),a.element_id=-Number(a.field_id),a.field_id=-Number(a.field_id),a.field_value=""}}catch(o){i.e(o)}finally{i.f()}return n.items_list=[],delete n.app_id,delete n.icon.id,delete n.group_id,delete n.trash,delete n.last_update,delete n.file_list,n}}])}();
297
297
  },{"../../gudhub.js":"U9gy"}],"E7yc":[function(require,module,exports) {
298
298
  "use strict";function e(t){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})(t)}function t(t){if(null!=t){var r=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(e(t)+" is not iterable")}function r(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 n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l(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(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,l=Object.create(a.prototype);return u(l,"_invoke",function(r,n,o){var i,a,u,f=0,l=o||[],s=!1,p={p:0,n:0,v:e,a:y,f:y.bind(e,4),d:function(t,r){return i=t,a=0,u=e,p.n=r,c}};function y(r,n){for(a=r,u=n,t=0;!s&&f&&!o&&t<l.length;t++){var o,i=l[t],y=p.p,b=i[2];r>3?(o=b===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=y&&((o=r<2&&y<i[1])?(a=0,p.v=n,p.n=i[1]):y<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,p.n=b,a=0))}if(o||r>1)return c;throw s=!0,n}return function(o,l,b){if(f>1)throw TypeError("Generator is already running");for(s&&1===l&&y(l,b),a=l,u=b;(t=a<2?e:u)||!s;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(f=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(s=p.n<0)?u:r.call(n,p))!==c)break}catch(t){i=e,a=1,u=t}finally{f=1}}return{value:t,done:s}}}(r,o,i),!0),l}var c={};function f(){}function l(){}function s(){}t=Object.getPrototypeOf;var p=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),y=s.prototype=f.prototype=Object.create(p);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,u(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e}return l.prototype=s,u(y,"constructor",s),u(s,"constructor",l),l.displayName="GeneratorFunction",u(s,o,"GeneratorFunction"),u(y),u(y,o,"Generator"),u(y,n,function(){return this}),u(y,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:b}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(u=function(e,t,r,n){function i(t,r){u(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 c(e){return p(e)||s(e)||l(e)||f()}function f(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){if(e){if("string"==typeof e)return y(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)?y(e,t):void 0}}function s(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function p(e){if(Array.isArray(e))return y(e)}function y(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 b(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){b(i,n,o,a,u,"next",e)}function u(e){b(i,n,o,a,u,"throw",e)}a(void 0)})}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(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,g(n.key),n)}}function h(e,t,r){return t&&m(e.prototype,t),r&&m(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function g(t){var r=w(t,"string");return"symbol"==e(r)?r:r+""}function w(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileHelper=void 0;var _=exports.FileHelper=function(){return h(function e(t){v(this,e),this.gudhub=t},[{key:"fileInstallerHelper",value:function(){var e=d(a().m(function e(t,r,n,o,i,u){var f,l,s,p,y,b;return a().w(function(e){for(;;)switch(e.n){case 0:f=[[]],l=[],n.forEach(function(e){var t=e.item_id,n=e.fields.find(function(e){return e.element_id===o});null!=n&&n.field_value&&n.field_value.split(".").forEach(function(e){var n={source:e,destination:{app_id:r,item_id:t,element_id:o}};10!==f[f.length-1].length?f[f.length-1].push(n):f.push([n])})}),s=0,p=f;case 1:if(!(s<p.length)){e.n=8;break}if((y=p[s]).length){e.n=2;break}return e.a(3,7);case 2:if(b=void 0,!i){e.n=4;break}return e.n=3,this._copyFilesFromRemoteServer(t,y,u);case 3:b=e.v,e.n=6;break;case 4:return e.n=5,this.gudhub.duplicateFile(y);case 5:b=e.v;case 6:l=[].concat(c(l),c(b));case 7:s++,e.n=1;break;case 8:n.forEach(function(e){var t=e.item_id,r=e.fields.find(function(e){return e.element_id===o});null!=r&&r.field_value&&(r.field_value="",l.forEach(function(e){e.item_id===t&&(r.field_value=r.field_value.split(",").filter(function(e){return e}).concat(e.file_id).join(","))}))});case 9:return e.a(2)}},e,this)}));return function(t,r,n,o,i,a){return e.apply(this,arguments)}}()},{key:"_copyFilesFromRemoteServer",value:function(){var e=d(a().m(function e(r,o,u){var c,f,l,s,p,y=this;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:c=[],f=i(o),e.p=1,s=a().m(function e(){var t,o,f,s,p,b,d,v,m,h;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=l.value,o=String(t.source).split(",").map(function(e){return e.trim()}).filter(Boolean),f=r.find(function(e){return e.new_app_id===t.destination.app_id})){e.n=1;break}return console.warn("App mapping not found for:",t.destination.app_id),e.a(2,1);case 1:s=f.old_app_id,p=i(o),e.p=2,p.s();case 3:if((b=p.n()).done){e.n=7;break}return d=b.value,e.n=4,u.getFile(s,d);case 4:return v=e.v,e.n=5,y.gudhub.uploadFileFromString(n(n({},v),{},{app_id:t.destination.app_id,item_id:t.destination.item_id,element_id:t.destination.element_id}));case 5:m=e.v,c.push(m);case 6:e.n=3;break;case 7:e.n=9;break;case 8:e.p=8,h=e.v,p.e(h);case 9:return e.p=9,p.f(),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}),f.s();case 2:if((l=f.n()).done){e.n=5;break}return e.d(t(s()),3);case 3:if(!e.v){e.n=4;break}return e.a(3,4);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,p=e.v,f.e(p);case 7:return e.p=7,f.f(),e.f(7);case 8:return e.a(2,c)}},e,null,[[1,6,7,8]])}));return function(t,r,n){return e.apply(this,arguments)}}()}])}();
299
299
  },{}],"AefJ":[function(require,module,exports) {