@gudhub/core 1.0.48 → 1.0.51

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.
@@ -1,9 +1,11 @@
1
1
  export class FieldProcessor {
2
- constructor(storage, req, appProcessor, itemProcessor) {
2
+ constructor(storage, req, appProcessor, itemProcessor, pipeService) {
3
3
  this.storage = storage;
4
4
  this.req = req;
5
5
  this.appProcessor = appProcessor;
6
6
  this.itemProcessor = itemProcessor;
7
+ this.pipeService = pipeService;
8
+ this.fieldListeners();
7
9
  }
8
10
 
9
11
  deleteFieldApi(field_id) {
@@ -136,4 +138,45 @@ export class FieldProcessor {
136
138
  await this.setFieldValueApi(app_id, item_id, field_id, field_value);
137
139
  this.updateFieldValue(app_id, item_id, field_id, field_value);
138
140
  }
141
+
142
+ fieldListeners() {
143
+ this.pipeService.onRoot('gh_value_get', {}, async (event, data) => {
144
+ if(data.app_id && data.item_id && data.field_id) {
145
+ let field_value = await this.getFieldValue(data.app_id, data.item_id, data.field_id);
146
+ this.pipeService.emit('gh_value_get', data, field_value);
147
+ }
148
+ });
149
+
150
+ this.pipeService.onRoot('gh_value_set', {}, async (event, data) => {
151
+ if(data.item_id) {
152
+ this.setFieldValue(data.app_id, data.item_id, data.field_id, data.new_value);
153
+ delete data.new_value;
154
+ }
155
+ });
156
+
157
+ this.pipeService.onRoot('gh_model_get', {}, async (event, data) => {
158
+ try {
159
+ let field_model = await this.getField(data.app_id, data.field_id);
160
+ this.pipeService.emit('gh_model_get', data, field_model)
161
+ } catch (error) {
162
+ console.log('Field model: ', error);
163
+ }
164
+ });
165
+
166
+ this.pipeService.onRoot('gh_model_update', {}, async (event, data) => {
167
+ let field_model = await this.updateField(data.app_id, data.field_model);
168
+ this.pipeService.emit('gh_model_update', { app_id: data.app_id, field_id: data.field_id }, field_model);
169
+ });
170
+
171
+ this.pipeService.onRoot('gh_models_get', {}, async (event, data) => {
172
+ let field_models = await this.getFieldModels(data.app_id);
173
+ this.pipeService.emit('gh_models_get', data, field_models);
174
+ });
175
+
176
+ this.pipeService.onRoot('gh_model_delete', {}, async (event, data) => {
177
+ let status = await this.deleteField(data.app_id, data.field_id);
178
+ this.pipeService.emit('gh_model_delete', data, status);
179
+ });
180
+ }
181
+
139
182
  }
@@ -9,7 +9,7 @@ import {
9
9
  import { group } from "./filter/group.js";
10
10
  import { searchValue } from "./filter/utils.js";
11
11
  import populateItems from "./populate_items/populate_items.js";
12
- import { populateWithDate, getDate } from "./get_date/get_date.js";
12
+ import { populateWithDate, getDate, checkRecurringDate } from "./get_date/get_date.js";
13
13
  import { mergeObjects } from "./merge_objects/merge_objects.js";
14
14
  import { mergeChunks } from "./merge_chunks/merge_chunks.js";
15
15
  import { getInterpretedValue } from "./interpretation/interpretation.js";
@@ -85,6 +85,10 @@ export class Utils {
85
85
  return getDate(queryKey);
86
86
  }
87
87
 
88
+ checkRecurringDate(date, option) {
89
+ return checkRecurringDate(date, option);
90
+ }
91
+
88
92
  populateItems(items, model, keep_data) {
89
93
  return populateItems(items, model, keep_data);
90
94
  }
@@ -171,6 +171,13 @@ class Checker {
171
171
  );
172
172
  };
173
173
  break;
174
+ case "recurring_date":
175
+ this._checkFn = function (data, filtersValues) {
176
+ return filtersValues.some((_filter) =>
177
+ data.some((_dataItem) => gudhub.checkRecurringDate(_dataItem, _filter))
178
+ );
179
+ };
180
+ break;
174
181
  }
175
182
  return this;
176
183
  }
@@ -236,6 +243,16 @@ class BooleanFetchStrategy {
236
243
  }
237
244
  }
238
245
 
246
+ class RecurringDateStrategy {
247
+ convert(val) {
248
+ return [Number(val)];
249
+ }
250
+
251
+ convertFilterValue(val) {
252
+ return String(val);
253
+ }
254
+ }
255
+
239
256
  class Aggregate {
240
257
  constructor() {
241
258
  this._strategies = {
@@ -244,6 +261,7 @@ class Aggregate {
244
261
  booleanStrategy: new BooleanFetchStrategy(),
245
262
  rangeStrategy: new RangeFetchStrategy(),
246
263
  dateStrategy: new dateFetchStrategy(),
264
+ recurringDateStrategy: new RecurringDateStrategy()
247
265
  };
248
266
  }
249
267
 
@@ -277,6 +295,8 @@ class Aggregate {
277
295
  case "value":
278
296
  this._currentStrategy = this._strategies.booleanStrategy;
279
297
  break;
298
+ case "recurring_date":
299
+ this._currentStrategy = this._strategies.recurringDateStrategy
280
300
  }
281
301
  return this;
282
302
  }
@@ -88,3 +88,45 @@ export function getDate(queryKey) {
88
88
  return date.getTime();
89
89
  }
90
90
  }
91
+
92
+ //********************** CHECK RECURRING DATE ************************//
93
+
94
+ export function checkRecurringDate(date, option) {
95
+
96
+ date = new Date(date);
97
+
98
+ let currentDate = new Date();
99
+
100
+ switch (option) {
101
+ case 'day':
102
+ if(date.getDate() + '.' + date.getMonth() === currentDate.getDate() + '.' + currentDate.getMonth()) {
103
+ return true;
104
+ } else {
105
+ return false;
106
+ }
107
+ case 'week':
108
+ if(getWeek(currentDate) === getWeek(date)) {
109
+ return true;
110
+ } else {
111
+ return false;
112
+ }
113
+ case 'month':
114
+ if(date.getMonth() === currentDate.getMonth()) {
115
+ return true;
116
+ } else {
117
+ return false;
118
+ }
119
+ default:
120
+ return true;
121
+ }
122
+
123
+ function getWeek(date) {
124
+ let d = new Date(date.getFullYear(), date.getMonth(), date.getDate());
125
+ let dayNumber = d.getDay();
126
+ d.setDate(d.getDate() + 4 - dayNumber);
127
+ let firstJanuary = new Date(date.getFullYear(), 0, 1);
128
+ let weekNumber = Math.ceil((((d- firstJanuary) / 86400000) + 1) / 7);
129
+ return weekNumber;
130
+ }
131
+
132
+ }
@@ -50,4 +50,37 @@ describe("GET DATE", function () {
50
50
  let day = gudhub.getDate('this_saturday');
51
51
  day.getDay().should.equal(6);
52
52
  });
53
+
54
+ it("CHECK IF DATE TODAY", function() {
55
+ let today = new Date();
56
+ let result = gudhub.checkRecurringDate(today, 'day');
57
+ result.should.equal(true);
58
+
59
+ let tommorow = new Date();
60
+ tommorow.setDate(tommorow.getDate() + 1);
61
+ result = gudhub.checkRecurringDate(tommorow, 'day');
62
+ result.should.equal(false);
63
+ })
64
+
65
+ it("CHECK IF DATE IN THIS WEEK", function() {
66
+ let today = new Date();
67
+ let result = gudhub.checkRecurringDate(today, 'week');
68
+ result.should.equal(true);
69
+
70
+ let twoWeeksLater = new Date();
71
+ twoWeeksLater.setDate(twoWeeksLater.getDate() + 14);
72
+ result = gudhub.checkRecurringDate(twoWeeksLater, 'week');
73
+ result.should.equal(false);
74
+ });
75
+
76
+ it("CHECK IF DATE IN THIS MONTH", function() {
77
+ let today = new Date();
78
+ let result = gudhub.checkRecurringDate(today, 'month');
79
+ result.should.equal(true);
80
+
81
+ let twoMonthsLater = new Date();
82
+ twoMonthsLater.setDate(twoMonthsLater.getDate() + 60);
83
+ result = gudhub.checkRecurringDate(twoMonthsLater, 'month');
84
+ result.should.equal(false);
85
+ });
53
86
  });
package/GUDHUB/gudhub.js CHANGED
@@ -63,7 +63,8 @@ export class GudHub {
63
63
  this.storage,
64
64
  this.req,
65
65
  this.appProcessor,
66
- this.itemProcessor
66
+ this.itemProcessor,
67
+ this.pipeService
67
68
  );
68
69
  this.fileManager = new FileManager(this.storage, this.pipeService, this.req, this.appProcessor);
69
70
  this.documentManager = new DocumentManager(this.req);
@@ -178,6 +179,10 @@ export class GudHub {
178
179
  return this.util.populateWithDate(items, model);
179
180
  }
180
181
 
182
+ checkRecurringDate(date, option) {
183
+ return this.util.checkRecurringDate(date, option);
184
+ }
185
+
181
186
  populateItems(items, model, keep_data) {
182
187
  return this.util.populateItems(items, model, keep_data);
183
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.0.48",
3
+ "version": "1.0.51",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -118,7 +118,7 @@ var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t
118
118
  },{}],"zsiC":[function(require,module,exports) {
119
119
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDate=c,exports.getDistanceFromLatLonInKm=l,exports.isSimilarStrings=g,exports.searchValue=d;var e=t(require("fuse.js"));function t(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return i(e)||u(e,t)||a(e,t)||n()}function n(){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 a(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.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)?o(e,t):void 0}}function o(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 u(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],u=!0,i=!1;try{for(r=r.call(e);!(u=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);u=!0);}catch(l){i=!0,a=l}finally{try{u||null==r.return||r.return()}finally{if(i)throw a}}return o}}function i(e){if(Array.isArray(e))return e}function l(e,t){var n=r(e.split(":"),3),a=n[0],o=n[1],u=n[2],i=r(t.split(":"),2),l=i[0],c=i[1],f=s(l-a),h=s(c-o),d=Math.sin(f/2)*Math.sin(f/2)+Math.cos(s(a))*Math.cos(s(l))*Math.sin(h/2)*Math.sin(h/2),v=6371*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)));return Number(u)>=v}function s(e){return e*(Math.PI/180)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.type,n=e.date,a=void 0===n?0:n,o=e.match,u=void 0===o||o,i=arguments.length>1?arguments[1]:void 0;if(!i&&t)return!1;var l=new Date,s=!0;switch(t){case"day":var c=h(a),d=h(a+1);s=c<=i&&i<d;break;case"days":if(a<0){var v=h(1);s=h(-6)<=i&&i<v}else{var g=h(),y=h(7);s=g<=i&&i<y}break;case"day_week":s=a===new Date(i).getDay();break;case"week":var w=l.getDate()-l.getDay(),p=w+6,b=r(f(l.setDate(w+7*a),l.setDate(p+7*a)),2),D=b[0],m=b[1];s=D<=i&&i<=m;break;case"month":if(l.getFullYear()!==new Date(i).getFullYear())return!1;s=l.getMonth()+a===new Date(i).getMonth();break;case"year":s=l.getFullYear()+a===new Date(i).getFullYear();break;default:return!0}return u?s:!s}function f(e,t){return[new Date(e),new Date(t)]}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e).valueOf()}function d(e,t){if(e&&e.length)return t?e.filter(function(e){return e.fields.find(function(e){return e.index_value&&-1!==e.index_value.toLowerCase().indexOf(t.toLowerCase())})}):e}var v=new e.default([]);function g(e,t){return v.setCollection(t),Boolean(v.search(e).length)}
120
120
  },{"fuse.js":"jqRt"}],"mbGN":[function(require,module,exports) {
121
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=b;var e=require("./utils.js");function t(e){return(t="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 n(e,t){return c(e)||i(e,t)||u(e,t)||r()}function r(){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 u(e,t){if(e){if("string"==typeof e)return o(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)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,u,o=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(a){c=!0,u=a}finally{try{i||null==n.return||n.return()}finally{if(c)throw u}}return o}}function c(e){if(Array.isArray(e))return e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=y();return function(){var n,r=_(e);if(t){var u=_(this).constructor;n=Reflect.construct(r,arguments,u)}else n=r.apply(this,arguments);return l(this,n)}}function l(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t){var n=new O,r=new k;return e&&e.length?e.filter(function(e){return t.filter(function(e){return e.valuesArray.length}).every(function(t){var u=e.fields.find(function(e){return t.field_id==e.field_id});return n.setStrategy(t.search_type).setEntity(u&&null!=u.field_value?u.field_value:null).setFilterValues(t.valuesArray),r.check(n)})}):[]}var k=function(){function t(){p(this,t)}return g(t,[{key:"changeBehavior",value:function(t){switch(t){case"contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"not_contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"not_contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"equal_or":this._checkFn=function(e,t){return!!e.length&&e.some(function(e){return t.some(function(t){return e==t})})};break;case"equal_and":this._checkFn=function(e,t){if(!e.length)return!1;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();n.has(r)&&n.delete(r)}return!n.size};break;case"not_equal_or":this._checkFn=function(e,t){if(!e.length)return!0;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(!n.has(r))return!0}return!1};break;case"not_equal_and":this._checkFn=function(e,t){for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(n.has(r))return!1}return!0};break;case"bigger":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e>t})})};break;case"lower":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e<t})})};break;case"range":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return t.start<=e&&e<t.end})})};break;case"value":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return e==t})})};break;case"search":this._checkFn=function(t,n){return n.some(function(n){return(0,e.isSimilarStrings)(n,t)})};break;case"phone_equal_or":this._checkFn=function(e,t){return!!e.length&&t.some(function(t){return e.some(function(e){return-1!==e.replace(/[^0-9]/g,"").indexOf(t.replace(/[^0-9]/g,""))})})};break;case"distance":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDistanceFromLatLonInKm)(n,t)})})};break;case"date_in":case"date_out":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDate)(n,t)})})}}return this}},{key:"check",value:function(e){return this.changeBehavior(e.getCheckOption())._checkFn(e.getEntity(),e.getFilterValues())}}]),t}(),d=function(){function e(){p(this,e)}return g(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return Number(e)}}]),e}(),m=function(e){a(n,d);var t=f(n);function n(){return p(this,n),t.apply(this,arguments)}return g(n,[{key:"convertFilterValue",value:function(e){return{start:Number(e.split(":")[0]),end:Number(e.split(":")[1])}}}]),n}(),S=function(){function e(){p(this,e)}return g(e,[{key:"convert",value:function(e){return String(null!=e?e:"").toLowerCase().split(",")}},{key:"convertFilterValue",value:function(e){return 0===e?"0":String(e||"").toLowerCase()}}]),e}(),w=function(e){a(r,d);var t=f(r);function r(){return p(this,r),t.apply(this,arguments)}return g(r,[{key:"convertFilterValue",value:function(e){var t=n(e.split(":"),3),r=t[0],u=t[1],o=t[2];return{type:r,date:Number(u),match:!!Number(o)}}}]),r}(),F=function(){function e(){p(this,e)}return g(e,[{key:"convert",value:function(e){return[String(Boolean(e))]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),O=function(){function e(){p(this,e),this._strategies={stringStrategy:new S,numberStrategy:new d,booleanStrategy:new F,rangeStrategy:new m,dateStrategy:new w}}return g(e,[{key:"setStrategy",value:function(e){switch(this._checkOption=e,e){case"contain_or":case"contain_and":case"not_contain_or":case"not_contain_and":case"equal_or":case"equal_and":case"not_equal_or":case"not_equal_and":case"phone_equal_or":case"distance":case"search":this._currentStrategy=this._strategies.stringStrategy;break;case"bigger":case"lower":this._currentStrategy=this._strategies.numberStrategy;break;case"range":this._currentStrategy=this._strategies.rangeStrategy;break;case"date_in":case"date_out":this._currentStrategy=this._strategies.dateStrategy;break;case"value":this._currentStrategy=this._strategies.booleanStrategy}return this}},{key:"setEntity",value:function(e){return this._entity=this._currentStrategy.convert(e),this}},{key:"getEntity",value:function(){return this._entity}},{key:"setFilterValues",value:function(e){var t=this,n=Array.isArray(e)?e:[e];return this._filterValues=n.map(function(e){return t._currentStrategy.convertFilterValue(e)}),this}},{key:"getFilterValues",value:function(){return this._filterValues}},{key:"getCheckOption",value:function(){return this._checkOption}}]),e}();
121
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=b;var e=require("./utils.js");function t(e){return(t="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 n(e,t){return c(e)||o(e,t)||u(e,t)||r()}function r(){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 u(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,u,i=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);o=!0);}catch(a){c=!0,u=a}finally{try{o||null==n.return||n.return()}finally{if(c)throw u}}return i}}function c(e){if(Array.isArray(e))return e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=y();return function(){var n,r=_(e);if(t){var u=_(this).constructor;n=Reflect.construct(r,arguments,u)}else n=r.apply(this,arguments);return l(this,n)}}function l(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function p(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t){var n=new j,r=new k;return e&&e.length?e.filter(function(e){return t.filter(function(e){return e.valuesArray.length}).every(function(t){var u=e.fields.find(function(e){return t.field_id==e.field_id});return n.setStrategy(t.search_type).setEntity(u&&null!=u.field_value?u.field_value:null).setFilterValues(t.valuesArray),r.check(n)})}):[]}var k=function(){function t(){g(this,t)}return p(t,[{key:"changeBehavior",value:function(t){switch(t){case"contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.some(function(e){return-1!==e.indexOf(t)})})};break;case"not_contain_or":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"not_contain_and":this._checkFn=function(e,t){return t.every(function(t){return e.every(function(e){return-1===e.indexOf(t)})})};break;case"equal_or":this._checkFn=function(e,t){return!!e.length&&e.some(function(e){return t.some(function(t){return e==t})})};break;case"equal_and":this._checkFn=function(e,t){if(!e.length)return!1;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();n.has(r)&&n.delete(r)}return!n.size};break;case"not_equal_or":this._checkFn=function(e,t){if(!e.length)return!0;for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(!n.has(r))return!0}return!1};break;case"not_equal_and":this._checkFn=function(e,t){for(var n=new Set(t);e.length&&n.size;){var r=e.pop();if(n.has(r))return!1}return!0};break;case"bigger":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e>t})})};break;case"lower":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return e<t})})};break;case"range":this._checkFn=function(e,t){return t.some(function(t){return e.every(function(e){return t.start<=e&&e<t.end})})};break;case"value":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return e==t})})};break;case"search":this._checkFn=function(t,n){return n.some(function(n){return(0,e.isSimilarStrings)(n,t)})};break;case"phone_equal_or":this._checkFn=function(e,t){return!!e.length&&t.some(function(t){return e.some(function(e){return-1!==e.replace(/[^0-9]/g,"").indexOf(t.replace(/[^0-9]/g,""))})})};break;case"distance":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDistanceFromLatLonInKm)(n,t)})})};break;case"date_in":case"date_out":this._checkFn=function(t,n){return n.some(function(n){return t.some(function(t){return(0,e.getDate)(n,t)})})};break;case"recurring_date":this._checkFn=function(e,t){return t.some(function(t){return e.some(function(e){return gudhub.checkRecurringDate(e,t)})})}}return this}},{key:"check",value:function(e){return this.changeBehavior(e.getCheckOption())._checkFn(e.getEntity(),e.getFilterValues())}}]),t}(),d=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return Number(e)}}]),e}(),m=function(e){a(n,d);var t=f(n);function n(){return g(this,n),t.apply(this,arguments)}return p(n,[{key:"convertFilterValue",value:function(e){return{start:Number(e.split(":")[0]),end:Number(e.split(":")[1])}}}]),n}(),S=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return String(null!=e?e:"").toLowerCase().split(",")}},{key:"convertFilterValue",value:function(e){return 0===e?"0":String(e||"").toLowerCase()}}]),e}(),w=function(e){a(r,d);var t=f(r);function r(){return g(this,r),t.apply(this,arguments)}return p(r,[{key:"convertFilterValue",value:function(e){var t=n(e.split(":"),3),r=t[0],u=t[1],i=t[2];return{type:r,date:Number(u),match:!!Number(i)}}}]),r}(),F=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[String(Boolean(e))]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),O=function(){function e(){g(this,e)}return p(e,[{key:"convert",value:function(e){return[Number(e)]}},{key:"convertFilterValue",value:function(e){return String(e)}}]),e}(),j=function(){function e(){g(this,e),this._strategies={stringStrategy:new S,numberStrategy:new d,booleanStrategy:new F,rangeStrategy:new m,dateStrategy:new w,recurringDateStrategy:new O}}return p(e,[{key:"setStrategy",value:function(e){switch(this._checkOption=e,e){case"contain_or":case"contain_and":case"not_contain_or":case"not_contain_and":case"equal_or":case"equal_and":case"not_equal_or":case"not_equal_and":case"phone_equal_or":case"distance":case"search":this._currentStrategy=this._strategies.stringStrategy;break;case"bigger":case"lower":this._currentStrategy=this._strategies.numberStrategy;break;case"range":this._currentStrategy=this._strategies.rangeStrategy;break;case"date_in":case"date_out":this._currentStrategy=this._strategies.dateStrategy;break;case"value":this._currentStrategy=this._strategies.booleanStrategy;break;case"recurring_date":this._currentStrategy=this._strategies.recurringDateStrategy}return this}},{key:"setEntity",value:function(e){return this._entity=this._currentStrategy.convert(e),this}},{key:"getEntity",value:function(){return this._entity}},{key:"setFilterValues",value:function(e){var t=this,n=Array.isArray(e)?e:[e];return this._filterValues=n.map(function(e){return t._currentStrategy.convertFilterValue(e)}),this}},{key:"getFilterValues",value:function(){return this._filterValues}},{key:"getCheckOption",value:function(){return this._checkOption}}]),e}();
122
122
  },{"./utils.js":"zsiC"}],"h8f7":[function(require,module,exports) {
123
123
  var define;
124
124
  var global = arguments[3];
@@ -147,7 +147,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
147
147
  },{"../addDays/index.js":"gKTe","../addMonths/index.js":"aD4K","../toDate/index.js":"dYQD","../_lib/requiredArgs/index.js":"wNNf","../_lib/toInteger/index.js":"Rltm"}],"kCXN":[function(require,module,exports) {
148
148
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=a;var e=n(require("../addDays/index.js")),t=n(require("../toDate/index.js")),r=n(require("../_lib/toInteger/index.js")),u=n(require("../_lib/requiredArgs/index.js"));function n(e){return e&&e.__esModule?e:{default:e}}function a(n,a,l){(0,u.default)(2,arguments);var s=l||{},d=s.locale,i=d&&d.options&&d.options.weekStartsOn,o=null==i?0:(0,r.default)(i),f=null==s.weekStartsOn?o:(0,r.default)(s.weekStartsOn);if(!(f>=0&&f<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var x=(0,t.default)(n),p=(0,r.default)(a),w=x.getDay(),c=7-f,_=p<0||p>6?p-(w+c)%7:((p%7+7)%7+c)%7-(w+c)%7;return(0,e.default)(x,_)}module.exports=exports.default;
149
149
  },{"../addDays/index.js":"gKTe","../toDate/index.js":"dYQD","../_lib/toInteger/index.js":"Rltm","../_lib/requiredArgs/index.js":"wNNf"}],"VzfS":[function(require,module,exports) {
150
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDate=s,exports.populateWithDate=r;var e=a(require("date-fns/add/index.js")),t=a(require("date-fns/setDay/index.js"));function a(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return e.forEach(function(e){t.forEach(function(t){var a=e.fields.find(function(e){return e.element_id==t.element_id});a?a.field_value=s(t.date_type):e.fields.push({field_id:t.element_id,element_id:t.element_id,field_value:s(t.date_type)})})}),e}function s(a){var r=new Date;switch(a){case"next_day":return(0,e.default)(r,{days:1}).getTime();case"two_days_after":return(0,e.default)(r,{days:2}).getTime();case"three_days_after":return(0,e.default)(r,{days:3}).getTime();case"four_days_after":return(0,e.default)(r,{days:4}).getTime();case"next_week":return(0,e.default)(r,{weeks:1}).getTime();case"two_weeks_after":return(0,e.default)(r,{weeks:2}).getTime();case"three_weeks_after":return(0,e.default)(r,{weeks:3}).getTime();case"this_sunday":return(0,t.default)(r,0,{weekStartsOn:1});case"this_monday":return(0,t.default)(r,1,{weekStartsOn:1});case"this_tuesday":return(0,t.default)(r,2,{weekStartsOn:1});case"this_wednesday":return(0,t.default)(r,3,{weekStartsOn:1});case"this_thursday":return(0,t.default)(r,4,{weekStartsOn:1});case"this_friday":return(0,t.default)(r,5,{weekStartsOn:1});case"this_saturday":return(0,t.default)(r,6,{weekStartsOn:1});case"now":default:return r.getTime()}}
150
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkRecurringDate=s,exports.getDate=n,exports.populateWithDate=r;var e=a(require("date-fns/add/index.js")),t=a(require("date-fns/setDay/index.js"));function a(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return e.forEach(function(e){t.forEach(function(t){var a=e.fields.find(function(e){return e.element_id==t.element_id});a?a.field_value=n(t.date_type):e.fields.push({field_id:t.element_id,element_id:t.element_id,field_value:n(t.date_type)})})}),e}function n(a){var r=new Date;switch(a){case"next_day":return(0,e.default)(r,{days:1}).getTime();case"two_days_after":return(0,e.default)(r,{days:2}).getTime();case"three_days_after":return(0,e.default)(r,{days:3}).getTime();case"four_days_after":return(0,e.default)(r,{days:4}).getTime();case"next_week":return(0,e.default)(r,{weeks:1}).getTime();case"two_weeks_after":return(0,e.default)(r,{weeks:2}).getTime();case"three_weeks_after":return(0,e.default)(r,{weeks:3}).getTime();case"this_sunday":return(0,t.default)(r,0,{weekStartsOn:1});case"this_monday":return(0,t.default)(r,1,{weekStartsOn:1});case"this_tuesday":return(0,t.default)(r,2,{weekStartsOn:1});case"this_wednesday":return(0,t.default)(r,3,{weekStartsOn:1});case"this_thursday":return(0,t.default)(r,4,{weekStartsOn:1});case"this_friday":return(0,t.default)(r,5,{weekStartsOn:1});case"this_saturday":return(0,t.default)(r,6,{weekStartsOn:1});case"now":default:return r.getTime()}}function s(e,t){e=new Date(e);var a=new Date;switch(t){case"day":return e.getDate()+"."+e.getMonth()==a.getDate()+"."+a.getMonth();case"week":return r(a)===r(e);case"month":return e.getMonth()===a.getMonth();default:return!0}function r(e){var t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=t.getDay();t.setDate(t.getDate()+4-a);var r=new Date(e.getFullYear(),0,1);return Math.ceil(((t-r)/864e5+1)/7)}}
151
151
  },{"date-fns/add/index.js":"YNMJ","date-fns/setDay/index.js":"kCXN"}],"EE1j":[function(require,module,exports) {
152
152
  "use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(t)}function t(r,t,e){return i(r,t,e)}function e(t){return t&&"object"===r(t)&&"[object RegExp]"!==Object.prototype.toString.call(t)&&"[object Date]"!==Object.prototype.toString.call(t)}function n(r){return Array.isArray(r)?[]:{}}function o(r,t){return t&&!0===t.clone&&e(r)?i(n(r),r,t):r}function c(r,t,n){var c=r.slice();return t.forEach(function(t,u){void 0===c[u]?c[u]=o(t,n):e(t)?c[u]=i(r[u],t,n):-1===r.indexOf(t)&&c.push(o(t,n))}),c}function u(r,t,n){var c={};return e(r)&&Object.keys(r).forEach(function(t){c[t]=o(r[t],n)}),Object.keys(t).forEach(function(u){e(t[u])&&r[u]?c[u]=i(r[u],t[u],n):c[u]=o(t[u],n)}),c}function i(r,t,e){var n=Array.isArray(t),i=(e||{arrayMerge:c}).arrayMerge||c;return n?Array.isArray(r)?i(r,t,e):o(t,e):u(r,t,e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeObjects=t,i.all=function(r,t){if(!Array.isArray(r)||r.length<2)throw new Error("first argument should be an array with at least two elements");return r.reduce(function(r,e){return i(r,e,t)})};
153
153
  },{}],"AMYJ":[function(require,module,exports) {
@@ -161,7 +161,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
161
161
  },{}],"nKaW":[function(require,module,exports) {
162
162
  "use strict";function e(e){return u(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 u(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 i(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?i(Object(t),!0).forEach(function(r){c(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e,r,t,n,u,a,i){try{var o=e[a](i),c=o.value}catch(p){return void t(p)}o.done?r(c):Promise.resolve(c).then(n,u)}function s(e){return function(){var r=this,t=arguments;return new Promise(function(n,u){var a=e.apply(r,t);function i(e){p(a,n,u,i,o,"next",e)}function o(e){p(a,n,u,i,o,"throw",e)}i(void 0)})}}function f(r,t,n,u){function a(e,r,t){return i.apply(this,arguments)}function i(){return(i=s(regeneratorRuntime.mark(function e(r,t,n){var u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(u=null,"array"!==r.type){e.next=13;break}if(!Number(r.is_static)){e.next=10;break}return e.t0=Array,e.next=6,m(r.childs,t,n);case 6:e.t1=e.sent,u=new e.t0(e.t1),e.next=13;break;case 10:return e.next=12,p(r,t,n);case 12:u=e.sent;case 13:if("object"!==r.type){e.next=23;break}if(!Number(r.current_item)){e.next=20;break}return e.next=17,l(r,t);case 17:u=e.sent,e.next=23;break;case 20:return e.next=22,m(r.childs,t,n);case 22:u=e.sent;case 23:if("property"!==r.type){e.next=27;break}return e.next=26,y(r,t,n);case 26:u=e.sent;case 27:return e.abrupt("return",c({},r.property_name,u));case 28:case"end":return e.stop()}},e)}))).apply(this,arguments)}function p(e,r,t){return f.apply(this,arguments)}function f(){return(f=s(regeneratorRuntime.mark(function e(r,t,u){var a,i,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.gudhub.getApp(Number(r.app_id));case 2:return a=e.sent,e.next=5,x(r.filter,a.items_list,u,t);case 5:return i=e.sent,o=i.map(function(){var e=s(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",m(r.childs,t,a));case 1:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}()),e.abrupt("return",Promise.all(o));case 8:case"end":return e.stop()}},e)}))).apply(this,arguments)}function l(e,r){return b.apply(this,arguments)}function b(){return(b=s(regeneratorRuntime.mark(function e(r,t){var u,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.gudhub.getApp(r.app_id);case 2:return u=e.sent,a=u.items_list||[],e.abrupt("return",m(r.childs,t||a[0],u));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function m(e,r,t){return d.apply(this,arguments)}function d(){return(d=s(regeneratorRuntime.mark(function e(r,t,n){var u,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.map(function(){var e=s(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a(r,t,n));case 1:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}());case 2:return u=e.sent,e.next=5,Promise.all(u);case 5:return i=e.sent,e.abrupt("return",i.reduce(function(e,r){return o(o({},e),r)},{}));case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)}function y(e,r,t){return h.apply(this,arguments)}function h(){return(h=s(regeneratorRuntime.mark(function e(r,t,u){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r.property_type,e.next="static"===e.t0?3:"variable"===e.t0?4:"field_id"===e.t0?9:(e.t0,10);break;case 3:return e.abrupt("return",r.static_field_value);case 4:e.t1=r.variable_type,e.next="app_id"===e.t1?7:(e.t1,8);break;case 7:return e.abrupt("return",u.app_id);case 8:return e.abrupt("return","".concat(u.app_id,".").concat(t.item_id));case 9:return e.abrupt("return",r.field_id);case 10:if(!Boolean(Number(r.interpretation))){e.next=14;break}return e.abrupt("return",n.gudhub.getInterpretedValue(Number(u.app_id),Number(t.item_id),Number(r.field_id)));case 14:return e.abrupt("return",n.gudhub.getFieldValue(Number(u.app_id),Number(t.item_id),Number(r.field_id)));case 15:case"end":return e.stop()}},e)}))).apply(this,arguments)}function g(e,r,t,n){return v.apply(this,arguments)}function v(){return(v=s(regeneratorRuntime.mark(function r(t,a,i,o){var c;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,n.gudhub.prefilter(t,a,i,u);case 2:return c=r.sent,r.abrupt("return",n.gudhub.filter(o,[].concat(e(c),e(t))));case 4:case"end":return r.stop()}},r)}))).apply(this,arguments)}function x(){return w.apply(this,arguments)}function w(){return(w=s(regeneratorRuntime.mark(function r(){var t,n,u,a,i=arguments;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:[],n=i.length>1&&void 0!==i[1]?i[1]:[],u=i.length>2&&void 0!==i[2]?i[2]:{},a=i.length>3&&void 0!==i[3]?i[3]:{},r.abrupt("return",t.length?g(t,u.app_id,a.item_id,n):e(n));case 5:case"end":return r.stop()}},r)}))).apply(this,arguments)}return a(r,t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.compiler=f;
163
163
  },{}],"mWlG":[function(require,module,exports) {
164
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=v(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),i=require("./filter/group.js"),o=require("./filter/utils.js"),u=v(require("./populate_items/populate_items.js")),a=require("./get_date/get_date.js"),s=require("./merge_objects/merge_objects.js"),l=require("./merge_chunks/merge_chunks.js"),c=require("./interpretation/interpretation.js"),f=require("./nested_list/nested_list.js"),p=require("./compare_items_lists_worker/compare_items_lists.worker.js"),m=require("./json_constructor/json_constructor.js");function v(e){return e&&e.__esModule?e:{default:e}}function h(e){return _(e)||y(e)||d(e)||g()}function g(){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 d(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.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)?j(e,t):void 0}}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _(e){if(Array.isArray(e))return j(e)}function j(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 k(e,t,r,n,i,o,u){try{var a=e[o](u),s=a.value}catch(l){return void r(l)}a.done?t(s):Promise.resolve(s).then(n,i)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function u(e){k(o,n,i,u,a,"next",e)}function a(e){k(o,n,i,u,a,"throw",e)}u(void 0)})}}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(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 q(e,t,r){return t&&I(e.prototype,t),r&&I(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var A=function(){function v(e){w(this,v),this.gudhub=e}return q(v,[{key:"prefilter",value:function(t,r,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,i,this.gudhub.storage,this.gudhub.pipeService,o)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,i.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=b(regeneratorRuntime.mark(function e(){var t,r,n,i,u,a,s,l,c,f,p,m=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=m.length>0&&void 0!==m[0]?m[0]:[],r=m.length>1&&void 0!==m[1]?m[1]:[],n=m.length>2?m[2]:void 0,i=m.length>3?m[3]:void 0,u=m.length>4?m[4]:void 0,a=m.length>5&&void 0!==m[5]?m[5]:"",s=m.length>6?m[6]:void 0,l=m.length>7?m[7]:void 0,e.next=10,this.prefilter(r,n,i,u);case 10:return c=e.sent,f=this.filter(t,[].concat(h(r),h(c))),p=this.group(a,f),e.abrupt("return",p.filter(function(e){return!s||1===(0,o.searchValue)([e],s).length}).filter(function(e){return!l||1===(0,o.searchValue)([e],l).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,a.getDate)(e)}},{key:"populateItems",value:function(e,t,r){return(0,u.default)(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return(0,c.getInterpretedValue)(this.gudhub,e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,a.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,i,o,u){return(0,n.populateWithItemRef)(e,t,r,i,o,u)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,s.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,i){return(0,f.makeNestedList)(e,t,r,n,i)}},{key:"mergeChunks",value:function(e){return(0,l.mergeChunks)(e)}},{key:"jsonConstructor",value:function(e,t,r){return(0,m.compiler)(e,t,this,r)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,p.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}}]),v}();exports.Utils=A;
164
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utils=void 0;var e=require("./filter/filterPreparation.js"),t=v(require("./filter/filter.js")),r=require("./json_to_items/json_to_items.js"),n=require("./merge_compare_items/merge_compare_items.js"),i=require("./filter/group.js"),u=require("./filter/utils.js"),o=v(require("./populate_items/populate_items.js")),a=require("./get_date/get_date.js"),s=require("./merge_objects/merge_objects.js"),l=require("./merge_chunks/merge_chunks.js"),c=require("./interpretation/interpretation.js"),f=require("./nested_list/nested_list.js"),p=require("./compare_items_lists_worker/compare_items_lists.worker.js"),m=require("./json_constructor/json_constructor.js");function v(e){return e&&e.__esModule?e:{default:e}}function h(e){return k(e)||y(e)||d(e)||g()}function g(){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 d(e,t){if(e){if("string"==typeof e)return _(e,t);var r=Object.prototype.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)?_(e,t):void 0}}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function k(e){if(Array.isArray(e))return _(e)}function _(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 j(e,t,r,n,i,u,o){try{var a=e[u](o),s=a.value}catch(l){return void r(l)}a.done?t(s):Promise.resolve(s).then(n,i)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var u=e.apply(t,r);function o(e){j(u,n,i,o,a,"next",e)}function a(e){j(u,n,i,o,a,"throw",e)}o(void 0)})}}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(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 q(e,t,r){return t&&I(e.prototype,t),r&&I(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var A=function(){function v(e){w(this,v),this.gudhub=e}return q(v,[{key:"prefilter",value:function(t,r,n,i){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,e.filterPreparation)(t,r,n,i,this.gudhub.storage,this.gudhub.pipeService,u)}},{key:"filter",value:function(e,r){return(0,t.default)(e,r)}},{key:"group",value:function(e,t){return(0,i.group)(e,t)}},{key:"getFilteredItems",value:function(){var e=b(regeneratorRuntime.mark(function e(){var t,r,n,i,o,a,s,l,c,f,p,m=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=m.length>0&&void 0!==m[0]?m[0]:[],r=m.length>1&&void 0!==m[1]?m[1]:[],n=m.length>2?m[2]:void 0,i=m.length>3?m[3]:void 0,o=m.length>4?m[4]:void 0,a=m.length>5&&void 0!==m[5]?m[5]:"",s=m.length>6?m[6]:void 0,l=m.length>7?m[7]:void 0,e.next=10,this.prefilter(r,n,i,o);case 10:return c=e.sent,f=this.filter(t,[].concat(h(r),h(c))),p=this.group(a,f),e.abrupt("return",p.filter(function(e){return!s||1===(0,u.searchValue)([e],s).length}).filter(function(e){return!l||1===(0,u.searchValue)([e],l).length}));case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"jsonToItems",value:function(e,t){return(0,r.jsonToItems)(e,t)}},{key:"getDate",value:function(e){return(0,a.getDate)(e)}},{key:"checkRecurringDate",value:function(e,t){return(0,a.checkRecurringDate)(e,t)}},{key:"populateItems",value:function(e,t,r){return(0,o.default)(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return(0,c.getInterpretedValue)(this.gudhub,e,t,r)}},{key:"populateWithDate",value:function(e,t){return(0,a.populateWithDate)(e,t)}},{key:"populateWithItemRef",value:function(e,t,r,i,u,o){return(0,n.populateWithItemRef)(e,t,r,i,u,o)}},{key:"compareItems",value:function(e,t,r){return(0,n.compareItems)(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return(0,n.mergeItems)(e,t,r)}},{key:"mergeObjects",value:function(e,t,r){return(0,s.mergeObjects)(e,t,r)}},{key:"makeNestedList",value:function(e,t,r,n,i){return(0,f.makeNestedList)(e,t,r,n,i)}},{key:"mergeChunks",value:function(e){return(0,l.mergeChunks)(e)}},{key:"jsonConstructor",value:function(e,t,r){return(0,m.compiler)(e,t,this,r)}},{key:"compareAppsItemsLists",value:function(e,t,r){var n=new Blob([(0,p.compare_items_lists_Worker)()],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.worker.postMessage({items_list1:e,items_list2:t}),this.worker.addEventListener("message",function(e){var t=e.data.diff;r(t)})}}]),v}();exports.Utils=A;
165
165
  },{"./filter/filterPreparation.js":"DvAj","./filter/filter.js":"mbGN","./json_to_items/json_to_items.js":"UCDv","./merge_compare_items/merge_compare_items.js":"xDLX","./filter/group.js":"VgUi","./filter/utils.js":"zsiC","./populate_items/populate_items.js":"EzAv","./get_date/get_date.js":"VzfS","./merge_objects/merge_objects.js":"EE1j","./merge_chunks/merge_chunks.js":"AMYJ","./interpretation/interpretation.js":"pMyP","./nested_list/nested_list.js":"S7Iy","./compare_items_lists_worker/compare_items_lists.worker.js":"xR4c","./json_constructor/json_constructor.js":"nKaW"}],"rK64":[function(require,module,exports) {
166
166
  "use strict";function e(e,t,r,n,u,a,s){try{var i=e[a](s),o=i.value}catch(c){return void r(c)}i.done?t(o):Promise.resolve(o).then(n,u)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(u,a){var s=t.apply(r,n);function i(t){e(s,u,a,i,o,"next",t)}function o(t){e(s,u,a,i,o,"throw",t)}i(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var a=function(){function e(t,n){r(this,e),this.req=t,this.storage=n}return u(e,[{key:"login",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.username,r=e.password;return this.req.simplePost({url:"/auth/login",form:{username:t,password:r}})}},{key:"logout",value:function(e){return this.req.post({url:"/auth/logout",form:{token:e}})}},{key:"signup",value:function(e){return this.req.simplePost({url:"/auth/singup",form:{user:JSON.stringify(e)}})}},{key:"getUsersList",value:function(e){return this.req.get({url:"/auth/userlist",params:{keyword:e}})}},{key:"updateUserApi",value:function(e){return this.req.post({url:"/auth/updateuser",form:{user:JSON.stringify(e)}})}},{key:"updateToken",value:function(e){return this.req.simplePost({url:"/auth/login",form:{auth_key:e}})}},{key:"avatarUploadApi",value:function(e){return this.req.post({url:"/auth/avatar-upload",form:{image:e}})}},{key:"getUserByIdApi",value:function(e){return this.req.get({url:"/auth/getuserbyid",params:{id:e}})}},{key:"getVersion",value:function(){return this.req.get({url:"/version"})}},{key:"getUserFromStorage",value:function(e){return this.storage.getUsersList().find(function(t){return t.user_id==e})}},{key:"saveUserToStorage",value:function(e){var t=this.storage.getUsersList(),r=t.find(function(t){return t.user_id==e.user_id});return r||(t.push(e),e)}},{key:"getUserById",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getUserFromStorage(t)){e.next=9;break}return e.next=4,this.getUserByIdApi(t);case 4:if(n=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:(r=this.getUserFromStorage(t))||(this.saveUserToStorage(n),r=n);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getToken",value:function(){var e=t(regeneratorRuntime.mark(function e(){var t,r,n,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=new Date(this.storage.getUser().expirydate),r=new Date,n=this.storage.getUser().accesstoken,!(t<r)&&n){e.next=9;break}return e.next=6,this.updateToken(this.storage.getUser().auth_key);case 6:u=e.sent,this.storage.updateUser(u),n=u.accesstoken;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateUser",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.updateUserApi(t);case 2:return r=e.sent,this.storage.updateUser(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAvatar",value:function(){var e=t(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.avatarUploadApi(t);case 2:return r=e.sent,this.storage.updateUser(r),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();exports.Auth=a;
167
167
  },{}],"UV2u":[function(require,module,exports) {
@@ -171,7 +171,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
171
171
  },{"../../consts.js":"UV2u"}],"EQyW":[function(require,module,exports) {
172
172
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemProcessor=void 0;var e=require("../../utils.js");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function r(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){i(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 i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t,r,i,n,a,s){try{var u=e[a](s),p=u.value}catch(o){return void r(o)}u.done?t(p):Promise.resolve(p).then(i,n)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var s=e.apply(t,r);function u(e){n(s,i,a,u,p,"next",e)}function p(e){n(s,i,a,u,p,"throw",e)}u(void 0)})}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var o=function(){function t(e,r,i,n,a){s(this,t),this.storage=e,this.pipeService=r,this.req=i,this.appProcessor=n,this.util=a,this.itemListeners()}return p(t,[{key:"addItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/add",form:{items:JSON.stringify(r),app_id:t}});case 3:return i=e.sent,e.abrupt("return",i);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:"updateItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/update",form:{items:JSON.stringify(r),app_id:t}});case 3:return i=e.sent,e.abrupt("return",i);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:"deleteItemsApi",value:function(e){try{var t=this.req.post({url:"/api/items/delete",form:{items_ids:JSON.stringify(e)}});return t.from_apps_list=!0,t}catch(r){return console.log(r),null}}},{key:"addItemsToStorage",value:function(e,t){var r=this,i=this.storage.getApp(e);return i&&(t.forEach(function(t){i.items_list.push(t),r.pipeService.emit("gh_item_update",{app_id:e},[t])}),this.pipeService.emit("gh_items_update",{app_id:e},i.items_list),this.storage.updateApp(i)),i}},{key:"updateItemsInStorage",value:function(e,t){var r=this;this.pipeService.emit("gh_items_update",{app_id:e},t);var i=this.storage.getApp(e);return i&&t&&t.forEach(function(t){var n={app_id:e};r.pipeService.emit("gh_item_update",n,[t]),n.item_id=t.item_id,r.pipeService.emit("gh_item_update",n,t);var a=i.items_list.find(function(e){return e.item_id==t.item_id});a&&t.fields.forEach(function(e){var t=a.fields.find(function(t){return t.field_id==e.field_id});n.field_id=e.field_id,t?t.field_value!=e.field_value&&(t.field_value=e.field_value,r.pipeService.emit("gh_value_update",n,e.field_value)):(a.fields.push(e),r.pipeService.emit("gh_value_update",n,e.field_value))})}),t}},{key:"deleteItemsFromStorage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.storage.getApp(e);r&&(r.items_list=r.items_list.filter(function(e){return!t.includes(e.item_id)}),this.pipeService.emit("gh_items_update",{app_id:e},r.items_list),this.storage.updateApp(r))}},{key:"getItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t){var r,i,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]&&n[1],e.next=3,this.appProcessor.getApp(t,r);case 3:if(i=e.sent){e.next=6;break}return e.abrupt("return",null);case 6:return e.abrupt("return",i.items_list);case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(){var t=a(regeneratorRuntime.mark(function t(i,n){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=n.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.addItemsApi(i,a);case 3:return s=t.sent,this.addItemsToStorage(i,s),this.pipeService.emit("gh_items_add",{app_id:i},s),t.abrupt("return",s);case 7:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"updateItems",value:function(){var t=a(regeneratorRuntime.mark(function t(i,n){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=n.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.updateItemsApi(i,a);case 3:return s=t.sent,t.abrupt("return",this.updateItemsInStorage(i,s));case 5:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"deleteItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var i=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deleteItemsApi(r).then(function(){return i.deleteItemsFromStorage(t,r)}));case 1:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){var e=this;this.pipeService.onRoot("gh_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.app_id){t.next=5;break}return t.next=3,e.getItems(i.app_id);case 3:(n=t.sent)?e.pipeService.emit("gh_items_get",i,n):e.pipeService.emit("gh_items_get",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_add",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i&&i.app_id&&i.items)){t.next=5;break}return t.next=3,e.addNewItems(i.app_id,i.items);case 3:(n=t.sent)?e.pipeService.emit("gh_items_add",i,n):e.pipeService.emit("gh_items_add",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_update",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i&&i.app_id&&i.items)){t.next=5;break}return t.next=3,e.updateItems(i.app_id,i.items);case 3:(n=t.sent)?e.pipeService.emit("gh_items_update",i,n):e.pipeService.emit("gh_items_update",i,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_item_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.app_id){t.next=6;break}return t.next=3,e.getItems(i.app_id);case 3:n=t.sent,a=n.find(function(e){return e.item_id==i.item_id}),e.pipeService.emit("gh_item_get",i,a);case 6:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filtered_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.element_app_id){t.next=8;break}return t.next=3,e.getItems(i.element_app_id);case 3:return n=t.sent,t.next=6,e.util.getFilteredItems(n,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 6:a=t.sent,e.pipeService.emit("gh_filtered_items_get",i,a);case 8:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filter_items",{},function(){var t=a(regeneratorRuntime.mark(function t(r,i){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!i||!i.items){t.next=5;break}return t.next=3,e.util.getFilteredItems(i.items,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 3:n=t.sent,e.pipeService.emit("gh_filter_items",i,n);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}]),t}();exports.ItemProcessor=o;
173
173
  },{"../../utils.js":"EgeI"}],"eGYU":[function(require,module,exports) {
174
- "use strict";function e(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 t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach(function(e){r(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t,r,n,i,u,a){try{var o=e[u](a),s=o.value}catch(c){return void r(c)}o.done?t(s):Promise.resolve(s).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(i,u){var a=e.apply(t,r);function o(e){n(a,i,u,o,s,"next",e)}function s(e){n(a,i,u,o,s,"throw",e)}o(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 o(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FieldProcessor=void 0;var s=function(){function e(t,r,n,i){u(this,e),this.storage=t,this.req=r,this.appProcessor=n,this.itemProcessor=i}return o(e,[{key:"deleteFieldApi",value:function(e){return this.req.post({url:"/api/app/delete-field",form:{field_id:e}})}},{key:"updatedFieldApi",value:function(){var e=i(regeneratorRuntime.mark(function e(r){var n,i,u,a=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},e.next=3,this.appProcessor.getApp(r);case 3:return i=e.sent,u={app_id:r,app_name:i.app_name,group_id:i.group_id,icon:i.icon,field_list:i.field_list.map(function(e){return e.field_id==n.field_id?t(t({},e),n):e}),views_list:i.views_list},e.abrupt("return",this.appProcessor.updateApp(u));case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setFieldValueApi",value:function(e,t,r,n){var i=[{item_id:t,fields:[{field_id:r,field_value:n}]}];return this.itemProcessor.updateItems(e,i)}},{key:"deleteFieldInStorage",value:function(e,t){var r=this.storage.getApp(e);r.field_list=r.field_list.filter(function(e){return e.file_id!=t}),r.items_list=r.items_list.map(function(e){return e.fields=e.fields.filter(function(e){return e.field_id!=t}),e}),this.storage.updateApp(r)}},{key:"updateFieldInStorage",value:function(e,r){var n=this.storage.getApp(e);return n.field_list=n.field_list.map(function(e){return e.field_id==r.field_id?t(t({},e),r):e}),this.storage.updateApp(n),r}},{key:"updateFieldValue",value:function(e,t,r,n){var i=this.storage.getApp(e);i.items_list.forEach(function(e){e.item_id==t&&e.fields.forEach(function(e){e.field_id==r&&(e.field_value=n)})}),this.storage.updateApp(i)}},{key:"getField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.appProcessor.getApp(t);case 2:if(n=e.sent){e.next=5;break}return e.abrupt("return",null);case 5:return e.abrupt("return",n.field_list.find(function(e){return e.field_id==r}));case 6:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldModels",value:function(){var e=i(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.appProcessor.getApp(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",null);case 5:return e.abrupt("return",r.field_list);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.updatedFieldApi(t,r);case 4:return n=e.sent,e.abrupt("return",this.updateFieldInStorage(t,n));case 6:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteFieldApi(r);case 2:return e.abrupt("return",this.deleteFieldInStorage(t,r));case 3:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldValue",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r,n){var i,u,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,e.next=3,this.appProcessor.getApp(t);case 3:return(u=e.sent)&&(a=u.items_list.find(function(e){return e.item_id==r}))&&(o=a.fields.find(function(e){return e.field_id==n}))&&(i=o.field_value),e.abrupt("return",i);case 6:case"end":return e.stop()}},e,this)}));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"setFieldValue",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r,n,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r&&n){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.setFieldValueApi(t,r,n,i);case 4:this.updateFieldValue(t,r,n,i);case 5:case"end":return e.stop()}},e,this)}));return function(t,r,n,i){return e.apply(this,arguments)}}()}]),e}();exports.FieldProcessor=s;
174
+ "use strict";function e(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 t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach(function(e){r(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t,r,n,i,u,a){try{var o=e[u](a),s=o.value}catch(p){return void r(p)}o.done?t(s):Promise.resolve(s).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(i,u){var a=e.apply(t,r);function o(e){n(a,i,u,o,s,"next",e)}function s(e){n(a,i,u,o,s,"throw",e)}o(void 0)})}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 o(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FieldProcessor=void 0;var s=function(){function e(t,r,n,i,a){u(this,e),this.storage=t,this.req=r,this.appProcessor=n,this.itemProcessor=i,this.pipeService=a,this.fieldListeners()}return o(e,[{key:"deleteFieldApi",value:function(e){return this.req.post({url:"/api/app/delete-field",form:{field_id:e}})}},{key:"updatedFieldApi",value:function(){var e=i(regeneratorRuntime.mark(function e(r){var n,i,u,a=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},e.next=3,this.appProcessor.getApp(r);case 3:return i=e.sent,u={app_id:r,app_name:i.app_name,group_id:i.group_id,icon:i.icon,field_list:i.field_list.map(function(e){return e.field_id==n.field_id?t(t({},e),n):e}),views_list:i.views_list},e.abrupt("return",this.appProcessor.updateApp(u));case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setFieldValueApi",value:function(e,t,r,n){var i=[{item_id:t,fields:[{field_id:r,field_value:n}]}];return this.itemProcessor.updateItems(e,i)}},{key:"deleteFieldInStorage",value:function(e,t){var r=this.storage.getApp(e);r.field_list=r.field_list.filter(function(e){return e.file_id!=t}),r.items_list=r.items_list.map(function(e){return e.fields=e.fields.filter(function(e){return e.field_id!=t}),e}),this.storage.updateApp(r)}},{key:"updateFieldInStorage",value:function(e,r){var n=this.storage.getApp(e);return n.field_list=n.field_list.map(function(e){return e.field_id==r.field_id?t(t({},e),r):e}),this.storage.updateApp(n),r}},{key:"updateFieldValue",value:function(e,t,r,n){var i=this.storage.getApp(e);i.items_list.forEach(function(e){e.item_id==t&&e.fields.forEach(function(e){e.field_id==r&&(e.field_value=n)})}),this.storage.updateApp(i)}},{key:"getField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.appProcessor.getApp(t);case 2:if(n=e.sent){e.next=5;break}return e.abrupt("return",null);case 5:return e.abrupt("return",n.field_list.find(function(e){return e.field_id==r}));case 6:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldModels",value:function(){var e=i(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.appProcessor.getApp(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",null);case 5:return e.abrupt("return",r.field_list);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.updatedFieldApi(t,r);case 4:return n=e.sent,e.abrupt("return",this.updateFieldInStorage(t,n));case 6:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteField",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteFieldApi(r);case 2:return e.abrupt("return",this.deleteFieldInStorage(t,r));case 3:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldValue",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r,n){var i,u,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,e.next=3,this.appProcessor.getApp(t);case 3:return(u=e.sent)&&(a=u.items_list.find(function(e){return e.item_id==r}))&&(o=a.fields.find(function(e){return e.field_id==n}))&&(i=o.field_value),e.abrupt("return",i);case 6:case"end":return e.stop()}},e,this)}));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"setFieldValue",value:function(){var e=i(regeneratorRuntime.mark(function e(t,r,n,i){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r&&n){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.setFieldValueApi(t,r,n,i);case 4:this.updateFieldValue(t,r,n,i);case 5:case"end":return e.stop()}},e,this)}));return function(t,r,n,i){return e.apply(this,arguments)}}()},{key:"fieldListeners",value:function(){var e=this;this.pipeService.onRoot("gh_value_get",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n.app_id&&n.item_id&&n.field_id)){t.next=5;break}return t.next=3,e.getFieldValue(n.app_id,n.item_id,n.field_id);case 3:i=t.sent,e.pipeService.emit("gh_value_get",n,i);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_value_set",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n.item_id&&(e.setFieldValue(n.app_id,n.item_id,n.field_id,n.new_value),delete n.new_value);case 1:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_get",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getField(n.app_id,n.field_id);case 3:i=t.sent,e.pipeService.emit("gh_model_get",n,i),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),console.log("Field model: ",t.t0);case 10:case"end":return t.stop()}},t,null,[[0,7]])}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_update",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.updateField(n.app_id,n.field_model);case 2:i=t.sent,e.pipeService.emit("gh_model_update",{app_id:n.app_id,field_id:n.field_id},i);case 4:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_models_get",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFieldModels(n.app_id);case 2:i=t.sent,e.pipeService.emit("gh_models_get",n,i);case 4:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_delete",{},function(){var t=i(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.deleteField(n.app_id,n.field_id);case 2:i=t.sent,e.pipeService.emit("gh_model_delete",n,i);case 4:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}]),e}();exports.FieldProcessor=s;
175
175
  },{}],"WIY5":[function(require,module,exports) {
176
176
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"AppProcessor",{enumerable:!0,get:function(){return e.AppProcessor}}),Object.defineProperty(exports,"FieldProcessor",{enumerable:!0,get:function(){return o.FieldProcessor}}),Object.defineProperty(exports,"ItemProcessor",{enumerable:!0,get:function(){return r.ItemProcessor}});var e=require("./AppProcessor/AppProcessor.js"),r=require("./ItemProcessor/ItemProcessor.js"),o=require("./FieldProcessor/FieldProcessor.js");
177
177
  },{"./AppProcessor/AppProcessor.js":"I3sf","./ItemProcessor/ItemProcessor.js":"EQyW","./FieldProcessor/FieldProcessor.js":"eGYU"}],"gVik":[function(require,module,exports) {
@@ -183,7 +183,7 @@ var e,t=arguments[3],n=require("process");!function(n){if("object"==typeof expor
183
183
  },{}],"WyOa":[function(require,module,exports) {
184
184
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ChunksManager",{enumerable:!0,get:function(){return n.ChunksManager}}),Object.defineProperty(exports,"DocumentManager",{enumerable:!0,get:function(){return e.DocumentManager}}),Object.defineProperty(exports,"FileManager",{enumerable:!0,get:function(){return r.FileManager}});var e=require("./DocumentManager/DocumentManager.js"),r=require("./FileManager/FileManager.js"),n=require("./ChunksManager/ChunksManager.js");
185
185
  },{"./DocumentManager/DocumentManager.js":"gVik","./FileManager/FileManager.js":"ndt3","./ChunksManager/ChunksManager.js":"yYLL"}],"U9gy":[function(require,module,exports) {
186
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHub=void 0;var e=require("./gudhub-https-service.js"),t=require("./PipeService/PipeService.js"),r=require("./Storage/Storage.js"),i=require("./WebSocket/WebSocket.js"),n=require("./config.js"),s=require("./Utils/Utils.js"),o=require("./Auth/Auth.js"),u=require("./Processors/processors.js"),a=require("./Managers/managers.js"),l=require("./consts.js");function c(e,t,r,i,n,s,o){try{var u=e[s](o),a=u.value}catch(l){return void r(l)}u.done?t(a):Promise.resolve(a).then(i,n)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function o(e){c(s,i,n,o,u,"next",e)}function u(e){c(s,i,n,o,u,"throw",e)}o(void 0)})}}function d(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 i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var g=function(){function c(l){var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{server_url:n.server_url,wss_url:n.wss_url,initWebsocket:!1,activateSW:!1,swLink:""};d(this,c),this.pipeService=new t.PipeService,this.storage=new r.Storage(this.pipeService),this.util=new s.Utils(this),this.req=new e.GudHubHttpsService(p.server_url),this.auth=new o.Auth(this.req,this.storage),l&&this.storage.setUser({auth_key:l}),this.req.init(this.auth.getToken.bind(this.auth)),this.ws=new i.WebSocketApi(p.wss_url,this.auth),this.chunksManager=new a.ChunksManager(this.storage,this.pipeService,this.req,this.util),this.appProcessor=new u.AppProcessor(this.storage,this.pipeService,this.req,this.ws,this.chunksManager,this.util,p.activateSW),this.itemProcessor=new u.ItemProcessor(this.storage,this.pipeService,this.req,this.appProcessor,this.util),this.fieldProcessor=new u.FieldProcessor(this.storage,this.req,this.appProcessor,this.itemProcessor),this.fileManager=new a.FileManager(this.storage,this.pipeService,this.req,this.appProcessor),this.documentManager=new a.DocumentManager(this.req),p.initWebsocket&&this.ws.initWebSocket(this.websocketHandler.bind(this),this.appProcessor.refreshApps.bind(this.appProcessor)),p.activateSW&&this.activateSW(p.swLink)}return h(c,[{key:"activateSW",value:function(){var e=p(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(l.IS_WEB&&"serviceWorker"in window.navigator)){e.next=14;break}return e.prev=1,e.next=4,window.navigator.serviceWorker.register(t);case 4:(r=e.sent).update().then(function(){return console.log("%cSW ->>> Service worker successful updated","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;")}).catch(function(){return console.warn("SW ->>> Service worker is not updated")}),console.log("%cSW ->>> Service worker is registered","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.warn("%cSW ->>> Service worker is not registered","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",e.t0);case 12:e.next=15;break;case 14:console.log("%cSW ->>> ServiceWorkers not supported","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;");case 15:case"end":return e.stop()}},e,null,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"on",value:function(e,t,r){return this.pipeService.on(e,t,r),this}},{key:"emit",value:function(e,t,r,i){return this.pipeService.emit(e,t,r,i),this}},{key:"destroy",value:function(e,t,r){return this.pipeService.destroy(e,t,r),this}},{key:"prefilter",value:function(e,t,r,i,n){return this.util.prefilter(e,t,r,i,n)}},{key:"filter",value:function(e,t){return this.util.filter(e,t)}},{key:"group",value:function(e,t){return this.util.group(e,t)}},{key:"getFilteredItems",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.util.getFilteredItems(e,t,r.element_app_id,r.app_id,r.item_id,r.field_group,r.search,r.search_params)}},{key:"jsonToItems",value:function(e,t){return this.util.jsonToItems(e,t)}},{key:"getDate",value:function(e){return this.util.getDate(e)}},{key:"populateWithDate",value:function(e,t){return this.util.populateWithDate(e,t)}},{key:"populateItems",value:function(e,t,r){return this.util.populateItems(e,t,r)}},{key:"populateWithItemRef",value:function(e,t,r,i,n,s){return this.util.populateWithItemRef(e,t,r,i,n,s)}},{key:"compareItems",value:function(e,t,r){return this.util.compareItems(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return this.util.mergeItems(e,t,r)}},{key:"mergeObjects",value:function(e,t){return this.util.mergeObjects(e,t)}},{key:"makeNestedList",value:function(e,t,r,i,n){return this.util.makeNestedList(e,t,r,i,n)}},{key:"jsonConstructor",value:function(e,t,r){return this.util.jsonConstructor(e,t,r)}},{key:"getAppsList",value:function(){return this.appProcessor.getAppsList()}},{key:"getAppInfo",value:function(e){return this.appProcessor.getAppInfo(e)}},{key:"deleteApp",value:function(e){return this.appProcessor.deleteApp(e)}},{key:"getApp",value:function(e){return this.appProcessor.getApp(e)}},{key:"updateApp",value:function(e){return this.appProcessor.updateApp(e)}},{key:"updateAppInfo",value:function(e){return this.appProcessor.updateAppInfo(e)}},{key:"createNewApp",value:function(e){return this.appProcessor.createNewApp(e)}},{key:"getItems",value:function(e){return this.itemProcessor.getItems(e)}},{key:"getItem",value:function(){var e=p(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getItems(t);case 2:if(!(i=e.sent)){e.next=5;break}return e.abrupt("return",i.find(function(e){return e.item_id==r}));case 5:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(e,t){return this.itemProcessor.addNewItems(e,t)}},{key:"updateItems",value:function(e,t){return this.itemProcessor.updateItems(e,t)}},{key:"deleteItems",value:function(e,t){return this.itemProcessor.deleteItems(e,t)}},{key:"getField",value:function(e,t){return this.fieldProcessor.getField(e,t)}},{key:"getFieldModels",value:function(e){return this.fieldProcessor.getFieldModels(e)}},{key:"updateField",value:function(e,t){return this.fieldProcessor.updateField(e,t)}},{key:"deleteField",value:function(e,t){return this.fieldProcessor.deleteField(e,t)}},{key:"getFieldValue",value:function(e,t,r){return this.fieldProcessor.getFieldValue(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return this.util.getInterpretedValue(e,t,r)}},{key:"setFieldValue",value:function(e,t,r,i){return this.fieldProcessor.setFieldValue(e,t,r,i)}},{key:"getFile",value:function(e,t){return this.fileManager.getFile(e,t)}},{key:"getFiles",value:function(e,t){return this.fileManager.getFiles(e,t)}},{key:"uploadFile",value:function(e,t,r){return this.fileManager.uploadFile(e,t,r)}},{key:"uploadFileFromString",value:function(e,t,r,i,n,s,o){return this.fileManager.uploadFileFromString(e,t,r,i,n,s,o)}},{key:"updateFileFromString",value:function(e,t,r,i,n){return this.fileManager.updateFileFromString(e,t,r,i,n)}},{key:"deleteFile",value:function(e,t){return this.fileManager.deleteFile(e,t)}},{key:"duplicateFile",value:function(e){return this.fileManager.duplicateFile(e)}},{key:"downloadFileFromString",value:function(e,t){return this.fileManager.downloadFileFromString(e,t)}},{key:"createDocument",value:function(e){return this.documentManager.createDocument(e)}},{key:"getDocument",value:function(e){return this.documentManager.getDocument(e)}},{key:"getDocuments",value:function(e){return this.documentManager.getDocuments(e)}},{key:"deleteDocument",value:function(e){return this.documentManager.deleteDocument(e)}},{key:"login",value:function(e){return this.auth.login(e)}},{key:"logout",value:function(e){return this.appProcessor.clearAppProcessor(),this.auth.logout(e)}},{key:"signup",value:function(e){return this.auth.signup(e)}},{key:"getUsersList",value:function(e){return this.auth.getUsersList(e)}},{key:"updateToken",value:function(e){return this.auth.updateToken(e)}},{key:"avatarUploadApi",value:function(e){return this.auth.avatarUploadApi(e)}},{key:"getVersion",value:function(){return this.auth.getVersion()}},{key:"getUserById",value:function(e){return this.auth.getUserById(e)}},{key:"getToken",value:function(){return this.auth.getToken()}},{key:"updateUser",value:function(e){return this.auth.updateUser(e)}},{key:"updateAvatar",value:function(e){return this.auth.updateAvatar(e)}},{key:"websocketHandler",value:function(e){switch(e.api){case"/items/update":console.log("/items/update - ",e),this.itemProcessor.updateItemsInStorage(e.app_id,e.response);break;case"/items/add":console.log("/items/add - ",e),this.itemProcessor.addItemsToStorage(e.app_id,e.response);break;case"/items/delete":console.log("/items/delete - ",e),this.itemProcessor.deleteItemsFromStorage(e.app_id,e.response);break;case"/app/update":console.log("/app/update - ",e),this.appProcessor.updatingAppInStorage(e.response);break;case"/file/delete":console.log("file/delete - ",e),this.fileManager.deleteFileFromStorage(e.response.file_id,e.app_id);break;case"/file/upload":console.log("file/upload - ",e),this.fileManager.addFileToStorage(e.app_id,e.response);break;case"/file/formupload":console.log("file/formupload - ",e);break;case"/file/update":this.fileManager.updateFileInStorage(e.response.file_id,e.response.app_id,e.response),console.log("file/update - ",e);break;case"/new/file/duplicate":this.fileManager.addFilesToStorage(e.app_id,e.response),console.log("new/file/duplicate - ",e);break;default:console.warn("WEBSOCKETS is not process this API:",e.api)}}}]),c}();exports.GudHub=g;
186
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GudHub=void 0;var e=require("./gudhub-https-service.js"),t=require("./PipeService/PipeService.js"),r=require("./Storage/Storage.js"),i=require("./WebSocket/WebSocket.js"),n=require("./config.js"),s=require("./Utils/Utils.js"),o=require("./Auth/Auth.js"),u=require("./Processors/processors.js"),a=require("./Managers/managers.js"),l=require("./consts.js");function c(e,t,r,i,n,s,o){try{var u=e[s](o),a=u.value}catch(l){return void r(l)}u.done?t(a):Promise.resolve(a).then(i,n)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function o(e){c(s,i,n,o,u,"next",e)}function u(e){c(s,i,n,o,u,"throw",e)}o(void 0)})}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var g=function(){function c(l){var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{server_url:n.server_url,wss_url:n.wss_url,initWebsocket:!1,activateSW:!1,swLink:""};d(this,c),this.pipeService=new t.PipeService,this.storage=new r.Storage(this.pipeService),this.util=new s.Utils(this),this.req=new e.GudHubHttpsService(p.server_url),this.auth=new o.Auth(this.req,this.storage),l&&this.storage.setUser({auth_key:l}),this.req.init(this.auth.getToken.bind(this.auth)),this.ws=new i.WebSocketApi(p.wss_url,this.auth),this.chunksManager=new a.ChunksManager(this.storage,this.pipeService,this.req,this.util),this.appProcessor=new u.AppProcessor(this.storage,this.pipeService,this.req,this.ws,this.chunksManager,this.util,p.activateSW),this.itemProcessor=new u.ItemProcessor(this.storage,this.pipeService,this.req,this.appProcessor,this.util),this.fieldProcessor=new u.FieldProcessor(this.storage,this.req,this.appProcessor,this.itemProcessor,this.pipeService),this.fileManager=new a.FileManager(this.storage,this.pipeService,this.req,this.appProcessor),this.documentManager=new a.DocumentManager(this.req),p.initWebsocket&&this.ws.initWebSocket(this.websocketHandler.bind(this),this.appProcessor.refreshApps.bind(this.appProcessor)),p.activateSW&&this.activateSW(p.swLink)}return f(c,[{key:"activateSW",value:function(){var e=p(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(l.IS_WEB&&"serviceWorker"in window.navigator)){e.next=14;break}return e.prev=1,e.next=4,window.navigator.serviceWorker.register(t);case 4:(r=e.sent).update().then(function(){return console.log("%cSW ->>> Service worker successful updated","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;")}).catch(function(){return console.warn("SW ->>> Service worker is not updated")}),console.log("%cSW ->>> Service worker is registered","display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.warn("%cSW ->>> Service worker is not registered","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",e.t0);case 12:e.next=15;break;case 14:console.log("%cSW ->>> ServiceWorkers not supported","display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;");case 15:case"end":return e.stop()}},e,null,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"on",value:function(e,t,r){return this.pipeService.on(e,t,r),this}},{key:"emit",value:function(e,t,r,i){return this.pipeService.emit(e,t,r,i),this}},{key:"destroy",value:function(e,t,r){return this.pipeService.destroy(e,t,r),this}},{key:"prefilter",value:function(e,t,r,i,n){return this.util.prefilter(e,t,r,i,n)}},{key:"filter",value:function(e,t){return this.util.filter(e,t)}},{key:"group",value:function(e,t){return this.util.group(e,t)}},{key:"getFilteredItems",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.util.getFilteredItems(e,t,r.element_app_id,r.app_id,r.item_id,r.field_group,r.search,r.search_params)}},{key:"jsonToItems",value:function(e,t){return this.util.jsonToItems(e,t)}},{key:"getDate",value:function(e){return this.util.getDate(e)}},{key:"populateWithDate",value:function(e,t){return this.util.populateWithDate(e,t)}},{key:"checkRecurringDate",value:function(e,t){return this.util.checkRecurringDate(e,t)}},{key:"populateItems",value:function(e,t,r){return this.util.populateItems(e,t,r)}},{key:"populateWithItemRef",value:function(e,t,r,i,n,s){return this.util.populateWithItemRef(e,t,r,i,n,s)}},{key:"compareItems",value:function(e,t,r){return this.util.compareItems(e,t,r)}},{key:"mergeItems",value:function(e,t,r){return this.util.mergeItems(e,t,r)}},{key:"mergeObjects",value:function(e,t){return this.util.mergeObjects(e,t)}},{key:"makeNestedList",value:function(e,t,r,i,n){return this.util.makeNestedList(e,t,r,i,n)}},{key:"jsonConstructor",value:function(e,t,r){return this.util.jsonConstructor(e,t,r)}},{key:"getAppsList",value:function(){return this.appProcessor.getAppsList()}},{key:"getAppInfo",value:function(e){return this.appProcessor.getAppInfo(e)}},{key:"deleteApp",value:function(e){return this.appProcessor.deleteApp(e)}},{key:"getApp",value:function(e){return this.appProcessor.getApp(e)}},{key:"updateApp",value:function(e){return this.appProcessor.updateApp(e)}},{key:"updateAppInfo",value:function(e){return this.appProcessor.updateAppInfo(e)}},{key:"createNewApp",value:function(e){return this.appProcessor.createNewApp(e)}},{key:"getItems",value:function(e){return this.itemProcessor.getItems(e)}},{key:"getItem",value:function(){var e=p(regeneratorRuntime.mark(function e(t,r){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getItems(t);case 2:if(!(i=e.sent)){e.next=5;break}return e.abrupt("return",i.find(function(e){return e.item_id==r}));case 5:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(e,t){return this.itemProcessor.addNewItems(e,t)}},{key:"updateItems",value:function(e,t){return this.itemProcessor.updateItems(e,t)}},{key:"deleteItems",value:function(e,t){return this.itemProcessor.deleteItems(e,t)}},{key:"getField",value:function(e,t){return this.fieldProcessor.getField(e,t)}},{key:"getFieldModels",value:function(e){return this.fieldProcessor.getFieldModels(e)}},{key:"updateField",value:function(e,t){return this.fieldProcessor.updateField(e,t)}},{key:"deleteField",value:function(e,t){return this.fieldProcessor.deleteField(e,t)}},{key:"getFieldValue",value:function(e,t,r){return this.fieldProcessor.getFieldValue(e,t,r)}},{key:"getInterpretedValue",value:function(e,t,r){return this.util.getInterpretedValue(e,t,r)}},{key:"setFieldValue",value:function(e,t,r,i){return this.fieldProcessor.setFieldValue(e,t,r,i)}},{key:"getFile",value:function(e,t){return this.fileManager.getFile(e,t)}},{key:"getFiles",value:function(e,t){return this.fileManager.getFiles(e,t)}},{key:"uploadFile",value:function(e,t,r){return this.fileManager.uploadFile(e,t,r)}},{key:"uploadFileFromString",value:function(e,t,r,i,n,s,o){return this.fileManager.uploadFileFromString(e,t,r,i,n,s,o)}},{key:"updateFileFromString",value:function(e,t,r,i,n){return this.fileManager.updateFileFromString(e,t,r,i,n)}},{key:"deleteFile",value:function(e,t){return this.fileManager.deleteFile(e,t)}},{key:"duplicateFile",value:function(e){return this.fileManager.duplicateFile(e)}},{key:"downloadFileFromString",value:function(e,t){return this.fileManager.downloadFileFromString(e,t)}},{key:"createDocument",value:function(e){return this.documentManager.createDocument(e)}},{key:"getDocument",value:function(e){return this.documentManager.getDocument(e)}},{key:"getDocuments",value:function(e){return this.documentManager.getDocuments(e)}},{key:"deleteDocument",value:function(e){return this.documentManager.deleteDocument(e)}},{key:"login",value:function(e){return this.auth.login(e)}},{key:"logout",value:function(e){return this.appProcessor.clearAppProcessor(),this.auth.logout(e)}},{key:"signup",value:function(e){return this.auth.signup(e)}},{key:"getUsersList",value:function(e){return this.auth.getUsersList(e)}},{key:"updateToken",value:function(e){return this.auth.updateToken(e)}},{key:"avatarUploadApi",value:function(e){return this.auth.avatarUploadApi(e)}},{key:"getVersion",value:function(){return this.auth.getVersion()}},{key:"getUserById",value:function(e){return this.auth.getUserById(e)}},{key:"getToken",value:function(){return this.auth.getToken()}},{key:"updateUser",value:function(e){return this.auth.updateUser(e)}},{key:"updateAvatar",value:function(e){return this.auth.updateAvatar(e)}},{key:"websocketHandler",value:function(e){switch(e.api){case"/items/update":console.log("/items/update - ",e),this.itemProcessor.updateItemsInStorage(e.app_id,e.response);break;case"/items/add":console.log("/items/add - ",e),this.itemProcessor.addItemsToStorage(e.app_id,e.response);break;case"/items/delete":console.log("/items/delete - ",e),this.itemProcessor.deleteItemsFromStorage(e.app_id,e.response);break;case"/app/update":console.log("/app/update - ",e),this.appProcessor.updatingAppInStorage(e.response);break;case"/file/delete":console.log("file/delete - ",e),this.fileManager.deleteFileFromStorage(e.response.file_id,e.app_id);break;case"/file/upload":console.log("file/upload - ",e),this.fileManager.addFileToStorage(e.app_id,e.response);break;case"/file/formupload":console.log("file/formupload - ",e);break;case"/file/update":this.fileManager.updateFileInStorage(e.response.file_id,e.response.app_id,e.response),console.log("file/update - ",e);break;case"/new/file/duplicate":this.fileManager.addFilesToStorage(e.app_id,e.response),console.log("new/file/duplicate - ",e);break;default:console.warn("WEBSOCKETS is not process this API:",e.api)}}}]),c}();exports.GudHub=g;
187
187
  },{"./gudhub-https-service.js":"hDvy","./PipeService/PipeService.js":"E3xI","./Storage/Storage.js":"CSHe","./WebSocket/WebSocket.js":"pHMV","./config.js":"TPH7","./Utils/Utils.js":"mWlG","./Auth/Auth.js":"rK64","./Processors/processors.js":"WIY5","./Managers/managers.js":"WyOa","./consts.js":"UV2u"}],"iRRN":[function(require,module,exports) {
188
188
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"GudHub",{enumerable:!0,get:function(){return e.GudHub}}),exports.default=void 0,require("regenerator-runtime/runtime.js");var e=require("./GUDHUB/gudhub.js"),r=e.GudHub;exports.default=r;
189
189
  },{"regenerator-runtime/runtime.js":"KA2S","./GUDHUB/gudhub.js":"U9gy"}]},{},["iRRN"], "GudHubLibrary")