@gudhub/core 1.1.91 → 1.2.1
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.
- package/.vscode/launch.json +31 -0
- package/GUDHUB/AppProcessor/AppProcessor.js +24 -46
- package/GUDHUB/Auth/Auth.js +0 -18
- package/GUDHUB/Auth/Auth.test.js +1 -11
- package/GUDHUB/ChunksManager/ChunksManager.js +17 -31
- package/GUDHUB/DataService/AppDataService.js +5 -0
- package/GUDHUB/DataService/CacheAPI/index.js +1 -0
- package/GUDHUB/DataService/ChunkDataService.js +5 -0
- package/GUDHUB/DataService/DataService.js +1 -0
- package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +98 -0
- package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +110 -0
- package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +7 -0
- package/GUDHUB/DataService/IndexedDB/appDataConf.js +7 -0
- package/GUDHUB/DataService/IndexedDB/chunkDataConf.js +7 -0
- package/GUDHUB/DataService/IndexedDB/consts.js +2 -0
- package/GUDHUB/DataService/IndexedDB/init.js +21 -0
- package/GUDHUB/DataService/export.js +48 -0
- package/GUDHUB/DataService/httpService/AppHttpService.js +31 -0
- package/GUDHUB/DataService/httpService/ChunkHttpService.js +32 -0
- package/GUDHUB/DataService/httpService/HttpService.js +1 -0
- package/GUDHUB/DataService/utils.js +34 -0
- package/GUDHUB/api/AppApi.js +14 -0
- package/GUDHUB/api/ChunkApi.js +19 -0
- package/GUDHUB/config.js +3 -0
- package/GUDHUB/gudhub.js +7 -18
- package/package.json +1 -1
- package/umd/library.min.js +140 -70
- package/umd/library.min.js.map +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
export let objectAssignWithoutOverride = (target, ...sourceList) => {
|
|
3
|
+
for (let source of sourceList) {
|
|
4
|
+
if (!source) continue;
|
|
5
|
+
for(let key of Object.keys(source)) {//this doesnt iterate over class like source properties
|
|
6
|
+
if (!(key in target)) {//checks own and inherited keys, works fine also for class prototypes and instances
|
|
7
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
8
|
+
if (desc.enumerable) Object.defineProperty(target, key, desc);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export let objectAssignWithOverride = (target, ...sourceList) => {
|
|
15
|
+
for (let source of sourceList) {
|
|
16
|
+
if (!source) continue;
|
|
17
|
+
for(let key of Object.keys(source)) {//this doesnt iterate over class like source properties
|
|
18
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
19
|
+
if (desc.enumerable) Object.defineProperty(target, key, desc);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export let checkInstanceModifier = (target, ...sourceList) => {
|
|
27
|
+
for (let source of sourceList) {
|
|
28
|
+
if (!source) continue;
|
|
29
|
+
for(let key of Object.keys(source)) {//this doesnt iterate over class like source properties
|
|
30
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
31
|
+
if (desc.enumerable) Object.defineProperty(target, key, desc);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class ChunkAPI {
|
|
2
|
+
constructor(req) {
|
|
3
|
+
this.req = req;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
async getChunk(app_id, chunk_id) {
|
|
7
|
+
return this.req.get({
|
|
8
|
+
url: `${this.req.root}/api/get-items-chunk/${app_id}/${chunk_id}`,
|
|
9
|
+
method: 'GET'
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getLastChunk(app_id) {
|
|
14
|
+
return this.req.axiosRequest({
|
|
15
|
+
url: `${this.req.root}/api/get-last-items-chunk/${app_id}`,
|
|
16
|
+
method: 'GET'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
package/GUDHUB/config.js
CHANGED
|
@@ -8,5 +8,8 @@ export const async_modules_path = 'build/latest/async_modules_node/';
|
|
|
8
8
|
export const automation_modules_path = 'build/latest/automation_modules/'
|
|
9
9
|
export const file_server_url = 'https://gudhub.com'
|
|
10
10
|
|
|
11
|
+
export const cache_chunk_requests = true;
|
|
12
|
+
export const cache_app_requests = true;
|
|
13
|
+
|
|
11
14
|
// FOR TESTS
|
|
12
15
|
export const port = 9000;
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -18,6 +18,7 @@ import { WebsocketHandler } from './WebSocket/WebsocketHandler.js';
|
|
|
18
18
|
import { GroupSharing } from './Utils/sharing/GroupSharing.js';
|
|
19
19
|
import { Sharing } from './Utils/sharing/Sharing.js';
|
|
20
20
|
import { WebSocketEmitter } from './WebSocket/WebSocketEmitter.js';
|
|
21
|
+
import { AppDataService, ChunkDataService, appDataServiceConf, chunkDataServiceConf } from "./DataService/export.js";
|
|
21
22
|
|
|
22
23
|
export class GudHub {
|
|
23
24
|
constructor(
|
|
@@ -31,9 +32,7 @@ export class GudHub {
|
|
|
31
32
|
swLink: "",
|
|
32
33
|
async_modules_path,
|
|
33
34
|
file_server_url,
|
|
34
|
-
automation_modules_path
|
|
35
|
-
accesstoken: this.accesstoken,
|
|
36
|
-
expirydate: this.expirydate
|
|
35
|
+
automation_modules_path
|
|
37
36
|
}
|
|
38
37
|
) {
|
|
39
38
|
this.config = options;
|
|
@@ -46,15 +45,7 @@ export class GudHub {
|
|
|
46
45
|
this.auth = new Auth(this.req, this.storage);
|
|
47
46
|
this.sharing = new Sharing(this, this.req);
|
|
48
47
|
this.groupSharing = new GroupSharing(this, this.req, this.pipeService);
|
|
49
|
-
|
|
50
|
-
// Login with access token - pass to setUser access token and after it user can make requests with access token
|
|
51
|
-
// This method created for optimize GudHub initialization without auth key
|
|
52
|
-
if (authKey) {
|
|
53
|
-
this.storage.setUser({ auth_key: authKey })
|
|
54
|
-
} else if(options.accesstoken && options.expirydate) {
|
|
55
|
-
this.storage.setUser({accesstoken: options.accesstoken, expirydate: options.expirydate})
|
|
56
|
-
}
|
|
57
|
-
|
|
48
|
+
if (authKey) this.storage.setUser({ auth_key: authKey });
|
|
58
49
|
this.req.init(this.auth.getToken.bind(this.auth));
|
|
59
50
|
|
|
60
51
|
this.ws = new WebSocketApi(options.wss_url, this.auth);
|
|
@@ -62,7 +53,8 @@ export class GudHub {
|
|
|
62
53
|
this.storage,
|
|
63
54
|
this.pipeService,
|
|
64
55
|
this.req,
|
|
65
|
-
this.util
|
|
56
|
+
this.util,
|
|
57
|
+
new ChunkDataService(this.req, chunkDataServiceConf),
|
|
66
58
|
);
|
|
67
59
|
this.appProcessor = new AppProcessor(
|
|
68
60
|
this.storage,
|
|
@@ -71,7 +63,8 @@ export class GudHub {
|
|
|
71
63
|
this.ws,
|
|
72
64
|
this.chunksManager,
|
|
73
65
|
this.util,
|
|
74
|
-
options.activateSW
|
|
66
|
+
options.activateSW,
|
|
67
|
+
new AppDataService(this.req, appDataServiceConf),
|
|
75
68
|
);
|
|
76
69
|
this.itemProcessor = new ItemProcessor(
|
|
77
70
|
this.storage,
|
|
@@ -452,10 +445,6 @@ export class GudHub {
|
|
|
452
445
|
return this.auth.login(data);
|
|
453
446
|
}
|
|
454
447
|
|
|
455
|
-
loginWithToken(token) {
|
|
456
|
-
return this.auth.loginWithToken(token);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
448
|
logout(token) {
|
|
460
449
|
this.appProcessor.clearAppProcessor();
|
|
461
450
|
return this.auth.logout(token);
|