@gudhub/core 1.1.117 → 1.1.118

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.
@@ -333,7 +333,7 @@ export default class AppsTemplateService {
333
333
  progress.apps.push(source_app.icon);
334
334
 
335
335
  let appTemplate = self.prepareAppTemplate(source_app);
336
- appTemplate.app_name = appTemplate.app_name + ' New';
336
+ appTemplate.app_name = appTemplate.app_name;
337
337
  appTemplate.privacy = 1;
338
338
  if(pack.data_to_change) {
339
339
  if(pack.data_to_change.name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.117",
3
+ "version": "1.1.118",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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";function e(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(c(e)+" is not iterable")}function t(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=n(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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,c=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return u=e.done,e},e:function(e){c=!0,o=e},f:function(){try{u||null==i.return||i.return()}finally{if(c)throw o}}}}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function u(n,i,r,o){var u=i&&i.prototype instanceof f?i:f,p=Object.create(u.prototype);return a(p,"_invoke",function(n,i,r){var a,o,u,f=0,p=r||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,o=0,u=e,s.n=n,c}};function d(n,i){for(o=n,u=i,t=0;!l&&f&&!r&&t<p.length;t++){var r,a=p[t],d=s.p,_=a[2];n>3?(r=_===i)&&(u=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=d&&((r=n<2&&d<a[1])?(o=0,s.v=i,s.n=a[1]):d<_&&(r=n<3||a[0]>i||i>_)&&(a[4]=n,a[5]=i,s.n=_,o=0))}if(r||n>1)return c;throw l=!0,i}return function(r,p,_){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,_),o=p,u=_;(t=o<2?e:u)||!l;){a||(o?o<3?(o>1&&(s.n=-1),d(o,u)):s.n=u:s.v=u);try{if(f=2,a){if(o||(r="next"),t=a[r]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,o<2&&(o=0)}else 1===o&&(t=a.return)&&t.call(a),o<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),o=1);a=e}else if((t=(l=s.n<0)?u:n.call(i,s))!==c)break}catch(t){a=e,o=1,u=t}finally{f=1}}return{value:t,done:l}}}(n,r,o),!0),p}var c={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][i]?t(t([][i]())):(a(t={},i,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function _(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,a(d,"constructor",l),a(l,"constructor",p),p.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,i,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:_}})()}function a(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}(a=function(e,t,n,i){function o(t,n){a(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))})(e,t,n,i)}function o(e,t,n,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(i,r)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var a=e.apply(t,n);function u(e){o(a,i,r,u,c,"next",e)}function c(e){o(a,i,r,u,c,"throw",e)}u(void 0)})}}function c(e){return(c="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 f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function l(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=d(e,"string");return"symbol"==c(t)?t:t+""}function d(e,t){if("object"!=c(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=c(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _=exports.default=function(){return l(function e(t){f(this,e),this.gudhub=t,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}},[{key:"createAppsFromTemplate",value:function(e,t,n,i){var r=this,a=this;return new Promise(function(o){var u=100/(6*e.apps.length),f=0;a.createApps(e,function(e){f+=1,n&&n.call(r,{percent:f*u,status:e})},i).then(function(e){a.createItems(e,t,function(e){"string"==typeof e?(f+=1,n&&n.call(r,{percent:f*u,status:e})):"object"===c(e)&&(n&&n.call(r,{status:"Done",apps:e}),o())},i)})})}},{key:"createItems",value:function(e,t,n,i){var a=this;return new Promise(function(){var o=u(r().m(function o(c){var f,p,l,s,d,_;return r().w(function(o){for(;;)switch(o.n){case 0:return f=t||1e5,p=a,l=[],s=[],o.n=1,p.gudhub.req.axiosRequest({method:"POST",url:"https://app.gudhub.com/GudHub/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 1:d=o.v,_=d.accesstoken,e.forEach(function(e){s.push(new Promise(function(){var t=u(r().m(function t(o){var u,c,s;return r().w(function(t){for(;;)switch(t.n){case 0:if(!i){t.n=2;break}return t.n=1,p.gudhub.req.axiosRequest({url:"https://app.gudhub.com/GudHub/api/app/get?token=".concat(_,"&app_id=").concat(p._searchOldAppId(e.app_id,p.appsConnectingMap.apps)),method:"GET"});case 1:u=t.v,t.n=4;break;case 2:return t.n=3,p.gudhub.getApp(p._searchOldAppId(e.app_id,p.appsConnectingMap.apps));case 3:u=t.v;case 4:n&&n.call(a,"GET APP: ".concat(u.app_name," (Items steps)")),c=JSON.parse(JSON.stringify(u)),s=c.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,t){return t<=f}),p.gudhub.addNewItems(e.app_id,s).then(function(t){n&&n.call(a,"ADD NEW ITEMS: ".concat(u.app_name," (Items steps)")),e.items_list=t,p._updateMap(e.items_list,c.items_list),p._addFieldValue(c.items_list,e.items_list,p.appsConnectingMap),l.push(e),o()});case 5:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()))}),Promise.all(s).then(function(){l.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){p.appsConnectingMap.fields.forEach(function(t){e.field_id===t.old_field_id&&(e.field_id=t.new_field_id,e.element_id=t.new_field_id)})})})}),p.deleteField(l),p.replaceValue(l,p.appsConnectingMap).then(function(){var e=[];l.forEach(function(t){e.push(new Promise(function(e){var i=t.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e});p.gudhub.updateItems(t.app_id,i).then(function(){n&&n.call(a,"REPLACE VALUE: ".concat(t.app_name," (Items steps)")),e()})}))}),Promise.all(e).then(function(){n.call(a,l),c()})})});case 2:return o.a(2)}},o)}));return function(e){return o.apply(this,arguments)}}())}},{key:"deleteField",value:function(e){e.forEach(function(e){e.items_list.forEach(function(t){t.fields=t.fields.filter(function(t){return e.field_list.findIndex(function(e){return e.field_id==t.field_id})>-1})})})}},{key:"replaceValue",value:function(e,t){var n=this;return new Promise(function(){var i=u(r().m(function i(a){var o,u;return r().w(function(i){for(;;)switch(i.n){case 0:o=[],u=n,e.forEach(function(e){e.field_list.forEach(function(n){"item_ref"===n.data_type&&u._replaceValueItemRef(e,n,t),o.push(new Promise(function(t){u.gudhub.ghconstructor.getInstance(n.data_type).then(function(i){return void 0===i?(console.log("ERROR WHILE GETTING INSTANCE OF ",n.data_type),void t({type:n.data_type})):"file"==i.getTemplate().constructor?u.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(e)}):void("document"==i.getTemplate().constructor?u.documentInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(i)}):t(i))})}))})}),o.length>0?Promise.all(o).then(function(e){a(e)}):a(result);case 1:return i.a(2)}},i)}));return function(e){return i.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(e,n,i){var a=this,o=[];return new Promise(function(){var c=u(r().m(function u(c){var f,p,l,s,d,_,h,m;return r().w(function(r){for(;;)switch(r.p=r.n){case 0:f=t(n),r.p=1,f.s();case 2:if((p=f.n()).done){r.n=6;break}if(l=p.value,s=l.item_id,!((d=l.fields.find(function(e){return e.element_id===i}))&&d.field_value&&d.field_value.length>0)){r.n=5;break}return r.n=3,a.gudhub.getDocument({_id:d.field_value});case 3:if(!(_=r.v)||!_.data){r.n=5;break}return r.n=4,a.gudhub.createDocument({app_id:e,item_id:s,element_id:i,data:_.data});case 4:h=r.v,d.field_value=h._id,o.push(l);case 5:r.n=2;break;case 6:r.n=8;break;case 7:r.p=7,m=r.v,f.e(m);case 8:return r.p=8,f.f(),r.f(8);case 9:c(o);case 10:return r.a(2)}},u,null,[[1,7,8,9]])}));return function(e){return c.apply(this,arguments)}}())}},{key:"_replaceValueItemRef",value:function(e,t,n){e.items_list.forEach(function(e){e.fields.forEach(function(e){if(e.field_id===t.field_id&&e.field_value){var i=e.field_value.split(",");i.forEach(function(e,t){var r=e.split(".");n.apps.forEach(function(e){r[0]==e.old_app_id&&(r[0]=e.new_app_id)}),n.items.forEach(function(e){r[1]==e.old_item_id&&(r[1]=e.new_item_id)}),i[t]=r.join(".")}),e.field_value=i.join(",")}})})}},{key:"_addFieldValue",value:function(e,t,n){t.forEach(function(t){n.items.forEach(function(n){t.item_id===n.new_item_id&&e.forEach(function(e){n.old_item_id===e.item_id&&(t.fields=e.fields)})})})}},{key:"_updateMap",value:function(e,t){var n=this;t.forEach(function(t){e.forEach(function(e){t.index_number===e.index_number&&n.appsConnectingMap.items.push({old_item_id:t.item_id,new_item_id:e.item_id})})})}},{key:"_searchOldAppId",value:function(e,t){var n=0;return t.forEach(function(t){t.new_app_id===e&&(n=t.old_app_id)}),n}},{key:"createApps",value:function(n,i,a){var o=this,c=this,f={step_size:100/(3*n.apps.length),apps:[]};return new Promise(function(){var p=u(r().m(function u(p){var l,s,d,_,h,m,v,y,b;return r().w(function(u){for(;;)switch(u.p=u.n){case 0:return l={},s=[],d=[],u.n=1,c.gudhub.req.axiosRequest({method:"POST",url:"https://app.gudhub.com/GudHub/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 1:_=u.v,h=_.accesstoken,m=t(n.apps),u.p=2,y=r().m(function e(){var t,u,_,m;return r().w(function(e){for(;;)switch(e.n){case 0:if(t=v.value,!a){e.n=2;break}return e.n=1,c.gudhub.req.axiosRequest({url:"https://app.gudhub.com/GudHub/api/app/get?token=".concat(h,"&app_id=").concat(t),method:"GET"});case 1:u=e.v,e.n=4;break;case 2:return e.n=3,c.gudhub.getApp(t);case 3:u=e.v;case 4:i&&i.call(o,"GET APP: ".concat(u.app_name," (App steps)")),_=JSON.parse(JSON.stringify(u)),l[_.app_id]=_,f.apps.push(_.icon),(m=c.prepareAppTemplate(_)).app_name=m.app_name+" New",m.privacy=1,n.data_to_change&&(n.data_to_change.name&&(m.app_name=n.data_to_change.name),n.data_to_change.icon&&(m.icon=n.data_to_change.icon)),c.resetViewsIds(m),c.gudhub.createNewApp(m).then(function(e){i&&i.call(o,"CREATE NEW APP: ".concat(u.app_name," (App steps)")),s.push(e),c.mapApp(_,e,c.appsConnectingMap),n.apps.length==s.length&&(c.connectApps(s,c.appsConnectingMap,l),s.forEach(function(e){c.gudhub.updateApp(e).then(function(e){i&&i.call(o,"UPDATE APP: ".concat(u.app_name," (App steps)")),d.push(e),n.apps.length==d.length&&p(d)})}))});case 5:return e.a(2)}},e)}),m.s();case 3:if((v=m.n()).done){u.n=5;break}return u.d(e(y()),4);case 4:u.n=3;break;case 5:u.n=7;break;case 6:u.p=6,b=u.v,m.e(b);case 7:return u.p=7,m.f(),u.f(7);case 8:return u.a(2)}},u,null,[[2,6,7,8]])}));return function(e){return p.apply(this,arguments)}}())}},{key:"mapApp",value:function(e,t,n){n.apps.push({old_app_id:e.app_id,new_app_id:t.app_id,old_view_init:e.view_init,new_view_init:t.view_init}),e.field_list.forEach(function(e){t.field_list.forEach(function(t){e.name_space==t.name_space&&n.fields.push({name_space:e.name_space,old_field_id:e.field_id,new_field_id:t.field_id})})}),e.views_list.forEach(function(e){t.views_list.forEach(function(t){e.name==t.name&&n.views.push({name:e.name,old_view_id:e.view_id,new_view_id:t.view_id})})})}},{key:"crawling",value:function(e,t){var n=null===e?[]:Object.keys(e),i=this;n.length>0&&n.forEach(function(n){var r=e[n];void 0!==r&&"string"!=typeof e&&(t(n,r,e),i.crawling(r,t))})}},{key:"resetViewsIds",value:function(e){e.view_init=0,this.crawling(e.views_list,function(e,t,n){"view_id"!=e&&"container_id"!=e||(n[e]=0)})}},{key:"connectApps",value:function(e,t,n){var i=this;return e.forEach(function(e){t.apps.forEach(function(n){e.view_init===n.new_view_init&&t.views.forEach(function(t){n.old_view_init===t.old_view_id&&(e.view_init=t.new_view_id)})}),i.crawling(e.field_list,function(r,a,o){var u=function(e,t){return t.some(function(t){return-1!==e.indexOf(t)})};if(u(r,["field_id","FieldId","destination_field","element_id"])){var c=String(a).split(","),f=[];t.fields.forEach(function(e){c.forEach(function(t){t==e.old_field_id&&f.push(e.new_field_id)})}),f.length&&(o[r]=f.join(","))}if(u(r,["app_id","AppId","destination_app"])&&t.apps.forEach(function(e){a==e.old_app_id&&(o[r]=e.new_app_id)}),u(r,["view_id"])&&t.views.forEach(function(e){a==e.old_view_id&&(o[r]=e.new_view_id)}),u(r,["src"])&&isFinite(a)){var p=t.apps.find(function(t){return t.new_app_id===e.app_id}).old_app_id,l=i.findPath(n[p].views_list,"container_id",a);o[r]="".concat(i.getValueByPath(e.views_list,l,"container_id"))}if(-1!==r.indexOf("trigger")&&a.model&&a.model.nodes){var s=a.model.nodes,d=["inputs","outputs"],_=function(e){d.forEach(function(n){var i=s[e];Object.keys(i[n]).filter(function(e){return""!==e&&!isNaN(e)}).forEach(function(e){var r=t.fields.filter(function(t){return t.old_field_id==e});if(0!==r.length&&r[0].new_field_id){var a=r[0].new_field_id.toString(),o=i[n][e];o.connections.forEach(function(t){t.input==e&&(t.input=a),t.output==e&&(t.output=a)}),delete i[n][e],i[n][a]=o}})})};for(var h in s)_(h)}})}),e}},{key:"getValueByPath",value:function(e,t,n){var i=e;return t.split(".").forEach(function(e){i=i[e]}),i[n]}},{key:"findPath",value:function(e,t,n){var i=!1,r=!1,a=[];return this.crawling(e,function(e,o,u){r&&a.reverse().forEach(function(e){r&&(e.delete=!0,e.parent===u&&(r=!1,(a=a.filter(function(e){return!e.delete})).reverse()))}),i||("object"===c(u[e])&&a.push({prop:e,parent:u}),o==n&&t===e?i=!0:Object.keys(u).pop()===e&&"object"!==c(u[e])&&(r=!0))}),a.map(function(e){return e.prop}).join(".")}},{key:"prepareAppTemplate",value:function(e){var t=JSON.parse(JSON.stringify(e));return this.crawling(t.views_list,function(e,t,n){"element_id"==e&&(n.element_id=-Number(t),n.create_element=-Number(t))}),t.field_list.forEach(function(e){e.create_field=-Number(e.field_id),e.element_id=-Number(e.field_id),e.field_id=-Number(e.field_id),e.field_value=""}),t.items_list=[],delete t.app_id,delete t.icon.id,delete t.group_id,delete t.trash,delete t.last_update,delete t.file_list,t}}])}();
296
+ "use strict";function e(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(c(e)+" is not iterable")}function t(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=n(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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,c=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return u=e.done,e},e:function(e){c=!0,o=e},f:function(){try{u||null==i.return||i.return()}finally{if(c)throw o}}}}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function r(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function u(n,i,r,o){var u=i&&i.prototype instanceof f?i:f,p=Object.create(u.prototype);return a(p,"_invoke",function(n,i,r){var a,o,u,f=0,p=r||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,o=0,u=e,s.n=n,c}};function d(n,i){for(o=n,u=i,t=0;!l&&f&&!r&&t<p.length;t++){var r,a=p[t],d=s.p,_=a[2];n>3?(r=_===i)&&(u=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=d&&((r=n<2&&d<a[1])?(o=0,s.v=i,s.n=a[1]):d<_&&(r=n<3||a[0]>i||i>_)&&(a[4]=n,a[5]=i,s.n=_,o=0))}if(r||n>1)return c;throw l=!0,i}return function(r,p,_){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,_),o=p,u=_;(t=o<2?e:u)||!l;){a||(o?o<3?(o>1&&(s.n=-1),d(o,u)):s.n=u:s.v=u);try{if(f=2,a){if(o||(r="next"),t=a[r]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,o<2&&(o=0)}else 1===o&&(t=a.return)&&t.call(a),o<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),o=1);a=e}else if((t=(l=s.n<0)?u:n.call(i,s))!==c)break}catch(t){a=e,o=1,u=t}finally{f=1}}return{value:t,done:l}}}(n,r,o),!0),p}var c={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][i]?t(t([][i]())):(a(t={},i,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function _(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,a(d,"constructor",l),a(l,"constructor",p),p.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,i,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:_}})()}function a(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}(a=function(e,t,n,i){function o(t,n){a(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))})(e,t,n,i)}function o(e,t,n,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(i,r)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var a=e.apply(t,n);function u(e){o(a,i,r,u,c,"next",e)}function c(e){o(a,i,r,u,c,"throw",e)}u(void 0)})}}function c(e){return(c="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 f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function l(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=d(e,"string");return"symbol"==c(t)?t:t+""}function d(e,t){if("object"!=c(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=c(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _=exports.default=function(){return l(function e(t){f(this,e),this.gudhub=t,this.appsConnectingMap={apps:[],fields:[],items:[],views:[]}},[{key:"createAppsFromTemplate",value:function(e,t,n,i){var r=this,a=this;return new Promise(function(o){var u=100/(6*e.apps.length),f=0;a.createApps(e,function(e){f+=1,n&&n.call(r,{percent:f*u,status:e})},i).then(function(e){a.createItems(e,t,function(e){"string"==typeof e?(f+=1,n&&n.call(r,{percent:f*u,status:e})):"object"===c(e)&&(n&&n.call(r,{status:"Done",apps:e}),o())},i)})})}},{key:"createItems",value:function(e,t,n,i){var a=this;return new Promise(function(){var o=u(r().m(function o(c){var f,p,l,s,d,_;return r().w(function(o){for(;;)switch(o.n){case 0:return f=t||1e5,p=a,l=[],s=[],o.n=1,p.gudhub.req.axiosRequest({method:"POST",url:"https://app.gudhub.com/GudHub/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 1:d=o.v,_=d.accesstoken,e.forEach(function(e){s.push(new Promise(function(){var t=u(r().m(function t(o){var u,c,s;return r().w(function(t){for(;;)switch(t.n){case 0:if(!i){t.n=2;break}return t.n=1,p.gudhub.req.axiosRequest({url:"https://app.gudhub.com/GudHub/api/app/get?token=".concat(_,"&app_id=").concat(p._searchOldAppId(e.app_id,p.appsConnectingMap.apps)),method:"GET"});case 1:u=t.v,t.n=4;break;case 2:return t.n=3,p.gudhub.getApp(p._searchOldAppId(e.app_id,p.appsConnectingMap.apps));case 3:u=t.v;case 4:n&&n.call(a,"GET APP: ".concat(u.app_name," (Items steps)")),c=JSON.parse(JSON.stringify(u)),s=c.items_list.map(function(e){return{index_number:e.index_number,item_id:0,fields:[]}}).filter(function(e,t){return t<=f}),p.gudhub.addNewItems(e.app_id,s).then(function(t){n&&n.call(a,"ADD NEW ITEMS: ".concat(u.app_name," (Items steps)")),e.items_list=t,p._updateMap(e.items_list,c.items_list),p._addFieldValue(c.items_list,e.items_list,p.appsConnectingMap),l.push(e),o()});case 5:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()))}),Promise.all(s).then(function(){l.forEach(function(e){e.items_list.forEach(function(e){e.fields.forEach(function(e){p.appsConnectingMap.fields.forEach(function(t){e.field_id===t.old_field_id&&(e.field_id=t.new_field_id,e.element_id=t.new_field_id)})})})}),p.deleteField(l),p.replaceValue(l,p.appsConnectingMap).then(function(){var e=[];l.forEach(function(t){e.push(new Promise(function(e){var i=t.items_list.map(function(e){return e.fields.forEach(function(e){delete e.data_id}),e});p.gudhub.updateItems(t.app_id,i).then(function(){n&&n.call(a,"REPLACE VALUE: ".concat(t.app_name," (Items steps)")),e()})}))}),Promise.all(e).then(function(){n.call(a,l),c()})})});case 2:return o.a(2)}},o)}));return function(e){return o.apply(this,arguments)}}())}},{key:"deleteField",value:function(e){e.forEach(function(e){e.items_list.forEach(function(t){t.fields=t.fields.filter(function(t){return e.field_list.findIndex(function(e){return e.field_id==t.field_id})>-1})})})}},{key:"replaceValue",value:function(e,t){var n=this;return new Promise(function(){var i=u(r().m(function i(a){var o,u;return r().w(function(i){for(;;)switch(i.n){case 0:o=[],u=n,e.forEach(function(e){e.field_list.forEach(function(n){"item_ref"===n.data_type&&u._replaceValueItemRef(e,n,t),o.push(new Promise(function(t){u.gudhub.ghconstructor.getInstance(n.data_type).then(function(i){return void 0===i?(console.log("ERROR WHILE GETTING INSTANCE OF ",n.data_type),void t({type:n.data_type})):"file"==i.getTemplate().constructor?u.gudhub.util.fileInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(e)}):void("document"==i.getTemplate().constructor?u.documentInstallerHelper(e.app_id,e.items_list,n.field_id).then(function(e){t(i)}):t(i))})}))})}),o.length>0?Promise.all(o).then(function(e){a(e)}):a(result);case 1:return i.a(2)}},i)}));return function(e){return i.apply(this,arguments)}}())}},{key:"documentInstallerHelper",value:function(e,n,i){var a=this,o=[];return new Promise(function(){var c=u(r().m(function u(c){var f,p,l,s,d,_,h,m;return r().w(function(r){for(;;)switch(r.p=r.n){case 0:f=t(n),r.p=1,f.s();case 2:if((p=f.n()).done){r.n=6;break}if(l=p.value,s=l.item_id,!((d=l.fields.find(function(e){return e.element_id===i}))&&d.field_value&&d.field_value.length>0)){r.n=5;break}return r.n=3,a.gudhub.getDocument({_id:d.field_value});case 3:if(!(_=r.v)||!_.data){r.n=5;break}return r.n=4,a.gudhub.createDocument({app_id:e,item_id:s,element_id:i,data:_.data});case 4:h=r.v,d.field_value=h._id,o.push(l);case 5:r.n=2;break;case 6:r.n=8;break;case 7:r.p=7,m=r.v,f.e(m);case 8:return r.p=8,f.f(),r.f(8);case 9:c(o);case 10:return r.a(2)}},u,null,[[1,7,8,9]])}));return function(e){return c.apply(this,arguments)}}())}},{key:"_replaceValueItemRef",value:function(e,t,n){e.items_list.forEach(function(e){e.fields.forEach(function(e){if(e.field_id===t.field_id&&e.field_value){var i=e.field_value.split(",");i.forEach(function(e,t){var r=e.split(".");n.apps.forEach(function(e){r[0]==e.old_app_id&&(r[0]=e.new_app_id)}),n.items.forEach(function(e){r[1]==e.old_item_id&&(r[1]=e.new_item_id)}),i[t]=r.join(".")}),e.field_value=i.join(",")}})})}},{key:"_addFieldValue",value:function(e,t,n){t.forEach(function(t){n.items.forEach(function(n){t.item_id===n.new_item_id&&e.forEach(function(e){n.old_item_id===e.item_id&&(t.fields=e.fields)})})})}},{key:"_updateMap",value:function(e,t){var n=this;t.forEach(function(t){e.forEach(function(e){t.index_number===e.index_number&&n.appsConnectingMap.items.push({old_item_id:t.item_id,new_item_id:e.item_id})})})}},{key:"_searchOldAppId",value:function(e,t){var n=0;return t.forEach(function(t){t.new_app_id===e&&(n=t.old_app_id)}),n}},{key:"createApps",value:function(n,i,a){var o=this,c=this,f={step_size:100/(3*n.apps.length),apps:[]};return new Promise(function(){var p=u(r().m(function u(p){var l,s,d,_,h,m,v,y,b;return r().w(function(u){for(;;)switch(u.p=u.n){case 0:return l={},s=[],d=[],u.n=1,c.gudhub.req.axiosRequest({method:"POST",url:"https://app.gudhub.com/GudHub/auth/login",form:{auth_key:"3HMOtCbC0M/1/1e4y4Uxo/Kh/aFN4V5LG2//5ixx7TZyiUfMb7IHAAHCj9PsLrOSDrZuuWkbX4BIX23f51H+eA=="}});case 1:_=u.v,h=_.accesstoken,m=t(n.apps),u.p=2,y=r().m(function e(){var t,u,_,m;return r().w(function(e){for(;;)switch(e.n){case 0:if(t=v.value,!a){e.n=2;break}return e.n=1,c.gudhub.req.axiosRequest({url:"https://app.gudhub.com/GudHub/api/app/get?token=".concat(h,"&app_id=").concat(t),method:"GET"});case 1:u=e.v,e.n=4;break;case 2:return e.n=3,c.gudhub.getApp(t);case 3:u=e.v;case 4:i&&i.call(o,"GET APP: ".concat(u.app_name," (App steps)")),_=JSON.parse(JSON.stringify(u)),l[_.app_id]=_,f.apps.push(_.icon),(m=c.prepareAppTemplate(_)).app_name=m.app_name,m.privacy=1,n.data_to_change&&(n.data_to_change.name&&(m.app_name=n.data_to_change.name),n.data_to_change.icon&&(m.icon=n.data_to_change.icon)),c.resetViewsIds(m),c.gudhub.createNewApp(m).then(function(e){i&&i.call(o,"CREATE NEW APP: ".concat(u.app_name," (App steps)")),s.push(e),c.mapApp(_,e,c.appsConnectingMap),n.apps.length==s.length&&(c.connectApps(s,c.appsConnectingMap,l),s.forEach(function(e){c.gudhub.updateApp(e).then(function(e){i&&i.call(o,"UPDATE APP: ".concat(u.app_name," (App steps)")),d.push(e),n.apps.length==d.length&&p(d)})}))});case 5:return e.a(2)}},e)}),m.s();case 3:if((v=m.n()).done){u.n=5;break}return u.d(e(y()),4);case 4:u.n=3;break;case 5:u.n=7;break;case 6:u.p=6,b=u.v,m.e(b);case 7:return u.p=7,m.f(),u.f(7);case 8:return u.a(2)}},u,null,[[2,6,7,8]])}));return function(e){return p.apply(this,arguments)}}())}},{key:"mapApp",value:function(e,t,n){n.apps.push({old_app_id:e.app_id,new_app_id:t.app_id,old_view_init:e.view_init,new_view_init:t.view_init}),e.field_list.forEach(function(e){t.field_list.forEach(function(t){e.name_space==t.name_space&&n.fields.push({name_space:e.name_space,old_field_id:e.field_id,new_field_id:t.field_id})})}),e.views_list.forEach(function(e){t.views_list.forEach(function(t){e.name==t.name&&n.views.push({name:e.name,old_view_id:e.view_id,new_view_id:t.view_id})})})}},{key:"crawling",value:function(e,t){var n=null===e?[]:Object.keys(e),i=this;n.length>0&&n.forEach(function(n){var r=e[n];void 0!==r&&"string"!=typeof e&&(t(n,r,e),i.crawling(r,t))})}},{key:"resetViewsIds",value:function(e){e.view_init=0,this.crawling(e.views_list,function(e,t,n){"view_id"!=e&&"container_id"!=e||(n[e]=0)})}},{key:"connectApps",value:function(e,t,n){var i=this;return e.forEach(function(e){t.apps.forEach(function(n){e.view_init===n.new_view_init&&t.views.forEach(function(t){n.old_view_init===t.old_view_id&&(e.view_init=t.new_view_id)})}),i.crawling(e.field_list,function(r,a,o){var u=function(e,t){return t.some(function(t){return-1!==e.indexOf(t)})};if(u(r,["field_id","FieldId","destination_field","element_id"])){var c=String(a).split(","),f=[];t.fields.forEach(function(e){c.forEach(function(t){t==e.old_field_id&&f.push(e.new_field_id)})}),f.length&&(o[r]=f.join(","))}if(u(r,["app_id","AppId","destination_app"])&&t.apps.forEach(function(e){a==e.old_app_id&&(o[r]=e.new_app_id)}),u(r,["view_id"])&&t.views.forEach(function(e){a==e.old_view_id&&(o[r]=e.new_view_id)}),u(r,["src"])&&isFinite(a)){var p=t.apps.find(function(t){return t.new_app_id===e.app_id}).old_app_id,l=i.findPath(n[p].views_list,"container_id",a);o[r]="".concat(i.getValueByPath(e.views_list,l,"container_id"))}if(-1!==r.indexOf("trigger")&&a.model&&a.model.nodes){var s=a.model.nodes,d=["inputs","outputs"],_=function(e){d.forEach(function(n){var i=s[e];Object.keys(i[n]).filter(function(e){return""!==e&&!isNaN(e)}).forEach(function(e){var r=t.fields.filter(function(t){return t.old_field_id==e});if(0!==r.length&&r[0].new_field_id){var a=r[0].new_field_id.toString(),o=i[n][e];o.connections.forEach(function(t){t.input==e&&(t.input=a),t.output==e&&(t.output=a)}),delete i[n][e],i[n][a]=o}})})};for(var h in s)_(h)}})}),e}},{key:"getValueByPath",value:function(e,t,n){var i=e;return t.split(".").forEach(function(e){i=i[e]}),i[n]}},{key:"findPath",value:function(e,t,n){var i=!1,r=!1,a=[];return this.crawling(e,function(e,o,u){r&&a.reverse().forEach(function(e){r&&(e.delete=!0,e.parent===u&&(r=!1,(a=a.filter(function(e){return!e.delete})).reverse()))}),i||("object"===c(u[e])&&a.push({prop:e,parent:u}),o==n&&t===e?i=!0:Object.keys(u).pop()===e&&"object"!==c(u[e])&&(r=!0))}),a.map(function(e){return e.prop}).join(".")}},{key:"prepareAppTemplate",value:function(e){var t=JSON.parse(JSON.stringify(e));return this.crawling(t.views_list,function(e,t,n){"element_id"==e&&(n.element_id=-Number(t),n.create_element=-Number(t))}),t.field_list.forEach(function(e){e.create_field=-Number(e.field_id),e.element_id=-Number(e.field_id),e.field_id=-Number(e.field_id),e.field_value=""}),t.items_list=[],delete t.app_id,delete t.icon.id,delete t.group_id,delete t.trash,delete t.last_update,delete t.file_list,t}}])}();
297
297
  },{}],"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(e){return o(e)||i(e)||n(e)||r()}function r(){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 n(e,t){if(e){if("string"==typeof e)return u(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)?u(e,t):void 0}}function i(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function o(e){if(Array.isArray(e))return u(e)}function u(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 l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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,c(n.key),n)}}function a(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(t){var r=s(t,"string");return"symbol"==e(r)?r:r+""}function s(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;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 d=exports.FileHelper=function(){return a(function e(t){l(this,e),this.gudhub=t},[{key:"fileInstallerHelper",value:function(e,r,n){var i=this;return new Promise(function(o){var u=[[]],l=Promise.resolve(),f=[];r.forEach(function(t){var r=t.item_id,i=t.fields.find(function(e){return e.element_id===n});i&&i.field_value&&i.field_value.split(".").forEach(function(t){var i={source:t,destination:{app_id:e,item_id:r,element_id:n}};10!==u[u.length-1].length?u[u.length-1].push(i):u.push([i])})}),u.forEach(function(e){l=l.then(function(){return i.gudhub.duplicateFile(e)}).then(function(e){f=[].concat(t(f),t(e))})}),l.then(function(){r.forEach(function(e){var t=e.item_id,r=e.fields.find(function(e){return e.element_id===n});r&&r.field_value&&(r.field_value="",f.forEach(function(e){e.item_id===t&&(r.field_value=r.field_value.split(",").filter(function(e){return e}).concat(e.file_id).join(","))}))}),o()})})}}])}();
299
299
  },{}],"AefJ":[function(require,module,exports) {