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.
Files changed (92) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/jest.config.d.ts +2 -0
  3. package/dist/src/client/analysis.d.ts +35 -0
  4. package/dist/src/client/analysis.js +318 -319
  5. package/dist/src/client/client.d.ts +25 -0
  6. package/dist/src/client/client.js +162 -168
  7. package/dist/src/client/cluster.d.ts +1 -0
  8. package/dist/src/client/cluster.js +1 -2
  9. package/dist/src/client/database.d.ts +13 -0
  10. package/dist/src/client/database.js +28 -27
  11. package/dist/src/client/execute.d.ts +24 -0
  12. package/dist/src/client/execute.js +61 -51
  13. package/dist/src/client/http.d.ts +7 -0
  14. package/dist/src/client/http.js +29 -26
  15. package/dist/src/client/javascript.d.ts +47 -0
  16. package/dist/src/client/javascript.js +110 -136
  17. package/dist/src/client/job_database.d.ts +10 -0
  18. package/dist/src/client/job_database.js +27 -29
  19. package/dist/src/client/job_execute.d.ts +20 -0
  20. package/dist/src/client/job_execute.js +148 -146
  21. package/dist/src/client/os.d.ts +29 -0
  22. package/dist/src/client/os.js +131 -136
  23. package/dist/src/client/resource.d.ts +7 -0
  24. package/dist/src/client/resource.js +93 -104
  25. package/dist/src/client/shell.d.ts +16 -0
  26. package/dist/src/client/shell.js +102 -98
  27. package/dist/src/computed.d.ts +13 -0
  28. package/dist/src/interface/base.d.ts +70 -0
  29. package/dist/src/interface/bus.d.ts +90 -0
  30. package/dist/src/interface/enum.d.ts +143 -0
  31. package/dist/src/interface/execute.d.ts +20 -0
  32. package/dist/src/interface/record.d.ts +93 -0
  33. package/dist/src/interface/server.d.ts +76 -0
  34. package/dist/src/interface/struct.d.ts +182 -0
  35. package/dist/src/interface/table.d.ts +20 -0
  36. package/dist/src/interface/ui.d.ts +29 -0
  37. package/dist/src/interface.d.ts +29 -0
  38. package/dist/src/plugins/i18n.d.ts +1666 -0
  39. package/dist/src/script/console_manager.d.ts +18 -0
  40. package/dist/src/script/console_manager.js +97 -91
  41. package/dist/src/script/console_server_manager.d.ts +13 -0
  42. package/dist/src/script/console_server_manager.js +29 -26
  43. package/dist/src/script/execute/base.d.ts +45 -0
  44. package/dist/src/script/execute/base.js +165 -162
  45. package/dist/src/script/execute/feedback.d.ts +12 -0
  46. package/dist/src/script/execute/feedback.js +162 -171
  47. package/dist/src/script/execute/interface.d.ts +8 -0
  48. package/dist/src/script/execute/region_job.d.ts +5 -0
  49. package/dist/src/script/execute/region_job.js +1 -0
  50. package/dist/src/script/execute/region_project.d.ts +10 -0
  51. package/dist/src/script/execute/region_project.js +4 -0
  52. package/dist/src/script/execute/region_subtask.d.ts +5 -0
  53. package/dist/src/script/execute/region_subtask.js +1 -0
  54. package/dist/src/script/execute/region_task.d.ts +10 -0
  55. package/dist/src/script/execute/region_task.js +4 -0
  56. package/dist/src/script/execute/runner.d.ts +14 -0
  57. package/dist/src/script/execute/runner.js +129 -139
  58. package/dist/src/script/execute/util_parser.d.ts +14 -0
  59. package/dist/src/script/execute/util_parser.js +119 -121
  60. package/dist/src/script/execute_manager.d.ts +25 -0
  61. package/dist/src/script/execute_manager.js +266 -278
  62. package/dist/src/script/socket_manager.d.ts +31 -0
  63. package/dist/src/script/socket_manager.js +196 -193
  64. package/dist/src/script/webhook_manager.d.ts +3 -0
  65. package/dist/src/script/webhook_server_manager.d.ts +13 -0
  66. package/dist/src/script/webhook_server_manager.js +79 -86
  67. package/dist/src/server/detail.d.ts +72 -0
  68. package/dist/src/server/detail.js +401 -378
  69. package/dist/src/server/io.d.ts +46 -0
  70. package/dist/src/server/io.js +42 -51
  71. package/dist/src/server/plugin.d.ts +18 -0
  72. package/dist/src/server/plugin.js +45 -54
  73. package/dist/src/server/server.d.ts +27 -0
  74. package/dist/src/server/server.js +38 -36
  75. package/dist/src/server.d.ts +4 -0
  76. package/dist/src/util/console_handle.d.ts +20 -0
  77. package/dist/src/util/console_handle.js +214 -218
  78. package/dist/src/util/log_handle.d.ts +23 -0
  79. package/dist/src/util/log_handle.js +158 -164
  80. package/dist/test/TEST.d.ts +1 -0
  81. package/dist/test/TEST.js +37 -54
  82. package/dist/test/client/execute.test.d.ts +1 -0
  83. package/dist/test/client/execute.test.js +6 -15
  84. package/dist/test/client/javascript.test.d.ts +1 -0
  85. package/dist/test/client/javascript.test.js +21 -30
  86. package/dist/test/client/server.test.d.ts +1 -0
  87. package/dist/test/client/task.test.d.ts +1 -0
  88. package/dist/test/client/task.test.js +1 -1
  89. package/dist/test/script/parser.test.d.ts +1 -0
  90. package/dist/test/script/socket.test.d.ts +1 -0
  91. package/package.json +1 -1
  92. package/tsconfig.json +5 -3
@@ -4,306 +4,294 @@ exports.ExecuteManager = void 0;
4
4
  const interface_1 = require("../interface");
5
5
  const runner_1 = require("./execute/runner");
6
6
  class ExecuteManager extends runner_1.ExecuteManager_Runner {
7
- constructor() {
8
- super(...arguments);
9
- this.Update = () => {
10
- var _a;
11
- if (this.state != interface_1.ExecuteState.RUNNING)
12
- return;
13
- else if (this.current_p == undefined && this.current_projects.length > 0) {
14
- this.current_p = this.current_projects[0];
15
- this.messager_log(`[Execute] Project Start ${this.current_p.uuid}`);
16
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectStart([this.current_p, 0]);
17
- this.SyncDatabase(this.current_p);
7
+ Update = () => {
8
+ if (this.state != interface_1.ExecuteState.RUNNING)
9
+ return;
10
+ else if (this.current_p == undefined && this.current_projects.length > 0) {
11
+ this.current_p = this.current_projects[0];
12
+ this.messager_log(`[Execute] Project Start ${this.current_p.uuid}`);
13
+ this.proxy?.executeProjectStart([this.current_p, 0]);
14
+ this.SyncDatabase(this.current_p);
15
+ }
16
+ else if (this.current_p != undefined) {
17
+ if (this.first)
18
+ this.first = false;
19
+ this.ExecuteProject(this.current_p);
20
+ }
21
+ };
22
+ Stop = () => {
23
+ this.current_nodes.forEach(x => {
24
+ const h = {
25
+ name: 'stop_job',
26
+ message: 'Stop All Jobs',
27
+ data: {}
28
+ };
29
+ x.websocket.send(JSON.stringify(h));
30
+ });
31
+ this.jobstack = 0;
32
+ this.current_nodes.forEach(x => x.current_job = []);
33
+ };
34
+ Register = (lib) => {
35
+ this.current_projects = this.record.projects;
36
+ this.current_nodes = [];
37
+ this.record.nodes.forEach(x => {
38
+ const n = this.websocket_manager.targets.find(y => y.uuid == x.uuid);
39
+ if (n != undefined)
40
+ this.current_nodes.push(n);
41
+ });
42
+ this.messager_log(`[Execute] Start executing, Project count: ${this.current_projects.length}, Node count: ${this.current_nodes.length}`);
43
+ if (this.state == interface_1.ExecuteState.RUNNING) {
44
+ this.messager_log(`[Execute] Init error, There are projects being execute right now`);
45
+ return -1;
46
+ }
47
+ if (this.current_nodes.length == 0) {
48
+ this.messager_log(`[Execute] Node count should be bigger than one`);
49
+ return -1;
50
+ }
51
+ if (this.current_projects.map(x => x.task.length).reduce((acc, cur) => acc + cur, 0) == 0) {
52
+ this.messager_log(`[Execute] No task can be executing`);
53
+ return -1;
54
+ }
55
+ if (!this.validation(this.current_projects)) {
56
+ this.messager_log(`[Execute] Init failed, Format checking error`);
57
+ return -1;
58
+ }
59
+ if (lib != undefined)
60
+ this.libs = this.filter_lib(this.record.projects, lib);
61
+ else
62
+ this.libs = { libs: [] };
63
+ this.state = interface_1.ExecuteState.RUNNING;
64
+ this.messager_log(`[Execute] Init successfully, Enter process right now, length: ${this.current_projects.length}`);
65
+ let i = 0;
66
+ for (const x of this.current_projects) {
67
+ if (x.task.length > 0) {
68
+ break;
18
69
  }
19
- else if (this.current_p != undefined) {
20
- if (this.first)
21
- this.first = false;
22
- this.ExecuteProject(this.current_p);
70
+ else {
71
+ i++;
23
72
  }
24
- };
25
- this.Stop = () => {
26
- this.current_nodes.forEach(x => {
27
- const h = {
28
- name: 'stop_job',
29
- message: 'Stop All Jobs',
30
- data: {}
31
- };
32
- x.websocket.send(JSON.stringify(h));
33
- });
34
- this.jobstack = 0;
35
- this.current_nodes.forEach(x => x.current_job = []);
36
- };
37
- this.Register = (lib) => {
38
- this.current_projects = this.record.projects;
39
- this.current_nodes = [];
40
- this.record.nodes.forEach(x => {
41
- const n = this.websocket_manager.targets.find(y => y.uuid == x.uuid);
42
- if (n != undefined)
43
- this.current_nodes.push(n);
73
+ }
74
+ return i;
75
+ };
76
+ Clean = () => {
77
+ this.current_projects = [];
78
+ this.current_p = undefined;
79
+ this.current_t = undefined;
80
+ this.current_cron = [];
81
+ this.current_job = [];
82
+ this.current_nodes = [];
83
+ this.current_multithread = 1;
84
+ this.state = interface_1.ExecuteState.NONE;
85
+ };
86
+ Release = () => {
87
+ this.current_nodes.forEach(x => this.release(x));
88
+ };
89
+ NewConnection = (source) => {
90
+ if (this.state == interface_1.ExecuteState.RUNNING && this.localPara != undefined) {
91
+ this.sync_para(this.localPara, source);
92
+ }
93
+ };
94
+ Disconnect = (source) => {
95
+ if (this.current_p == undefined)
96
+ return;
97
+ if (this.current_t == undefined)
98
+ return;
99
+ if (this.current_job.length > 0) {
100
+ const singleContainIt = this.current_job.filter(x => x.uuid == source.uuid && x.state == interface_1.ExecuteState.RUNNING);
101
+ singleContainIt.forEach((x, index) => {
102
+ x.uuid = '';
103
+ x.state = interface_1.ExecuteState.NONE;
44
104
  });
45
- this.messager_log(`[Execute] Start executing, Project count: ${this.current_projects.length}, Node count: ${this.current_nodes.length}`);
46
- if (this.state == interface_1.ExecuteState.RUNNING) {
47
- this.messager_log(`[Execute] Init error, There are projects being execute right now`);
48
- return -1;
49
- }
50
- if (this.current_nodes.length == 0) {
51
- this.messager_log(`[Execute] Node count should be bigger than one`);
52
- return -1;
53
- }
54
- if (this.current_projects.map(x => x.task.length).reduce((acc, cur) => acc + cur, 0) == 0) {
55
- this.messager_log(`[Execute] No task can be executing`);
56
- return -1;
57
- }
58
- if (!this.validation(this.current_projects)) {
59
- this.messager_log(`[Execute] Init failed, Format checking error`);
60
- return -1;
61
- }
62
- if (lib != undefined)
63
- this.libs = this.filter_lib(this.record.projects, lib);
64
- else
65
- this.libs = { libs: [] };
66
- this.state = interface_1.ExecuteState.RUNNING;
67
- this.messager_log(`[Execute] Init successfully, Enter process right now, length: ${this.current_projects.length}`);
68
- let i = 0;
69
- for (const x of this.current_projects) {
70
- if (x.task.length > 0) {
71
- break;
72
- }
73
- else {
74
- i++;
75
- }
76
- }
77
- return i;
78
- };
79
- this.Clean = () => {
80
- this.current_projects = [];
81
- this.current_p = undefined;
82
- this.current_t = undefined;
83
- this.current_cron = [];
84
- this.current_job = [];
85
- this.current_nodes = [];
86
- this.current_multithread = 1;
87
- this.state = interface_1.ExecuteState.NONE;
88
- };
89
- this.Release = () => {
90
- this.current_nodes.forEach(x => this.release(x));
91
- };
92
- this.NewConnection = (source) => {
93
- if (this.state == interface_1.ExecuteState.RUNNING && this.localPara != undefined) {
94
- this.sync_para(this.localPara, source);
95
- }
96
- };
97
- this.Disconnect = (source) => {
98
- var _a;
99
- if (this.current_p == undefined)
100
- return;
101
- if (this.current_t == undefined)
102
- return;
103
- if (this.current_job.length > 0) {
104
- const singleContainIt = this.current_job.filter(x => x.uuid == source.uuid && x.state == interface_1.ExecuteState.RUNNING);
105
- singleContainIt.forEach((x, index) => {
106
- x.uuid = '';
107
- x.state = interface_1.ExecuteState.NONE;
108
- });
109
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
110
- }
111
- else if (this.current_cron.length > 0) {
112
- const cronContainIt = this.current_cron.filter(x => x.work.filter(y => y.state == interface_1.ExecuteState.RUNNING && y.uuid == source.uuid).length > 0);
113
- cronContainIt.forEach(element => {
114
- var _a;
115
- element.work.forEach(x => {
116
- x.uuid = '';
117
- x.state = interface_1.ExecuteState.NONE;
118
- });
119
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, element.id - 1, '', interface_1.ExecuteState.NONE]);
120
- });
121
- }
122
- source.current_job = [];
123
- };
124
- this.ClearState = (task_index) => {
125
- var _a, _b;
126
- if (this.current_p == undefined)
127
- return;
128
- if (this.current_t == undefined)
129
- return;
130
- if (this.current_job.length > 0) {
131
- this.current_job = [];
132
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
133
- }
134
- else if (this.current_cron.length > 0) {
135
- const target = this.current_cron[task_index];
136
- target.work.forEach(x => {
105
+ this.proxy?.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
106
+ }
107
+ else if (this.current_cron.length > 0) {
108
+ const cronContainIt = this.current_cron.filter(x => x.work.filter(y => y.state == interface_1.ExecuteState.RUNNING && y.uuid == source.uuid).length > 0);
109
+ cronContainIt.forEach(element => {
110
+ element.work.forEach(x => {
137
111
  x.uuid = '';
138
112
  x.state = interface_1.ExecuteState.NONE;
139
113
  });
140
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeSubtaskUpdate([this.current_t, target.id - 1, '', interface_1.ExecuteState.NONE]);
141
- }
142
- };
143
- this.SkipProject = () => {
144
- return this.jumpProject(true);
145
- };
146
- this.PreviousProject = () => {
147
- return this.jumpProject(false);
148
- };
149
- this.SkipTask = () => {
150
- return this.jumpTask(true);
151
- };
152
- this.PreviousTask = () => {
153
- return this.jumpTask(false);
154
- };
155
- this.SkipSubTask = (v) => {
156
- if (this.current_p == undefined) {
157
- console.error("No project exist, Skip failed");
158
- return -2;
159
- }
160
- if (this.current_t == undefined) {
161
- console.error("Project has no task, Skip failed");
162
- return -2;
163
- }
164
- else {
165
- if (!this.current_t.cronjob) {
166
- return this.SkipTask();
167
- }
168
- const min = Math.min(v, this.current_cron.length);
169
- for (let i = 0; i < min; i++) {
170
- const ps = this.current_cron[i].work.filter(y => y.state != interface_1.ExecuteState.FINISH && y.state != interface_1.ExecuteState.ERROR);
171
- ps.forEach(x => x.state = interface_1.ExecuteState.FINISH);
172
- }
173
- return min;
174
- }
175
- };
176
- this.jumpProject = (forward) => {
177
- if (this.current_projects.length == 0) {
178
- console.error("There is no project exists");
179
- return -2;
180
- }
181
- if (this.current_p == undefined) {
182
- return forward ? this.skipProjectFirst() : -2;
183
- }
184
- else {
185
- return this._jumpProject(forward);
186
- }
187
- };
188
- this.jumpTask = (forward) => {
189
- if (this.current_p == undefined)
190
- return -2;
191
- if (this.current_t == undefined) {
192
- return forward ? this.skipTaskFirst() : this.previousTaskFirst();
193
- }
194
- else {
195
- return forward ? this.skipTask() : this.previousTask();
114
+ this.proxy?.executeSubtaskUpdate([this.current_t, element.id - 1, '', interface_1.ExecuteState.NONE]);
115
+ });
116
+ }
117
+ source.current_job = [];
118
+ };
119
+ ClearState = (task_index) => {
120
+ if (this.current_p == undefined)
121
+ return;
122
+ if (this.current_t == undefined)
123
+ return;
124
+ if (this.current_job.length > 0) {
125
+ this.current_job = [];
126
+ this.proxy?.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
127
+ }
128
+ else if (this.current_cron.length > 0) {
129
+ const target = this.current_cron[task_index];
130
+ target.work.forEach(x => {
131
+ x.uuid = '';
132
+ x.state = interface_1.ExecuteState.NONE;
133
+ });
134
+ this.proxy?.executeSubtaskUpdate([this.current_t, target.id - 1, '', interface_1.ExecuteState.NONE]);
135
+ }
136
+ };
137
+ SkipProject = () => {
138
+ return this.jumpProject(true);
139
+ };
140
+ PreviousProject = () => {
141
+ return this.jumpProject(false);
142
+ };
143
+ SkipTask = () => {
144
+ return this.jumpTask(true);
145
+ };
146
+ PreviousTask = () => {
147
+ return this.jumpTask(false);
148
+ };
149
+ SkipSubTask = (v) => {
150
+ if (this.current_p == undefined) {
151
+ console.error("No project exist, Skip failed");
152
+ return -2;
153
+ }
154
+ if (this.current_t == undefined) {
155
+ console.error("Project has no task, Skip failed");
156
+ return -2;
157
+ }
158
+ else {
159
+ if (!this.current_t.cronjob) {
160
+ return this.SkipTask();
196
161
  }
197
- };
198
- this.skipProjectFirst = () => {
199
- var _a;
200
- this.current_p = this.current_projects[1];
201
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectStart([this.current_p, 1]);
202
- this.SyncDatabase(this.current_p);
203
- this.state = interface_1.ExecuteState.RUNNING;
204
- return 1;
205
- };
206
- this._jumpProject = (forward) => {
207
- var _a, _b;
208
- const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
209
- if (forward)
210
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectFinish([this.current_p, index]);
211
- const atend = forward ? index == this.current_projects.length - 1 : index == 0;
212
- if (atend) {
213
- if (forward) {
214
- this.current_p = undefined;
215
- this.current_t = undefined;
216
- this.state = interface_1.ExecuteState.FINISH;
217
- this.messager_log(`[Execute] Skip project to Finish !`);
218
- }
219
- else {
220
- this.current_p = this.current_projects[0];
221
- this.current_t = undefined;
222
- this.state = interface_1.ExecuteState.RUNNING;
223
- this.messager_log(`[Execute] Previous project to Begining !`);
224
- }
225
- return -1;
162
+ const min = Math.min(v, this.current_cron.length);
163
+ for (let i = 0; i < min; i++) {
164
+ const ps = this.current_cron[i].work.filter(y => y.state != interface_1.ExecuteState.FINISH && y.state != interface_1.ExecuteState.ERROR);
165
+ ps.forEach(x => x.state = interface_1.ExecuteState.FINISH);
226
166
  }
227
- else {
228
- const next = forward ? this.current_projects[index + 1] : this.current_projects[index - 1];
229
- this.current_p = next;
167
+ return min;
168
+ }
169
+ };
170
+ jumpProject = (forward) => {
171
+ if (this.current_projects.length == 0) {
172
+ console.error("There is no project exists");
173
+ return -2;
174
+ }
175
+ if (this.current_p == undefined) {
176
+ return forward ? this.skipProjectFirst() : -2;
177
+ }
178
+ else {
179
+ return this._jumpProject(forward);
180
+ }
181
+ };
182
+ jumpTask = (forward) => {
183
+ if (this.current_p == undefined)
184
+ return -2;
185
+ if (this.current_t == undefined) {
186
+ return forward ? this.skipTaskFirst() : this.previousTaskFirst();
187
+ }
188
+ else {
189
+ return forward ? this.skipTask() : this.previousTask();
190
+ }
191
+ };
192
+ skipProjectFirst = () => {
193
+ this.current_p = this.current_projects[1];
194
+ this.proxy?.executeProjectStart([this.current_p, 1]);
195
+ this.SyncDatabase(this.current_p);
196
+ this.state = interface_1.ExecuteState.RUNNING;
197
+ return 1;
198
+ };
199
+ _jumpProject = (forward) => {
200
+ const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
201
+ if (forward)
202
+ this.proxy?.executeProjectFinish([this.current_p, index]);
203
+ const atend = forward ? index == this.current_projects.length - 1 : index == 0;
204
+ if (atend) {
205
+ if (forward) {
206
+ this.current_p = undefined;
230
207
  this.current_t = undefined;
231
- this.state = interface_1.ExecuteState.RUNNING;
232
- if (forward) {
233
- this.messager_log(`[Execute] Skip project ${index}. ${this.current_p.uuid}`);
234
- }
235
- else {
236
- this.messager_log(`[Execute] Previous project ${index}. ${this.current_p.uuid}`);
237
- }
238
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeProjectStart([this.current_p, index + (forward ? 1 : -1)]);
239
- this.SyncDatabase(this.current_p);
240
- return index;
241
- }
242
- };
243
- this.skipTaskFirst = () => {
244
- var _a;
245
- if (this.current_p.task.length > 0) {
246
- this.current_t = this.current_p.task[0];
247
- const taskCount = this.get_task_state_count(this.current_t);
248
- if (this.current_t.cronjob) {
249
- this.Init_CronContainer(this.current_t, taskCount);
250
- }
251
- this.t_state = interface_1.ExecuteState.NONE;
252
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([this.current_t, taskCount]);
253
- return 0;
208
+ this.state = interface_1.ExecuteState.FINISH;
209
+ this.messager_log(`[Execute] Skip project to Finish !`);
254
210
  }
255
211
  else {
256
- console.error("Project has no task, Skip failed");
257
- return -2;
258
- }
259
- };
260
- this.previousTaskFirst = () => {
261
- const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
262
- if (index == 0) {
212
+ this.current_p = this.current_projects[0];
263
213
  this.current_t = undefined;
214
+ this.state = interface_1.ExecuteState.RUNNING;
215
+ this.messager_log(`[Execute] Previous project to Begining !`);
264
216
  }
265
- else {
266
- this.current_p = this.current_projects[index - 1];
267
- this.messager_log(`[Execute] Previous task ${index}. Jump Project: ${this.current_p.uuid}`);
268
- }
269
- this.current_job = [];
270
- this.t_state = interface_1.ExecuteState.NONE;
271
- return index;
272
- };
273
- this.skipTask = () => {
274
- var _a, _b, _c;
275
- const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
276
- if (index == this.current_p.task.length - 1) {
277
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskFinish(this.current_t);
278
- this.current_t = undefined;
279
- this.messager_log(`[Execute] Skip task to Finish !`);
217
+ return -1;
218
+ }
219
+ else {
220
+ const next = forward ? this.current_projects[index + 1] : this.current_projects[index - 1];
221
+ this.current_p = next;
222
+ this.current_t = undefined;
223
+ this.state = interface_1.ExecuteState.RUNNING;
224
+ if (forward) {
225
+ this.messager_log(`[Execute] Skip project ${index}. ${this.current_p.uuid}`);
280
226
  }
281
227
  else {
282
- (_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeTaskFinish(this.current_t);
283
- this.current_t = this.current_p.task[index + 1];
284
- this.messager_log(`[Execute] Skip task ${index}. ${this.current_t.uuid}`);
285
- const taskCount = this.get_task_state_count(this.current_t);
286
- if (this.current_t.cronjob) {
287
- this.Init_CronContainer(this.current_t, taskCount);
288
- }
289
- (_c = this.proxy) === null || _c === void 0 ? void 0 : _c.executeTaskStart([this.current_t, taskCount]);
228
+ this.messager_log(`[Execute] Previous project ${index}. ${this.current_p.uuid}`);
290
229
  }
291
- this.current_job = [];
292
- this.t_state = interface_1.ExecuteState.NONE;
230
+ this.proxy?.executeProjectStart([this.current_p, index + (forward ? 1 : -1)]);
231
+ this.SyncDatabase(this.current_p);
293
232
  return index;
294
- };
295
- this.previousTask = () => {
296
- var _a;
297
- const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
298
- this.current_t = this.current_p.task[index - 1];
233
+ }
234
+ };
235
+ skipTaskFirst = () => {
236
+ if (this.current_p.task.length > 0) {
237
+ this.current_t = this.current_p.task[0];
299
238
  const taskCount = this.get_task_state_count(this.current_t);
300
239
  if (this.current_t.cronjob) {
301
240
  this.Init_CronContainer(this.current_t, taskCount);
302
241
  }
303
242
  this.t_state = interface_1.ExecuteState.NONE;
304
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([this.current_t, taskCount]);
243
+ this.proxy?.executeTaskStart([this.current_t, taskCount]);
305
244
  return 0;
306
- };
307
- }
245
+ }
246
+ else {
247
+ console.error("Project has no task, Skip failed");
248
+ return -2;
249
+ }
250
+ };
251
+ previousTaskFirst = () => {
252
+ const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
253
+ if (index == 0) {
254
+ this.current_t = undefined;
255
+ }
256
+ else {
257
+ this.current_p = this.current_projects[index - 1];
258
+ this.messager_log(`[Execute] Previous task ${index}. Jump Project: ${this.current_p.uuid}`);
259
+ }
260
+ this.current_job = [];
261
+ this.t_state = interface_1.ExecuteState.NONE;
262
+ return index;
263
+ };
264
+ skipTask = () => {
265
+ const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
266
+ if (index == this.current_p.task.length - 1) {
267
+ this.proxy?.executeTaskFinish(this.current_t);
268
+ this.current_t = undefined;
269
+ this.messager_log(`[Execute] Skip task to Finish !`);
270
+ }
271
+ else {
272
+ this.proxy?.executeTaskFinish(this.current_t);
273
+ this.current_t = this.current_p.task[index + 1];
274
+ this.messager_log(`[Execute] Skip task ${index}. ${this.current_t.uuid}`);
275
+ const taskCount = this.get_task_state_count(this.current_t);
276
+ if (this.current_t.cronjob) {
277
+ this.Init_CronContainer(this.current_t, taskCount);
278
+ }
279
+ this.proxy?.executeTaskStart([this.current_t, taskCount]);
280
+ }
281
+ this.current_job = [];
282
+ this.t_state = interface_1.ExecuteState.NONE;
283
+ return index;
284
+ };
285
+ previousTask = () => {
286
+ const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
287
+ this.current_t = this.current_p.task[index - 1];
288
+ const taskCount = this.get_task_state_count(this.current_t);
289
+ if (this.current_t.cronjob) {
290
+ this.Init_CronContainer(this.current_t, taskCount);
291
+ }
292
+ this.t_state = interface_1.ExecuteState.NONE;
293
+ this.proxy?.executeTaskStart([this.current_t, taskCount]);
294
+ return 0;
295
+ };
308
296
  }
309
297
  exports.ExecuteManager = ExecuteManager;
@@ -0,0 +1,31 @@
1
+ import { Node, NodeProxy, NodeTable, WebsocketPack } from "../interface";
2
+ import * as ws from 'ws';
3
+ export declare class WebsocketManager {
4
+ targets: Array<WebsocketPack>;
5
+ newConnect: Function;
6
+ disconnect: Function;
7
+ onAnalysis: Function;
8
+ proxy: NodeProxy;
9
+ private messager_log;
10
+ constructor(_newConnect: Function, _disconnect: Function, _onAnalysis: Function, _messager_log: Function, _proxy: NodeProxy);
11
+ server_start: (url: string, id: string) => WebSocket | ws.WebSocket | undefined;
12
+ server_stop: (uuid: string, reason?: string) => void;
13
+ server_update: () => Array<NodeTable>;
14
+ server_record: (ns: Array<Node>) => void;
15
+ shell_open: (uuid: string) => void;
16
+ shell_enter: (uuid: string, text: string) => void;
17
+ shell_close: (uuid: string) => void;
18
+ shell_folder: (uuid: string, path: string) => void;
19
+ private serverconnect;
20
+ private analysis;
21
+ private socket_analysis;
22
+ private sendUpdate;
23
+ private removeByUUID;
24
+ private update;
25
+ private shell_reply;
26
+ private shell_folder_reply;
27
+ private system_info;
28
+ private node_info;
29
+ private pong;
30
+ private plugin_info_reply;
31
+ }