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
@@ -4,6 +4,10 @@ exports.Region_Project = void 0;
4
4
  const interface_1 = require("../../interface");
5
5
  const region_task_1 = require("./region_task");
6
6
  class Region_Project {
7
+ target;
8
+ state;
9
+ project;
10
+ task;
7
11
  constructor(_target, _project) {
8
12
  this.project = _project;
9
13
  this.target = _target;
@@ -0,0 +1,5 @@
1
+ import { ExecuteManager } from "../execute_manager";
2
+ export declare class Region_Subtask {
3
+ target: ExecuteManager;
4
+ constructor(_target: ExecuteManager);
5
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Region_Subtask = void 0;
4
4
  class Region_Subtask {
5
+ target;
5
6
  constructor(_target) {
6
7
  this.target = _target;
7
8
  }
@@ -0,0 +1,10 @@
1
+ import { ExecuteState, Task } from "../../interface";
2
+ import { ExecuteManager } from "../execute_manager";
3
+ import { Region_Subtask } from "./region_subtask";
4
+ export declare class Region_Task {
5
+ target: ExecuteManager;
6
+ state: ExecuteState;
7
+ task: Task;
8
+ subtask: Region_Subtask | undefined;
9
+ constructor(_target: ExecuteManager, _task: Task);
10
+ }
@@ -4,6 +4,10 @@ exports.Region_Task = void 0;
4
4
  const interface_1 = require("../../interface");
5
5
  const region_subtask_1 = require("./region_subtask");
6
6
  class Region_Task {
7
+ target;
8
+ state;
9
+ task;
10
+ subtask;
7
11
  constructor(_target, _task) {
8
12
  this.task = _task;
9
13
  this.target = _target;
@@ -0,0 +1,14 @@
1
+ import { Project, Task } from "../../interface";
2
+ import { ExecuteManager_Feedback } from "./feedback";
3
+ export declare class ExecuteManager_Runner extends ExecuteManager_Feedback {
4
+ protected ExecuteProject: (project: Project) => void;
5
+ private ExecuteTask;
6
+ private ExecuteTask_Cronjob;
7
+ private ExecuteTask_Single;
8
+ private ExecuteTask_Setup;
9
+ private ExecuteTask_AllFinish;
10
+ private ExecuteCronTask;
11
+ private ExecuteJob;
12
+ SyncDatabase: (p: Project) => void;
13
+ protected Init_CronContainer: (task: Task, taskCount: number) => void;
14
+ }
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecuteManager_Runner = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const interface_1 = require("../../interface");
6
+ const feedback_1 = require("./feedback");
7
+ const util_parser_1 = require("./util_parser");
8
+ class ExecuteManager_Runner extends feedback_1.ExecuteManager_Feedback {
9
+ ExecuteProject = (project) => {
10
+ if (this.current_t == undefined && project.task.length > 0 && this.t_state != interface_1.ExecuteState.FINISH) {
11
+ this.current_t = project.task[0];
12
+ this.messager_log(`[Execute] Task Start ${this.current_t.uuid}`);
13
+ this.messager_log(`[Execute] Task cron state: ${this.current_t.cronjob}`);
14
+ this.current_job = [];
15
+ this.current_cron = [];
16
+ }
17
+ else if (project.task.length == 0) {
18
+ this.current_t = undefined;
19
+ }
20
+ if (this.current_t != undefined) {
21
+ this.ExecuteTask(project, this.current_t);
22
+ }
23
+ else {
24
+ const index = this.current_projects.findIndex(x => x.uuid == project.uuid);
25
+ if (index < this.current_projects.length - 1) {
26
+ this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
27
+ this.proxy?.executeProjectFinish([this.current_p, index]);
28
+ this.current_p = this.current_projects[index + 1];
29
+ this.proxy?.executeProjectStart([this.current_p, index + 1]);
30
+ this.t_state = interface_1.ExecuteState.NONE;
31
+ }
32
+ else {
33
+ this.messager_log(`[Execute] Project Finish ${this.current_p.uuid}`);
34
+ this.proxy?.executeProjectFinish([this.current_p, index]);
35
+ this.current_p = undefined;
36
+ this.state = interface_1.ExecuteState.FINISH;
37
+ this.t_state = interface_1.ExecuteState.NONE;
38
+ }
39
+ }
40
+ };
41
+ ExecuteTask = (project, task) => {
42
+ if (this.t_state == interface_1.ExecuteState.NONE) {
43
+ this.t_state = interface_1.ExecuteState.RUNNING;
44
+ this.current_multithread = task.multi ? this.get_task_multi_count(task) : 1;
45
+ this.current_task_count = this.get_task_state_count(task);
46
+ }
47
+ let allJobFinish = false;
48
+ const hasJob = task.jobs.length > 0;
49
+ if (!hasJob) {
50
+ this.proxy?.executeTaskStart([task, this.current_task_count]);
51
+ this.proxy?.executeTaskFinish(task);
52
+ this.messager_log(`[Execute] Skip ! No job exists ${task.uuid}`);
53
+ this.ExecuteTask_AllFinish(project, task);
54
+ return;
55
+ }
56
+ if (task.setupjob) {
57
+ allJobFinish = this.ExecuteTask_Setup(project, task, this.current_task_count);
58
+ }
59
+ else if (task.cronjob) {
60
+ allJobFinish = this.ExecuteTask_Cronjob(project, task, this.current_task_count);
61
+ }
62
+ else {
63
+ allJobFinish = this.ExecuteTask_Single(project, task, this.current_task_count);
64
+ }
65
+ if (allJobFinish) {
66
+ this.ExecuteTask_AllFinish(project, task);
67
+ }
68
+ };
69
+ ExecuteTask_Cronjob(project, task, taskCount) {
70
+ let ns = this.get_idle_open();
71
+ let allJobFinish = false;
72
+ if (this.current_cron.length == 0) {
73
+ this.Init_CronContainer(task, taskCount);
74
+ this.messager_log(`[Execute] TaskCount: ${taskCount}`);
75
+ }
76
+ else {
77
+ const worker = this.current_cron.filter(x => x.uuid != '').map(x => x.uuid);
78
+ const counter = [];
79
+ worker.forEach(uuid => {
80
+ const index = counter.findIndex(x => x[0] == uuid);
81
+ if (index == -1)
82
+ counter.push([uuid, 1]);
83
+ else
84
+ counter[index][1] += 1;
85
+ });
86
+ const fullLoadUUID = counter.filter(x => x[1] >= this.current_multithread).map(x => x[0]);
87
+ ns = ns.filter(x => !fullLoadUUID.includes(x.uuid));
88
+ }
89
+ if (this.check_all_cron_end()) {
90
+ allJobFinish = true;
91
+ }
92
+ else {
93
+ const needs = this.current_cron.filter(x => x.uuid == '' && x.work.filter(y => y.state != interface_1.ExecuteState.FINISH && y.state != interface_1.ExecuteState.ERROR).length > 0);
94
+ const min = Math.min(needs.length, ns.length);
95
+ for (let i = 0; i < min; i++) {
96
+ needs[i].uuid = ns[i].uuid;
97
+ }
98
+ const single = this.current_cron.filter(x => x.uuid != '');
99
+ for (var cronwork of single) {
100
+ const index = this.current_nodes.findIndex(x => x.uuid == cronwork.uuid);
101
+ if (index != -1) {
102
+ this.ExecuteCronTask(project, task, cronwork, this.current_nodes[index]);
103
+ }
104
+ }
105
+ }
106
+ return allJobFinish;
107
+ }
108
+ ExecuteTask_Single(project, task, taskCount) {
109
+ let allJobFinish = false;
110
+ let ns = [];
111
+ if (this.current_job.length > 0) {
112
+ const last = this.current_nodes.find(x => x.uuid == this.current_job[0].uuid);
113
+ if (last == undefined) {
114
+ ns = this.get_idle();
115
+ this.current_job = [];
116
+ }
117
+ else {
118
+ ns = [last];
119
+ if (ns[0].websocket.readyState != 1) {
120
+ ns = this.get_idle();
121
+ this.current_job = [];
122
+ }
123
+ }
124
+ }
125
+ else {
126
+ this.sync_local_para(this.localPara);
127
+ ns = this.get_idle();
128
+ if (ns.length > 0) {
129
+ this.proxy?.executeTaskStart([task, taskCount]);
130
+ this.proxy?.executeSubtaskStart([task, 0, ns[0].uuid]);
131
+ }
132
+ }
133
+ if (ns.length > 0 && ns[0].websocket.readyState == 1 && this.check_socket_state(ns[0]) != interface_1.ExecuteState.RUNNING) {
134
+ if (this.check_single_end()) {
135
+ allJobFinish = true;
136
+ }
137
+ else {
138
+ if (this.current_job.length != task.jobs.length) {
139
+ const job = JSON.parse(JSON.stringify(task.jobs[this.current_job.length]));
140
+ const runtime = (0, uuid_1.v6)();
141
+ this.current_job.push({
142
+ uuid: ns[0].uuid,
143
+ runtime: runtime,
144
+ state: interface_1.ExecuteState.RUNNING,
145
+ job: job
146
+ });
147
+ job.index = 0;
148
+ job.runtime_uuid = runtime;
149
+ this.ExecuteJob(project, task, job, ns[0], false);
150
+ }
151
+ }
152
+ }
153
+ return allJobFinish;
154
+ }
155
+ ExecuteTask_Setup(project, task, taskCount) {
156
+ let ns = this.get_idle_open();
157
+ let allJobFinish = false;
158
+ if (this.current_cron.length == 0) {
159
+ this.Init_CronContainer(task, taskCount);
160
+ this.messager_log(`[Execute] TaskCount: ${taskCount}`);
161
+ for (let i = 0; i < this.current_cron.length; i++) {
162
+ this.current_cron[i].uuid = this.current_nodes[i].uuid;
163
+ }
164
+ }
165
+ if (this.check_all_cron_end()) {
166
+ allJobFinish = true;
167
+ }
168
+ else {
169
+ const single = this.current_cron.filter(x => x.uuid != '');
170
+ for (var cronwork of single) {
171
+ const index = this.current_nodes.findIndex(x => x.uuid == cronwork.uuid);
172
+ if (index != -1) {
173
+ this.ExecuteCronTask(project, task, cronwork, this.current_nodes[index]);
174
+ }
175
+ }
176
+ }
177
+ return allJobFinish;
178
+ }
179
+ ExecuteTask_AllFinish(project, task) {
180
+ this.proxy?.executeTaskFinish(task);
181
+ this.messager_log(`[Execute] Task Finish ${task.uuid}`);
182
+ const index = project.task.findIndex(x => x.uuid == task.uuid);
183
+ if (index == project.task.length - 1) {
184
+ this.current_t = undefined;
185
+ this.t_state = interface_1.ExecuteState.FINISH;
186
+ }
187
+ else {
188
+ this.current_t = project.task[index + 1];
189
+ this.t_state = interface_1.ExecuteState.NONE;
190
+ }
191
+ this.current_job = [];
192
+ this.current_cron = [];
193
+ }
194
+ ExecuteCronTask = (project, task, work, ns) => {
195
+ if (ns.current_job.length < this.current_multithread) {
196
+ const rindex = work.work.findIndex(x => x.state == interface_1.ExecuteState.RUNNING);
197
+ if (rindex != -1)
198
+ return;
199
+ const index = work.work.findIndex(x => x.state == interface_1.ExecuteState.NONE);
200
+ if (index == 0)
201
+ this.proxy?.executeSubtaskStart([task, work.id, ns.uuid]);
202
+ if (index == -1)
203
+ return;
204
+ work.work[index].state = interface_1.ExecuteState.RUNNING;
205
+ try {
206
+ const job = JSON.parse(JSON.stringify(task.jobs[index]));
207
+ job.index = work.id;
208
+ job.runtime_uuid = work.work[index].runtime;
209
+ this.ExecuteJob(project, task, job, ns, true);
210
+ }
211
+ catch (err) {
212
+ this.messager_log(`[ExecuteCronTask Error] UUID: ${task.uuid}, Job count: ${task.jobs.length}, index: ${index}`);
213
+ }
214
+ }
215
+ };
216
+ ExecuteJob = (project, task, job, wss, iscron) => {
217
+ const n = job.index;
218
+ this.messager_log(`[Execute] Job Start ${n} ${job.uuid} ${wss.uuid}`);
219
+ this.proxy?.executeJobStart([job, n, wss.uuid]);
220
+ ExecuteManager_Runner.string_args_transform(task, job, this.messager_log, this.localPara, n);
221
+ const h = {
222
+ name: 'execute_job',
223
+ channel: this.uuid,
224
+ data: job
225
+ };
226
+ wss.current_job.push(job.runtime_uuid);
227
+ const stringdata = JSON.stringify(h);
228
+ wss.websocket.send(stringdata);
229
+ this.jobstack = this.jobstack + 1;
230
+ };
231
+ SyncDatabase = (p) => {
232
+ this.localPara = JSON.parse(JSON.stringify(p.database));
233
+ this.messager_log("[Execute] Sync Database !");
234
+ this.messager_log("[Execute] Generate local database object");
235
+ for (let i = 0; i < this.localPara.containers.length; i++) {
236
+ if (this.localPara.containers[i].type == interface_1.DataType.Expression && this.localPara.containers[i].meta != undefined) {
237
+ const text = `%{${this.localPara.containers[i].meta}}%`;
238
+ const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(this.localPara)]);
239
+ this.localPara.containers[i].value = e.replacePara(text);
240
+ }
241
+ }
242
+ this.sync_local_para(this.localPara);
243
+ };
244
+ Init_CronContainer = (task, taskCount) => {
245
+ this.sync_local_para(this.localPara);
246
+ this.current_cron = [];
247
+ for (let i = 0; i < taskCount; i++) {
248
+ const d = {
249
+ id: i,
250
+ uuid: "",
251
+ work: task.jobs.map(x => ({
252
+ uuid: x.uuid,
253
+ runtime: '',
254
+ state: interface_1.ExecuteState.NONE,
255
+ job: x
256
+ }))
257
+ };
258
+ d.work.forEach((x, j) => x.runtime = (0, uuid_1.v6)({}, undefined, i * taskCount + j));
259
+ this.current_cron.push(d);
260
+ }
261
+ this.proxy?.executeTaskStart([task, taskCount]);
262
+ };
263
+ }
264
+ exports.ExecuteManager_Runner = ExecuteManager_Runner;
@@ -0,0 +1,14 @@
1
+ import { KeyValue, Database, DatabaseContainer } from "../../interface";
2
+ export declare class Util_Parser {
3
+ paras: Array<KeyValue>;
4
+ get count(): number;
5
+ constructor(_paras: Array<KeyValue>);
6
+ clone: () => Util_Parser;
7
+ static to_keyvalue: (p: Database) => Array<KeyValue>;
8
+ private static getDeepKeys;
9
+ static _to_keyvalue: (p: Array<DatabaseContainer>) => Array<KeyValue>;
10
+ static replaceAll: (str: string, fi: string, tar: string) => string;
11
+ replacePara: (text: string) => string;
12
+ parse: (str: string) => string;
13
+ private _replacePara;
14
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Util_Parser = void 0;
4
+ const expressionparser_1 = require("expressionparser");
5
+ const interface_1 = require("../../interface");
6
+ class Util_Parser {
7
+ paras = [];
8
+ get count() {
9
+ return this.paras.length;
10
+ }
11
+ constructor(_paras) {
12
+ this.paras = _paras;
13
+ }
14
+ clone = () => {
15
+ const b = JSON.parse(JSON.stringify(this.paras));
16
+ return new Util_Parser(b);
17
+ };
18
+ static to_keyvalue = (p) => {
19
+ return [
20
+ ...this._to_keyvalue(p.containers)
21
+ ];
22
+ };
23
+ static getDeepKeys = (obj, name) => {
24
+ let keys = [];
25
+ for (var key in obj) {
26
+ keys.push([name ? name + "." + key : key, obj[key]]);
27
+ if (typeof obj[key] === "object") {
28
+ if (Array.isArray(obj[key])) {
29
+ if (typeof obj[key]['length'] === 'number') {
30
+ keys.push([name ? name + "." + key + ".length" : key + ".length", obj[key]['length']]);
31
+ }
32
+ }
33
+ var subkeys = this.getDeepKeys(obj[key]);
34
+ keys = keys.concat(subkeys.map(function (subkey) {
35
+ return [name ? name + "." + key + "." + subkey[0] : key + "." + subkey[0], subkey[1]];
36
+ }));
37
+ }
38
+ }
39
+ return keys;
40
+ };
41
+ static _to_keyvalue = (p) => {
42
+ const r = [];
43
+ r.push(...p.filter(x => x.type == interface_1.DataType.Boolean || x.type == interface_1.DataType.String || x.type == interface_1.DataType.Textarea || x.type == interface_1.DataType.Number || x.type == interface_1.DataType.Expression).map(x => { return { key: x.name, value: x.value.toString() }; }));
44
+ const objs = p.filter(x => x.type == interface_1.DataType.Object);
45
+ const lists = p.filter(x => x.type == interface_1.DataType.List);
46
+ const selects = p.filter(x => x.type == interface_1.DataType.Select);
47
+ for (const obj of objs) {
48
+ const v = obj.value;
49
+ const keys = this.getDeepKeys(v, obj.name);
50
+ r.push(...keys.map(x => { return { key: x[0], value: x[1].toString() }; }));
51
+ }
52
+ for (const list of lists) {
53
+ const a = list.value;
54
+ r.push(...a.map((x, index) => { return { key: list.name + "." + String(index), value: x }; }));
55
+ r.push({ key: list.name + ".length", value: a.length });
56
+ }
57
+ for (const select of selects) {
58
+ const a = select.meta;
59
+ const target = a[select.value];
60
+ r.push({ key: select.name, value: target });
61
+ }
62
+ return r;
63
+ };
64
+ static replaceAll = (str, fi, tar) => {
65
+ let p = str;
66
+ while (p.includes(fi))
67
+ p = p.replace(fi, tar);
68
+ return p;
69
+ };
70
+ replacePara = (text) => {
71
+ let buffer = '';
72
+ let store = '';
73
+ let state = false;
74
+ let ignore = -1;
75
+ let useExp = false;
76
+ for (const v of text) {
77
+ if (v == interface_1.IGNORE_CHARACTER && ignore == -1)
78
+ ignore = 0;
79
+ else if (ignore == 0)
80
+ ignore = 1;
81
+ else if (ignore == 1)
82
+ ignore = 2;
83
+ else if (ignore == 2)
84
+ ignore = -1;
85
+ if (v == interface_1.ENV_CHARACTER && ignore == -1) {
86
+ state = !state;
87
+ if (!state) {
88
+ if (useExp) {
89
+ buffer += this.parse(store);
90
+ }
91
+ else {
92
+ buffer += this._replacePara(store);
93
+ }
94
+ store = "";
95
+ useExp = false;
96
+ }
97
+ }
98
+ if (v == '{' && state && store.length == 0)
99
+ useExp = true;
100
+ if (state && v != interface_1.ENV_CHARACTER && (ignore != 0))
101
+ store += v;
102
+ if (!state && v != interface_1.ENV_CHARACTER && (ignore != 0))
103
+ buffer += (ignore > 0 ? (interface_1.ENV_CHARACTER + v) : v);
104
+ }
105
+ return buffer;
106
+ };
107
+ parse = (str) => {
108
+ str = str.substring(1, str.length - 1);
109
+ const parser = (0, expressionparser_1.init)(expressionparser_1.formula, (term) => {
110
+ if (term.includes("_ck_")) {
111
+ const index = this.paras.findIndex(x => x.key == "ck");
112
+ if (index != -1)
113
+ term = Util_Parser.replaceAll(term, "_ck_", this.paras[index].value);
114
+ }
115
+ const index = this.paras.findIndex(x => x.key == term);
116
+ if (index != -1) {
117
+ const n = Number(this.paras[index].value);
118
+ if (Number.isNaN(n))
119
+ return this.paras[index].value;
120
+ return n;
121
+ }
122
+ else
123
+ return 0;
124
+ });
125
+ const r = parser.expressionToValue(str).toString();
126
+ return r;
127
+ };
128
+ _replacePara = (store) => {
129
+ const index = this.paras.findIndex(x => x.key == store);
130
+ if (index == -1)
131
+ return `%${store}%`;
132
+ return this.paras[index].value;
133
+ };
134
+ }
135
+ exports.Util_Parser = Util_Parser;
@@ -0,0 +1,25 @@
1
+ import { Libraries, WebsocketPack } from "../interface";
2
+ import { ExecuteManager_Runner } from "./execute/runner";
3
+ export declare class ExecuteManager extends ExecuteManager_Runner {
4
+ Update: () => void;
5
+ Stop: () => void;
6
+ Register: (lib?: Libraries) => number;
7
+ Clean: () => void;
8
+ Release: () => void;
9
+ NewConnection: (source: WebsocketPack) => void;
10
+ Disconnect: (source: WebsocketPack) => void;
11
+ ClearState: (task_index: number) => void;
12
+ SkipProject: () => number;
13
+ PreviousProject: () => number;
14
+ SkipTask: () => number;
15
+ PreviousTask: () => number;
16
+ SkipSubTask: (v: number) => number;
17
+ private jumpProject;
18
+ private jumpTask;
19
+ private skipProjectFirst;
20
+ private _jumpProject;
21
+ private skipTaskFirst;
22
+ private previousTaskFirst;
23
+ private skipTask;
24
+ private previousTask;
25
+ }