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
@@ -5,141 +5,132 @@ const uuid_1 = require("uuid");
5
5
  const interface_1 = require("../../interface");
6
6
  const util_parser_1 = require("./util_parser");
7
7
  class ExecuteManager_Base {
8
+ uuid;
9
+ name;
10
+ record;
11
+ current_t = undefined;
12
+ current_p = undefined;
13
+ current_projects = [];
14
+ current_nodes = [];
15
+ current_cron = [];
16
+ current_job = [];
17
+ current_multithread = 1;
18
+ current_task_count = -1;
19
+ state = interface_1.ExecuteState.NONE;
20
+ t_state = interface_1.ExecuteState.NONE;
21
+ jobstack = 0;
22
+ first = false;
23
+ libs = undefined;
24
+ proxy = undefined;
25
+ localPara = undefined;
26
+ websocket_manager;
27
+ messager_log;
8
28
  constructor(_name, _websocket_manager, _messager_log, _record) {
9
- this.current_t = undefined;
10
- this.current_p = undefined;
11
- this.current_projects = [];
12
- this.current_nodes = [];
13
- this.current_cron = [];
14
- this.current_job = [];
15
- this.current_multithread = 1;
16
- this.current_task_count = -1;
17
- this.state = interface_1.ExecuteState.NONE;
18
- this.t_state = interface_1.ExecuteState.NONE;
19
- this.jobstack = 0;
20
- this.first = false;
21
- this.libs = undefined;
22
- this.proxy = undefined;
23
- this.localPara = undefined;
24
- this.sync_local_para = (target) => {
25
- var _a;
26
- this.current_nodes.forEach(x => this.sync_para(target, x));
27
- (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.updateDatabase(target);
28
- };
29
- this.sync_para = (target, source) => {
30
- const h = {
31
- name: 'set_database',
32
- channel: this.uuid,
33
- data: target
34
- };
35
- const h2 = {
36
- name: 'set_libs',
37
- channel: this.uuid,
38
- data: this.libs
39
- };
40
- source.websocket.send(JSON.stringify(h));
41
- source.websocket.send(JSON.stringify(h2));
42
- };
43
- this.release = (source) => {
44
- const h = {
45
- name: 'release',
46
- channel: this.uuid,
47
- data: 0
48
- };
49
- source.websocket.send(JSON.stringify(h));
50
- };
51
- this.check_all_cron_end = () => {
52
- return this.current_cron.filter(x => !this.check_cron_end(x)).length == 0;
29
+ this.name = _name;
30
+ this.uuid = (0, uuid_1.v6)();
31
+ this.record = _record;
32
+ this.websocket_manager = _websocket_manager;
33
+ this.messager_log = _messager_log;
34
+ }
35
+ sync_local_para = (target) => {
36
+ this.current_nodes.forEach(x => this.sync_para(target, x));
37
+ this.proxy?.updateDatabase(target);
38
+ };
39
+ sync_para = (target, source) => {
40
+ const h = {
41
+ name: 'set_database',
42
+ channel: this.uuid,
43
+ data: target
53
44
  };
54
- this.check_cron_end = (cron) => {
55
- return cron.work.filter(x => x.state == interface_1.ExecuteState.RUNNING || x.state == interface_1.ExecuteState.NONE).length == 0;
45
+ const h2 = {
46
+ name: 'set_libs',
47
+ channel: this.uuid,
48
+ data: this.libs
56
49
  };
57
- this.check_single_end = () => {
58
- if (this.current_t == undefined)
59
- return false;
60
- return this.current_job.length == this.current_t.jobs.length &&
61
- this.current_job.filter(y => y.state == interface_1.ExecuteState.RUNNING || y.state == interface_1.ExecuteState.NONE).length == 0;
50
+ source.websocket.send(JSON.stringify(h));
51
+ source.websocket.send(JSON.stringify(h2));
52
+ };
53
+ release = (source) => {
54
+ const h = {
55
+ name: 'release',
56
+ channel: this.uuid,
57
+ data: 0
62
58
  };
63
- this.validation = (projects) => {
64
- if (this.websocket_manager.targets.length == 0) {
65
- this.messager_log(`[Execute State] The execute node does not exists`);
66
- return false;
67
- }
68
- projects.forEach(x => {
69
- x.task.forEach(t => {
70
- var _a, _b, _c, _d, _e, _f;
71
- if (t.cronjob) {
72
- const index = (_b = (_a = x.database) === null || _a === void 0 ? void 0 : _a.containers.findIndex(x => x.name == t.cronjobKey && x.type == interface_1.DataType.Number)) !== null && _b !== void 0 ? _b : -1;
73
- if (index == -1) {
74
- this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
75
- this.messager_log(`[Execute:CronJob] Cron task registerd key not found`);
76
- return false;
77
- }
78
- else if (((_c = x.database) === null || _c === void 0 ? void 0 : _c.containers[index].value) == 0) {
79
- this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
80
- this.messager_log(`[Execute:CronJob] Cron task value must bigger than 0`);
81
- return false;
82
- }
59
+ source.websocket.send(JSON.stringify(h));
60
+ };
61
+ check_all_cron_end = () => {
62
+ return this.current_cron.filter(x => !this.check_cron_end(x)).length == 0;
63
+ };
64
+ check_cron_end = (cron) => {
65
+ return cron.work.filter(x => x.state == interface_1.ExecuteState.RUNNING || x.state == interface_1.ExecuteState.NONE).length == 0;
66
+ };
67
+ check_single_end = () => {
68
+ if (this.current_t == undefined)
69
+ return false;
70
+ return this.current_job.length == this.current_t.jobs.length &&
71
+ this.current_job.filter(y => y.state == interface_1.ExecuteState.RUNNING || y.state == interface_1.ExecuteState.NONE).length == 0;
72
+ };
73
+ validation = (projects) => {
74
+ if (this.websocket_manager.targets.length == 0) {
75
+ this.messager_log(`[Execute State] The execute node does not exists`);
76
+ return false;
77
+ }
78
+ projects.forEach(x => {
79
+ x.task.forEach(t => {
80
+ if (t.cronjob) {
81
+ const index = x.database?.containers.findIndex(x => x.name == t.cronjobKey && x.type == interface_1.DataType.Number) ?? -1;
82
+ if (index == -1) {
83
+ this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
84
+ this.messager_log(`[Execute:CronJob] Cron task registerd key not found`);
85
+ return false;
83
86
  }
84
- if (t.cronjob && t.multi) {
85
- const index = (_e = (_d = x.database) === null || _d === void 0 ? void 0 : _d.containers.findIndex(x => x.name == t.multiKey && x.type == interface_1.DataType.Number)) !== null && _e !== void 0 ? _e : -1;
86
- if (index == -1) {
87
- this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
88
- this.messager_log(`[Execute:Multi] Cron task registerd key not found`);
89
- return false;
90
- }
91
- else if (((_f = x.database) === null || _f === void 0 ? void 0 : _f.containers[index].value) == 0) {
92
- this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
93
- this.messager_log(`[Execute:Multi] Cron task value must bigger than 0`);
94
- return false;
95
- }
87
+ else if (x.database?.containers[index].value == 0) {
88
+ this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
89
+ this.messager_log(`[Execute:CronJob] Cron task value must bigger than 0`);
90
+ return false;
96
91
  }
97
- });
92
+ }
93
+ if (t.cronjob && t.multi) {
94
+ const index = x.database?.containers.findIndex(x => x.name == t.multiKey && x.type == interface_1.DataType.Number) ?? -1;
95
+ if (index == -1) {
96
+ this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
97
+ this.messager_log(`[Execute:Multi] Cron task registerd key not found`);
98
+ return false;
99
+ }
100
+ else if (x.database?.containers[index].value == 0) {
101
+ this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
102
+ this.messager_log(`[Execute:Multi] Cron task value must bigger than 0`);
103
+ return false;
104
+ }
105
+ }
98
106
  });
99
- return true;
100
- };
101
- this.filter_lib = (projects, lib) => {
102
- const r = { libs: [] };
103
- projects.forEach(x => {
104
- x.task.forEach(y => {
105
- y.jobs.forEach(z => {
106
- let code = -1;
107
- if ((z.category == interface_1.JobCategory.Execution && z.type == interface_1.JobType.JAVASCRIPT) || (z.category == interface_1.JobCategory.Condition && z.type == interface_1.JobType2.JAVASCRIPT))
108
- code = 0;
109
- if (code == -1)
110
- return;
111
- z.string_args.forEach(s1 => {
112
- const target = lib.libs.find(l => l.name == s1);
113
- if (target != undefined)
114
- r.libs.push(target);
115
- });
107
+ });
108
+ return true;
109
+ };
110
+ filter_lib = (projects, lib) => {
111
+ const r = { libs: [] };
112
+ projects.forEach(x => {
113
+ x.task.forEach(y => {
114
+ y.jobs.forEach(z => {
115
+ let code = -1;
116
+ if ((z.category == interface_1.JobCategory.Execution && z.type == interface_1.JobType.JAVASCRIPT) || (z.category == interface_1.JobCategory.Condition && z.type == interface_1.JobType2.JAVASCRIPT))
117
+ code = 0;
118
+ if (code == -1)
119
+ return;
120
+ z.string_args.forEach(s1 => {
121
+ const target = lib.libs.find(l => l.name == s1);
122
+ if (target != undefined)
123
+ r.libs.push(target);
116
124
  });
117
125
  });
118
126
  });
119
- return JSON.parse(JSON.stringify(r));
120
- };
121
- this.get_task_multi_count = (t) => {
122
- const r = this.get_number(t.multiKey);
123
- return r == -1 ? 1 : r;
124
- };
125
- this.removeDups = (arr) => {
126
- return [...new Set(arr)];
127
- };
128
- this.get_idle = () => {
129
- return this.current_nodes.filter(x => this.check_socket_state(x) != interface_1.ExecuteState.RUNNING && x.websocket.readyState == 1);
130
- };
131
- this.get_idle_open = () => {
132
- return this.current_nodes.filter(x => x.websocket.readyState == 1);
133
- };
134
- this.check_socket_state = (target) => {
135
- return target.current_job.length == 0 ? interface_1.ExecuteState.NONE : interface_1.ExecuteState.RUNNING;
136
- };
137
- this.name = _name;
138
- this.uuid = (0, uuid_1.v6)();
139
- this.record = _record;
140
- this.websocket_manager = _websocket_manager;
141
- this.messager_log = _messager_log;
142
- }
127
+ });
128
+ return JSON.parse(JSON.stringify(r));
129
+ };
130
+ get_task_multi_count = (t) => {
131
+ const r = this.get_number(t.multiKey);
132
+ return r == -1 ? 1 : r;
133
+ };
143
134
  get_task_state_count(t) {
144
135
  if (t.setupjob)
145
136
  return this.current_nodes.length;
@@ -156,42 +147,54 @@ class ExecuteManager_Base {
156
147
  const a = e.replacePara(`%{${key}}%`);
157
148
  return Number(a);
158
149
  }
150
+ removeDups = (arr) => {
151
+ return [...new Set(arr)];
152
+ };
153
+ get_idle = () => {
154
+ return this.current_nodes.filter(x => this.check_socket_state(x) != interface_1.ExecuteState.RUNNING && x.websocket.readyState == 1);
155
+ };
156
+ get_idle_open = () => {
157
+ return this.current_nodes.filter(x => x.websocket.readyState == 1);
158
+ };
159
+ check_socket_state = (target) => {
160
+ return target.current_job.length == 0 ? interface_1.ExecuteState.NONE : interface_1.ExecuteState.RUNNING;
161
+ };
162
+ static string_args_transform = (task, job, messager_log, localPara, n) => {
163
+ let e = ExecuteManager_Base.database_update(localPara, n);
164
+ e = ExecuteManager_Base.property_update(task, e);
165
+ for (let i = 0; i < job.string_args.length; i++) {
166
+ const b = job.string_args[i];
167
+ if (b == null || b == undefined || b.length == 0)
168
+ continue;
169
+ if (job.category == interface_1.JobCategory.Execution && job.type == interface_1.JobType.CREATE_FILE && i == 1)
170
+ continue;
171
+ job.string_args[i] = e.replacePara(job.string_args[i]);
172
+ }
173
+ };
174
+ static property_update = (task, e) => {
175
+ for (let j = 0; j < task.properties.length; j++) {
176
+ const target = task.properties[j];
177
+ const times = target.deep ? target.deep : 1;
178
+ let act = target.expression;
179
+ for (let k = 0; k < times; k++) {
180
+ act = e.replacePara(`%{${act}}%`);
181
+ }
182
+ e.paras.push({ key: task.properties[j].name, value: act });
183
+ }
184
+ return e;
185
+ };
186
+ static database_update = (localPara, n) => {
187
+ const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(localPara)]);
188
+ if (n != undefined) {
189
+ e.paras.push({ key: 'ck', value: n.toString() });
190
+ }
191
+ localPara.containers.forEach((c, index) => {
192
+ if (c.type != interface_1.DataType.Expression)
193
+ return;
194
+ c.value = e.replacePara(`%{${c.meta}}%`);
195
+ e.paras.find(p => p.key == c.name).value = c.value;
196
+ });
197
+ return e;
198
+ };
159
199
  }
160
200
  exports.ExecuteManager_Base = ExecuteManager_Base;
161
- ExecuteManager_Base.string_args_transform = (task, job, messager_log, localPara, n) => {
162
- let e = ExecuteManager_Base.database_update(localPara, n);
163
- e = ExecuteManager_Base.property_update(task, e);
164
- for (let i = 0; i < job.string_args.length; i++) {
165
- const b = job.string_args[i];
166
- if (b == null || b == undefined || b.length == 0)
167
- continue;
168
- if (job.category == interface_1.JobCategory.Execution && job.type == interface_1.JobType.CREATE_FILE && i == 1)
169
- continue;
170
- job.string_args[i] = e.replacePara(job.string_args[i]);
171
- }
172
- };
173
- ExecuteManager_Base.property_update = (task, e) => {
174
- for (let j = 0; j < task.properties.length; j++) {
175
- const target = task.properties[j];
176
- const times = target.deep ? target.deep : 1;
177
- let act = target.expression;
178
- for (let k = 0; k < times; k++) {
179
- act = e.replacePara(`%{${act}}%`);
180
- }
181
- e.paras.push({ key: task.properties[j].name, value: act });
182
- }
183
- return e;
184
- };
185
- ExecuteManager_Base.database_update = (localPara, n) => {
186
- const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(localPara)]);
187
- if (n != undefined) {
188
- e.paras.push({ key: 'ck', value: n.toString() });
189
- }
190
- localPara.containers.forEach((c, index) => {
191
- if (c.type != interface_1.DataType.Expression)
192
- return;
193
- c.value = e.replacePara(`%{${c.meta}}%`);
194
- e.paras.find(p => p.key == c.name).value = c.value;
195
- });
196
- return e;
197
- };
@@ -0,0 +1,12 @@
1
+ import { BusAnalysis } from "../../interface";
2
+ import { ExecuteManager_Base } from "./base";
3
+ export declare class ExecuteManager_Feedback extends ExecuteManager_Base {
4
+ Analysis: (d: BusAnalysis) => void;
5
+ private feedback_message;
6
+ private feedback_job;
7
+ private feedback_string;
8
+ private feedback_number;
9
+ private feedback_object;
10
+ private feedback_boolean;
11
+ private GetCronAndWork;
12
+ }