@webtypen/webframez-core 0.3.51 → 0.3.52

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.
@@ -15,6 +15,9 @@ export declare class QueueWorkerCommand extends ConsoleCommand {
15
15
  jobsFailed: number;
16
16
  lastJob: any;
17
17
  log(message: string): void;
18
+ private formatAutomationCommand;
19
+ private formatAutomationExecution;
20
+ private logRegisteredAutomation;
18
21
  handle(): Promise<void>;
19
22
  init(): boolean;
20
23
  canStart(): boolean;
@@ -49,6 +49,47 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
49
49
  .tz(this.workerConfig.timezone ? this.workerConfig.timezone : "Europe/Berlin")
50
50
  .format("YY-MM-DD HH:mm:ss")}] ${message}`);
51
51
  }
52
+ formatAutomationCommand(automation) {
53
+ if (automation.jobclass === "BackupRunJob" && automation.payload && automation.payload.backupKey) {
54
+ return `backup:run ${automation.payload.backupKey}`;
55
+ }
56
+ return automation.jobclass || "unknown";
57
+ }
58
+ formatAutomationExecution(execution) {
59
+ if (!Array.isArray(execution)) {
60
+ return "invalid execution";
61
+ }
62
+ const [type, value, options] = execution;
63
+ const suffix = options && options.identifier ? ` (${options.identifier})` : "";
64
+ if (type === "daily") {
65
+ return `daily at ${value}${suffix}`;
66
+ }
67
+ if (type === "every_hour") {
68
+ return `every hour at minute ${value !== undefined && value !== null ? value : 0}${suffix}`;
69
+ }
70
+ if (type === "every_x_mins") {
71
+ return `every ${value} minute(s)${suffix}`;
72
+ }
73
+ if (value !== undefined && value !== null) {
74
+ return `${type} at ${value}${suffix}`;
75
+ }
76
+ return `${type}${suffix}`;
77
+ }
78
+ logRegisteredAutomation() {
79
+ const automations = this.getWorkerAutomation();
80
+ if (!automations || automations.length < 1) {
81
+ this.log("Registered automations: none");
82
+ return;
83
+ }
84
+ this.log("Registered automations:");
85
+ for (const automation of automations) {
86
+ const command = this.formatAutomationCommand(automation);
87
+ const executions = automation.executions && Array.isArray(automation.executions) && automation.executions.length > 0
88
+ ? automation.executions.map((execution) => this.formatAutomationExecution(execution)).join(", ")
89
+ : "no executions";
90
+ this.log(`- ${command}: ${executions}`);
91
+ }
92
+ }
52
93
  handle() {
53
94
  return __awaiter(this, void 0, void 0, function* () {
54
95
  const workerKey = this.getOption("worker");
@@ -80,6 +121,7 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
80
121
  });
81
122
  try {
82
123
  this.log("Queue started");
124
+ this.logRegisteredAutomation();
83
125
  yield this.run();
84
126
  }
85
127
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.3.51",
3
+ "version": "0.3.52",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",