@gudhub/core 1.0.45 → 1.0.46

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.
@@ -74,7 +74,7 @@ export class FileManager {
74
74
  if(await this.isFileExists(app_id, file_id)) {
75
75
  let file = await this.getFile(app_id, file_id);
76
76
  let data = await this.req.get({
77
- url: file.url,
77
+ url: file.url + '?timestamp=' + file.last_update,
78
78
  externalResource: true
79
79
  });
80
80
  return {
@@ -152,29 +152,35 @@ export class FileManager {
152
152
  }
153
153
 
154
154
  async getFile(app_id, file_id) {
155
- try {
156
- const app = await this.appProcessor.getApp(app_id);
157
- return app.file_list.find((file) => {
158
- return file.file_id == file_id;
155
+ const app = await this.appProcessor.getApp(app_id);
156
+ return new Promise((resolve,reject) => {
157
+ let findedFile = app.file_list.find((file) => {
158
+ return file.file_id == file_id
159
159
  });
160
- } catch (err) {
161
- console.log(err);
162
- return null;
163
- }
164
- }
160
+ if(findedFile) {
161
+ resolve(findedFile)
162
+ } else {
163
+ resolve('')
164
+ }
165
+ })
166
+ }
165
167
 
166
- async getFiles(app_id, filesId = []) {
167
- try {
168
- const app = await this.appProcessor.getApp(app_id);
169
- return app.file_list.filter((file) => {
168
+ async getFiles(app_id, filesId = []) {
169
+
170
+ const app = await this.appProcessor.getApp(app_id);
171
+ return new Promise((resolve, reject) => {
172
+ let findedFiles = app.file_list.filter((file) => {
170
173
  return filesId.some(id => {
171
174
  return id == file.file_id;
172
- })});
173
- } catch (err) {
174
- console.log(err);
175
- return null;
176
- }
177
- }
175
+ })
176
+ });
177
+ if(findedFiles) {
178
+ resolve(findedFiles);
179
+ } else {
180
+ resolve('')
181
+ }
182
+ })
183
+ }
178
184
 
179
185
  async uploadFile(fileData, app_id, item_id) {
180
186
  const file = await this.uploadFileApi(fileData, app_id, item_id);
package/GUDHUB/config.js CHANGED
@@ -1,7 +1,7 @@
1
- //export const server_url = "https://gudhub.com/GudHub";
1
+ export const server_url = "https://gudhub.com/GudHub";
2
2
  //export const server_url = "https://gudhub.com/GudHub_Temp";
3
3
  //export const server_url = "https://integration.gudhub.com/GudHub_Test";
4
- export const server_url = "http://localhost:9000";
4
+ //export const server_url = "http://localhost:9000";
5
5
  export const wss_url = "wss://gudhub.com/GudHub/ws/app/";
6
6
 
7
7
  // FOR TESTS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -82,7 +82,7 @@ module.exports=require("./lib/axios");
82
82
  },{}],"pHMV":[function(require,module,exports) {
83
83
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WebSocketApi=void 0;var e=t(require("ws"));function t(e){return e&&e.__esModule?e:{default:e}}function n(e,t,n,o,r,s,i){try{var a=e[s](i),c=a.value}catch(u){return void n(u)}a.done?t(c):Promise.resolve(c).then(o,r)}function o(e){return function(){var t=this,o=arguments;return new Promise(function(r,s){var i=e.apply(t,o);function a(e){n(i,r,s,a,c,"next",e)}function c(e){n(i,r,s,a,c,"throw",e)}a(void 0)})}}function r(e){return(r="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 s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var c=function(){function t(e,n){s(this,t),this.websocket=null,this.connected=!1,this.queue=[],this.url=e,this.auth=n,this.heartBeatTimeStemp=1e13,this.ALLOWED_HEART_BEAT_DELEY=12e3,this.firstHeartBeat=!0,this.reload=!0,this.isBrowser=!["undefined"==typeof window?"undefined":r(window),"undefined"==typeof document?"undefined":r(document)].includes("undefined")}return a(t,[{key:"addSubscription",value:function(){var e=o(regeneratorRuntime.mark(function e(t){var n,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.auth.getToken();case 2:n=e.sent,o="token=".concat(n,"/~/app_id=").concat(t),this.connected&&this.websocket.send(o),this.queue.push(t);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"onOpen",value:function(){var e=o(regeneratorRuntime.mark(function e(){var t,n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.reload=!0,console.log("websocket opened"),this.connected=!0,e.next=5,this.auth.getToken();case 5:t=e.sent,this.queue.forEach(function(e){var o="token=".concat(t,"/~/app_id=").concat(e);n.websocket.send(o)});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"onError",value:function(e){console.log("websocket error: ",e),this.websocket.close()}},{key:"onClose",value:function(){console.log("websocket close"),this.connected=!1,this.initWebSocket()}},{key:"onMessage",value:function(){var e=o(regeneratorRuntime.mark(function e(t){var n,o,r,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.isBrowser?t.data:t).match(/HeartBeat/)){e.next=10;break}if(o=(new Date).getTime()-this.heartBeatTimeStemp,!(this.ALLOWED_HEART_BEAT_DELEY<o)){e.next=8;break}return e.next=6,this.onConnectionLost();case 6:e.next=10;break;case 8:this.websocket.send("HeartBeat"),this.heartBeatTimeStemp=(new Date).getTime();case 10:if(this.firstHeartBeat&&(this.connectionChecker(),this.firstHeartBeat=!1),!n.match(/[{}]/)){e.next=17;break}return r=JSON.parse(n),e.next=15,this.auth.getToken();case 15:s=e.sent,r.token!=s&&this.onMassageHandler(r);case 17:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"initWebSocket",value:function(t,n){this.onMassageHandler=t,this.refreshAppsHandler=n,this.isBrowser?(this.websocket=new WebSocket(this.url),this.websocket.onopen=this.onOpen.bind(this),this.websocket.onerror=this.onError.bind(this),this.websocket.onclose=this.onClose.bind(this),this.websocket.onmessage=this.onMessage.bind(this)):(this.websocket=new e.default(this.url),this.websocket.on("open",this.onOpen),this.websocket.on("error",this.onError),this.websocket.on("close",this.onClose),this.websocket.on("message",this.onMessage)),console.log("websocket initialized")}},{key:"connectionChecker",value:function(){var e=this;setInterval(o(regeneratorRuntime.mark(function t(){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=(new Date).getTime()-e.heartBeatTimeStemp,!(e.ALLOWED_HEART_BEAT_DELEY<n)){t.next=4;break}return t.next=4,e.onConnectionLost();case 4:case"end":return t.stop()}},t)})),1e3)}},{key:"onConnectionLost",value:function(){var e=o(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.auth.getVersion();case 3:this.reload&&(this.reload=!1,console.log("Connected"),this.heartBeatTimeStemp=1e13,this.websocket.close(),this.refreshAppsHandler(this.queue)),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.log(e.t0);case 9:case"end":return e.stop()}},e,this,[[0,6]])}));return function(){return e.apply(this,arguments)}}()}]),t}();exports.WebSocketApi=c;
84
84
  },{"ws":"p58b"}],"TPH7":[function(require,module,exports) {
85
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.port=exports.wss_url=exports.server_url=void 0;var r="http://localhost:9000";exports.server_url=r;var e="wss://gudhub.com/GudHub/ws/app/";exports.wss_url=e;var s=9e3;exports.port=s;
85
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.port=exports.wss_url=exports.server_url=void 0;var r="https://gudhub.com/GudHub";exports.server_url=r;var e="wss://gudhub.com/GudHub/ws/app/";exports.wss_url=e;var s=9e3;exports.port=s;
86
86
  },{}],"DvAj":[function(require,module,exports) {
87
87
  "use strict";function e(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=t(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var a=0,u=function(){};return{s:u,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:u}}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,i=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(c)throw o}}}}function t(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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)?r(e,t):void 0}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t,r,n,a,u,o){try{var i=e[u](o),c=i.value}catch(l){return void r(l)}i.done?t(c):Promise.resolve(c).then(n,a)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(a,u){var o=e.apply(t,r);function i(e){n(o,a,u,i,c,"next",e)}function c(e){n(o,a,u,i,c,"throw",e)}i(void 0)})}}function u(e,t,r,n,a,u){return o.apply(this,arguments)}function o(){return(o=a(regeneratorRuntime.mark(function t(r,n,a,u,o,i){var c,l,f,s,p,v,h,b,d,y,g=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(y=function(e){return new Promise(function(t){i.on("gh_value_get",e,function r(n,a){i.destroy("gh_value_get",e,r),t(a)}).emit("gh_value_get",{},e)})},c=g.length>6&&void 0!==g[6]?g[6]:[],l=[],f={variableMethodcurrent_app:function(){return[a]},variableMethodelement_app:function(){return[n]},variableMethodcurrent_item:function(){return["".concat(a,".").concat(u)]},variableMethoduser_id:function(){return[o.getUser().user_id]},variableMethoduser_email:function(e){return[o.getUser().username]},variableMethodtoday:function(e){var t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1);return[r.valueOf().toString()+":"+n.valueOf().toString()]},variableMethodvariable:function(){return c}},!r){t.next=40;break}s=e(r),t.prev=6,s.s();case 8:if((p=s.n()).done){t.next=32;break}if(!(v=p.value)){t.next=29;break}t.t0=v.input_type,t.next="variable"===t.t0?14:"field"===t.t0?19:25;break;case 14:return h=v.input_type+"Method"+v.input_value,b=f[h],v.valuesArray="function"==typeof b?b():f.variableMethodvariable(),l.push(v),t.abrupt("break",27);case 19:return t.next=21,y({app_id:a,item_id:u,field_id:v.input_value});case 21:return null!=(d=t.sent)&&v.valuesArray.push(d),l.push(v),t.abrupt("break",27);case 25:return l.push(v),t.abrupt("break",27);case 27:t.next=30;break;case 29:l.push(v);case 30:t.next=8;break;case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(6),s.e(t.t1);case 37:return t.prev=37,s.f(),t.finish(37);case 40:return t.abrupt("return",l);case 41:case"end":return t.stop()}},t,null,[[6,34,37,40]])}))).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.filterPreparation=u;
88
88
  },{}],"jqRt":[function(require,module,exports) {
@@ -149,7 +149,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
149
149
  },{"./AppProcessor/AppProcessor.js":"I3sf","./ItemProcessor/ItemProcessor.js":"EQyW","./FieldProcessor/FieldProcessor.js":"eGYU"}],"gVik":[function(require,module,exports) {
150
150
  "use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentManager=void 0;var o=function(){function n(t){e(this,n),this.req=t}return t(n,[{key:"createDocument",value:function(e){return this.req.post({url:"/api/new/document/insert-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocument",value:function(e){return this.req.post({url:"/api/new/document/find-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"getDocuments",value:function(e){return this.req.post({url:"/api/new/document/find",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}},{key:"deleteDocument",value:function(e){return this.req.post({url:"/api/new/document/remove-one",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{document:JSON.stringify(e)}})}}]),n}();exports.DocumentManager=o;
151
151
  },{}],"ndt3":[function(require,module,exports) {
152
- "use strict";function e(e){return i(e)||n(e)||t(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 t(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.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)?u(e,r):void 0}}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return u(e)}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r,t,n,i,u,a){try{var o=e[u](a),s=o.value}catch(c){return void t(c)}o.done?r(s):Promise.resolve(s).then(n,i)}function o(e){return function(){var r=this,t=arguments;return new Promise(function(n,i){var u=e.apply(r,t);function o(e){a(u,n,i,o,s,"next",e)}function s(e){a(u,n,i,o,s,"throw",e)}o(void 0)})}}function s(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function c(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,r,t){return r&&c(e.prototype,r),t&&c(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileManager=void 0;var l=function(){function r(e,t,n,i){s(this,r),this.storage=e,this.pipeService=t,this.req=n,this.appProcessor=i}return p(r,[{key:"uploadFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,i={"file-0":r,app_id:t,item_id:n},e.next=4,this.req.post({url:"/file/formupload",form:i});case 4:return u=e.sent,e.abrupt("return",u);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/file/upload",form:{file:JSON.stringify(r)}});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,u){var a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a={file_name:n,extension:i,file_id:t,format:u,source:r},e.next=4,this.req.post({url:"/file/update",form:{file:JSON.stringify(a)}});case 4:return o=e.sent,e.abrupt("return",o);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n,i,u){return e.apply(this,arguments)}}()},{key:"duplicateFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.req.post({url:"/api/new/file/duplicate",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{files:JSON.stringify(r)}}));case 1:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"downloadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.isFileExists(r,t);case 2:if(!e.sent){e.next=12;break}return e.next=5,this.getFile(r,t);case 5:return n=e.sent,e.next=8,this.req.get({url:n.url,externalResource:!0});case 8:return i=e.sent,e.abrupt("return",{file:n,data:i,type:"file"});case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"duplicateFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.duplicateFileApi(r);case 2:return(t=e.sent).forEach(function(e){n.addFileToStorage(e.app_id,e)}),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"deleteFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/file/delete?file_id=".concat(r)});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"addFileToStorage",value:function(e,r){var t=this.storage.getApp(e);t&&(t.file_list.push(r),this.storage.updateApp(t))}},{key:"addFilesToStorage",value:function(r,t){var n,i=this.storage.getApp(r);i&&((n=i.file_list).push.apply(n,e(t)),this.storage.updateApp(i))}},{key:"deleteFileFromStorage",value:function(e,r){var t,n=this.storage.getApp(r);n&&(n.file_list=n.file_list.filter(function(r){return r.file_id!=e||(t=r,!1)}),this.storage.updateApp(n),this.pipeService.emit("gh_file_delete",{file_id:e},t))}},{key:"updateFileInStorage",value:function(e,r,t){var n=this.storage.getApp(r);n&&(n.file_list=n.file_list.map(function(r){return r.file_id==e?t:r}),this.storage.updateApp(n),this.pipeService.emit("gh_file_update",{file_id:e}))}},{key:"getFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.appProcessor.getApp(r);case 3:return n=e.sent,e.abrupt("return",n.file_list.find(function(e){return e.file_id==t}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r,t){return e.apply(this,arguments)}}()},{key:"getFiles",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n,i=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>1&&void 0!==i[1]?i[1]:[],e.prev=1,e.next=4,this.appProcessor.getApp(r);case 4:return n=e.sent,e.abrupt("return",n.file_list.filter(function(e){return t.some(function(r){return r==e.file_id})}));case 8:return e.prev=8,e.t0=e.catch(1),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[1,8]])}));return function(r){return e.apply(this,arguments)}}()},{key:"uploadFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileApi(r,t,n);case 2:return i=e.sent,this.addFileToStorage(t,i),e.abrupt("return",i);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileFromStringApi(r);case 2:return t=e.sent,this.addFileToStorage(t.app_id,t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,u){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateFileFromStringApi(r,t,n,i,u);case 2:return a=e.sent,this.updateFileInStorage(t,a.app_id,a),e.abrupt("return",a);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n,i,u){return e.apply(this,arguments)}}()},{key:"deleteFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteFileApi(r);case 2:return this.deleteFileFromStorage(r,t),e.abrupt("return",!0);case 4:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"isFileExists",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/,!Boolean(t)){e.next=12;break}return e.next=4,this.getFile(r,t);case 4:if(i=e.sent,!Boolean(i)){e.next=9;break}return e.abrupt("return",n.test(i.url));case 9:return e.abrupt("return",!1);case 10:e.next=13;break;case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()}]),r}();exports.FileManager=l;
152
+ "use strict";function e(e){return i(e)||n(e)||t(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 t(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.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)?a(e,r):void 0}}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return a(e)}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function u(e,r,t,n,i,a,u){try{var o=e[a](u),s=o.value}catch(c){return void t(c)}o.done?r(s):Promise.resolve(s).then(n,i)}function o(e){return function(){var r=this,t=arguments;return new Promise(function(n,i){var a=e.apply(r,t);function o(e){u(a,n,i,o,s,"next",e)}function s(e){u(a,n,i,o,s,"throw",e)}o(void 0)})}}function s(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function c(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,r,t){return r&&c(e.prototype,r),t&&c(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileManager=void 0;var l=function(){function r(e,t,n,i){s(this,r),this.storage=e,this.pipeService=t,this.req=n,this.appProcessor=i}return p(r,[{key:"uploadFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,i={"file-0":r,app_id:t,item_id:n},e.next=4,this.req.post({url:"/file/formupload",form:i});case 4:return a=e.sent,e.abrupt("return",a);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/file/upload",form:{file:JSON.stringify(r)}});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromStringApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,a){var u,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u={file_name:n,extension:i,file_id:t,format:a,source:r},e.next=4,this.req.post({url:"/file/update",form:{file:JSON.stringify(u)}});case 4:return o=e.sent,e.abrupt("return",o);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(r,t,n,i,a){return e.apply(this,arguments)}}()},{key:"duplicateFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.req.post({url:"/api/new/file/duplicate",headers:{"Content-Type":"application/x-www-form-urlencoded"},form:{files:JSON.stringify(r)}}));case 1:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"downloadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.isFileExists(r,t);case 2:if(!e.sent){e.next=12;break}return e.next=5,this.getFile(r,t);case 5:return n=e.sent,e.next=8,this.req.get({url:n.url+"?timestamp="+n.last_update,externalResource:!0});case 8:return i=e.sent,e.abrupt("return",{file:n,data:i,type:"file"});case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"duplicateFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.duplicateFileApi(r);case 2:return(t=e.sent).forEach(function(e){n.addFileToStorage(e.app_id,e)}),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"deleteFileApi",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/file/delete?file_id=".concat(r)});case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(r){return e.apply(this,arguments)}}()},{key:"addFileToStorage",value:function(e,r){var t=this.storage.getApp(e);t&&(t.file_list.push(r),this.storage.updateApp(t))}},{key:"addFilesToStorage",value:function(r,t){var n,i=this.storage.getApp(r);i&&((n=i.file_list).push.apply(n,e(t)),this.storage.updateApp(i))}},{key:"deleteFileFromStorage",value:function(e,r){var t,n=this.storage.getApp(r);n&&(n.file_list=n.file_list.filter(function(r){return r.file_id!=e||(t=r,!1)}),this.storage.updateApp(n),this.pipeService.emit("gh_file_delete",{file_id:e},t))}},{key:"updateFileInStorage",value:function(e,r,t){var n=this.storage.getApp(r);n&&(n.file_list=n.file_list.map(function(r){return r.file_id==e?t:r}),this.storage.updateApp(n),this.pipeService.emit("gh_file_update",{file_id:e}))}},{key:"getFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.appProcessor.getApp(r);case 2:return n=e.sent,e.abrupt("return",new Promise(function(e,r){var i=n.file_list.find(function(e){return e.file_id==t});e(i||"")}));case 4:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"getFiles",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t,n,i=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>1&&void 0!==i[1]?i[1]:[],e.next=3,this.appProcessor.getApp(r);case 3:return n=e.sent,e.abrupt("return",new Promise(function(e,r){var i=n.file_list.filter(function(e){return t.some(function(r){return r==e.file_id})});e(i||"")}));case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"uploadFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileApi(r,t,n);case 2:return i=e.sent,this.addFileToStorage(t,i),e.abrupt("return",i);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n){return e.apply(this,arguments)}}()},{key:"uploadFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.uploadFileFromStringApi(r);case 2:return t=e.sent,this.addFileToStorage(t.app_id,t),e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(r){return e.apply(this,arguments)}}()},{key:"updateFileFromString",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t,n,i,a){var u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateFileFromStringApi(r,t,n,i,a);case 2:return u=e.sent,this.updateFileInStorage(t,u.app_id,u),e.abrupt("return",u);case 5:case"end":return e.stop()}},e,this)}));return function(r,t,n,i,a){return e.apply(this,arguments)}}()},{key:"deleteFile",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteFileApi(r);case 2:return this.deleteFileFromStorage(r,t),e.abrupt("return",!0);case 4:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()},{key:"isFileExists",value:function(){var e=o(regeneratorRuntime.mark(function e(r,t){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/,!Boolean(t)){e.next=12;break}return e.next=4,this.getFile(r,t);case 4:if(i=e.sent,!Boolean(i)){e.next=9;break}return e.abrupt("return",n.test(i.url));case 9:return e.abrupt("return",!1);case 10:e.next=13;break;case 12:return e.abrupt("return",!1);case 13:case"end":return e.stop()}},e,this)}));return function(r,t){return e.apply(this,arguments)}}()}]),r}();exports.FileManager=l;
153
153
  },{}],"yYLL":[function(require,module,exports) {
154
154
  "use strict";function e(e,t,r,n,u,a,i){try{var s=e[a](i),o=s.value}catch(c){return void r(c)}s.done?t(o):Promise.resolve(o).then(n,u)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(u,a){var i=t.apply(r,n);function s(t){e(i,u,a,s,o,"next",t)}function o(t){e(i,u,a,s,o,"throw",t)}s(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChunksManager=void 0;var a=function(){function e(t,n,u,a){r(this,e),this.storage=t,this.pipeService=n,this.req=u,this.util=a,this.itemListeners()}return u(e,[{key:"getChunkApi",value:function(){var e=t(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.simpleGet({url:"/api/get-items-chunk/".concat(t,"/").concat(r)});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getLastChunkApi",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.simpleGet({url:"/api/get-last-items-chunk/".concat(t)});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getChunk",value:function(e,t){return this.getChunkApi(e,t)}},{key:"getChunks",value:function(){var e=t(regeneratorRuntime.mark(function e(t,r){var n,u=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=[],!r){e.next=5;break}return e.next=4,Promise.all(r.map(function(e){return u.getChunkApi(t,e)}));case 4:n=e.sent;case 5:return e.abrupt("return",n);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getLastChunk",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getLastChunkApi(t);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){}},{key:"getApp",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",null);case 2:if(r=this.getAppFromStorage(t)){e.next=16;break}if(!this.getAppPromises[t]){e.next=6;break}return e.abrupt("return",this.getAppPromises[t]);case 6:return this.getAppPromises[t]=this.getAppApi(t),e.next=9,this.getAppPromises[t];case 9:if(!(r=e.sent)){e.next=15;break}this.saveAppInStorage(r),this.ws.addSubscription(t),e.next=16;break;case 15:return e.abrupt("return",null);case 16:return e.abrupt("return",r);case 17:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();exports.ChunksManager=a;
155
155
  },{}],"WyOa":[function(require,module,exports) {