verteilen-core 1.2.4 → 1.2.7
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/client/analysis.d.ts +35 -0
- package/dist/client/analysis.js +382 -0
- package/dist/client/client.d.ts +25 -0
- package/dist/client/client.js +227 -0
- package/dist/client/cluster.d.ts +1 -0
- package/dist/{src/client → client}/cluster.js +1 -2
- package/dist/client/database.d.ts +13 -0
- package/dist/client/database.js +37 -0
- package/dist/client/execute.d.ts +24 -0
- package/dist/{src/client → client}/execute.js +61 -51
- package/dist/client/http.d.ts +7 -0
- package/dist/client/http.js +40 -0
- package/dist/client/javascript.d.ts +47 -0
- package/dist/{src/client → client}/javascript.js +110 -136
- package/dist/client/job_database.d.ts +10 -0
- package/dist/client/job_database.js +34 -0
- package/dist/client/job_execute.d.ts +20 -0
- package/dist/client/job_execute.js +173 -0
- package/dist/client/os.d.ts +29 -0
- package/dist/client/os.js +197 -0
- package/dist/client/resource.d.ts +7 -0
- package/dist/client/resource.js +107 -0
- package/dist/client/shell.d.ts +16 -0
- package/dist/client/shell.js +122 -0
- package/dist/computed.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/interface/base.d.ts +70 -0
- package/dist/interface/bus.d.ts +90 -0
- package/dist/interface/enum.d.ts +143 -0
- package/dist/interface/execute.d.ts +20 -0
- package/dist/interface/record.d.ts +93 -0
- package/dist/interface/server.d.ts +76 -0
- package/dist/interface/struct.d.ts +182 -0
- package/dist/interface/table.d.ts +20 -0
- package/dist/interface/ui.d.ts +29 -0
- package/dist/interface.d.ts +29 -0
- package/dist/plugins/i18n.d.ts +1666 -0
- package/dist/script/console_manager.d.ts +18 -0
- package/dist/script/console_manager.js +131 -0
- package/dist/script/console_server_manager.d.ts +13 -0
- package/dist/script/console_server_manager.js +40 -0
- package/dist/script/execute/base.d.ts +45 -0
- package/dist/script/execute/base.js +200 -0
- package/dist/script/execute/feedback.d.ts +12 -0
- package/dist/script/execute/feedback.js +179 -0
- package/dist/script/execute/interface.d.ts +8 -0
- package/dist/script/execute/region_job.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_job.js +1 -0
- package/dist/script/execute/region_project.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_project.js +4 -0
- package/dist/script/execute/region_subtask.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_subtask.js +1 -0
- package/dist/script/execute/region_task.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_task.js +4 -0
- package/dist/script/execute/runner.d.ts +14 -0
- package/dist/script/execute/runner.js +264 -0
- package/dist/script/execute/util_parser.d.ts +14 -0
- package/dist/script/execute/util_parser.js +135 -0
- package/dist/script/execute_manager.d.ts +25 -0
- package/dist/script/execute_manager.js +297 -0
- package/dist/script/socket_manager.d.ts +31 -0
- package/dist/script/socket_manager.js +263 -0
- package/dist/script/webhook_manager.d.ts +3 -0
- package/dist/script/webhook_server_manager.d.ts +13 -0
- package/dist/script/webhook_server_manager.js +133 -0
- package/dist/server/detail.d.ts +72 -0
- package/dist/server/detail.js +451 -0
- package/dist/server/io.d.ts +46 -0
- package/dist/{src/server → server}/io.js +42 -51
- package/dist/server/plugin.d.ts +18 -0
- package/dist/{src/server → server}/plugin.js +45 -54
- package/dist/server/server.d.ts +27 -0
- package/dist/server/server.js +53 -0
- package/dist/server.d.ts +4 -0
- package/dist/util/console_handle.d.ts +20 -0
- package/dist/util/console_handle.js +244 -0
- package/dist/util/log_handle.d.ts +23 -0
- package/dist/util/log_handle.js +224 -0
- package/index.ts +1 -6
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/test/TEST.d.ts +1 -0
- package/test/TEST.js +88 -0
- package/test/client/execute.test.d.ts +1 -0
- package/{dist/test → test}/client/execute.test.js +6 -15
- package/test/client/javascript.test.d.ts +1 -0
- package/{dist/test → test}/client/javascript.test.js +21 -30
- package/test/client/server.test.d.ts +1 -0
- package/test/client/task.test.d.ts +1 -0
- package/{dist/test → test}/client/task.test.js +1 -1
- package/test/script/parser.test.d.ts +1 -0
- package/test/script/socket.test.d.ts +1 -0
- package/tsconfig.json +8 -4
- package/dist/jest.config.js +0 -8
- package/dist/src/client/analysis.js +0 -383
- package/dist/src/client/client.js +0 -233
- package/dist/src/client/database.js +0 -36
- package/dist/src/client/http.js +0 -37
- package/dist/src/client/job_database.js +0 -36
- package/dist/src/client/job_execute.js +0 -171
- package/dist/src/client/job_parameter.js +0 -36
- package/dist/src/client/os.js +0 -202
- package/dist/src/client/parameter.js +0 -36
- package/dist/src/client/resource.js +0 -118
- package/dist/src/client/shell.js +0 -118
- package/dist/src/script/console_manager.js +0 -125
- package/dist/src/script/console_server_manager.js +0 -37
- package/dist/src/script/execute/base.js +0 -197
- package/dist/src/script/execute/feedback.js +0 -188
- package/dist/src/script/execute/runner.js +0 -274
- package/dist/src/script/execute/util_parser.js +0 -137
- package/dist/src/script/execute_manager.js +0 -309
- package/dist/src/script/socket_manager.js +0 -260
- package/dist/src/script/webhook_server_manager.js +0 -140
- package/dist/src/server/detail.js +0 -428
- package/dist/src/server/server.js +0 -51
- package/dist/src/util/console_handle.js +0 -248
- package/dist/src/util/log_handle.js +0 -230
- package/dist/src/util/server/console_handle.js +0 -248
- package/dist/src/util/server/log_handle.js +0 -230
- package/dist/test/TEST.js +0 -105
- /package/dist/{src/computed.js → computed.js} +0 -0
- /package/dist/{src/interface → interface}/base.js +0 -0
- /package/dist/{src/interface → interface}/bus.js +0 -0
- /package/dist/{src/interface → interface}/enum.js +0 -0
- /package/dist/{src/interface → interface}/execute.js +0 -0
- /package/dist/{src/interface → interface}/record.js +0 -0
- /package/dist/{src/interface → interface}/server.js +0 -0
- /package/dist/{src/interface → interface}/struct.js +0 -0
- /package/dist/{src/interface → interface}/table.js +0 -0
- /package/dist/{src/interface → interface}/ui.js +0 -0
- /package/dist/{src/interface.js → interface.js} +0 -0
- /package/dist/{src/lan → lan}/en.json +0 -0
- /package/dist/{src/lan → lan}/zh_TW.json +0 -0
- /package/dist/{src/plugins → plugins}/i18n.js +0 -0
- /package/dist/{src/script → script}/execute/interface.js +0 -0
- /package/dist/{src/script → script}/webhook_manager.js +0 -0
- /package/dist/{src/server.js → server.js} +0 -0
- /package/{dist/test → test}/client/server.test.js +0 -0
- /package/{dist/test → test}/script/parser.test.js +0 -0
- /package/{dist/test → test}/script/socket.test.js +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ClientOS = void 0;
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const tree_kill_1 = __importDefault(require("tree-kill"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const interface_1 = require("../interface");
|
|
46
|
+
class ClientOS {
|
|
47
|
+
messager;
|
|
48
|
+
messager_log;
|
|
49
|
+
tag;
|
|
50
|
+
runtime;
|
|
51
|
+
children = [];
|
|
52
|
+
constructor(_tag, _runtime, _messager, _messager_log) {
|
|
53
|
+
this.tag = _tag;
|
|
54
|
+
this.runtime = _runtime;
|
|
55
|
+
this.messager = _messager;
|
|
56
|
+
this.messager_log = _messager_log;
|
|
57
|
+
}
|
|
58
|
+
file_copy = (data) => {
|
|
59
|
+
this.messager(`[OS Action] File copy, ${data.from} => ${data.to}`, this.tag());
|
|
60
|
+
fs.copyFileSync(data.from, data.to);
|
|
61
|
+
};
|
|
62
|
+
dir_copy = (data) => {
|
|
63
|
+
this.messager(`[OS Action] Folder copy, ${data.from} => ${data.to}`, this.tag());
|
|
64
|
+
fs.cpSync(data.from, data.to, { recursive: true, force: true });
|
|
65
|
+
};
|
|
66
|
+
file_delete = (data) => {
|
|
67
|
+
this.messager(`[OS Action] File delete, ${data.path}`, this.tag());
|
|
68
|
+
fs.rmSync(data.path);
|
|
69
|
+
};
|
|
70
|
+
dir_delete = (data) => {
|
|
71
|
+
this.messager(`[OS Action] Folder delete, ${data.path}`, this.tag());
|
|
72
|
+
fs.rmSync(data.path, { recursive: true, force: true });
|
|
73
|
+
};
|
|
74
|
+
rename = (data) => {
|
|
75
|
+
this.messager(`[OS Action] File or dir rename, ${data.from} => ${data.to}`, this.tag());
|
|
76
|
+
fs.renameSync(data.from, data.to);
|
|
77
|
+
};
|
|
78
|
+
fs_exist = (data) => {
|
|
79
|
+
const v = fs.existsSync(data.path);
|
|
80
|
+
this.messager(`[OS Action] Check path exists, ${data.path}`, this.tag());
|
|
81
|
+
return v;
|
|
82
|
+
};
|
|
83
|
+
fs_dir_exist = (data) => {
|
|
84
|
+
const p = this.fs_exist(data);
|
|
85
|
+
if (!p)
|
|
86
|
+
return false;
|
|
87
|
+
const stat = fs.statSync(data.path);
|
|
88
|
+
return stat.isDirectory();
|
|
89
|
+
};
|
|
90
|
+
fs_file_exist = (data) => {
|
|
91
|
+
const p = this.fs_exist(data);
|
|
92
|
+
if (!p)
|
|
93
|
+
return false;
|
|
94
|
+
const stat = fs.statSync(data.path);
|
|
95
|
+
return stat.isFile();
|
|
96
|
+
};
|
|
97
|
+
dir_files = (data) => {
|
|
98
|
+
const r = fs.readdirSync(data.path, { withFileTypes: true }).filter(x => x.isFile()).map(x => x.name);
|
|
99
|
+
return r;
|
|
100
|
+
};
|
|
101
|
+
dir_dirs = (data) => {
|
|
102
|
+
const r = fs.readdirSync(data.path, { withFileTypes: true }).filter(x => x.isDirectory()).map(x => x.name);
|
|
103
|
+
return r;
|
|
104
|
+
};
|
|
105
|
+
dir_create = (data) => {
|
|
106
|
+
this.messager(`[OS Action] Create folder, ${data.path}`, this.tag());
|
|
107
|
+
fs.mkdirSync(data.path, { recursive: true });
|
|
108
|
+
};
|
|
109
|
+
file_write = (data) => {
|
|
110
|
+
this.messager(`[OS Action] Create file, ${data.from}`, this.tag());
|
|
111
|
+
fs.writeFileSync(data.from, data.to);
|
|
112
|
+
};
|
|
113
|
+
file_read = (data) => {
|
|
114
|
+
return fs.readFileSync(data.path).toString();
|
|
115
|
+
};
|
|
116
|
+
stopall = () => {
|
|
117
|
+
this.children.forEach(x => {
|
|
118
|
+
x.stdin.write('q');
|
|
119
|
+
x.stdin.end();
|
|
120
|
+
(0, tree_kill_1.default)(x.pid, 'SIGKILL');
|
|
121
|
+
});
|
|
122
|
+
this.children = [];
|
|
123
|
+
};
|
|
124
|
+
lib_command = async (command, args) => {
|
|
125
|
+
const cc = process.platform == "win32" ? command : "./" + command;
|
|
126
|
+
return this.command(cc, args, path.join(os.homedir(), interface_1.DATA_FOLDER, "exe"));
|
|
127
|
+
};
|
|
128
|
+
command = async (command, args, cwd) => {
|
|
129
|
+
this.messager_log(`[OS Action] Command cwd: ${cwd}`, this.tag());
|
|
130
|
+
this.messager_log(`[OS Action] Command command: ${command}`, this.tag());
|
|
131
|
+
this.messager_log(`[OS Action] Command args: ${args}`, this.tag());
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
const child = (0, child_process_1.spawn)(command, args.split(' '), {
|
|
134
|
+
cwd: cwd,
|
|
135
|
+
shell: true,
|
|
136
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
137
|
+
});
|
|
138
|
+
child.stdin.setDefaultEncoding('utf8');
|
|
139
|
+
child.on('spawn', () => {
|
|
140
|
+
this.children.push(child);
|
|
141
|
+
this.messager_log(`[Command] Spawn process`, this.tag());
|
|
142
|
+
});
|
|
143
|
+
child.on('error', (err) => {
|
|
144
|
+
this.messager_log(`[Command] Error: ${err}`, this.tag());
|
|
145
|
+
reject(`Error ${err}`);
|
|
146
|
+
});
|
|
147
|
+
child.on('exit', (code, signal) => {
|
|
148
|
+
this.messager_log(`[Command] Process Exit: ${code}`, this.tag());
|
|
149
|
+
});
|
|
150
|
+
child.on('message', (message, sendHandle) => {
|
|
151
|
+
this.messager_log(`[Command] : ${message.toString()}`, this.tag());
|
|
152
|
+
});
|
|
153
|
+
child.on('close', (code, signal) => {
|
|
154
|
+
this.messager_log(`[Command] Process Close: ${code}`, this.tag());
|
|
155
|
+
const index = this.children.findIndex(x => x.pid == child.pid);
|
|
156
|
+
if (index != -1)
|
|
157
|
+
this.children.splice(index, 1);
|
|
158
|
+
resolve(`Successfully ${code}`);
|
|
159
|
+
});
|
|
160
|
+
child.stdout.setEncoding('utf8');
|
|
161
|
+
child.stdout.on('data', (chunk) => {
|
|
162
|
+
this.messager_log(`[Command Info] : ${chunk.toString()}`, this.tag());
|
|
163
|
+
});
|
|
164
|
+
child.stderr.setEncoding('utf8');
|
|
165
|
+
child.stderr.on('data', (chunk) => {
|
|
166
|
+
this.messager_log(`[Command Error] : ${chunk.toString()}`, this.tag());
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
command_sync = async (command, args, cwd) => {
|
|
171
|
+
return this.command(command, args, cwd);
|
|
172
|
+
};
|
|
173
|
+
command_exec = (command, args, cwd) => {
|
|
174
|
+
this.messager_log(`[OS Action] Command cwd: ${cwd}`, this.tag());
|
|
175
|
+
this.messager_log(`[OS Action] Command command: ${command}`, this.tag());
|
|
176
|
+
this.messager_log(`[OS Action] Command args: ${args}`, this.tag());
|
|
177
|
+
const child = (0, child_process_1.exec)(`${command} ${args}`, {
|
|
178
|
+
cwd: cwd
|
|
179
|
+
});
|
|
180
|
+
child.on('spawn', () => {
|
|
181
|
+
this.messager_log(`[Command] Spawn process`, this.tag());
|
|
182
|
+
});
|
|
183
|
+
child.on('error', (err) => {
|
|
184
|
+
this.messager_log(`[Command] Error: ${err}`, this.tag());
|
|
185
|
+
});
|
|
186
|
+
child.on('exit', (code, signal) => {
|
|
187
|
+
this.messager_log(`[Command] Process Exit: ${code}`, this.tag());
|
|
188
|
+
});
|
|
189
|
+
child.on('message', (message, sendHandle) => {
|
|
190
|
+
this.messager_log(`[Command] : ${message.toString()}`, this.tag());
|
|
191
|
+
});
|
|
192
|
+
child.on('close', (code, signal) => {
|
|
193
|
+
this.messager_log(`[Command] Process Close: ${code}`, this.tag());
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
exports.ClientOS = ClientOS;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ResourceType } from "../interface";
|
|
2
|
+
import { SystemLoad } from "../interface/struct";
|
|
3
|
+
export declare class ClientResource {
|
|
4
|
+
is_query: boolean;
|
|
5
|
+
Query: (src?: SystemLoad | undefined, type?: ResourceType) => Promise<SystemLoad>;
|
|
6
|
+
private create_new;
|
|
7
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClientResource = void 0;
|
|
7
|
+
const systeminformation_1 = __importDefault(require("systeminformation"));
|
|
8
|
+
const interface_1 = require("../interface");
|
|
9
|
+
class ClientResource {
|
|
10
|
+
is_query = false;
|
|
11
|
+
Query = async (src = undefined, type = interface_1.ResourceType.ALL) => {
|
|
12
|
+
this.is_query = true;
|
|
13
|
+
const result = src != undefined ? src : this.create_new();
|
|
14
|
+
const _system = (type & interface_1.ResourceType.SYSTEM) == interface_1.ResourceType.SYSTEM ? systeminformation_1.default.system() : undefined;
|
|
15
|
+
const _cpu = systeminformation_1.default.cpu();
|
|
16
|
+
const _ram = systeminformation_1.default.mem();
|
|
17
|
+
const _battery = systeminformation_1.default.battery();
|
|
18
|
+
const _load = systeminformation_1.default.currentLoad();
|
|
19
|
+
const _os = systeminformation_1.default.osInfo();
|
|
20
|
+
const _gpu = systeminformation_1.default.graphics();
|
|
21
|
+
const _disk = systeminformation_1.default.fsSize();
|
|
22
|
+
const _net = systeminformation_1.default.networkStats();
|
|
23
|
+
this.is_query = false;
|
|
24
|
+
return await Promise.all([_system, _cpu, _ram, _battery, _load, _os, _gpu, _disk, _net]).then(x => {
|
|
25
|
+
const system = x[0];
|
|
26
|
+
const cpu = x[1];
|
|
27
|
+
const ram = x[2];
|
|
28
|
+
const battery = x[3];
|
|
29
|
+
const load = x[4];
|
|
30
|
+
const os = x[5];
|
|
31
|
+
const gpu = x[6];
|
|
32
|
+
const disk = x[7];
|
|
33
|
+
const net = x[8];
|
|
34
|
+
if (system != undefined) {
|
|
35
|
+
result.system_name = `${system.manufacturer} ${system.model}`;
|
|
36
|
+
result.virtual = system.virtual;
|
|
37
|
+
}
|
|
38
|
+
if (os != undefined) {
|
|
39
|
+
result.platform = process.platform;
|
|
40
|
+
result.arch = process.arch;
|
|
41
|
+
result.hostname = os.hostname;
|
|
42
|
+
}
|
|
43
|
+
if (cpu != undefined) {
|
|
44
|
+
result.cpu_name = `${cpu.manufacturer} ${cpu.brand} ${cpu.speed}`;
|
|
45
|
+
result.cpu_core = cpu.cores;
|
|
46
|
+
}
|
|
47
|
+
if (load != undefined) {
|
|
48
|
+
result.cpu_usage = load.currentLoadGuest + load.currentLoadIrq + load.currentLoadSystem + load.currentLoad + load.currentLoadSteal + load.currentLoadNice;
|
|
49
|
+
}
|
|
50
|
+
if (ram != undefined) {
|
|
51
|
+
result.ram_usage = ram.used;
|
|
52
|
+
result.ram_free = ram.free;
|
|
53
|
+
result.ram_total = ram.total;
|
|
54
|
+
}
|
|
55
|
+
if (battery != undefined) {
|
|
56
|
+
result.battery = battery.hasBattery ? battery.percent : 1;
|
|
57
|
+
result.charging = battery.isCharging;
|
|
58
|
+
}
|
|
59
|
+
if (gpu != undefined) {
|
|
60
|
+
result.gpu = gpu.controllers.map(x => ({
|
|
61
|
+
gpu_name: `${x.vendor} ${x.model}`
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
if (disk != undefined) {
|
|
65
|
+
result.disk = disk.map(x => ({
|
|
66
|
+
disk_name: x.fs,
|
|
67
|
+
disk_type: x.type,
|
|
68
|
+
disk_free: x.available,
|
|
69
|
+
disk_total: x.size,
|
|
70
|
+
disk_usage: x.used,
|
|
71
|
+
disk_percentage: x.use,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
if (net != undefined) {
|
|
75
|
+
result.net = net.map(x => ({
|
|
76
|
+
net_name: x.iface,
|
|
77
|
+
download: x.rx_sec,
|
|
78
|
+
upload: x.tx_sec
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
result.pid_usage = process.pid;
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
create_new = () => {
|
|
86
|
+
return {
|
|
87
|
+
system_name: '',
|
|
88
|
+
virtual: false,
|
|
89
|
+
platform: '',
|
|
90
|
+
arch: '',
|
|
91
|
+
hostname: '',
|
|
92
|
+
cpu_name: '',
|
|
93
|
+
cpu_core: 0,
|
|
94
|
+
cpu_usage: 0,
|
|
95
|
+
ram_usage: 0,
|
|
96
|
+
ram_free: 0,
|
|
97
|
+
ram_total: 0,
|
|
98
|
+
battery: 0,
|
|
99
|
+
charging: false,
|
|
100
|
+
gpu: [],
|
|
101
|
+
disk: [],
|
|
102
|
+
net: [],
|
|
103
|
+
pid_usage: 0
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
exports.ClientResource = ClientResource;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { Messager } from "../interface";
|
|
3
|
+
import { Client } from "./client";
|
|
4
|
+
export declare class ClientShell {
|
|
5
|
+
private messager;
|
|
6
|
+
private messager_log;
|
|
7
|
+
private os;
|
|
8
|
+
private shell_workers;
|
|
9
|
+
constructor(_messager: Messager, _messager_log: Messager, _client: Client);
|
|
10
|
+
open_shell: (data: number, source: WebSocket) => void;
|
|
11
|
+
enter_shell: (input: string, source: WebSocket) => void;
|
|
12
|
+
close_shell: (data: number, source: WebSocket) => void;
|
|
13
|
+
close_shell_all: (data: number) => void;
|
|
14
|
+
shell_folder: (data: string, source: WebSocket) => void;
|
|
15
|
+
disconnect: (source: WebSocket) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientShell = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const os_1 = require("./os");
|
|
6
|
+
class ClientShell {
|
|
7
|
+
messager;
|
|
8
|
+
messager_log;
|
|
9
|
+
os;
|
|
10
|
+
shell_workers = [];
|
|
11
|
+
constructor(_messager, _messager_log, _client) {
|
|
12
|
+
this.os = new os_1.ClientOS(() => "SHELL", () => "", _messager, _messager_log);
|
|
13
|
+
this.messager = _messager;
|
|
14
|
+
this.messager_log = _messager_log;
|
|
15
|
+
}
|
|
16
|
+
open_shell = (data, source) => {
|
|
17
|
+
if (this.shell_workers.find(x => x[0] == source)) {
|
|
18
|
+
this.messager_log(`[Shell] Error the source already open the shell`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const program = process.platform === "win32" ? 'cmd' : 'bash';
|
|
22
|
+
const child = (0, child_process_1.spawn)(program, [], {
|
|
23
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
24
|
+
shell: true,
|
|
25
|
+
windowsHide: true,
|
|
26
|
+
env: {
|
|
27
|
+
...process.env,
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
this.shell_workers.push([source, child]);
|
|
31
|
+
let t = "";
|
|
32
|
+
const workerFeedback = (str) => {
|
|
33
|
+
for (let i = 0; i < str.length; i++) {
|
|
34
|
+
if (str[i] == '\n') {
|
|
35
|
+
const data = {
|
|
36
|
+
data: t
|
|
37
|
+
};
|
|
38
|
+
const d = {
|
|
39
|
+
name: "shell_reply",
|
|
40
|
+
data: data
|
|
41
|
+
};
|
|
42
|
+
source.send(JSON.stringify(d));
|
|
43
|
+
t = "";
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
t += str[i];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
child.on('exit', (code, signal) => {
|
|
51
|
+
const index = this.shell_workers.findIndex(x => x[0] == source);
|
|
52
|
+
if (index != -1)
|
|
53
|
+
this.shell_workers.splice(index, 1);
|
|
54
|
+
});
|
|
55
|
+
child.on('message', (message, sendHandle) => {
|
|
56
|
+
workerFeedback(message.toString());
|
|
57
|
+
});
|
|
58
|
+
child.stdout.setEncoding('utf8');
|
|
59
|
+
child.stdout.on('data', (chunk) => {
|
|
60
|
+
workerFeedback(chunk.toString());
|
|
61
|
+
});
|
|
62
|
+
child.stderr.setEncoding('utf8');
|
|
63
|
+
child.stderr.on('data', (chunk) => {
|
|
64
|
+
workerFeedback(chunk.toString());
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
enter_shell = (input, source) => {
|
|
68
|
+
const p = this.shell_workers.find(x => x[0] == source);
|
|
69
|
+
if (p == undefined) {
|
|
70
|
+
this.messager_log(`[Shell] Cannot find shell instance`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
p[1].stdin?.write(input + '\n');
|
|
74
|
+
if (process.platform == 'win32')
|
|
75
|
+
p[1].stdin?.write("echo %cd%" + '\n');
|
|
76
|
+
else
|
|
77
|
+
p[1].stdin?.write("pwd" + '\n');
|
|
78
|
+
};
|
|
79
|
+
close_shell = (data, source) => {
|
|
80
|
+
const p = this.shell_workers.find(x => x[0] == source);
|
|
81
|
+
if (p == undefined) {
|
|
82
|
+
this.messager_log(`[Shell] Cannot find shell instance`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
p[1].kill();
|
|
86
|
+
};
|
|
87
|
+
close_shell_all = (data) => {
|
|
88
|
+
this.shell_workers.forEach(p => {
|
|
89
|
+
if (p == undefined) {
|
|
90
|
+
this.messager_log(`[Shell] Cannot find shell instance`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
p[1].kill();
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
shell_folder = (data, source) => {
|
|
97
|
+
if (data.length == 0) {
|
|
98
|
+
data = process.cwd();
|
|
99
|
+
}
|
|
100
|
+
if (!this.os.fs_dir_exist({ path: data })) {
|
|
101
|
+
data = process.cwd();
|
|
102
|
+
}
|
|
103
|
+
const d = {
|
|
104
|
+
path: data,
|
|
105
|
+
cwd: process.cwd(),
|
|
106
|
+
folders: this.os.dir_dirs({ path: data }),
|
|
107
|
+
files: this.os.dir_files({ path: data })
|
|
108
|
+
};
|
|
109
|
+
const h = {
|
|
110
|
+
name: "shell_folder_reply",
|
|
111
|
+
data: d
|
|
112
|
+
};
|
|
113
|
+
source.send(JSON.stringify(h));
|
|
114
|
+
};
|
|
115
|
+
disconnect = (source) => {
|
|
116
|
+
const p = this.shell_workers.find(x => x[0] == source);
|
|
117
|
+
if (p == undefined)
|
|
118
|
+
return;
|
|
119
|
+
p[1].kill();
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
exports.ClientShell = ClientShell;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * as ClientAnalysis from './client/analysis';
|
|
2
|
+
export * as Client from './client/client';
|
|
3
|
+
export * as ClientCluster from './client/cluster';
|
|
4
|
+
export * as ClientExecute from './client/execute';
|
|
5
|
+
export * as ClientJobExecute from './client/job_execute';
|
|
6
|
+
export * as ClientJobParameter from './client/job_database';
|
|
7
|
+
export * as ClientHttp from './client/http';
|
|
8
|
+
export * as ClientJavascript from './client/javascript';
|
|
9
|
+
export * as ClientOS from './client/os';
|
|
10
|
+
export * as ClientParameter from './client/database';
|
|
11
|
+
export * as ClientResource from './client/resource';
|
|
12
|
+
export * as ClientShell from './client/shell';
|
|
13
|
+
export * as Execute_WebhookServerManager from './script/webhook_server_manager';
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./computed"), exports);
|
|
18
|
+
__exportStar(require("./interface"), exports);
|
|
19
|
+
__exportStar(require("./server"), exports);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DataType, DataTypeBase } from "./enum";
|
|
2
|
+
import { ACLType, LocalPermission as LocalPermission } from "./server";
|
|
3
|
+
export interface DatabaseConfigTrigger {
|
|
4
|
+
types: Array<DataTypeBase>;
|
|
5
|
+
}
|
|
6
|
+
export interface DatabaseContainer {
|
|
7
|
+
name: string;
|
|
8
|
+
meta?: any;
|
|
9
|
+
config?: DatabaseConfigTrigger;
|
|
10
|
+
type: DataType;
|
|
11
|
+
hidden: boolean;
|
|
12
|
+
runtimeOnly: boolean;
|
|
13
|
+
value: any;
|
|
14
|
+
}
|
|
15
|
+
export interface Property {
|
|
16
|
+
name: string;
|
|
17
|
+
expression: string;
|
|
18
|
+
deep?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Database {
|
|
21
|
+
uuid: string;
|
|
22
|
+
title: string;
|
|
23
|
+
canWrite: boolean;
|
|
24
|
+
containers: Array<DatabaseContainer>;
|
|
25
|
+
permission?: LocalPermission;
|
|
26
|
+
}
|
|
27
|
+
export interface Job {
|
|
28
|
+
index?: number;
|
|
29
|
+
uuid: string;
|
|
30
|
+
runtime_uuid?: string;
|
|
31
|
+
category: number;
|
|
32
|
+
type: number;
|
|
33
|
+
script: string;
|
|
34
|
+
string_args: Array<string>;
|
|
35
|
+
number_args: Array<number>;
|
|
36
|
+
boolean_args: Array<boolean>;
|
|
37
|
+
id_args: Array<boolean>;
|
|
38
|
+
permission?: LocalPermission;
|
|
39
|
+
}
|
|
40
|
+
export interface Task {
|
|
41
|
+
uuid: string;
|
|
42
|
+
title: string;
|
|
43
|
+
description: string;
|
|
44
|
+
setupjob: boolean;
|
|
45
|
+
cronjob: boolean;
|
|
46
|
+
cronjobKey: string;
|
|
47
|
+
multi: boolean;
|
|
48
|
+
multiKey: string;
|
|
49
|
+
properties: Array<Property>;
|
|
50
|
+
jobs: Array<Job>;
|
|
51
|
+
permission?: LocalPermission;
|
|
52
|
+
}
|
|
53
|
+
export interface Project {
|
|
54
|
+
owner?: string;
|
|
55
|
+
uuid: string;
|
|
56
|
+
title: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
database_uuid: string;
|
|
59
|
+
database?: Database;
|
|
60
|
+
task: Array<Task>;
|
|
61
|
+
permission?: LocalPermission;
|
|
62
|
+
acl?: ACLType;
|
|
63
|
+
}
|
|
64
|
+
export interface Node {
|
|
65
|
+
uuid: string;
|
|
66
|
+
parent?: string;
|
|
67
|
+
url: string;
|
|
68
|
+
permission?: LocalPermission;
|
|
69
|
+
acl?: ACLType;
|
|
70
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Job, Database, Project, Task } from "./base";
|
|
2
|
+
import { ExecuteState } from "./enum";
|
|
3
|
+
import { ExecutionLog, Log, Preference } from "./record";
|
|
4
|
+
import { Login } from "./server";
|
|
5
|
+
import { FeedBack, Header, Setter, ShellFolder, Single, WebsocketPack } from "./struct";
|
|
6
|
+
import { NodeTable } from "./table";
|
|
7
|
+
import { ToastData } from "./ui";
|
|
8
|
+
type Handler<T = unknown> = (event: T) => void;
|
|
9
|
+
export type Messager = (msg: string, tag?: string) => void;
|
|
10
|
+
export type Messager_log = (msg: string, tag?: string, meta?: string) => void;
|
|
11
|
+
export interface BusAnalysis {
|
|
12
|
+
name: string;
|
|
13
|
+
h: Header;
|
|
14
|
+
c: WebsocketPack | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface Rename {
|
|
17
|
+
oldname: string;
|
|
18
|
+
newname: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RawSend {
|
|
21
|
+
name: string;
|
|
22
|
+
token?: string;
|
|
23
|
+
data: any;
|
|
24
|
+
}
|
|
25
|
+
export interface EmitterProxy<T> {
|
|
26
|
+
on<Key extends keyof T>(type: T, handler: Handler<T[Key]>): void;
|
|
27
|
+
off<Key extends keyof T>(type: T, handler: Handler<T[Key]>): void;
|
|
28
|
+
emit<Key extends keyof T>(type: T, handler: T[Key]): void;
|
|
29
|
+
}
|
|
30
|
+
export interface ExecuteProxy {
|
|
31
|
+
executeProjectStart: (data: [Project, number]) => void;
|
|
32
|
+
executeProjectFinish: (data: [Project, number]) => void;
|
|
33
|
+
executeTaskStart: (data: [Task, number]) => void;
|
|
34
|
+
executeTaskFinish: (data: Task) => void;
|
|
35
|
+
executeSubtaskStart: (data: [Task, number, string]) => void;
|
|
36
|
+
executeSubtaskUpdate: (data: [Task, number, string, ExecuteState]) => void;
|
|
37
|
+
executeSubtaskFinish: (data: [Task, number, string]) => void;
|
|
38
|
+
executeJobStart: (data: [Job, number, string]) => void;
|
|
39
|
+
executeJobFinish: (data: [Job, number, string, number]) => void;
|
|
40
|
+
feedbackMessage: (data: FeedBack) => void;
|
|
41
|
+
updateDatabase: (data: Database) => void;
|
|
42
|
+
}
|
|
43
|
+
export interface NodeProxy {
|
|
44
|
+
shellReply: (data: Single, w?: WebsocketPack) => void;
|
|
45
|
+
folderReply: (data: ShellFolder, w?: WebsocketPack) => void;
|
|
46
|
+
}
|
|
47
|
+
export type BusType = {
|
|
48
|
+
setting: void;
|
|
49
|
+
guide: void;
|
|
50
|
+
makeToast: ToastData;
|
|
51
|
+
modeSelect: boolean;
|
|
52
|
+
createProject: void;
|
|
53
|
+
updateProject: void;
|
|
54
|
+
recoverProject: Project;
|
|
55
|
+
recoverDatabase: Database;
|
|
56
|
+
relogin: void;
|
|
57
|
+
loginGuest: void;
|
|
58
|
+
login: Login;
|
|
59
|
+
logout: void;
|
|
60
|
+
updateTask: void;
|
|
61
|
+
updateJob: void;
|
|
62
|
+
updateDatabase: void;
|
|
63
|
+
selectDatabase: string;
|
|
64
|
+
updateLocate: void;
|
|
65
|
+
updateNode: Array<NodeTable>;
|
|
66
|
+
updateCurrent: ExecutionLog;
|
|
67
|
+
updateLog: Log;
|
|
68
|
+
updateHandle: void;
|
|
69
|
+
slowUpdateHandle: void;
|
|
70
|
+
shellReply: Single;
|
|
71
|
+
folderReply: ShellFolder;
|
|
72
|
+
feedbackMessage: FeedBack;
|
|
73
|
+
savePreference: Preference;
|
|
74
|
+
renameScript: Rename;
|
|
75
|
+
deleteScript: string;
|
|
76
|
+
analysis: BusAnalysis;
|
|
77
|
+
debuglog: string;
|
|
78
|
+
hotkey: string;
|
|
79
|
+
isExpress: boolean;
|
|
80
|
+
delay: Setter;
|
|
81
|
+
system: Setter;
|
|
82
|
+
};
|
|
83
|
+
export type BusWebType = {
|
|
84
|
+
raw_send: RawSend;
|
|
85
|
+
locate: string;
|
|
86
|
+
load_preference: string;
|
|
87
|
+
load_cookie: void;
|
|
88
|
+
get_token: string;
|
|
89
|
+
};
|
|
90
|
+
export {};
|