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.
Files changed (142) hide show
  1. package/dist/client/analysis.d.ts +35 -0
  2. package/dist/client/analysis.js +382 -0
  3. package/dist/client/client.d.ts +25 -0
  4. package/dist/client/client.js +227 -0
  5. package/dist/client/cluster.d.ts +1 -0
  6. package/dist/{src/client → client}/cluster.js +1 -2
  7. package/dist/client/database.d.ts +13 -0
  8. package/dist/client/database.js +37 -0
  9. package/dist/client/execute.d.ts +24 -0
  10. package/dist/{src/client → client}/execute.js +61 -51
  11. package/dist/client/http.d.ts +7 -0
  12. package/dist/client/http.js +40 -0
  13. package/dist/client/javascript.d.ts +47 -0
  14. package/dist/{src/client → client}/javascript.js +110 -136
  15. package/dist/client/job_database.d.ts +10 -0
  16. package/dist/client/job_database.js +34 -0
  17. package/dist/client/job_execute.d.ts +20 -0
  18. package/dist/client/job_execute.js +173 -0
  19. package/dist/client/os.d.ts +29 -0
  20. package/dist/client/os.js +197 -0
  21. package/dist/client/resource.d.ts +7 -0
  22. package/dist/client/resource.js +107 -0
  23. package/dist/client/shell.d.ts +16 -0
  24. package/dist/client/shell.js +122 -0
  25. package/dist/computed.d.ts +13 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.js +3 -3
  28. package/dist/interface/base.d.ts +70 -0
  29. package/dist/interface/bus.d.ts +90 -0
  30. package/dist/interface/enum.d.ts +143 -0
  31. package/dist/interface/execute.d.ts +20 -0
  32. package/dist/interface/record.d.ts +93 -0
  33. package/dist/interface/server.d.ts +76 -0
  34. package/dist/interface/struct.d.ts +182 -0
  35. package/dist/interface/table.d.ts +20 -0
  36. package/dist/interface/ui.d.ts +29 -0
  37. package/dist/interface.d.ts +29 -0
  38. package/dist/plugins/i18n.d.ts +1666 -0
  39. package/dist/script/console_manager.d.ts +18 -0
  40. package/dist/script/console_manager.js +131 -0
  41. package/dist/script/console_server_manager.d.ts +13 -0
  42. package/dist/script/console_server_manager.js +40 -0
  43. package/dist/script/execute/base.d.ts +45 -0
  44. package/dist/script/execute/base.js +200 -0
  45. package/dist/script/execute/feedback.d.ts +12 -0
  46. package/dist/script/execute/feedback.js +179 -0
  47. package/dist/script/execute/interface.d.ts +8 -0
  48. package/dist/script/execute/region_job.d.ts +5 -0
  49. package/dist/{src/script → script}/execute/region_job.js +1 -0
  50. package/dist/script/execute/region_project.d.ts +10 -0
  51. package/dist/{src/script → script}/execute/region_project.js +4 -0
  52. package/dist/script/execute/region_subtask.d.ts +5 -0
  53. package/dist/{src/script → script}/execute/region_subtask.js +1 -0
  54. package/dist/script/execute/region_task.d.ts +10 -0
  55. package/dist/{src/script → script}/execute/region_task.js +4 -0
  56. package/dist/script/execute/runner.d.ts +14 -0
  57. package/dist/script/execute/runner.js +264 -0
  58. package/dist/script/execute/util_parser.d.ts +14 -0
  59. package/dist/script/execute/util_parser.js +135 -0
  60. package/dist/script/execute_manager.d.ts +25 -0
  61. package/dist/script/execute_manager.js +297 -0
  62. package/dist/script/socket_manager.d.ts +31 -0
  63. package/dist/script/socket_manager.js +263 -0
  64. package/dist/script/webhook_manager.d.ts +3 -0
  65. package/dist/script/webhook_server_manager.d.ts +13 -0
  66. package/dist/script/webhook_server_manager.js +133 -0
  67. package/dist/server/detail.d.ts +72 -0
  68. package/dist/server/detail.js +451 -0
  69. package/dist/server/io.d.ts +46 -0
  70. package/dist/{src/server → server}/io.js +42 -51
  71. package/dist/server/plugin.d.ts +18 -0
  72. package/dist/{src/server → server}/plugin.js +45 -54
  73. package/dist/server/server.d.ts +27 -0
  74. package/dist/server/server.js +53 -0
  75. package/dist/server.d.ts +4 -0
  76. package/dist/util/console_handle.d.ts +20 -0
  77. package/dist/util/console_handle.js +244 -0
  78. package/dist/util/log_handle.d.ts +23 -0
  79. package/dist/util/log_handle.js +224 -0
  80. package/index.ts +1 -6
  81. package/package.json +1 -1
  82. package/src/index.ts +6 -0
  83. package/test/TEST.d.ts +1 -0
  84. package/test/TEST.js +88 -0
  85. package/test/client/execute.test.d.ts +1 -0
  86. package/{dist/test → test}/client/execute.test.js +6 -15
  87. package/test/client/javascript.test.d.ts +1 -0
  88. package/{dist/test → test}/client/javascript.test.js +21 -30
  89. package/test/client/server.test.d.ts +1 -0
  90. package/test/client/task.test.d.ts +1 -0
  91. package/{dist/test → test}/client/task.test.js +1 -1
  92. package/test/script/parser.test.d.ts +1 -0
  93. package/test/script/socket.test.d.ts +1 -0
  94. package/tsconfig.json +8 -4
  95. package/dist/jest.config.js +0 -8
  96. package/dist/src/client/analysis.js +0 -383
  97. package/dist/src/client/client.js +0 -233
  98. package/dist/src/client/database.js +0 -36
  99. package/dist/src/client/http.js +0 -37
  100. package/dist/src/client/job_database.js +0 -36
  101. package/dist/src/client/job_execute.js +0 -171
  102. package/dist/src/client/job_parameter.js +0 -36
  103. package/dist/src/client/os.js +0 -202
  104. package/dist/src/client/parameter.js +0 -36
  105. package/dist/src/client/resource.js +0 -118
  106. package/dist/src/client/shell.js +0 -118
  107. package/dist/src/script/console_manager.js +0 -125
  108. package/dist/src/script/console_server_manager.js +0 -37
  109. package/dist/src/script/execute/base.js +0 -197
  110. package/dist/src/script/execute/feedback.js +0 -188
  111. package/dist/src/script/execute/runner.js +0 -274
  112. package/dist/src/script/execute/util_parser.js +0 -137
  113. package/dist/src/script/execute_manager.js +0 -309
  114. package/dist/src/script/socket_manager.js +0 -260
  115. package/dist/src/script/webhook_server_manager.js +0 -140
  116. package/dist/src/server/detail.js +0 -428
  117. package/dist/src/server/server.js +0 -51
  118. package/dist/src/util/console_handle.js +0 -248
  119. package/dist/src/util/log_handle.js +0 -230
  120. package/dist/src/util/server/console_handle.js +0 -248
  121. package/dist/src/util/server/log_handle.js +0 -230
  122. package/dist/test/TEST.js +0 -105
  123. /package/dist/{src/computed.js → computed.js} +0 -0
  124. /package/dist/{src/interface → interface}/base.js +0 -0
  125. /package/dist/{src/interface → interface}/bus.js +0 -0
  126. /package/dist/{src/interface → interface}/enum.js +0 -0
  127. /package/dist/{src/interface → interface}/execute.js +0 -0
  128. /package/dist/{src/interface → interface}/record.js +0 -0
  129. /package/dist/{src/interface → interface}/server.js +0 -0
  130. /package/dist/{src/interface → interface}/struct.js +0 -0
  131. /package/dist/{src/interface → interface}/table.js +0 -0
  132. /package/dist/{src/interface → interface}/ui.js +0 -0
  133. /package/dist/{src/interface.js → interface.js} +0 -0
  134. /package/dist/{src/lan → lan}/en.json +0 -0
  135. /package/dist/{src/lan → lan}/zh_TW.json +0 -0
  136. /package/dist/{src/plugins → plugins}/i18n.js +0 -0
  137. /package/dist/{src/script → script}/execute/interface.js +0 -0
  138. /package/dist/{src/script → script}/webhook_manager.js +0 -0
  139. /package/dist/{src/server.js → server.js} +0 -0
  140. /package/{dist/test → test}/client/server.test.js +0 -0
  141. /package/{dist/test → test}/script/parser.test.js +0 -0
  142. /package/{dist/test → test}/script/socket.test.js +0 -0
@@ -1,248 +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
- constructor() {
7
- this.receivedPack = (model, record) => {
8
- var _a, _b;
9
- const pass = model.manager.Register();
10
- if (pass == -1) {
11
- model.record.running = false;
12
- model.record.stop = true;
13
- return false;
14
- }
15
- model.record.projects = record.projects;
16
- model.record.nodes = record.nodes;
17
- model.record.project_state = model.record.projects.map(x => {
18
- return {
19
- uuid: x.uuid,
20
- state: interface_1.ExecuteState.NONE
21
- };
22
- });
23
- model.record.project_index = pass;
24
- model.record.project = record.projects[pass].uuid;
25
- model.record.task_index = 0;
26
- model.record.task_state = model.record.projects[0].task.map(x => {
27
- return {
28
- uuid: x.uuid,
29
- state: interface_1.ExecuteState.NONE
30
- };
31
- });
32
- model.record.task_state[0].state = interface_1.ExecuteState.RUNNING;
33
- model.record.task_detail = [];
34
- const task = (_a = model.record.projects[model.record.project_index]) === null || _a === void 0 ? void 0 : _a.task[model.record.task_index];
35
- const count = task.cronjob ? ((_b = task === null || task === void 0 ? void 0 : task.jobs.length) !== null && _b !== void 0 ? _b : 0) : 1;
36
- for (let i = 0; i < count; i++) {
37
- model.record.task_detail.push({
38
- index: i,
39
- node: "",
40
- message: [],
41
- state: interface_1.ExecuteState.NONE
42
- });
43
- }
44
- model.manager.Update();
45
- return true;
46
- };
47
- }
48
- }
49
- exports.Util_Server_Console = Util_Server_Console;
50
- class Util_Server_Console_Proxy {
51
- constructor(_model) {
52
- this.execute_project_start = (d) => {
53
- var _a, _b;
54
- const index = d[1];
55
- if (index == -1)
56
- return;
57
- this.model.record.project = d[0].uuid;
58
- this.model.record.project_index = index;
59
- this.model.record.project_state[index].state = interface_1.ExecuteState.RUNNING;
60
- this.model.record.task_state = this.model.record.projects[index].task.map(x => {
61
- return {
62
- uuid: x.uuid,
63
- state: interface_1.ExecuteState.NONE
64
- };
65
- });
66
- this.model.record.task_detail = [];
67
- const task = (_a = this.model.record.projects[this.model.record.project_index]) === null || _a === void 0 ? void 0 : _a.task[this.model.record.task_index];
68
- const count = task.cronjob ? ((_b = task === null || task === void 0 ? void 0 : task.jobs.length) !== null && _b !== void 0 ? _b : 0) : 1;
69
- for (let i = 0; i < count; i++) {
70
- this.model.record.task_detail.push({
71
- index: i,
72
- node: "",
73
- message: [],
74
- state: interface_1.ExecuteState.NONE
75
- });
76
- }
77
- console.log("project start: ", this.model.record.projects.length, index);
78
- };
79
- this.execute_project_finish = (d) => {
80
- if (this.model.record.process_type >= 1) {
81
- this.model.record.running = false;
82
- this.model.record.stop = true;
83
- }
84
- const index = d[1];
85
- const size = this.model.record.projects.length;
86
- if (index == -1)
87
- return;
88
- this.model.record.project = "";
89
- this.model.record.project_state[index].state = interface_1.ExecuteState.FINISH;
90
- this.model.record.para = undefined;
91
- console.log("project finish: ", this.model.record.projects.length, index);
92
- if (index == size - 1) {
93
- this.model.record.command.push(['clean']);
94
- }
95
- };
96
- this.execute_task_start = (d) => {
97
- if (this.model.record.project_index == -1)
98
- return;
99
- const index = this.model.record.projects[this.model.record.project_index].task.findIndex(x => x.uuid == d[0].uuid);
100
- if (index == -1)
101
- return;
102
- this.model.record.useCron = d[0].cronjob;
103
- this.model.record.task = d[0].uuid;
104
- this.model.record.task_index = index;
105
- this.model.record.task_state[index].state = interface_1.ExecuteState.RUNNING;
106
- for (let i = 0; i < index; i++)
107
- this.model.record.task_state[i].state = interface_1.ExecuteState.FINISH;
108
- for (let i = index + 1; i < this.model.record.task_state.length; i++)
109
- this.model.record.task_state[i].state = interface_1.ExecuteState.NONE;
110
- this.model.record.task_detail = [];
111
- const p = this.model.record.projects[this.model.record.project_index];
112
- const t = p.task[this.model.record.task_index];
113
- const count = this.model.manager.get_task_state_count(t);
114
- for (let i = 0; i < count; i++) {
115
- this.model.record.task_detail.push({
116
- index: i,
117
- node: "",
118
- message: [],
119
- state: interface_1.ExecuteState.NONE
120
- });
121
- }
122
- };
123
- this.execute_task_finish = (d) => {
124
- if (this.model.record.process_type == 2) {
125
- this.model.record.running = false;
126
- this.model.record.stop = true;
127
- }
128
- if (this.model.record.project_index == -1)
129
- return;
130
- const index = this.model.record.projects[this.model.record.project_index].task.findIndex(x => x.uuid == d.uuid);
131
- if (index == -1)
132
- return;
133
- this.model.record.useCron = false;
134
- this.model.record.task = "";
135
- this.model.record.task_state[index].state = interface_1.ExecuteState.FINISH;
136
- if (index + 1 < this.model.record.task_state.length - 1) {
137
- this.model.record.task_state[index + 1].state = interface_1.ExecuteState.RUNNING;
138
- }
139
- };
140
- this.execute_subtask_start = (d) => {
141
- var _a;
142
- try {
143
- this.model.record.task_detail[d[1]].node = (_a = d[2]) !== null && _a !== void 0 ? _a : '';
144
- this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
145
- }
146
- catch (error) {
147
- console.error(`execute_subtask_start`, error.message);
148
- }
149
- };
150
- this.execute_subtask_update = (d) => {
151
- if (this.model.record.task_detail.length > d[1]) {
152
- this.model.record.task_detail[d[1]].node = d[2];
153
- this.model.record.task_detail[d[1]].state = d[3];
154
- }
155
- else {
156
- console.error(`subtask_start ${d[1]} is out of range: ${this.model.record.task_detail.length}`);
157
- }
158
- };
159
- this.execute_subtask_end = (d) => {
160
- try {
161
- this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
162
- }
163
- catch (error) {
164
- console.error(`execute_subtask_end`, error.message);
165
- }
166
- };
167
- this.execute_job_start = (d) => {
168
- if (this.model.record.project_index == -1)
169
- return;
170
- if (!this.model.record.useCron) {
171
- this.model.record.task_detail[0].node = d[2];
172
- }
173
- };
174
- this.execute_job_finish = (d) => {
175
- if (d[3] == 1) {
176
- const task = this.model.record.projects[this.model.record.project_index].task[this.model.record.task_index];
177
- const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
178
- if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
179
- const cr = task.jobs[index].number_args[0];
180
- if (cr == interface_1.ConditionResult.None)
181
- return;
182
- this.model.record.command.push(['stop']);
183
- let timer;
184
- timer = setInterval(() => {
185
- if (this.model.record.running == false) {
186
- clearInterval(timer);
187
- const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
188
- const target = this.model.record.task_detail[d[1]];
189
- if (target != undefined) {
190
- target.state = state;
191
- }
192
- if (cr == interface_1.ConditionResult.Pause)
193
- return;
194
- if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
195
- this.model.record.command.push(['skip', 0, state]);
196
- if (this.model.record.project.length > 0) {
197
- if (this.model.record.process_type == 0) {
198
- this.model.record.command.push(['execute', this.model.record.process_type]);
199
- }
200
- }
201
- }
202
- else if (cr == interface_1.ConditionResult.SkipTask || cr == interface_1.ConditionResult.ThrowTask) {
203
- this.model.record.command.push(['skip', 1, state]);
204
- if (this.model.record.project.length > 0) {
205
- if (this.model.record.process_type == 0) {
206
- this.model.record.command.push(['execute', this.model.record.process_type]);
207
- }
208
- }
209
- }
210
- }
211
- }, 1000);
212
- }
213
- }
214
- };
215
- this.feedback_message = (d) => {
216
- if (d.index == undefined || d.index == -1)
217
- return;
218
- const container = this.model.record.task_detail[d.index];
219
- if (container != undefined) {
220
- container.message.push(d.message);
221
- if (container.message.length > interface_1.MESSAGE_LIMIT) {
222
- container.message.shift();
223
- }
224
- }
225
- };
226
- this.update_runtime_parameter = (d) => {
227
- this.model.record.para = d;
228
- };
229
- this.model = _model;
230
- }
231
- get execute_proxy() {
232
- const d = {
233
- executeProjectStart: (data) => { this.execute_project_start(data); },
234
- executeProjectFinish: (data) => { this.execute_project_finish(data); },
235
- executeTaskStart: (data) => { this.execute_task_start(data); },
236
- executeTaskFinish: (data) => { this.execute_task_finish(data); },
237
- executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
238
- executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
239
- executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
240
- executeJobStart: (data) => { this.execute_job_start(data); },
241
- executeJobFinish: (data) => { this.execute_job_finish(data); },
242
- feedbackMessage: (data) => { this.feedback_message(data); },
243
- updateParameter: (data) => { this.update_runtime_parameter(data); }
244
- };
245
- return d;
246
- }
247
- }
248
- exports.Util_Server_Console_Proxy = Util_Server_Console_Proxy;
@@ -1,230 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.Util_Server_Log_Proxy = void 0;
46
- const uuid_1 = require("uuid");
47
- const interface_1 = require("../../interface");
48
- const fs = __importStar(require("fs"));
49
- class Util_Server_Log_Proxy {
50
- get target_log() {
51
- return this.logs.logs.find(x => x.uuid == this.uuid);
52
- }
53
- constructor(_model, _log, _preference) {
54
- this.task_index = 0;
55
- this.uuid = '';
56
- this.execute_project_start = (d) => __awaiter(this, void 0, void 0, function* () {
57
- const target = this.model.record.projects[this.model.record.project_index];
58
- const title = yield this.getnewname(target.title);
59
- this.uuid = (0, uuid_1.v6)();
60
- const newlog = {
61
- uuid: this.uuid,
62
- filename: title,
63
- dirty: true,
64
- output: this.preference.log,
65
- project: target,
66
- state: interface_1.ExecuteState.RUNNING,
67
- start_timer: Date.now(),
68
- parameter: d[0].parameter,
69
- end_timer: 0,
70
- logs: target.task.map(x => {
71
- return {
72
- start_timer: 0,
73
- end_timer: 0,
74
- task_state: {
75
- uuid: x.uuid,
76
- state: interface_1.ExecuteState.NONE
77
- },
78
- task_detail: []
79
- };
80
- })
81
- };
82
- this.logs.logs = [newlog].concat(this.logs.logs);
83
- });
84
- this.execute_project_finish = (d) => {
85
- if (this.target_log == undefined)
86
- return;
87
- this.target_log.state = interface_1.ExecuteState.FINISH;
88
- this.target_log.end_timer = Date.now();
89
- this.target_log.dirty = true;
90
- };
91
- this.execute_task_start = (d) => {
92
- if (this.target_log == undefined)
93
- return;
94
- const index = this.target_log.project.task.findIndex(x => x.uuid == d[0].uuid);
95
- if (index == -1)
96
- return;
97
- this.task_index = index;
98
- this.target_log.logs[this.task_index].task_detail = [];
99
- const p = this.model.record.projects[this.model.record.project_index];
100
- const t = p.task[this.task_index];
101
- const count = this.model.manager.get_task_state_count(t);
102
- for (let i = 0; i < count; i++) {
103
- this.target_log.logs[this.task_index].task_detail.push({
104
- index: i,
105
- node: "",
106
- message: [],
107
- state: interface_1.ExecuteState.NONE
108
- });
109
- }
110
- if (this.target_log.logs.length > this.task_index) {
111
- this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.RUNNING;
112
- this.target_log.logs[this.task_index].start_timer = Date.now();
113
- this.target_log.dirty = true;
114
- }
115
- };
116
- this.execute_task_finish = (d) => {
117
- if (this.target_log == undefined)
118
- return;
119
- if (this.target_log.logs.length > this.task_index) {
120
- this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.FINISH;
121
- this.target_log.logs[this.task_index].end_timer = Date.now();
122
- this.target_log.dirty = true;
123
- }
124
- };
125
- this.execute_subtask_start = (d) => {
126
- if (this.target_log == undefined)
127
- return;
128
- if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
129
- this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
130
- this.target_log.dirty = true;
131
- }
132
- };
133
- this.execute_subtask_update = (d) => {
134
- if (this.target_log == undefined)
135
- return;
136
- if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
137
- this.target_log.logs[this.task_index].task_detail[d[1]].state = d[3];
138
- this.target_log.dirty = true;
139
- }
140
- };
141
- this.execute_subtask_end = (d) => {
142
- if (this.target_log == undefined)
143
- return;
144
- if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
145
- this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
146
- this.target_log.dirty = true;
147
- }
148
- };
149
- this.execute_job_start = (d) => {
150
- };
151
- this.execute_job_finish = (d) => {
152
- if (this.target_log == undefined)
153
- return;
154
- if (d[3] == 1) {
155
- const currentLog = this.target_log;
156
- const task = currentLog.project.task[this.task_index];
157
- const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
158
- if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
159
- const cr = task.jobs[index].number_args[0];
160
- if (cr == interface_1.ConditionResult.None)
161
- return;
162
- const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
163
- const target = this.model.record.task_detail[d[1]];
164
- if (target != undefined) {
165
- target.state = state;
166
- }
167
- currentLog.logs[this.task_index].task_state.state = state;
168
- if (cr == interface_1.ConditionResult.Pause)
169
- return;
170
- if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
171
- currentLog.state = state;
172
- }
173
- }
174
- }
175
- };
176
- this.feedback_message = (d) => {
177
- if (this.target_log == undefined)
178
- return;
179
- if (d.index == undefined || d.index == -1)
180
- return;
181
- if (this.target_log == undefined)
182
- return;
183
- if (this.target_log.logs[this.task_index].task_detail.length > d.index) {
184
- this.target_log.logs[this.task_index].task_detail[d.index].message.push(d.message);
185
- this.target_log.dirty = true;
186
- }
187
- else {
188
- console.warn("Try access message by index but failed: ", d);
189
- }
190
- };
191
- this.update_runtime_parameter = (d) => {
192
- if (this.target_log != undefined) {
193
- this.target_log.parameter = d;
194
- this.target_log.dirty = true;
195
- }
196
- };
197
- this.getnewname = (name) => __awaiter(this, void 0, void 0, function* () {
198
- const root = "data/log";
199
- let count = 0;
200
- let filename = name;
201
- let p = `${root}/${filename}`;
202
- while (fs.existsSync(p + ".json")) {
203
- count = count + 1;
204
- filename = `${name} ${count}`;
205
- p = `${root}/${filename}`;
206
- }
207
- return filename;
208
- });
209
- this.model = _model;
210
- this.logs = _log;
211
- this.preference = _preference;
212
- }
213
- get execute_proxy() {
214
- const d = {
215
- executeProjectStart: (data) => { this.execute_project_start(data); },
216
- executeProjectFinish: (data) => { this.execute_project_finish(data); },
217
- executeTaskStart: (data) => { this.execute_task_start(data); },
218
- executeTaskFinish: (data) => { this.execute_task_finish(data); },
219
- executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
220
- executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
221
- executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
222
- executeJobStart: (data) => { this.execute_job_start(data); },
223
- executeJobFinish: (data) => { this.execute_job_finish(data); },
224
- feedbackMessage: (data) => { this.feedback_message(data); },
225
- updateParameter: (data) => { this.update_runtime_parameter(data); }
226
- };
227
- return d;
228
- }
229
- }
230
- exports.Util_Server_Log_Proxy = Util_Server_Log_Proxy;
package/dist/test/TEST.js DELETED
@@ -1,105 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- const pem = __importStar(require("pem"));
46
- const https = __importStar(require("https"));
47
- const ws = __importStar(require("ws"));
48
- let h = undefined;
49
- let w = undefined;
50
- function get_pem() {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- return new Promise(resolve => {
53
- pem.createCertificate({ days: 1, selfSigned: true }, (err, keys) => {
54
- resolve([keys.clientKey, keys.certificate]);
55
- });
56
- });
57
- });
58
- }
59
- function start_server() {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const pems = yield get_pem();
62
- h = https.createServer({ key: pems[0], cert: pems[1], minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3' }, (req, res) => {
63
- res.writeHead(200);
64
- res.end('HTTPS server is running');
65
- });
66
- h.addListener('upgrade', (req, res, head) => console.log('UPGRADE:', req.url));
67
- w = new ws.Server({ server: h });
68
- w.on('listening', (socket) => {
69
- console.log("Listen Event");
70
- });
71
- w.on('error', (err) => {
72
- console.log("Error Event");
73
- });
74
- w.on('connection', (socket) => {
75
- socket.on('message', (data) => {
76
- console.log("Recevied Data: ", data.toString());
77
- });
78
- });
79
- h.listen(10000, () => {
80
- console.log("Listen to 10000");
81
- });
82
- });
83
- }
84
- function start_client() {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- return new Promise((resolve) => {
87
- const cli = new ws.WebSocket("wss://127.0.0.1:10000", { agent: new https.Agent(), rejectUnauthorized: false });
88
- cli.on('error', (err) => {
89
- console.log("Socket Error: ", err);
90
- });
91
- setTimeout(() => {
92
- cli.send("Hello World");
93
- cli.close();
94
- resolve(undefined);
95
- }, 1000);
96
- });
97
- });
98
- }
99
- function main() {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- yield start_server();
102
- yield start_client();
103
- });
104
- }
105
- main();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes