verteilen-core 1.3.26 → 1.3.28
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/util/plugin_builder.js +5 -0
- package/package.json +1 -1
- package/src/util/plugin_builder.ts +6 -0
- package/dist/script/execute/interface.d.ts +0 -8
- package/dist/script/execute/interface.js +0 -24
- package/dist/util/console_handle.d.ts +0 -20
- package/dist/util/console_handle.js +0 -244
- package/dist/util/log_handle.d.ts +0 -23
- package/dist/util/log_handle.js +0 -224
|
@@ -38,6 +38,7 @@ const fs = __importStar(require("fs"));
|
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const interface_1 = require("../interface");
|
|
40
40
|
const PluginBuild = (plugins, templates) => {
|
|
41
|
+
console.log("Activate Plugin Build Process...");
|
|
41
42
|
const root = path.join(__dirname, 'dist');
|
|
42
43
|
const root_p = path.join(root, 'project');
|
|
43
44
|
const root_d = path.join(root, 'database');
|
|
@@ -58,6 +59,7 @@ const PluginBuild = (plugins, templates) => {
|
|
|
58
59
|
databases: []
|
|
59
60
|
};
|
|
60
61
|
if (fs.existsSync(m_path)) {
|
|
62
|
+
console.log("Detected manifest.json");
|
|
61
63
|
manifest = JSON.parse(fs.readFileSync(m_path).toString());
|
|
62
64
|
}
|
|
63
65
|
manifest.plugins = plugins.plugins;
|
|
@@ -75,11 +77,14 @@ const PluginBuild = (plugins, templates) => {
|
|
|
75
77
|
}));
|
|
76
78
|
delete manifest.acl;
|
|
77
79
|
delete manifest.permission;
|
|
80
|
+
console.log("Output manifest.json");
|
|
78
81
|
fs.writeFileSync(m_path, JSON.stringify(manifest, null, 4));
|
|
82
|
+
console.log("Output project templates");
|
|
79
83
|
templates.projects.forEach(item => {
|
|
80
84
|
const result = item.template((0, interface_1.CreateDefaultProject)());
|
|
81
85
|
fs.writeFileSync(path.join(root_p, `${item.title}.json`), JSON.stringify(result, null, 4), 'utf-8');
|
|
82
86
|
});
|
|
87
|
+
console.log("Output database templates");
|
|
83
88
|
templates.databases.forEach(item => {
|
|
84
89
|
const result = item.template();
|
|
85
90
|
fs.writeFileSync(path.join(root_d, `${item.title}.json`), JSON.stringify(result, null, 4), 'utf-8');
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import * as path from 'path'
|
|
|
3
3
|
import { CreateDefaultProject, DatabaseContainer, PluginContainer, PluginGenData, PluginNode, Project } from '../interface'
|
|
4
4
|
|
|
5
5
|
export const PluginBuild = (plugins:PluginNode, templates:PluginGenData) => {
|
|
6
|
+
console.log("Activate Plugin Build Process...")
|
|
6
7
|
const root = path.join(__dirname, 'dist')
|
|
7
8
|
const root_p = path.join(root, 'project')
|
|
8
9
|
const root_d = path.join(root, 'database')
|
|
@@ -22,6 +23,7 @@ export const PluginBuild = (plugins:PluginNode, templates:PluginGenData) => {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
if(fs.existsSync(m_path)){
|
|
26
|
+
console.log("Detected manifest.json")
|
|
25
27
|
manifest = JSON.parse(fs.readFileSync(m_path).toString())
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -41,14 +43,18 @@ export const PluginBuild = (plugins:PluginNode, templates:PluginGenData) => {
|
|
|
41
43
|
|
|
42
44
|
delete manifest.acl
|
|
43
45
|
delete manifest.permission
|
|
46
|
+
console.log("Output manifest.json")
|
|
44
47
|
fs.writeFileSync(m_path, JSON.stringify(manifest, null, 4))
|
|
45
48
|
|
|
49
|
+
console.log("Output project templates")
|
|
46
50
|
templates.projects.forEach(item => {
|
|
47
51
|
const result:Project = item.template(CreateDefaultProject())
|
|
48
52
|
fs.writeFileSync(
|
|
49
53
|
path.join(root_p, `${item.title}.json`),
|
|
50
54
|
JSON.stringify(result, null, 4), 'utf-8')
|
|
51
55
|
})
|
|
56
|
+
|
|
57
|
+
console.log("Output database templates")
|
|
52
58
|
templates.databases.forEach(item => {
|
|
53
59
|
const result:Array<DatabaseContainer> = item.template()
|
|
54
60
|
fs.writeFileSync(
|
|
@@ -1,24 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base"), exports);
|
|
18
|
-
__exportStar(require("./feedback"), exports);
|
|
19
|
-
__exportStar(require("./region_job"), exports);
|
|
20
|
-
__exportStar(require("./region_project"), exports);
|
|
21
|
-
__exportStar(require("./region_subtask"), exports);
|
|
22
|
-
__exportStar(require("./region_task"), exports);
|
|
23
|
-
__exportStar(require("./runner"), exports);
|
|
24
|
-
__exportStar(require("./util_parser"), exports);
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Util_Server_Console_Proxy = exports.Util_Server_Console = void 0;
|
|
4
|
-
const interface_1 = require("../interface");
|
|
5
|
-
class Util_Server_Console {
|
|
6
|
-
receivedPack = (model, record) => {
|
|
7
|
-
const pass = model.manager.Register();
|
|
8
|
-
if (pass == -1) {
|
|
9
|
-
model.record.running = false;
|
|
10
|
-
model.record.stop = true;
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
model.record.projects = record.projects;
|
|
14
|
-
model.record.nodes = record.nodes;
|
|
15
|
-
model.record.project_state = model.record.projects.map(x => {
|
|
16
|
-
return {
|
|
17
|
-
uuid: x.uuid,
|
|
18
|
-
state: interface_1.ExecuteState.NONE
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
model.record.project_index = pass;
|
|
22
|
-
model.record.project = record.projects[pass].uuid;
|
|
23
|
-
model.record.task_index = 0;
|
|
24
|
-
model.record.task_state = model.record.projects[0].tasks.map(x => {
|
|
25
|
-
return {
|
|
26
|
-
uuid: x.uuid,
|
|
27
|
-
state: interface_1.ExecuteState.NONE
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
model.record.task_state[0].state = interface_1.ExecuteState.RUNNING;
|
|
31
|
-
model.record.task_detail = [];
|
|
32
|
-
const task = model.record.projects[model.record.project_index]?.tasks[model.record.task_index];
|
|
33
|
-
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
34
|
-
for (let i = 0; i < count; i++) {
|
|
35
|
-
model.record.task_detail.push({
|
|
36
|
-
index: i,
|
|
37
|
-
node: "",
|
|
38
|
-
message: [],
|
|
39
|
-
state: interface_1.ExecuteState.NONE
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
model.manager.Update();
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
exports.Util_Server_Console = Util_Server_Console;
|
|
47
|
-
class Util_Server_Console_Proxy {
|
|
48
|
-
model;
|
|
49
|
-
constructor(_model) {
|
|
50
|
-
this.model = _model;
|
|
51
|
-
}
|
|
52
|
-
get execute_proxy() {
|
|
53
|
-
const d = {
|
|
54
|
-
executeProjectStart: (data) => { this.execute_project_start(data); },
|
|
55
|
-
executeProjectFinish: (data) => { this.execute_project_finish(data); },
|
|
56
|
-
executeTaskStart: (data) => { this.execute_task_start(data); },
|
|
57
|
-
executeTaskFinish: (data) => { this.execute_task_finish(data); },
|
|
58
|
-
executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
|
|
59
|
-
executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
|
|
60
|
-
executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
|
|
61
|
-
executeJobStart: (data) => { this.execute_job_start(data); },
|
|
62
|
-
executeJobFinish: (data) => { this.execute_job_finish(data); },
|
|
63
|
-
feedbackMessage: (data) => { this.feedback_message(data); },
|
|
64
|
-
updateDatabase: (data) => { this.update_runtime_database(data); }
|
|
65
|
-
};
|
|
66
|
-
return d;
|
|
67
|
-
}
|
|
68
|
-
execute_project_start = (d) => {
|
|
69
|
-
const index = d[1];
|
|
70
|
-
if (index == -1)
|
|
71
|
-
return;
|
|
72
|
-
this.model.record.project = d[0].uuid;
|
|
73
|
-
this.model.record.project_index = index;
|
|
74
|
-
this.model.record.project_state[index].state = interface_1.ExecuteState.RUNNING;
|
|
75
|
-
this.model.record.task_state = this.model.record.projects[index].tasks.map(x => {
|
|
76
|
-
return {
|
|
77
|
-
uuid: x.uuid,
|
|
78
|
-
state: interface_1.ExecuteState.NONE
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
this.model.record.task_detail = [];
|
|
82
|
-
const task = this.model.record.projects[this.model.record.project_index]?.tasks[this.model.record.task_index];
|
|
83
|
-
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
84
|
-
for (let i = 0; i < count; i++) {
|
|
85
|
-
this.model.record.task_detail.push({
|
|
86
|
-
index: i,
|
|
87
|
-
node: "",
|
|
88
|
-
message: [],
|
|
89
|
-
state: interface_1.ExecuteState.NONE
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
console.log("project start: ", this.model.record.projects.length, index);
|
|
93
|
-
};
|
|
94
|
-
execute_project_finish = (d) => {
|
|
95
|
-
if (this.model.record.process_type >= 1) {
|
|
96
|
-
this.model.record.running = false;
|
|
97
|
-
this.model.record.stop = true;
|
|
98
|
-
}
|
|
99
|
-
const index = d[1];
|
|
100
|
-
const size = this.model.record.projects.length;
|
|
101
|
-
if (index == -1)
|
|
102
|
-
return;
|
|
103
|
-
this.model.record.project = "";
|
|
104
|
-
this.model.record.project_state[index].state = interface_1.ExecuteState.FINISH;
|
|
105
|
-
this.model.record.para = undefined;
|
|
106
|
-
console.log("project finish: ", this.model.record.projects.length, index);
|
|
107
|
-
if (index == size - 1) {
|
|
108
|
-
this.model.record.command.push(['clean']);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
execute_task_start = (d) => {
|
|
112
|
-
if (this.model.record.project_index == -1)
|
|
113
|
-
return;
|
|
114
|
-
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
115
|
-
if (index == -1)
|
|
116
|
-
return;
|
|
117
|
-
this.model.record.useCron = d[0].cronjob;
|
|
118
|
-
this.model.record.task = d[0].uuid;
|
|
119
|
-
this.model.record.task_index = index;
|
|
120
|
-
this.model.record.task_state[index].state = interface_1.ExecuteState.RUNNING;
|
|
121
|
-
for (let i = 0; i < index; i++)
|
|
122
|
-
this.model.record.task_state[i].state = interface_1.ExecuteState.FINISH;
|
|
123
|
-
for (let i = index + 1; i < this.model.record.task_state.length; i++)
|
|
124
|
-
this.model.record.task_state[i].state = interface_1.ExecuteState.NONE;
|
|
125
|
-
this.model.record.task_detail = [];
|
|
126
|
-
const p = this.model.record.projects[this.model.record.project_index];
|
|
127
|
-
const t = p.tasks[this.model.record.task_index];
|
|
128
|
-
const count = this.model.manager.get_task_state_count(t);
|
|
129
|
-
for (let i = 0; i < count; i++) {
|
|
130
|
-
this.model.record.task_detail.push({
|
|
131
|
-
index: i,
|
|
132
|
-
node: "",
|
|
133
|
-
message: [],
|
|
134
|
-
state: interface_1.ExecuteState.NONE
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
execute_task_finish = (d) => {
|
|
139
|
-
if (this.model.record.process_type == 2) {
|
|
140
|
-
this.model.record.running = false;
|
|
141
|
-
this.model.record.stop = true;
|
|
142
|
-
}
|
|
143
|
-
if (this.model.record.project_index == -1)
|
|
144
|
-
return;
|
|
145
|
-
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d.uuid);
|
|
146
|
-
if (index == -1)
|
|
147
|
-
return;
|
|
148
|
-
this.model.record.useCron = false;
|
|
149
|
-
this.model.record.task = "";
|
|
150
|
-
this.model.record.task_state[index].state = interface_1.ExecuteState.FINISH;
|
|
151
|
-
if (index + 1 < this.model.record.task_state.length - 1) {
|
|
152
|
-
this.model.record.task_state[index + 1].state = interface_1.ExecuteState.RUNNING;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
execute_subtask_start = (d) => {
|
|
156
|
-
try {
|
|
157
|
-
this.model.record.task_detail[d[1]].node = d[2] ?? '';
|
|
158
|
-
this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
console.error(`execute_subtask_start`, error.message);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
execute_subtask_update = (d) => {
|
|
165
|
-
if (this.model.record.task_detail.length > d[1]) {
|
|
166
|
-
this.model.record.task_detail[d[1]].node = d[2];
|
|
167
|
-
this.model.record.task_detail[d[1]].state = d[3];
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
console.error(`subtask_start ${d[1]} is out of range: ${this.model.record.task_detail.length}`);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
execute_subtask_end = (d) => {
|
|
174
|
-
try {
|
|
175
|
-
this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
console.error(`execute_subtask_end`, error.message);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
execute_job_start = (d) => {
|
|
182
|
-
if (this.model.record.project_index == -1)
|
|
183
|
-
return;
|
|
184
|
-
if (!this.model.record.useCron) {
|
|
185
|
-
this.model.record.task_detail[0].node = d[2];
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
execute_job_finish = (d) => {
|
|
189
|
-
if (d[3] == 1) {
|
|
190
|
-
const task = this.model.record.projects[this.model.record.project_index].tasks[this.model.record.task_index];
|
|
191
|
-
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
192
|
-
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
193
|
-
const cr = task.jobs[index].number_args[0];
|
|
194
|
-
if (cr == interface_1.ConditionResult.None)
|
|
195
|
-
return;
|
|
196
|
-
this.model.record.command.push(['stop']);
|
|
197
|
-
let timer;
|
|
198
|
-
timer = setInterval(() => {
|
|
199
|
-
if (this.model.record.running == false) {
|
|
200
|
-
clearInterval(timer);
|
|
201
|
-
const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
|
|
202
|
-
const target = this.model.record.task_detail[d[1]];
|
|
203
|
-
if (target != undefined) {
|
|
204
|
-
target.state = state;
|
|
205
|
-
}
|
|
206
|
-
if (cr == interface_1.ConditionResult.Pause)
|
|
207
|
-
return;
|
|
208
|
-
if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
|
|
209
|
-
this.model.record.command.push(['skip', 0, state]);
|
|
210
|
-
if (this.model.record.project.length > 0) {
|
|
211
|
-
if (this.model.record.process_type == 0) {
|
|
212
|
-
this.model.record.command.push(['execute', this.model.record.process_type]);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else if (cr == interface_1.ConditionResult.SkipTask || cr == interface_1.ConditionResult.ThrowTask) {
|
|
217
|
-
this.model.record.command.push(['skip', 1, state]);
|
|
218
|
-
if (this.model.record.project.length > 0) {
|
|
219
|
-
if (this.model.record.process_type == 0) {
|
|
220
|
-
this.model.record.command.push(['execute', this.model.record.process_type]);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}, 1000);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
feedback_message = (d) => {
|
|
230
|
-
if (d.index == undefined || d.index == -1)
|
|
231
|
-
return;
|
|
232
|
-
const container = this.model.record.task_detail[d.index];
|
|
233
|
-
if (container != undefined) {
|
|
234
|
-
container.message.push(d.message);
|
|
235
|
-
if (container.message.length > interface_1.MESSAGE_LIMIT) {
|
|
236
|
-
container.message.shift();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
update_runtime_database = (d) => {
|
|
241
|
-
this.model.record.para = d;
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
exports.Util_Server_Console_Proxy = Util_Server_Console_Proxy;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ExecutePair, ExecuteProxy, ExecuteState, FeedBack, Job, Log, Database, Preference, Project, Task } from "../interface";
|
|
2
|
-
export declare class Util_Server_Log_Proxy {
|
|
3
|
-
model: ExecutePair;
|
|
4
|
-
logs: Log;
|
|
5
|
-
preference: Preference;
|
|
6
|
-
private task_index;
|
|
7
|
-
private uuid;
|
|
8
|
-
private get target_log();
|
|
9
|
-
constructor(_model: ExecutePair, _log: Log, _preference: Preference);
|
|
10
|
-
get execute_proxy(): ExecuteProxy;
|
|
11
|
-
execute_project_start: (d: [Project, number]) => Promise<void>;
|
|
12
|
-
execute_project_finish: (d: [Project, number]) => void;
|
|
13
|
-
execute_task_start: (d: [Task, number]) => void;
|
|
14
|
-
execute_task_finish: (d: Task) => void;
|
|
15
|
-
execute_subtask_start: (d: [Task, number, string]) => void;
|
|
16
|
-
execute_subtask_update: (d: [Task, number, string, ExecuteState]) => void;
|
|
17
|
-
execute_subtask_end: (d: [Task, number, string]) => void;
|
|
18
|
-
execute_job_start: (d: [Job, number, string]) => void;
|
|
19
|
-
execute_job_finish: (d: [Job, number, string, number]) => void;
|
|
20
|
-
feedback_message: (d: FeedBack) => void;
|
|
21
|
-
update_runtime_database: (d: Database) => void;
|
|
22
|
-
getnewname: (name: string) => Promise<string>;
|
|
23
|
-
}
|
package/dist/util/log_handle.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Util_Server_Log_Proxy = void 0;
|
|
37
|
-
const uuid_1 = require("uuid");
|
|
38
|
-
const interface_1 = require("../interface");
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
class Util_Server_Log_Proxy {
|
|
41
|
-
model;
|
|
42
|
-
logs;
|
|
43
|
-
preference;
|
|
44
|
-
task_index = 0;
|
|
45
|
-
uuid = '';
|
|
46
|
-
get target_log() {
|
|
47
|
-
return this.logs.logs.find(x => x.uuid == this.uuid);
|
|
48
|
-
}
|
|
49
|
-
constructor(_model, _log, _preference) {
|
|
50
|
-
this.model = _model;
|
|
51
|
-
this.logs = _log;
|
|
52
|
-
this.preference = _preference;
|
|
53
|
-
}
|
|
54
|
-
get execute_proxy() {
|
|
55
|
-
const d = {
|
|
56
|
-
executeProjectStart: (data) => { this.execute_project_start(data); },
|
|
57
|
-
executeProjectFinish: (data) => { this.execute_project_finish(data); },
|
|
58
|
-
executeTaskStart: (data) => { this.execute_task_start(data); },
|
|
59
|
-
executeTaskFinish: (data) => { this.execute_task_finish(data); },
|
|
60
|
-
executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
|
|
61
|
-
executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
|
|
62
|
-
executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
|
|
63
|
-
executeJobStart: (data) => { this.execute_job_start(data); },
|
|
64
|
-
executeJobFinish: (data) => { this.execute_job_finish(data); },
|
|
65
|
-
feedbackMessage: (data) => { this.feedback_message(data); },
|
|
66
|
-
updateDatabase: (data) => { this.update_runtime_database(data); }
|
|
67
|
-
};
|
|
68
|
-
return d;
|
|
69
|
-
}
|
|
70
|
-
execute_project_start = async (d) => {
|
|
71
|
-
const target = this.model.record.projects[this.model.record.project_index];
|
|
72
|
-
const title = await this.getnewname(target.title);
|
|
73
|
-
this.uuid = (0, uuid_1.v6)();
|
|
74
|
-
const newlog = {
|
|
75
|
-
uuid: this.uuid,
|
|
76
|
-
filename: title,
|
|
77
|
-
dirty: true,
|
|
78
|
-
output: this.preference.log,
|
|
79
|
-
project: target,
|
|
80
|
-
state: interface_1.ExecuteState.RUNNING,
|
|
81
|
-
start_timer: Date.now(),
|
|
82
|
-
database: d[0].database,
|
|
83
|
-
end_timer: 0,
|
|
84
|
-
logs: target.tasks.map(x => {
|
|
85
|
-
return {
|
|
86
|
-
start_timer: 0,
|
|
87
|
-
end_timer: 0,
|
|
88
|
-
task_state: {
|
|
89
|
-
uuid: x.uuid,
|
|
90
|
-
state: interface_1.ExecuteState.NONE
|
|
91
|
-
},
|
|
92
|
-
task_detail: []
|
|
93
|
-
};
|
|
94
|
-
})
|
|
95
|
-
};
|
|
96
|
-
this.logs.logs = [newlog].concat(this.logs.logs);
|
|
97
|
-
};
|
|
98
|
-
execute_project_finish = (d) => {
|
|
99
|
-
if (this.target_log == undefined)
|
|
100
|
-
return;
|
|
101
|
-
this.target_log.state = interface_1.ExecuteState.FINISH;
|
|
102
|
-
this.target_log.end_timer = Date.now();
|
|
103
|
-
this.target_log.dirty = true;
|
|
104
|
-
};
|
|
105
|
-
execute_task_start = (d) => {
|
|
106
|
-
if (this.target_log == undefined)
|
|
107
|
-
return;
|
|
108
|
-
const index = this.target_log.project.tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
109
|
-
if (index == -1)
|
|
110
|
-
return;
|
|
111
|
-
this.task_index = index;
|
|
112
|
-
this.target_log.logs[this.task_index].task_detail = [];
|
|
113
|
-
const p = this.model.record.projects[this.model.record.project_index];
|
|
114
|
-
const t = p.tasks[this.task_index];
|
|
115
|
-
const count = this.model.manager.get_task_state_count(t);
|
|
116
|
-
for (let i = 0; i < count; i++) {
|
|
117
|
-
this.target_log.logs[this.task_index].task_detail.push({
|
|
118
|
-
index: i,
|
|
119
|
-
node: "",
|
|
120
|
-
message: [],
|
|
121
|
-
state: interface_1.ExecuteState.NONE
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
if (this.target_log.logs.length > this.task_index) {
|
|
125
|
-
this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.RUNNING;
|
|
126
|
-
this.target_log.logs[this.task_index].start_timer = Date.now();
|
|
127
|
-
this.target_log.dirty = true;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
execute_task_finish = (d) => {
|
|
131
|
-
if (this.target_log == undefined)
|
|
132
|
-
return;
|
|
133
|
-
if (this.target_log.logs.length > this.task_index) {
|
|
134
|
-
this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.FINISH;
|
|
135
|
-
this.target_log.logs[this.task_index].end_timer = Date.now();
|
|
136
|
-
this.target_log.dirty = true;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
execute_subtask_start = (d) => {
|
|
140
|
-
if (this.target_log == undefined)
|
|
141
|
-
return;
|
|
142
|
-
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
143
|
-
this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
|
|
144
|
-
this.target_log.dirty = true;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
execute_subtask_update = (d) => {
|
|
148
|
-
if (this.target_log == undefined)
|
|
149
|
-
return;
|
|
150
|
-
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
151
|
-
this.target_log.logs[this.task_index].task_detail[d[1]].state = d[3];
|
|
152
|
-
this.target_log.dirty = true;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
execute_subtask_end = (d) => {
|
|
156
|
-
if (this.target_log == undefined)
|
|
157
|
-
return;
|
|
158
|
-
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
159
|
-
this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
|
|
160
|
-
this.target_log.dirty = true;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
execute_job_start = (d) => {
|
|
164
|
-
};
|
|
165
|
-
execute_job_finish = (d) => {
|
|
166
|
-
if (this.target_log == undefined)
|
|
167
|
-
return;
|
|
168
|
-
if (d[3] == 1) {
|
|
169
|
-
const currentLog = this.target_log;
|
|
170
|
-
const task = currentLog.project.tasks[this.task_index];
|
|
171
|
-
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
172
|
-
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
173
|
-
const cr = task.jobs[index].number_args[0];
|
|
174
|
-
if (cr == interface_1.ConditionResult.None)
|
|
175
|
-
return;
|
|
176
|
-
const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
|
|
177
|
-
const target = this.model.record.task_detail[d[1]];
|
|
178
|
-
if (target != undefined) {
|
|
179
|
-
target.state = state;
|
|
180
|
-
}
|
|
181
|
-
currentLog.logs[this.task_index].task_state.state = state;
|
|
182
|
-
if (cr == interface_1.ConditionResult.Pause)
|
|
183
|
-
return;
|
|
184
|
-
if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
|
|
185
|
-
currentLog.state = state;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
feedback_message = (d) => {
|
|
191
|
-
if (this.target_log == undefined)
|
|
192
|
-
return;
|
|
193
|
-
if (d.index == undefined || d.index == -1)
|
|
194
|
-
return;
|
|
195
|
-
if (this.target_log == undefined)
|
|
196
|
-
return;
|
|
197
|
-
if (this.target_log.logs[this.task_index].task_detail.length > d.index) {
|
|
198
|
-
this.target_log.logs[this.task_index].task_detail[d.index].message.push(d.message);
|
|
199
|
-
this.target_log.dirty = true;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
console.warn("Try access message by index but failed: ", d);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
update_runtime_database = (d) => {
|
|
206
|
-
if (this.target_log != undefined) {
|
|
207
|
-
this.target_log.database = d;
|
|
208
|
-
this.target_log.dirty = true;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
getnewname = async (name) => {
|
|
212
|
-
const root = "data/log";
|
|
213
|
-
let count = 0;
|
|
214
|
-
let filename = name;
|
|
215
|
-
let p = `${root}/${filename}`;
|
|
216
|
-
while (fs.existsSync(p + ".json")) {
|
|
217
|
-
count = count + 1;
|
|
218
|
-
filename = `${name} ${count}`;
|
|
219
|
-
p = `${root}/${filename}`;
|
|
220
|
-
}
|
|
221
|
-
return filename;
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
exports.Util_Server_Log_Proxy = Util_Server_Log_Proxy;
|