verteilen-core 1.2.4 → 1.2.6
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/dist/index.d.ts +3 -0
- package/dist/jest.config.d.ts +2 -0
- package/dist/src/client/analysis.d.ts +35 -0
- package/dist/src/client/analysis.js +318 -319
- package/dist/src/client/client.d.ts +25 -0
- package/dist/src/client/client.js +162 -168
- package/dist/src/client/cluster.d.ts +1 -0
- package/dist/src/client/cluster.js +1 -2
- package/dist/src/client/database.d.ts +13 -0
- package/dist/src/client/database.js +28 -27
- package/dist/src/client/execute.d.ts +24 -0
- package/dist/src/client/execute.js +61 -51
- package/dist/src/client/http.d.ts +7 -0
- package/dist/src/client/http.js +29 -26
- package/dist/src/client/javascript.d.ts +47 -0
- package/dist/src/client/javascript.js +110 -136
- package/dist/src/client/job_database.d.ts +10 -0
- package/dist/src/client/job_database.js +27 -29
- package/dist/src/client/job_execute.d.ts +20 -0
- package/dist/src/client/job_execute.js +148 -146
- package/dist/src/client/os.d.ts +29 -0
- package/dist/src/client/os.js +131 -136
- package/dist/src/client/resource.d.ts +7 -0
- package/dist/src/client/resource.js +93 -104
- package/dist/src/client/shell.d.ts +16 -0
- package/dist/src/client/shell.js +102 -98
- package/dist/src/computed.d.ts +13 -0
- package/dist/src/interface/base.d.ts +70 -0
- package/dist/src/interface/bus.d.ts +90 -0
- package/dist/src/interface/enum.d.ts +143 -0
- package/dist/src/interface/execute.d.ts +20 -0
- package/dist/src/interface/record.d.ts +93 -0
- package/dist/src/interface/server.d.ts +76 -0
- package/dist/src/interface/struct.d.ts +182 -0
- package/dist/src/interface/table.d.ts +20 -0
- package/dist/src/interface/ui.d.ts +29 -0
- package/dist/src/interface.d.ts +29 -0
- package/dist/src/plugins/i18n.d.ts +1666 -0
- package/dist/src/script/console_manager.d.ts +18 -0
- package/dist/src/script/console_manager.js +97 -91
- package/dist/src/script/console_server_manager.d.ts +13 -0
- package/dist/src/script/console_server_manager.js +29 -26
- package/dist/src/script/execute/base.d.ts +45 -0
- package/dist/src/script/execute/base.js +165 -162
- package/dist/src/script/execute/feedback.d.ts +12 -0
- package/dist/src/script/execute/feedback.js +162 -171
- package/dist/src/script/execute/interface.d.ts +8 -0
- package/dist/src/script/execute/region_job.d.ts +5 -0
- package/dist/src/script/execute/region_job.js +1 -0
- package/dist/src/script/execute/region_project.d.ts +10 -0
- package/dist/src/script/execute/region_project.js +4 -0
- package/dist/src/script/execute/region_subtask.d.ts +5 -0
- package/dist/src/script/execute/region_subtask.js +1 -0
- package/dist/src/script/execute/region_task.d.ts +10 -0
- package/dist/src/script/execute/region_task.js +4 -0
- package/dist/src/script/execute/runner.d.ts +14 -0
- package/dist/src/script/execute/runner.js +129 -139
- package/dist/src/script/execute/util_parser.d.ts +14 -0
- package/dist/src/script/execute/util_parser.js +119 -121
- package/dist/src/script/execute_manager.d.ts +25 -0
- package/dist/src/script/execute_manager.js +266 -278
- package/dist/src/script/socket_manager.d.ts +31 -0
- package/dist/src/script/socket_manager.js +196 -193
- package/dist/src/script/webhook_manager.d.ts +3 -0
- package/dist/src/script/webhook_server_manager.d.ts +13 -0
- package/dist/src/script/webhook_server_manager.js +79 -86
- package/dist/src/server/detail.d.ts +72 -0
- package/dist/src/server/detail.js +401 -378
- package/dist/src/server/io.d.ts +46 -0
- package/dist/src/server/io.js +42 -51
- package/dist/src/server/plugin.d.ts +18 -0
- package/dist/src/server/plugin.js +45 -54
- package/dist/src/server/server.d.ts +27 -0
- package/dist/src/server/server.js +38 -36
- package/dist/src/server.d.ts +4 -0
- package/dist/src/util/console_handle.d.ts +20 -0
- package/dist/src/util/console_handle.js +214 -218
- package/dist/src/util/log_handle.d.ts +23 -0
- package/dist/src/util/log_handle.js +158 -164
- package/dist/test/TEST.d.ts +1 -0
- package/dist/test/TEST.js +37 -54
- package/dist/test/client/execute.test.d.ts +1 -0
- package/dist/test/client/execute.test.js +6 -15
- package/dist/test/client/javascript.test.d.ts +1 -0
- package/dist/test/client/javascript.test.js +21 -30
- package/dist/test/client/server.test.d.ts +1 -0
- package/dist/test/client/task.test.d.ts +1 -0
- package/dist/test/client/task.test.js +1 -1
- package/dist/test/script/parser.test.d.ts +1 -0
- package/dist/test/script/socket.test.d.ts +1 -0
- package/package.json +1 -1
- package/tsconfig.json +5 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Project, RecordType, Database, UserProfile, Library, ExecutionLog, Node } from "../interface";
|
|
2
|
+
export interface MemoryData {
|
|
3
|
+
projects: Array<Project>;
|
|
4
|
+
database: Array<Database>;
|
|
5
|
+
nodes: Array<Node>;
|
|
6
|
+
logs: Array<ExecutionLog>;
|
|
7
|
+
libs: Array<Library>;
|
|
8
|
+
user: Array<UserProfile>;
|
|
9
|
+
}
|
|
10
|
+
export interface RecordIOLoader {
|
|
11
|
+
load_all: () => Promise<Array<string>>;
|
|
12
|
+
delete_all: () => Promise<void>;
|
|
13
|
+
list_all: () => Promise<Array<string>>;
|
|
14
|
+
save: (name: string, data: string) => Promise<void>;
|
|
15
|
+
load: (name: string, cache: boolean) => Promise<string>;
|
|
16
|
+
rename: (name: string, newname: string) => Promise<void>;
|
|
17
|
+
delete: (name: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface RecordLoader {
|
|
20
|
+
project: RecordIOLoader;
|
|
21
|
+
database: RecordIOLoader;
|
|
22
|
+
node: RecordIOLoader;
|
|
23
|
+
log: RecordIOLoader;
|
|
24
|
+
lib: RecordIOLoader;
|
|
25
|
+
user: RecordIOLoader;
|
|
26
|
+
}
|
|
27
|
+
export interface RecordIOBase {
|
|
28
|
+
root: string;
|
|
29
|
+
join: (...paths: Array<string>) => string;
|
|
30
|
+
read_dir: (path: string) => Promise<Array<string>>;
|
|
31
|
+
read_dir_dir: (path: string) => Promise<Array<string>>;
|
|
32
|
+
read_dir_file: (path: string) => Promise<Array<string>>;
|
|
33
|
+
read_string: (path: string, options?: any) => Promise<string>;
|
|
34
|
+
write_string: (path: string, content: string) => Promise<void>;
|
|
35
|
+
exists: (path: string) => boolean;
|
|
36
|
+
mkdir: (path: string) => Promise<void>;
|
|
37
|
+
rm: (path: string) => Promise<void>;
|
|
38
|
+
cp: (path: string, newpath: string) => Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface RecordMongoBase {
|
|
41
|
+
}
|
|
42
|
+
export declare const _CreateRecordMemoryLoader: (loader: MemoryData, type: RecordType) => RecordIOLoader;
|
|
43
|
+
export declare const _CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData, type: RecordType, folder: string, ext?: string) => RecordIOLoader;
|
|
44
|
+
export declare const CreateRecordMemoryLoader: (loader: MemoryData) => RecordLoader;
|
|
45
|
+
export declare const CreateRecordIOLoader: (loader: RecordIOBase, memory: MemoryData) => RecordLoader;
|
|
46
|
+
export declare const CreateRecordMongoLoader: (loader: RecordMongoBase, folder: string, ext?: string) => void;
|
package/dist/src/server/io.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.CreateRecordMongoLoader = exports.CreateRecordIOLoader = exports.CreateRecordMemoryLoader = exports._CreateRecordIOLoader = exports._CreateRecordMemoryLoader = void 0;
|
|
13
4
|
const interface_1 = require("../interface");
|
|
@@ -24,41 +15,41 @@ const _CreateRecordMemoryLoader = (loader, type) => {
|
|
|
24
15
|
}
|
|
25
16
|
};
|
|
26
17
|
return {
|
|
27
|
-
load_all: () =>
|
|
18
|
+
load_all: async () => {
|
|
28
19
|
return get_array(type).map(x => JSON.stringify(x));
|
|
29
|
-
}
|
|
30
|
-
delete_all: () =>
|
|
20
|
+
},
|
|
21
|
+
delete_all: async () => {
|
|
31
22
|
const arr = get_array(type).map(x => JSON.stringify(x));
|
|
32
23
|
arr.splice(0, arr.length);
|
|
33
|
-
}
|
|
34
|
-
list_all: () =>
|
|
24
|
+
},
|
|
25
|
+
list_all: async () => {
|
|
35
26
|
return get_array(type).map(x => x.uuid);
|
|
36
|
-
}
|
|
37
|
-
save: (name, data) =>
|
|
27
|
+
},
|
|
28
|
+
save: async (name, data) => {
|
|
38
29
|
const arr = get_array(type);
|
|
39
30
|
const b = arr.findIndex(x => name == x.uuid);
|
|
40
31
|
if (b != -1)
|
|
41
32
|
arr[b] = JSON.parse(data);
|
|
42
33
|
else
|
|
43
34
|
arr.push(JSON.parse(data));
|
|
44
|
-
}
|
|
45
|
-
load: (name) =>
|
|
35
|
+
},
|
|
36
|
+
load: async (name) => {
|
|
46
37
|
const arr = get_array(type);
|
|
47
38
|
const b = arr.find(x => name == x.uuid);
|
|
48
39
|
return b ? JSON.stringify(b) : "";
|
|
49
|
-
}
|
|
50
|
-
rename: (name, newname) =>
|
|
40
|
+
},
|
|
41
|
+
rename: async (name, newname) => {
|
|
51
42
|
const arr = get_array(type);
|
|
52
43
|
const b = arr.findIndex(x => x.uuid == name);
|
|
53
44
|
if (b != -1)
|
|
54
45
|
arr[b].uuid = newname;
|
|
55
|
-
}
|
|
56
|
-
delete: (name) =>
|
|
46
|
+
},
|
|
47
|
+
delete: async (name) => {
|
|
57
48
|
const arr = get_array(type);
|
|
58
49
|
const b = arr.findIndex(x => x.uuid == name);
|
|
59
50
|
if (b != -1)
|
|
60
51
|
arr.splice(b, 1);
|
|
61
|
-
}
|
|
52
|
+
}
|
|
62
53
|
};
|
|
63
54
|
};
|
|
64
55
|
exports._CreateRecordMemoryLoader = _CreateRecordMemoryLoader;
|
|
@@ -75,46 +66,46 @@ const _CreateRecordIOLoader = (loader, memory, type, folder, ext = ".json") => {
|
|
|
75
66
|
}
|
|
76
67
|
};
|
|
77
68
|
return {
|
|
78
|
-
load_all: () =>
|
|
69
|
+
load_all: async () => {
|
|
79
70
|
const root = loader.join(loader.root, folder);
|
|
80
71
|
if (!loader.exists(root))
|
|
81
|
-
|
|
82
|
-
const files =
|
|
72
|
+
await loader.mkdir(root);
|
|
73
|
+
const files = await loader.read_dir_file(root);
|
|
83
74
|
const r = files.map(x => loader.read_string(x, { encoding: 'utf8', flag: 'r' }));
|
|
84
|
-
const p =
|
|
75
|
+
const p = await Promise.all(r);
|
|
85
76
|
const arr = get_array(type);
|
|
86
77
|
arr.splice(0, arr.length);
|
|
87
78
|
arr.push(...p.map(x => JSON.parse(x)));
|
|
88
79
|
return p;
|
|
89
|
-
}
|
|
90
|
-
delete_all: () =>
|
|
80
|
+
},
|
|
81
|
+
delete_all: async () => {
|
|
91
82
|
const root = loader.join(loader.root, folder);
|
|
92
83
|
if (loader.exists(root))
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
await loader.rm(root);
|
|
85
|
+
await loader.mkdir(root);
|
|
95
86
|
const arr = get_array(type);
|
|
96
87
|
arr.splice(0, arr.length);
|
|
97
|
-
}
|
|
98
|
-
list_all: () =>
|
|
88
|
+
},
|
|
89
|
+
list_all: async () => {
|
|
99
90
|
const root = loader.join(loader.root, folder);
|
|
100
91
|
if (!loader.exists(root))
|
|
101
|
-
|
|
92
|
+
await loader.mkdir(root);
|
|
102
93
|
return loader.read_dir_file(root);
|
|
103
|
-
}
|
|
104
|
-
save: (name, data) =>
|
|
94
|
+
},
|
|
95
|
+
save: async (name, data) => {
|
|
105
96
|
const root = loader.join(loader.root, folder);
|
|
106
97
|
if (!loader.exists(root))
|
|
107
|
-
|
|
98
|
+
await loader.mkdir(root);
|
|
108
99
|
const file = loader.join(root, name + ext);
|
|
109
|
-
|
|
100
|
+
await loader.write_string(file, data);
|
|
110
101
|
const arr = get_array(type);
|
|
111
102
|
const b = arr.findIndex(x => x.uuid == name);
|
|
112
103
|
if (b != -1)
|
|
113
104
|
arr.push(JSON.parse(data));
|
|
114
105
|
else
|
|
115
106
|
arr[b] = JSON.parse(data);
|
|
116
|
-
}
|
|
117
|
-
load: (name, cache) =>
|
|
107
|
+
},
|
|
108
|
+
load: async (name, cache) => {
|
|
118
109
|
if (cache) {
|
|
119
110
|
const arr = get_array(type);
|
|
120
111
|
const b = arr.findIndex(x => x.uuid == name);
|
|
@@ -123,34 +114,34 @@ const _CreateRecordIOLoader = (loader, memory, type, folder, ext = ".json") => {
|
|
|
123
114
|
}
|
|
124
115
|
const root = loader.join(loader.root, folder);
|
|
125
116
|
if (!loader.exists(root))
|
|
126
|
-
|
|
117
|
+
await loader.mkdir(root);
|
|
127
118
|
const file = loader.join(root, name + ext);
|
|
128
119
|
return loader.read_string(file);
|
|
129
|
-
}
|
|
130
|
-
rename: (name, newname) =>
|
|
120
|
+
},
|
|
121
|
+
rename: async (name, newname) => {
|
|
131
122
|
const root = loader.join(loader.root, folder);
|
|
132
123
|
if (!loader.exists(root))
|
|
133
|
-
|
|
124
|
+
await loader.mkdir(root);
|
|
134
125
|
const oldfile = loader.join(root, name + ext);
|
|
135
126
|
const newfile = loader.join(root, newname + ext);
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
await loader.cp(oldfile, newfile);
|
|
128
|
+
await loader.rm(oldfile);
|
|
138
129
|
const arr = get_array(type);
|
|
139
130
|
const b = arr.findIndex(x => x.uuid == name);
|
|
140
131
|
if (b != -1)
|
|
141
132
|
arr[b].uuid = newname;
|
|
142
|
-
}
|
|
143
|
-
delete: (name) =>
|
|
133
|
+
},
|
|
134
|
+
delete: async (name) => {
|
|
144
135
|
const root = loader.join(loader.root, folder);
|
|
145
136
|
if (!loader.exists(root))
|
|
146
|
-
|
|
137
|
+
await loader.mkdir(root);
|
|
147
138
|
const file = loader.join(root, name + ext);
|
|
148
|
-
|
|
139
|
+
await loader.rm(file);
|
|
149
140
|
const arr = get_array(type);
|
|
150
141
|
const b = arr.findIndex(x => x.uuid == name);
|
|
151
142
|
if (b != -1)
|
|
152
143
|
arr.splice(b, 1);
|
|
153
|
-
}
|
|
144
|
+
}
|
|
154
145
|
};
|
|
155
146
|
};
|
|
156
147
|
exports._CreateRecordIOLoader = _CreateRecordIOLoader;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RecordIOBase } from "./io";
|
|
2
|
+
import { PluginList, PluginPageData, WebsocketPack } from "../interface";
|
|
3
|
+
import { PluginFeedback } from "./server";
|
|
4
|
+
export type SocketGetter = (uuid: string) => WebsocketPack | undefined;
|
|
5
|
+
export interface PluginLoader {
|
|
6
|
+
load_all: () => Promise<PluginPageData>;
|
|
7
|
+
get_project: (group: string, filename: string) => string | undefined;
|
|
8
|
+
get_database: (group: string, filename: string) => string | undefined;
|
|
9
|
+
get_plugin: () => Promise<Array<PluginList>>;
|
|
10
|
+
import_template: (name: string, url: string, token: string) => Promise<PluginPageData>;
|
|
11
|
+
import_plugin: (name: string, url: string, token: string) => Promise<PluginPageData>;
|
|
12
|
+
delete_template: (name: string) => Promise<void>;
|
|
13
|
+
delete_plugin: (name: string) => Promise<void>;
|
|
14
|
+
plugin_download: (uuid: string, plugin: string, tokens: string) => Promise<void>;
|
|
15
|
+
plugin_remove: (uuid: string, plugin: string) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const GetCurrentPlugin: (loader: RecordIOBase) => Promise<PluginPageData>;
|
|
18
|
+
export declare const CreatePluginLoader: (loader: RecordIOBase, memory: PluginPageData, socket: SocketGetter, feedback: PluginFeedback) => PluginLoader;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.CreatePluginLoader = exports.GetCurrentPlugin = void 0;
|
|
13
|
-
const GetCurrentPlugin = (loader) =>
|
|
14
|
-
return new Promise((resolve) =>
|
|
4
|
+
const GetCurrentPlugin = async (loader) => {
|
|
5
|
+
return new Promise(async (resolve) => {
|
|
15
6
|
const b = {
|
|
16
7
|
plugins: [],
|
|
17
8
|
templates: []
|
|
@@ -19,12 +10,12 @@ const GetCurrentPlugin = (loader) => __awaiter(void 0, void 0, void 0, function*
|
|
|
19
10
|
const root = loader.join(loader.root, 'template');
|
|
20
11
|
const root2 = loader.join(loader.root, 'plugin');
|
|
21
12
|
if (!loader.exists(root))
|
|
22
|
-
|
|
13
|
+
await loader.mkdir(root);
|
|
23
14
|
if (!loader.exists(root2))
|
|
24
|
-
|
|
25
|
-
const files = (
|
|
15
|
+
await loader.mkdir(root2);
|
|
16
|
+
const files = (await loader.read_dir_file(root)).filter(x => x.endsWith('.json'));
|
|
26
17
|
const _configs = files.map(file => loader.read_string(loader.join(root, file), { encoding: 'utf-8' }));
|
|
27
|
-
const configs = (
|
|
18
|
+
const configs = (await Promise.all(_configs)).map(x => JSON.parse(x));
|
|
28
19
|
for (let index = 0; index < configs.length; index++) {
|
|
29
20
|
const config = configs[index];
|
|
30
21
|
const ps = config.projects.map(x => ({
|
|
@@ -46,11 +37,11 @@ const GetCurrentPlugin = (loader) => __awaiter(void 0, void 0, void 0, function*
|
|
|
46
37
|
url: config.url
|
|
47
38
|
});
|
|
48
39
|
}
|
|
49
|
-
const files2 = (
|
|
40
|
+
const files2 = (await loader.read_dir_dir(root2)).filter(x => x.endsWith('.json'));
|
|
50
41
|
const p_config2 = files2.map(file => {
|
|
51
42
|
return loader.read_string(loader.join(root2, file), { encoding: 'utf-8' });
|
|
52
43
|
});
|
|
53
|
-
const configs2 = (
|
|
44
|
+
const configs2 = (await Promise.all(p_config2)).map(x => JSON.parse(x));
|
|
54
45
|
for (let index = 0; index < configs2.length; index++) {
|
|
55
46
|
const config = configs2[index];
|
|
56
47
|
config.title = files2[index].replace('.json', '');
|
|
@@ -58,17 +49,17 @@ const GetCurrentPlugin = (loader) => __awaiter(void 0, void 0, void 0, function*
|
|
|
58
49
|
}
|
|
59
50
|
resolve(b);
|
|
60
51
|
return b;
|
|
61
|
-
})
|
|
62
|
-
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
63
54
|
exports.GetCurrentPlugin = GetCurrentPlugin;
|
|
64
55
|
const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
65
56
|
return {
|
|
66
|
-
load_all: () =>
|
|
67
|
-
const cp =
|
|
57
|
+
load_all: async () => {
|
|
58
|
+
const cp = await (0, exports.GetCurrentPlugin)(loader);
|
|
68
59
|
memory.templates = cp.templates;
|
|
69
60
|
memory.plugins = cp.plugins;
|
|
70
61
|
return cp;
|
|
71
|
-
}
|
|
62
|
+
},
|
|
72
63
|
get_project: (group, filename) => {
|
|
73
64
|
let find = false;
|
|
74
65
|
let result = undefined;
|
|
@@ -101,10 +92,10 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
101
92
|
}
|
|
102
93
|
return result;
|
|
103
94
|
},
|
|
104
|
-
get_plugin: () =>
|
|
95
|
+
get_plugin: async () => {
|
|
105
96
|
return memory.plugins;
|
|
106
|
-
}
|
|
107
|
-
import_template: (name, url, token) =>
|
|
97
|
+
},
|
|
98
|
+
import_template: async (name, url, token) => {
|
|
108
99
|
const root = loader.join(loader.root, 'template');
|
|
109
100
|
const error_children = [];
|
|
110
101
|
const tokens = [undefined, ...token.split(' ')];
|
|
@@ -112,7 +103,7 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
112
103
|
const project_folder = loader.join(content_folder, 'project');
|
|
113
104
|
const database_folder = loader.join(content_folder, 'database');
|
|
114
105
|
if (!loader.exists(root))
|
|
115
|
-
|
|
106
|
+
await loader.mkdir(root);
|
|
116
107
|
let req = {};
|
|
117
108
|
let ob = undefined;
|
|
118
109
|
for (let t of tokens) {
|
|
@@ -129,8 +120,8 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
129
120
|
};
|
|
130
121
|
}
|
|
131
122
|
try {
|
|
132
|
-
const res =
|
|
133
|
-
const tex =
|
|
123
|
+
const res = await fetch(url, req);
|
|
124
|
+
const tex = await res.text();
|
|
134
125
|
ob = JSON.parse(tex);
|
|
135
126
|
break;
|
|
136
127
|
}
|
|
@@ -163,9 +154,9 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
163
154
|
ob.projects.forEach((p) => {
|
|
164
155
|
project_calls.push(fetch(folder + "/" + p.filename + '.json', req));
|
|
165
156
|
});
|
|
166
|
-
const pss =
|
|
157
|
+
const pss = await Promise.all(project_calls);
|
|
167
158
|
const project_calls2 = pss.map(x => x.text());
|
|
168
|
-
const pss_result =
|
|
159
|
+
const pss_result = await Promise.all(project_calls2);
|
|
169
160
|
pss_result.forEach((text, index) => {
|
|
170
161
|
const n = ob.projects[index].filename + '.json';
|
|
171
162
|
try {
|
|
@@ -180,9 +171,9 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
180
171
|
ob.databases.forEach((p) => {
|
|
181
172
|
database_calls.push(fetch(folder + "/" + p.filename + '.json', req));
|
|
182
173
|
});
|
|
183
|
-
const pss2 =
|
|
174
|
+
const pss2 = await Promise.all(database_calls);
|
|
184
175
|
const database_calls2 = pss2.map(x => x.text());
|
|
185
|
-
const pss_result2 =
|
|
176
|
+
const pss_result2 = await Promise.all(database_calls2);
|
|
186
177
|
pss_result2.forEach((text, index) => {
|
|
187
178
|
const n = ob.databases[index].filename + '.json';
|
|
188
179
|
try {
|
|
@@ -205,16 +196,16 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
205
196
|
}
|
|
206
197
|
return memory;
|
|
207
198
|
}
|
|
208
|
-
const cp =
|
|
199
|
+
const cp = await (0, exports.GetCurrentPlugin)(loader);
|
|
209
200
|
memory.templates = cp.templates;
|
|
210
201
|
memory.plugins = cp.plugins;
|
|
211
202
|
return cp;
|
|
212
|
-
}
|
|
213
|
-
import_plugin: (name, url, token) =>
|
|
203
|
+
},
|
|
204
|
+
import_plugin: async (name, url, token) => {
|
|
214
205
|
const root = loader.join(loader.root, 'plugin');
|
|
215
206
|
const tokens = [undefined, ...token.split(' ')];
|
|
216
207
|
if (!loader.exists(root))
|
|
217
|
-
|
|
208
|
+
await loader.mkdir(root);
|
|
218
209
|
let req = {};
|
|
219
210
|
let ob = undefined;
|
|
220
211
|
for (let t of tokens) {
|
|
@@ -232,8 +223,8 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
232
223
|
}
|
|
233
224
|
let tex = "";
|
|
234
225
|
try {
|
|
235
|
-
const res =
|
|
236
|
-
tex =
|
|
226
|
+
const res = await fetch(url, req);
|
|
227
|
+
tex = await res.text();
|
|
237
228
|
ob = JSON.parse(tex);
|
|
238
229
|
console.log("Fetch plugin json successfully");
|
|
239
230
|
break;
|
|
@@ -255,36 +246,36 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
255
246
|
}
|
|
256
247
|
ob.url = url;
|
|
257
248
|
loader.write_string(loader.join(root, name + '.json'), JSON.stringify(ob, null, 4));
|
|
258
|
-
const cp =
|
|
249
|
+
const cp = await (0, exports.GetCurrentPlugin)(loader);
|
|
259
250
|
memory.templates = cp.templates;
|
|
260
251
|
memory.plugins = cp.plugins;
|
|
261
252
|
return cp;
|
|
262
|
-
}
|
|
263
|
-
delete_template: (name) =>
|
|
253
|
+
},
|
|
254
|
+
delete_template: async (name) => {
|
|
264
255
|
const root = loader.join(loader.root, 'template');
|
|
265
256
|
if (loader.exists(loader.join(root, name + '.json')))
|
|
266
|
-
|
|
257
|
+
await loader.rm(loader.join(root, name + '.json'));
|
|
267
258
|
if (loader.exists(loader.join(root, name)))
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
delete_plugin: (name) =>
|
|
259
|
+
await loader.rm(loader.join(root, name));
|
|
260
|
+
},
|
|
261
|
+
delete_plugin: async (name) => {
|
|
271
262
|
const root = loader.join(loader.root, 'plugin');
|
|
272
263
|
if (loader.exists(loader.join(root, name + '.json')))
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
plugin_download: (uuid, plugin, tokens) =>
|
|
264
|
+
await loader.rm(loader.join(root, name + '.json'));
|
|
265
|
+
},
|
|
266
|
+
plugin_download: async (uuid, plugin, tokens) => {
|
|
276
267
|
const p = JSON.parse(plugin);
|
|
277
|
-
const p2 =
|
|
268
|
+
const p2 = { ...p, token: tokens.split(' ') };
|
|
278
269
|
const t = socket(uuid);
|
|
279
270
|
const h = { name: 'plugin_download', data: p2 };
|
|
280
|
-
t
|
|
281
|
-
}
|
|
282
|
-
plugin_remove: (uuid, plugin) =>
|
|
271
|
+
t?.websocket.send(JSON.stringify(h));
|
|
272
|
+
},
|
|
273
|
+
plugin_remove: async (uuid, plugin) => {
|
|
283
274
|
const p = JSON.parse(plugin);
|
|
284
275
|
const t = socket(uuid);
|
|
285
276
|
const h = { name: 'plugin_remove', data: p };
|
|
286
|
-
t
|
|
287
|
-
}
|
|
277
|
+
t?.websocket.send(JSON.stringify(h));
|
|
278
|
+
},
|
|
288
279
|
};
|
|
289
280
|
};
|
|
290
281
|
exports.CreatePluginLoader = CreatePluginLoader;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Execute_ConsoleServerManager, PluginPageData } from "../interface";
|
|
2
|
+
import { ServerDetail } from "./detail";
|
|
3
|
+
import { MemoryData, RecordIOBase, RecordLoader } from "./io";
|
|
4
|
+
import { PluginLoader } from "./plugin";
|
|
5
|
+
export type Caller_Electron = (channel: string, ...args: any[]) => void;
|
|
6
|
+
export type Caller_Socket = (data: any) => void;
|
|
7
|
+
export type TypeMap = {
|
|
8
|
+
[key: string]: Function;
|
|
9
|
+
};
|
|
10
|
+
export interface PluginFeedback {
|
|
11
|
+
electron: Caller_Electron | undefined;
|
|
12
|
+
socket: Caller_Socket | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class Server {
|
|
15
|
+
manager: Array<Execute_ConsoleServerManager.ConsoleServerManager>;
|
|
16
|
+
memory: MemoryData;
|
|
17
|
+
plugin: PluginPageData;
|
|
18
|
+
io: RecordIOBase | undefined;
|
|
19
|
+
loader: RecordLoader | undefined;
|
|
20
|
+
plugin_loader: PluginLoader | undefined;
|
|
21
|
+
memory_loader: RecordLoader;
|
|
22
|
+
detail: ServerDetail | undefined;
|
|
23
|
+
constructor();
|
|
24
|
+
get current_loader(): RecordLoader;
|
|
25
|
+
LoadFromDisk: () => Promise<Array<Array<string>>>;
|
|
26
|
+
Boradcasting: (name: string, data: any) => void;
|
|
27
|
+
}
|
|
@@ -3,43 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Server = void 0;
|
|
4
4
|
const io_1 = require("./io");
|
|
5
5
|
class Server {
|
|
6
|
+
manager = [];
|
|
7
|
+
memory = {
|
|
8
|
+
projects: [],
|
|
9
|
+
database: [],
|
|
10
|
+
nodes: [],
|
|
11
|
+
logs: [],
|
|
12
|
+
libs: [],
|
|
13
|
+
user: [],
|
|
14
|
+
};
|
|
15
|
+
plugin = {
|
|
16
|
+
templates: [],
|
|
17
|
+
plugins: [],
|
|
18
|
+
};
|
|
19
|
+
io = undefined;
|
|
20
|
+
loader = undefined;
|
|
21
|
+
plugin_loader = undefined;
|
|
22
|
+
memory_loader;
|
|
23
|
+
detail;
|
|
6
24
|
constructor() {
|
|
7
|
-
this.manager = [];
|
|
8
|
-
this.memory = {
|
|
9
|
-
projects: [],
|
|
10
|
-
database: [],
|
|
11
|
-
nodes: [],
|
|
12
|
-
logs: [],
|
|
13
|
-
libs: [],
|
|
14
|
-
user: [],
|
|
15
|
-
};
|
|
16
|
-
this.plugin = {
|
|
17
|
-
templates: [],
|
|
18
|
-
plugins: [],
|
|
19
|
-
};
|
|
20
|
-
this.io = undefined;
|
|
21
|
-
this.loader = undefined;
|
|
22
|
-
this.plugin_loader = undefined;
|
|
23
|
-
this.LoadFromDisk = () => {
|
|
24
|
-
const ts = [
|
|
25
|
-
this.current_loader.project.load_all(),
|
|
26
|
-
this.current_loader.database.load_all(),
|
|
27
|
-
this.current_loader.node.load_all(),
|
|
28
|
-
this.current_loader.log.load_all(),
|
|
29
|
-
this.current_loader.lib.load_all(),
|
|
30
|
-
this.current_loader.user.load_all(),
|
|
31
|
-
];
|
|
32
|
-
return Promise.all(ts);
|
|
33
|
-
};
|
|
34
|
-
this.Boradcasting = (name, data) => {
|
|
35
|
-
const d = {
|
|
36
|
-
name: name,
|
|
37
|
-
data: data
|
|
38
|
-
};
|
|
39
|
-
this.manager.forEach(x => {
|
|
40
|
-
x.ws.send(JSON.stringify(d));
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
25
|
this.memory_loader = (0, io_1.CreateRecordMemoryLoader)(this.memory);
|
|
44
26
|
}
|
|
45
27
|
get current_loader() {
|
|
@@ -47,5 +29,25 @@ class Server {
|
|
|
47
29
|
return this.loader;
|
|
48
30
|
return this.memory_loader;
|
|
49
31
|
}
|
|
32
|
+
LoadFromDisk = () => {
|
|
33
|
+
const ts = [
|
|
34
|
+
this.current_loader.project.load_all(),
|
|
35
|
+
this.current_loader.database.load_all(),
|
|
36
|
+
this.current_loader.node.load_all(),
|
|
37
|
+
this.current_loader.log.load_all(),
|
|
38
|
+
this.current_loader.lib.load_all(),
|
|
39
|
+
this.current_loader.user.load_all(),
|
|
40
|
+
];
|
|
41
|
+
return Promise.all(ts);
|
|
42
|
+
};
|
|
43
|
+
Boradcasting = (name, data) => {
|
|
44
|
+
const d = {
|
|
45
|
+
name: name,
|
|
46
|
+
data: data
|
|
47
|
+
};
|
|
48
|
+
this.manager.forEach(x => {
|
|
49
|
+
x.ws.send(JSON.stringify(d));
|
|
50
|
+
});
|
|
51
|
+
};
|
|
50
52
|
}
|
|
51
53
|
exports.Server = Server;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecutePair, ExecuteProxy, ExecuteState, FeedBack, Job, Database, Project, Record, Task } from "../interface";
|
|
2
|
+
export declare class Util_Server_Console {
|
|
3
|
+
receivedPack: (model: ExecutePair, record: Record) => boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class Util_Server_Console_Proxy {
|
|
6
|
+
model: ExecutePair;
|
|
7
|
+
constructor(_model: ExecutePair);
|
|
8
|
+
get execute_proxy(): ExecuteProxy;
|
|
9
|
+
execute_project_start: (d: [Project, number]) => void;
|
|
10
|
+
execute_project_finish: (d: [Project, number]) => void;
|
|
11
|
+
execute_task_start: (d: [Task, number]) => void;
|
|
12
|
+
execute_task_finish: (d: Task) => void;
|
|
13
|
+
execute_subtask_start: (d: [Task, number, string]) => void;
|
|
14
|
+
execute_subtask_update: (d: [Task, number, string, ExecuteState]) => void;
|
|
15
|
+
execute_subtask_end: (d: [Task, number, string]) => void;
|
|
16
|
+
execute_job_start: (d: [Job, number, string]) => void;
|
|
17
|
+
execute_job_finish: (d: [Job, number, string, number]) => void;
|
|
18
|
+
feedback_message: (d: FeedBack) => void;
|
|
19
|
+
update_runtime_database: (d: Database) => void;
|
|
20
|
+
}
|