@gudhub/core 1.0.37

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.
Files changed (67) hide show
  1. package/GUDHUB/Auth/Auth.js +137 -0
  2. package/GUDHUB/Auth/Auth.test.js +15 -0
  3. package/GUDHUB/Managers/ChunksManager/ChunksManager.js +80 -0
  4. package/GUDHUB/Managers/ChunksManager/ChunksManager.test.js +46 -0
  5. package/GUDHUB/Managers/DocumentManager/DocumentManager.js +48 -0
  6. package/GUDHUB/Managers/FileManager/FileManager.js +208 -0
  7. package/GUDHUB/Managers/FileManager/file_manager.test.js +17 -0
  8. package/GUDHUB/Managers/managers.js +5 -0
  9. package/GUDHUB/PipeService/PipeService.js +167 -0
  10. package/GUDHUB/PipeService/PipeService.test.js +64 -0
  11. package/GUDHUB/PipeService/utils.js +32 -0
  12. package/GUDHUB/Processors/AppProcessor/AppProcessor.js +433 -0
  13. package/GUDHUB/Processors/AppProcessor/AppProcessor.test.js +38 -0
  14. package/GUDHUB/Processors/AppProcessor/AppProcessorMocks.js +83 -0
  15. package/GUDHUB/Processors/FieldProcessor/FieldProcessor.js +139 -0
  16. package/GUDHUB/Processors/FieldProcessor/FieldProcessor.test.js +16 -0
  17. package/GUDHUB/Processors/FieldProcessor/Untitled-1.json +17 -0
  18. package/GUDHUB/Processors/FieldProcessor/field_processor.md +85 -0
  19. package/GUDHUB/Processors/ItemProcessor/ItemProcessor.js +247 -0
  20. package/GUDHUB/Processors/ItemProcessor/item_processor.md +50 -0
  21. package/GUDHUB/Processors/processors.js +5 -0
  22. package/GUDHUB/Storage/Storage.js +115 -0
  23. package/GUDHUB/Storage/Storage.test.js +112 -0
  24. package/GUDHUB/Utils/Utils.js +153 -0
  25. package/GUDHUB/Utils/compare_items_lists_worker/compare_items_lists.worker.js +50 -0
  26. package/GUDHUB/Utils/filter/filter.js +308 -0
  27. package/GUDHUB/Utils/filter/filter.test.js +94 -0
  28. package/GUDHUB/Utils/filter/filterPreparation.js +103 -0
  29. package/GUDHUB/Utils/filter/group.js +41 -0
  30. package/GUDHUB/Utils/filter/utils.js +119 -0
  31. package/GUDHUB/Utils/get_date/get_date.js +90 -0
  32. package/GUDHUB/Utils/get_date/get_date.test.js +53 -0
  33. package/GUDHUB/Utils/interpretation/interpretation.js +100 -0
  34. package/GUDHUB/Utils/json_constructor/json_constructor.js +130 -0
  35. package/GUDHUB/Utils/json_constructor/json_constructor.test.js +70 -0
  36. package/GUDHUB/Utils/json_to_items/json_to_items.js +161 -0
  37. package/GUDHUB/Utils/json_to_items/json_to_items.test.js +85 -0
  38. package/GUDHUB/Utils/merge_chunks/merge_chunks.js +30 -0
  39. package/GUDHUB/Utils/merge_compare_items/merge_compare_items.js +316 -0
  40. package/GUDHUB/Utils/merge_compare_items/merge_compare_items.test.js +632 -0
  41. package/GUDHUB/Utils/merge_objects/merge_objects.js +120 -0
  42. package/GUDHUB/Utils/merge_objects/merge_objects.test.js +137 -0
  43. package/GUDHUB/Utils/nested_list/nested_list.js +38 -0
  44. package/GUDHUB/Utils/nested_list/nested_list.test.js +70 -0
  45. package/GUDHUB/Utils/populate_items/populate_items.js +66 -0
  46. package/GUDHUB/WebSocket/WebSocket.js +136 -0
  47. package/GUDHUB/config.js +8 -0
  48. package/GUDHUB/consts.js +1 -0
  49. package/GUDHUB/gudhub-https-service.js +193 -0
  50. package/GUDHUB/gudhub.js +477 -0
  51. package/GUDHUB/gudhub.test.js +218 -0
  52. package/GUDHUB/utils.js +25 -0
  53. package/Readme.md +537 -0
  54. package/fake_server/fake_java_server.js +112 -0
  55. package/fake_server/fake_server_data/app_132.js +3037 -0
  56. package/fake_server/fake_server_data/app_16259.js +1152 -0
  57. package/fake_server/fake_server_data/app_214.js +2057 -0
  58. package/fake_server/fake_server_data/app_8263.js +4167 -0
  59. package/fake_server/fake_server_data/chunks_mocks/bcacjbgqorherqmtykrj_8263.js +44561 -0
  60. package/fake_server/fake_server_data/chunks_mocks/bcjyuoqaewybudfyhir_8263.js +44197 -0
  61. package/fake_server/fake_server_data/chunks_mocks/tpajkpolmzklodcba_8263.js +44977 -0
  62. package/fake_server/fake_server_data/fake_server_data.js +111 -0
  63. package/index.js +3 -0
  64. package/indexUMD.js +5 -0
  65. package/package.json +45 -0
  66. package/umd/library.min.js +186 -0
  67. package/umd/library.min.js.map +1 -0
@@ -0,0 +1,193 @@
1
+ //****************** GUDHUB HTTPS SERVICE ***********************//
2
+ //-- This Service decorates each POST and GET request with Token
3
+ //-- This Service take care of toking beeing always valid
4
+
5
+ import axios from "axios";
6
+ import { convertObjToUrlParams } from "./utils.js";
7
+ import qs from "qs";
8
+ export class GudHubHttpsService {
9
+ constructor(server_url) {
10
+ this.root = server_url;
11
+ this.requestPromises = [];
12
+ }
13
+
14
+
15
+ //****************** INITIALISATION **************//
16
+ // Here we set a function to get token
17
+ init(getToken) {
18
+ this.getToken = getToken;
19
+ this.promiseCollector(5000);
20
+ }
21
+
22
+
23
+ //********************* GET ***********************//
24
+ async get(request) {
25
+ const accessToken = await this.getToken();
26
+ const hesh = this.getHashCode(request);
27
+
28
+
29
+ if (this.requestPromises[hesh]) {
30
+ return this.requestPromises[hesh].promise;
31
+ }
32
+
33
+ const promise = new Promise((resolve, reject) => {
34
+ const url = this.root + request.url;
35
+
36
+ axios.get(
37
+ `${url}${
38
+ /\?/.test(url) ? "&" : "?"
39
+ }token=${accessToken}${convertObjToUrlParams(request.params)}`
40
+ ).then(function (response) {
41
+ // handle success
42
+ resolve(response.data);
43
+ })
44
+ .catch(function (err) {
45
+ console.log("ERROR -> GUDHUB HTTP SERVICE -> GET :", err.message);
46
+ console.log("Request message: ", request);
47
+ reject(err);
48
+ });
49
+
50
+ });
51
+ this.requestPromises[hesh] = {
52
+ promise,
53
+ time: Date.now()
54
+ }
55
+ return promise;
56
+ }
57
+
58
+
59
+ //********************* GET ***********************//
60
+ async simpleGet(request) {
61
+ const hesh = this.getHashCode(request);
62
+
63
+ if (this.requestPromises[hesh]) {
64
+ return this.requestPromises[hesh].promise;
65
+ }
66
+
67
+ const promise = new Promise((resolve, reject) => {
68
+ const url = this.root + request.url;
69
+
70
+ axios.get(url).then(function (response) {
71
+ // handle success
72
+ resolve(response.data);
73
+ })
74
+ .catch(function (err) {
75
+ console.log("ERROR -> GUDHUB HTTP SERVICE -> GET :", err.message);
76
+ console.log("Request message: ", request);
77
+ reject(err);
78
+ });
79
+
80
+ });
81
+ this.requestPromises[hesh] = {
82
+ promise,
83
+ time: Date.now()
84
+ }
85
+ return promise;
86
+ }
87
+
88
+
89
+ //********************* POST ***********************//
90
+ async post(request) {
91
+ const hesh = this.getHashCode(request);
92
+ request.form["token"] = await this.getToken();
93
+
94
+
95
+ if (this.requestPromises[hesh]) {
96
+ return this.requestPromises[hesh].promise;
97
+ }
98
+
99
+ const promise = new Promise((resolve, reject) => {
100
+ axios.post(
101
+ this.root + request.url,
102
+ qs.stringify(request.form),
103
+ {
104
+ headers: request.headers || {
105
+ "Content-Type": "application/x-www-form-urlencoded",
106
+ },
107
+ }
108
+ ).then(function (response) {
109
+ // handle success
110
+ resolve(response.data);
111
+ }).catch(function (error) {
112
+ console.log("ERROR -> GUDHUB HTTP SERVICE -> POST :", error.message);
113
+ console.log("Request message: ", request);
114
+ reject(error);
115
+ });
116
+ });
117
+ this.requestPromises[hesh] = {
118
+ promise,
119
+ time: Date.now()
120
+ }
121
+ return promise;
122
+ }
123
+
124
+
125
+ //********************* SIMPLE POST ***********************//
126
+ async simplePost(request) {
127
+ const hesh = this.getHashCode(request);
128
+
129
+ if (this.requestPromises[hesh]) {
130
+ return this.requestPromises[hesh].promise;
131
+ }
132
+
133
+ const promise = new Promise((resolve, reject) => {
134
+
135
+ axios.post(
136
+ this.root + request.url,
137
+ qs.stringify(request.form),
138
+ {
139
+ headers: request.headers || {
140
+ "Content-Type": "application/x-www-form-urlencoded",
141
+ },
142
+ }
143
+ ).then(function (response) {
144
+ // handle success
145
+ resolve(response.data);
146
+ }).catch(function (error) {
147
+ console.log("ERROR -> GUDHUB HTTP SERVICE -> SIMPLE POST :", error.message);
148
+ console.log("Request message: ", request);
149
+ reject(error);
150
+ });
151
+
152
+ });
153
+ this.requestPromises[hesh] = {
154
+ promise,
155
+ time: Date.now()
156
+ }
157
+ return promise;
158
+ }
159
+
160
+
161
+ //********************* GET HASH CODE ***********************//
162
+ // it generates numeric identificator whish is the same for similar requests
163
+ // HASH CODE is generated based on: request.params, request.url, request.form
164
+ getHashCode(request){
165
+ let hash = 0;
166
+ let str = qs.stringify(request)
167
+ if (str.length == 0) return hash;
168
+
169
+ for (let i = 0; i < str.length; i++) {
170
+ let char = str.charCodeAt(i);
171
+ hash = ((hash<<5)-hash)+char;
172
+ hash = hash & hash; // Convert to 32bit integer
173
+ }
174
+ return "h" + hash;
175
+ }
176
+
177
+
178
+ //********************* PROMICE COLLECTOR ***********************//
179
+ // Here we erace all promicess after period of time
180
+ // !!! Some modifications needed here, probably erace promicec those were resolved or save start time and erace it in a minute after promice created
181
+ promiseCollector( interval ) {
182
+ setInterval(() => {
183
+ Object.keys(this.requestPromises).forEach(hesh => {
184
+ if(Date.now() - this.requestPromises[hesh].time > interval ){
185
+ delete this.requestPromises[hesh];
186
+ }
187
+ });
188
+
189
+ //console.log("promises:", Object.keys(this.requestPromises).length);
190
+ }, interval);
191
+ }
192
+
193
+ }
@@ -0,0 +1,477 @@
1
+ import { GudHubHttpsService } from "./gudhub-https-service.js";
2
+ import { PipeService } from "./PipeService/PipeService.js";
3
+ import { Storage } from "./Storage/Storage.js";
4
+ import { WebSocketApi } from "./WebSocket/WebSocket.js";
5
+ import { wss_url, server_url } from "./config.js";
6
+ import { Utils } from "./Utils/Utils.js";
7
+ import { Auth } from "./Auth/Auth.js";
8
+ import {
9
+ AppProcessor,
10
+ FieldProcessor,
11
+ ItemProcessor,
12
+ } from "./Processors/processors.js";
13
+ import {
14
+ DocumentManager,
15
+ FileManager,
16
+ ChunksManager,
17
+ } from "./Managers/managers.js";
18
+ import { IS_WEB } from "./consts.js";
19
+
20
+ export class GudHub {
21
+ constructor(
22
+ authKey,
23
+ options = {
24
+ server_url,
25
+ wss_url,
26
+ initWebsocket: false,
27
+ activateSW: false,
28
+ swLink: "",
29
+ }
30
+ ) {
31
+ this.pipeService = new PipeService();
32
+ this.storage = new Storage(this.pipeService);
33
+ this.util = new Utils(this);
34
+ this.req = new GudHubHttpsService(options.server_url);
35
+ this.auth = new Auth(this.req, this.storage);
36
+ if (authKey) this.storage.setUser({ auth_key: authKey });
37
+ this.req.init(this.auth.getToken.bind(this.auth));
38
+
39
+ this.ws = new WebSocketApi(options.wss_url, this.auth);
40
+ this.chunksManager = new ChunksManager(
41
+ this.storage,
42
+ this.pipeService,
43
+ this.req,
44
+ this.util
45
+ );
46
+ this.appProcessor = new AppProcessor(
47
+ this.storage,
48
+ this.pipeService,
49
+ this.req,
50
+ this.ws,
51
+ this.chunksManager,
52
+ this.util,
53
+ options.activateSW
54
+ );
55
+ this.itemProcessor = new ItemProcessor(
56
+ this.storage,
57
+ this.pipeService,
58
+ this.req,
59
+ this.appProcessor,
60
+ this.util
61
+ );
62
+ this.fieldProcessor = new FieldProcessor(
63
+ this.storage,
64
+ this.req,
65
+ this.appProcessor,
66
+ this.itemProcessor
67
+ );
68
+ this.fileManager = new FileManager(this.storage, this.req, this.pipeService, this.appProcessor);
69
+ this.documentManager = new DocumentManager(this.req);
70
+
71
+ if (options.initWebsocket) {
72
+ this.ws.initWebSocket(
73
+ this.websocketHandler.bind(this),
74
+ this.appProcessor.refreshApps.bind(this.appProcessor)
75
+ );
76
+ }
77
+ if (options.activateSW) {
78
+ this.activateSW(options.swLink);
79
+ }
80
+ }
81
+
82
+ async activateSW(swLink) {
83
+ if (IS_WEB && "serviceWorker" in window.navigator) {
84
+ try {
85
+ const sw = await window.navigator.serviceWorker.register(swLink);
86
+ sw.update()
87
+ .then(() =>
88
+ console.log(
89
+ "%cSW ->>> Service worker successful updated",
90
+ "display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;"
91
+ )
92
+ )
93
+ .catch(() => console.warn("SW ->>> Service worker is not updated"));
94
+ console.log(
95
+ "%cSW ->>> Service worker is registered",
96
+ "display: inline-block ; background-color: #689f38 ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",
97
+ sw
98
+ );
99
+ } catch (error) {
100
+ console.warn(
101
+ "%cSW ->>> Service worker is not registered",
102
+ "display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;",
103
+ error
104
+ );
105
+ }
106
+ } else {
107
+ console.log(
108
+ "%cSW ->>> ServiceWorkers not supported",
109
+ "display: inline-block ; background-color: #d32f2f ; color: #ffffff ; font-weight: bold ; padding: 3px 7px; border-radius: 3px;"
110
+ );
111
+ }
112
+ }
113
+
114
+ //************************* PIPESERVICE METHODS ****************************//
115
+ //============= ON PIPE ===============//
116
+ on(types, destination, fn) {
117
+ this.pipeService.on(types, destination, fn);
118
+ return this;
119
+ }
120
+
121
+ //============= EMIT PIPE ==============//
122
+ emit(types, destination, address, params) {
123
+ this.pipeService.emit(types, destination, address, params);
124
+ return this;
125
+ }
126
+
127
+ //============ DELETE LISTENER ========//
128
+ destroy(types, destination, func) {
129
+ this.pipeService.destroy(types, destination, func);
130
+ return this;
131
+ }
132
+
133
+ //************************* FILTERATION ****************************//
134
+ prefilter(filters_list, element_app_id, app_id, item_id, variables) {
135
+ return this.util.prefilter(
136
+ filters_list,
137
+ element_app_id,
138
+ app_id,
139
+ item_id,
140
+ variables
141
+ );
142
+ }
143
+
144
+ //============ FILTER ==========//
145
+ filter(items, filter_list) {
146
+ return this.util.filter(items, filter_list);
147
+ }
148
+
149
+ //============ GROUP ==========//
150
+ group(fieldGroup, items) {
151
+ return this.util.group(fieldGroup, items);
152
+ }
153
+
154
+ //============ GET FILTERED ITEMS ==========//
155
+ //it returns items with applyed filter
156
+ getFilteredItems(items, filters_list, options = {}) {
157
+ return this.util.getFilteredItems(
158
+ items,
159
+ filters_list,
160
+ options.element_app_id,
161
+ options.app_id,
162
+ options.item_id,
163
+ options.field_group,
164
+ options.search,
165
+ options.search_params
166
+ );
167
+ }
168
+
169
+ jsonToItems(json, map) {
170
+ return this.util.jsonToItems(json, map);
171
+ }
172
+
173
+ getDate(queryKey) {
174
+ return this.util.getDate(queryKey);
175
+ }
176
+
177
+ populateWithDate(items, model) {
178
+ return this.util.populateWithDate(items, model);
179
+ }
180
+
181
+ populateItems(items, model, keep_data) {
182
+ return this.util.populateItems(items, model, keep_data);
183
+ }
184
+
185
+ populateWithItemRef(
186
+ sourceItemsRef,
187
+ srcFieldIdToCompare,
188
+ destinationItems,
189
+ destFieldIdToCompare,
190
+ destFieldForRef,
191
+ app_id
192
+ ) {
193
+ return this.util.populateWithItemRef(
194
+ sourceItemsRef,
195
+ srcFieldIdToCompare,
196
+ destinationItems,
197
+ destFieldIdToCompare,
198
+ destFieldForRef,
199
+ app_id
200
+ );
201
+ }
202
+
203
+ compareItems(sourceItems, destinationItems, fieldToCompare) {
204
+ return this.util.compareItems(
205
+ sourceItems,
206
+ destinationItems,
207
+ fieldToCompare
208
+ );
209
+ }
210
+
211
+ mergeItems(sourceItems, destinationItems, mergeByFieldId) {
212
+ return this.util.mergeItems(sourceItems, destinationItems, mergeByFieldId);
213
+ }
214
+
215
+ mergeObjects(sourceObject, destinationObject) {
216
+ return this.util.mergeObjects(sourceObject, destinationObject);
217
+ }
218
+
219
+ makeNestedList(arr, id, parent_id, children_property) {
220
+ return this.util.makeNestedList(arr, id, parent_id, children_property);
221
+ }
222
+
223
+ jsonConstructor(scheme, items, variables){
224
+ return this.util.jsonConstructor(scheme, items, variables)
225
+ }
226
+
227
+ //************************* APP PROCESSOR ****************************//
228
+ getAppsList() {
229
+ return this.appProcessor.getAppsList();
230
+ }
231
+
232
+ getAppInfo(app_id) {
233
+ return this.appProcessor.getAppInfo(app_id);
234
+ }
235
+
236
+ deleteApp(app_id) {
237
+ return this.appProcessor.deleteApp(app_id);
238
+ }
239
+
240
+ getApp(app_id) {
241
+ return this.appProcessor.getApp(app_id);
242
+ }
243
+
244
+ updateApp(app) {
245
+ return this.appProcessor.updateApp(app);
246
+ }
247
+
248
+ updateAppInfo(appInfo) {
249
+ return this.appProcessor.updateAppInfo(appInfo);
250
+ }
251
+
252
+ createNewApp(app) {
253
+ return this.appProcessor.createNewApp(app);
254
+ }
255
+
256
+ getItems(app_id) {
257
+ return this.itemProcessor.getItems(app_id);
258
+ }
259
+
260
+ async getItem(app_id, item_id) {
261
+ const items = await this.getItems(app_id);
262
+ if (items) {
263
+ return items.find((item) => item.item_id == item_id);
264
+ }
265
+ }
266
+
267
+ addNewItems(app_id, itemsList) {
268
+ return this.itemProcessor.addNewItems(app_id, itemsList);
269
+ }
270
+
271
+ updateItems(app_id, itemsList) {
272
+ return this.itemProcessor.updateItems(app_id, itemsList);
273
+ }
274
+
275
+ deleteItems(app_id, itemsIds) {
276
+ return this.itemProcessor.deleteItems(app_id, itemsIds);
277
+ }
278
+
279
+ getField(app_id, field_id) {
280
+ return this.fieldProcessor.getField(app_id, field_id);
281
+ }
282
+
283
+ getFieldModels(app_id) {
284
+ return this.fieldProcessor.getFieldModels(app_id);
285
+ }
286
+
287
+ updateField(app_id, fieldModel) {
288
+ return this.fieldProcessor.updateField(app_id, fieldModel);
289
+ }
290
+
291
+ deleteField(app_id, field_id) {
292
+ return this.fieldProcessor.deleteField(app_id, field_id);
293
+ }
294
+
295
+ getFieldValue(app_id, item_id, field_id) {
296
+ return this.fieldProcessor.getFieldValue(app_id, item_id, field_id);
297
+ }
298
+
299
+ getInterpretedValue(app_id, item_id, field_id) {
300
+ return this.util.getInterpretedValue(app_id, item_id, field_id)
301
+ }
302
+
303
+ setFieldValue(app_id, item_id, field_id, field_value) {
304
+ return this.fieldProcessor.setFieldValue(
305
+ app_id,
306
+ item_id,
307
+ field_id,
308
+ field_value
309
+ );
310
+ }
311
+
312
+ getFile(app_id, file_id) {
313
+ return this.fileManager.getFile(app_id, file_id);
314
+ }
315
+
316
+ getFiles(app_id, filesId) {
317
+ return this.fileManager.getFiles(app_id, filesId);
318
+ }
319
+
320
+ uploadFile(fileData, app_id, item_id) {
321
+ return this.fileManager.uploadFile(fileData, app_id, item_id);
322
+ }
323
+
324
+ uploadFileFromString(
325
+ source,
326
+ file_name,
327
+ app_id,
328
+ item_id,
329
+ extension,
330
+ format,
331
+ element_id
332
+ ) {
333
+ return this.fileManager.uploadFileFromString(
334
+ source,
335
+ file_name,
336
+ app_id,
337
+ item_id,
338
+ extension,
339
+ format,
340
+ element_id
341
+ );
342
+ }
343
+
344
+ updateFileFromString(data, file_id, file_name, extension, format) {
345
+ return this.fileManager.updateFileFromString(
346
+ data,
347
+ file_id,
348
+ file_name,
349
+ extension,
350
+ format
351
+ );
352
+ }
353
+
354
+ deleteFile(app_id, id) {
355
+ return this.fileManager.deleteFile(app_id, id);
356
+ }
357
+
358
+ duplicateFile(files) {
359
+ return this.fileManager.duplicateFile(files);
360
+ }
361
+
362
+ createDocument(documentObject) {
363
+ return this.documentManager.createDocumentApi(documentObject);
364
+ }
365
+
366
+ getDocument(documentAddress) {
367
+ return this.documentManager.getDocumentApi(documentAddress);
368
+ }
369
+
370
+ getDocuments(documentAddress) {
371
+ return this.documentManager.getDocumentsApi(documentAddress);
372
+ }
373
+
374
+ deleteDocument(documentAddress) {
375
+ return this.documentManager.deleteDocumentApi(documentAddress);
376
+ }
377
+
378
+ login(data) {
379
+ return this.auth.login(data);
380
+ }
381
+
382
+ logout(token) {
383
+ this.appProcessor.clearAppProcessor();
384
+ return this.auth.logout(token);
385
+ }
386
+
387
+ signup(user) {
388
+ return this.auth.signup(user);
389
+ }
390
+
391
+ getUsersList(keyword) {
392
+ return this.auth.getUsersList(keyword);
393
+ }
394
+
395
+ updateToken(auth_key) {
396
+ return this.auth.updateToken(auth_key);
397
+ }
398
+
399
+ avatarUploadApi(image) {
400
+ return this.auth.avatarUploadApi(image);
401
+ }
402
+
403
+ getVersion() {
404
+ return this.auth.getVersion();
405
+ }
406
+
407
+ getUserById(userId) {
408
+ return this.auth.getUserById(userId);
409
+ }
410
+
411
+ getToken() {
412
+ return this.auth.getToken();
413
+ }
414
+
415
+ updateUser(userData) {
416
+ return this.auth.updateUser(userData);
417
+ }
418
+
419
+ updateAvatar(imageData) {
420
+ return this.auth.updateAvatar(imageData);
421
+ }
422
+
423
+ websocketHandler(message) {
424
+ switch (message.api) {
425
+ case "/items/update":
426
+ console.log("/items/update - ", message);
427
+ this.itemProcessor.updateItemsInStorage(
428
+ message.app_id,
429
+ message.response
430
+ );
431
+ break;
432
+ case "/items/add":
433
+ console.log("/items/add - ", message);
434
+ this.itemProcessor.addItemsToStorage(message.app_id, message.response);
435
+ break;
436
+ case "/items/delete":
437
+ console.log("/items/delete - ", message);
438
+ this.itemProcessor.deleteItemsFromStorage(
439
+ message.app_id,
440
+ message.response
441
+ );
442
+ break;
443
+ case "/app/update":
444
+ console.log("/app/update - ", message);
445
+ this.appProcessor.updatingAppInStorage(message.response);
446
+ break;
447
+ case "/file/delete":
448
+ console.log("file/delete - ", message);
449
+ this.fileManager.deleteFileFromStorage(
450
+ message.response.file_id,
451
+ message.app_id
452
+ );
453
+ break;
454
+ case "/file/upload":
455
+ console.log("file/upload - ", message);
456
+ this.fileManager.addFileToStorage(message.app_id, message.response);
457
+ break;
458
+ case "/file/formupload": //I'm not shure if we are using it (probably in contact form)
459
+ console.log("file/formupload - ", message);
460
+ break;
461
+ case "/file/update": //I'm not shure if we are using it (probably in contact form)
462
+ this.fileManager.updateFileInStorage(
463
+ message.response.file_id,
464
+ message.response.app_id,
465
+ message.response
466
+ );
467
+ console.log("file/update - ", message);
468
+ break;
469
+ case "/new/file/duplicate": //I'm not shure if we are using it (probably in contact form)
470
+ this.fileManager.addFilesToStorage(message.app_id, message.response);
471
+ console.log("new/file/duplicate - ", message);
472
+ break;
473
+ default:
474
+ console.warn("WEBSOCKETS is not process this API:", message.api);
475
+ }
476
+ }
477
+ }