@diia-inhouse/workflow 1.17.7 → 2.5.0
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.
- package/dist/activities/index.d.ts +1 -0
- package/dist/activities/index.js +2 -18
- package/dist/activities/proxy.d.ts +34 -0
- package/dist/activities/proxy.js +16 -24
- package/dist/activity.d.ts +2 -0
- package/dist/activity.js +2 -15
- package/dist/cli/checkWorkflowDeterminism.js +249 -275
- package/dist/cli/determinism/errorClassifier.js +56 -60
- package/dist/cli/determinism/historyFiles.js +68 -97
- package/dist/cli/determinism/index.js +7 -19
- package/dist/cli/determinism/replayExecutor.js +114 -133
- package/dist/cli/determinism/replayOptions.js +13 -22
- package/dist/cli/determinism/report.js +55 -45
- package/dist/cli/determinism/reportPrinter.js +101 -138
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +79 -119
- package/dist/cli/syncTemporalSchedules.js +74 -91
- package/dist/cli/updateTemporalSchedule.js +43 -53
- package/dist/client.d.ts +3 -0
- package/dist/client.js +3 -19
- package/dist/common.d.ts +2 -0
- package/dist/common.js +2 -13
- package/dist/encryption/crypto.d.ts +7 -0
- package/dist/encryption/crypto.js +20 -22
- package/dist/encryption/dataConverter.d.ts +7 -0
- package/dist/encryption/dataConverter.js +15 -22
- package/dist/encryption/encryptionCodec.d.ts +31 -0
- package/dist/encryption/encryptionCodec.js +108 -124
- package/dist/encryption/index.d.ts +3 -0
- package/dist/encryption/index.js +4 -20
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -42
- package/dist/instrumentation.js +6 -10
- package/dist/interceptors/asyncLocalStorageBridge.js +29 -66
- package/dist/interceptors/traceLogAttributes.d.ts +6 -0
- package/dist/interceptors/traceLogAttributes.js +16 -54
- package/dist/interceptors.d.ts +6 -0
- package/dist/interceptors.js +6 -8
- package/dist/interfaces/config.d.ts +58 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/services/schedulesExporter.d.ts +96 -0
- package/dist/interfaces/services/worker.d.ts +60 -0
- package/dist/operations.d.ts +9 -0
- package/dist/operations.js +11 -75
- package/dist/services/client.d.ts +24 -0
- package/dist/services/client.js +89 -96
- package/dist/services/schedulesExporter.d.ts +101 -0
- package/dist/services/schedulesExporter.js +456 -0
- package/dist/services/worker/identity.d.ts +4 -0
- package/dist/services/worker/identity.js +6 -9
- package/dist/services/worker.d.ts +124 -0
- package/dist/services/worker.js +324 -304
- package/dist/services/workerHealth.d.ts +15 -0
- package/dist/services/workerHealth.js +26 -35
- package/dist/testing.d.ts +42 -0
- package/dist/testing.js +43 -54
- package/dist/worker.d.ts +9 -0
- package/dist/worker.js +7 -25
- package/package.json +40 -38
- package/dist/activities/index.js.map +0 -1
- package/dist/activities/proxy.js.map +0 -1
- package/dist/activity.js.map +0 -1
- package/dist/cli/checkWorkflowDeterminism.js.map +0 -1
- package/dist/cli/determinism/errorClassifier.js.map +0 -1
- package/dist/cli/determinism/historyFiles.js.map +0 -1
- package/dist/cli/determinism/index.js.map +0 -1
- package/dist/cli/determinism/replayExecutor.js.map +0 -1
- package/dist/cli/determinism/replayOptions.js.map +0 -1
- package/dist/cli/determinism/report.js.map +0 -1
- package/dist/cli/determinism/reportPrinter.js.map +0 -1
- package/dist/cli/determinism/types.js +0 -3
- package/dist/cli/determinism/types.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/syncTemporalSchedules.js.map +0 -1
- package/dist/cli/updateTemporalSchedule.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/encryption/crypto.js.map +0 -1
- package/dist/encryption/dataConverter.js.map +0 -1
- package/dist/encryption/encryptionCodec.js.map +0 -1
- package/dist/encryption/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/instrumentation.js.map +0 -1
- package/dist/interceptors/asyncLocalStorageBridge.js.map +0 -1
- package/dist/interceptors/index.js +0 -8
- package/dist/interceptors/index.js.map +0 -1
- package/dist/interceptors/traceLogAttributes.js.map +0 -1
- package/dist/interceptors.js.map +0 -1
- package/dist/interfaces/config.js +0 -3
- package/dist/interfaces/config.js.map +0 -1
- package/dist/interfaces/index.js +0 -18
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/services/worker.js +0 -3
- package/dist/interfaces/services/worker.js.map +0 -1
- package/dist/operations.js.map +0 -1
- package/dist/services/client.js.map +0 -1
- package/dist/services/index.js +0 -19
- package/dist/services/index.js.map +0 -1
- package/dist/services/worker/identity.js.map +0 -1
- package/dist/services/worker/index.js +0 -18
- package/dist/services/worker/index.js.map +0 -1
- package/dist/services/worker.js.map +0 -1
- package/dist/services/workerHealth.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/types/activities/index.d.ts +0 -1
- package/dist/types/activities/proxy.d.ts +0 -35
- package/dist/types/activity.d.ts +0 -1
- package/dist/types/cli/checkWorkflowDeterminism.d.ts +0 -19
- package/dist/types/cli/determinism/errorClassifier.d.ts +0 -15
- package/dist/types/cli/determinism/historyFiles.d.ts +0 -18
- package/dist/types/cli/determinism/index.d.ts +0 -10
- package/dist/types/cli/determinism/replayExecutor.d.ts +0 -9
- package/dist/types/cli/determinism/replayOptions.d.ts +0 -7
- package/dist/types/cli/determinism/report.d.ts +0 -16
- package/dist/types/cli/determinism/reportPrinter.d.ts +0 -5
- package/dist/types/cli/determinism/types.d.ts +0 -44
- package/dist/types/cli/index.d.ts +0 -2
- package/dist/types/cli/syncTemporalSchedules.d.ts +0 -12
- package/dist/types/cli/updateTemporalSchedule.d.ts +0 -9
- package/dist/types/client.d.ts +0 -2
- package/dist/types/common.d.ts +0 -1
- package/dist/types/encryption/crypto.d.ts +0 -3
- package/dist/types/encryption/dataConverter.d.ts +0 -3
- package/dist/types/encryption/encryptionCodec.d.ts +0 -27
- package/dist/types/encryption/index.d.ts +0 -3
- package/dist/types/index.d.ts +0 -3
- package/dist/types/instrumentation.d.ts +0 -2
- package/dist/types/interceptors/asyncLocalStorageBridge.d.ts +0 -21
- package/dist/types/interceptors/index.d.ts +0 -2
- package/dist/types/interceptors/traceLogAttributes.d.ts +0 -2
- package/dist/types/interceptors.d.ts +0 -2
- package/dist/types/interfaces/config.d.ts +0 -38
- package/dist/types/interfaces/index.d.ts +0 -1
- package/dist/types/interfaces/services/worker.d.ts +0 -37
- package/dist/types/operations.d.ts +0 -5
- package/dist/types/services/client.d.ts +0 -20
- package/dist/types/services/index.d.ts +0 -2
- package/dist/types/services/worker/identity.d.ts +0 -1
- package/dist/types/services/worker/index.d.ts +0 -1
- package/dist/types/services/worker.d.ts +0 -113
- package/dist/types/services/workerHealth.d.ts +0 -11
- package/dist/types/testing.d.ts +0 -42
- package/dist/types/worker.d.ts +0 -3
- package/dist/worker.js.map +0 -1
|
@@ -1,45 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
//#region src/cli/determinism/report.ts
|
|
2
|
+
var DeterminismReportBuilder = class {
|
|
3
|
+
successCount = 0;
|
|
4
|
+
failureCount = 0;
|
|
5
|
+
timeoutCount = 0;
|
|
6
|
+
skippedCount = 0;
|
|
7
|
+
errors = [];
|
|
8
|
+
warnings = [];
|
|
9
|
+
checkedWorkflows = [];
|
|
10
|
+
addSuccess(workflowId, workflowType) {
|
|
11
|
+
this.successCount++;
|
|
12
|
+
this.checkedWorkflows.push({
|
|
13
|
+
name: workflowType,
|
|
14
|
+
id: workflowId,
|
|
15
|
+
status: "success"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
addFailure(workflowId, workflowType, error) {
|
|
19
|
+
this.failureCount++;
|
|
20
|
+
this.errors.push(error);
|
|
21
|
+
this.checkedWorkflows.push({
|
|
22
|
+
name: workflowType,
|
|
23
|
+
id: workflowId,
|
|
24
|
+
status: "failure"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
addTimeout(workflowId, workflowType, warning) {
|
|
28
|
+
this.timeoutCount++;
|
|
29
|
+
this.warnings.push(warning);
|
|
30
|
+
this.checkedWorkflows.push({
|
|
31
|
+
name: workflowType,
|
|
32
|
+
id: workflowId,
|
|
33
|
+
status: "timeout"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
setSkippedCount(count) {
|
|
37
|
+
this.skippedCount = count;
|
|
38
|
+
}
|
|
39
|
+
addWarning(warning) {
|
|
40
|
+
this.warnings.push(warning);
|
|
41
|
+
}
|
|
42
|
+
build() {
|
|
43
|
+
return {
|
|
44
|
+
successCount: this.successCount,
|
|
45
|
+
failureCount: this.failureCount,
|
|
46
|
+
timeoutCount: this.timeoutCount,
|
|
47
|
+
skippedCount: this.skippedCount,
|
|
48
|
+
errors: [...this.errors],
|
|
49
|
+
warnings: [...this.warnings],
|
|
50
|
+
checkedWorkflows: [...this.checkedWorkflows]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { DeterminismReportBuilder };
|
|
@@ -1,152 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const bgBlue = '\u001B[44m';
|
|
17
|
-
const dim = '\u001B[2m';
|
|
1
|
+
import { format } from "node:util";
|
|
2
|
+
//#region src/cli/determinism/reportPrinter.ts
|
|
3
|
+
const reset = "\x1B[0m";
|
|
4
|
+
const bold = "\x1B[1m";
|
|
5
|
+
const green = "\x1B[32m";
|
|
6
|
+
const red = "\x1B[31m";
|
|
7
|
+
const yellow = "\x1B[33m";
|
|
8
|
+
const magenta = "\x1B[35m";
|
|
9
|
+
const cyan = "\x1B[36m";
|
|
10
|
+
const white = "\x1B[37m";
|
|
11
|
+
const bgRed = "\x1B[41m";
|
|
12
|
+
const bgGreen = "\x1B[42m";
|
|
13
|
+
const bgYellow = "\x1B[43m";
|
|
14
|
+
const bgBlue = "\x1B[44m";
|
|
15
|
+
const dim = "\x1B[2m";
|
|
18
16
|
function collectTypeStats(report) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const map = /* @__PURE__ */ new Map();
|
|
18
|
+
for (const wf of report.checkedWorkflows) {
|
|
19
|
+
let stats = map.get(wf.name);
|
|
20
|
+
if (!stats) {
|
|
21
|
+
stats = {
|
|
22
|
+
passed: 0,
|
|
23
|
+
failed: 0,
|
|
24
|
+
timedOut: 0
|
|
25
|
+
};
|
|
26
|
+
map.set(wf.name, stats);
|
|
27
|
+
}
|
|
28
|
+
const statusMap = {
|
|
29
|
+
success: "passed",
|
|
30
|
+
failure: "failed",
|
|
31
|
+
timeout: "timedOut"
|
|
32
|
+
};
|
|
33
|
+
stats[statusMap[wf.status]]++;
|
|
34
|
+
}
|
|
35
|
+
return map;
|
|
34
36
|
}
|
|
35
37
|
function formatTypeDetail(stats) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
parts.push(`${yellow}${stats.timedOut} timed out${reset}`);
|
|
43
|
-
}
|
|
44
|
-
if (parts.length === 0) {
|
|
45
|
-
return `${total} instance${total === 1 ? '' : 's'}`;
|
|
46
|
-
}
|
|
47
|
-
return `${parts.join(', ')} out of ${total}`;
|
|
38
|
+
const total = stats.passed + stats.failed + stats.timedOut;
|
|
39
|
+
const parts = [];
|
|
40
|
+
if (stats.failed > 0) parts.push(`${red}${stats.failed} failing${reset}`);
|
|
41
|
+
if (stats.timedOut > 0) parts.push(`${yellow}${stats.timedOut} timed out${reset}`);
|
|
42
|
+
if (parts.length === 0) return `${total} instance${total === 1 ? "" : "s"}`;
|
|
43
|
+
return `${parts.join(", ")} out of ${total}`;
|
|
48
44
|
}
|
|
49
45
|
function printWorkflowTypes(report, w) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (nonDeterministic.length > 0) {
|
|
64
|
-
w.write(`\n ${bgRed}${white}${bold} NON-DETERMINISTIC ${reset}\n\n`);
|
|
65
|
-
for (const [name, stats] of nonDeterministic) {
|
|
66
|
-
w.write(` ${red}✗${reset} ${bold}${name}${reset} (${formatTypeDetail(stats)})\n`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
46
|
+
const typeStats = collectTypeStats(report);
|
|
47
|
+
if (typeStats.size === 0) return;
|
|
48
|
+
const sorted = Array.from(typeStats.entries()).toSorted((a, b) => a[0].localeCompare(b[0]));
|
|
49
|
+
const deterministic = sorted.filter(([, s]) => s.failed === 0);
|
|
50
|
+
const nonDeterministic = sorted.filter(([, s]) => s.failed > 0);
|
|
51
|
+
if (deterministic.length > 0) {
|
|
52
|
+
w.write(`\n ${bgGreen}${white}${bold} DETERMINISTIC ${reset}\n\n`);
|
|
53
|
+
for (const [name, stats] of deterministic) w.write(` ${green}✓${reset} ${bold}${name}${reset} ${dim}(${formatTypeDetail(stats)})${reset}\n`);
|
|
54
|
+
}
|
|
55
|
+
if (nonDeterministic.length > 0) {
|
|
56
|
+
w.write(`\n ${bgRed}${white}${bold} NON-DETERMINISTIC ${reset}\n\n`);
|
|
57
|
+
for (const [name, stats] of nonDeterministic) w.write(` ${red}✗${reset} ${bold}${name}${reset} (${formatTypeDetail(stats)})\n`);
|
|
58
|
+
}
|
|
69
59
|
}
|
|
70
60
|
function printErrors(report, w) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (index < report.errors.length - 1) {
|
|
86
|
-
w.write('\n');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
61
|
+
if (report.errors.length === 0) return;
|
|
62
|
+
w.write(`\n ${bgRed}${white}${bold} ${report.errors.length} ERROR${report.errors.length > 1 ? "S" : ""} ${reset}\n\n`);
|
|
63
|
+
for (const [index, error] of report.errors.entries()) {
|
|
64
|
+
const errorTypeColor = error.errorType === "DeterminismViolation" ? red : yellow;
|
|
65
|
+
w.write(` ${bold}${index + 1}.${reset} ${cyan}${error.workflowId}${reset}\n`);
|
|
66
|
+
w.write(` ${errorTypeColor}${error.errorMessage}${reset}\n`);
|
|
67
|
+
if (error.details) for (const [key, value] of Object.entries(error.details)) {
|
|
68
|
+
const formattedValue = typeof value === "string" ? value : format("%o", value);
|
|
69
|
+
w.write(` ${magenta}${key}:${reset} ${formattedValue}\n`);
|
|
70
|
+
}
|
|
71
|
+
if (index < report.errors.length - 1) w.write("\n");
|
|
72
|
+
}
|
|
89
73
|
}
|
|
90
74
|
function printWarnings(report, w) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
for (const warning of otherWarnings) {
|
|
111
|
-
w.write(` ${yellow}⚠${reset} ${cyan}${warning.workflowId}${reset}: ${warning.errorMessage}\n`);
|
|
112
|
-
if (warning.details) {
|
|
113
|
-
for (const [key, value] of Object.entries(warning.details)) {
|
|
114
|
-
const formattedValue = typeof value === 'string' ? value : (0, node_util_1.format)('%o', value);
|
|
115
|
-
w.write(` ${magenta}${key}:${reset} ${formattedValue}\n`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
75
|
+
const encryptionWarnings = report.warnings.filter((x) => x.errorMessage.includes("Encrypted payloads"));
|
|
76
|
+
const timeoutWarnings = report.warnings.filter((x) => x.errorMessage.includes("timed out"));
|
|
77
|
+
const otherWarnings = report.warnings.filter((x) => !x.errorMessage.includes("Encrypted payloads") && !x.errorMessage.includes("timed out"));
|
|
78
|
+
const totalWarnings = encryptionWarnings.length + timeoutWarnings.length + otherWarnings.length;
|
|
79
|
+
if (totalWarnings === 0) return;
|
|
80
|
+
w.write(`\n ${bgYellow}${white}${bold} ${totalWarnings} WARNING${totalWarnings > 1 ? "S" : ""} ${reset}\n\n`);
|
|
81
|
+
if (encryptionWarnings.length > 0) w.write(` ${yellow}⊘${reset} ${bold}${encryptionWarnings.length}${reset} workflow(s) with encrypted payloads — decrypt or provide encryption keys\n`);
|
|
82
|
+
if (timeoutWarnings.length > 0) {
|
|
83
|
+
w.write(` ${yellow}⏰${reset} ${bold}${timeoutWarnings.length}${reset} workflow(s) timed out during replay\n`);
|
|
84
|
+
if (timeoutWarnings.length <= 5) for (const tw of timeoutWarnings) w.write(` ${dim}${tw.workflowId}${reset}\n`);
|
|
85
|
+
}
|
|
86
|
+
for (const warning of otherWarnings) {
|
|
87
|
+
w.write(` ${yellow}⚠${reset} ${cyan}${warning.workflowId}${reset}: ${warning.errorMessage}\n`);
|
|
88
|
+
if (warning.details) for (const [key, value] of Object.entries(warning.details)) {
|
|
89
|
+
const formattedValue = typeof value === "string" ? value : format("%o", value);
|
|
90
|
+
w.write(` ${magenta}${key}:${reset} ${formattedValue}\n`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
119
93
|
}
|
|
120
94
|
function printSummaryBanner(report, w) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const parts = [`${green}${report.successCount}${reset} passed`];
|
|
132
|
-
if (report.failureCount > 0) {
|
|
133
|
-
parts.push(`${red}${report.failureCount}${reset} failed`);
|
|
134
|
-
}
|
|
135
|
-
if (report.timeoutCount > 0) {
|
|
136
|
-
parts.push(`${yellow}${report.timeoutCount}${reset} timed out`);
|
|
137
|
-
}
|
|
138
|
-
if (report.skippedCount > 0) {
|
|
139
|
-
parts.push(`${dim}${report.skippedCount}${reset} skipped`);
|
|
140
|
-
}
|
|
141
|
-
const total = report.successCount + report.failureCount + report.timeoutCount + report.skippedCount;
|
|
142
|
-
w.write(` ${dim}(${parts.join(', ')}, ${bold}${total}${reset}${dim} total)${reset}\n\n`);
|
|
95
|
+
w.write("\n");
|
|
96
|
+
if (report.failureCount === 0 && report.successCount > 0) w.write(` ${bgGreen}${white}${bold} PASS ${reset} ${green}All workflows are deterministic${reset}`);
|
|
97
|
+
else if (report.failureCount > 0) w.write(` ${bgRed}${white}${bold} FAIL ${reset} ${red}${report.failureCount} workflow(s) have determinism issues${reset}`);
|
|
98
|
+
else w.write(` ${bgYellow}${white}${bold} SKIP ${reset} ${yellow}No workflows were checked${reset}`);
|
|
99
|
+
const parts = [`${green}${report.successCount}${reset} passed`];
|
|
100
|
+
if (report.failureCount > 0) parts.push(`${red}${report.failureCount}${reset} failed`);
|
|
101
|
+
if (report.timeoutCount > 0) parts.push(`${yellow}${report.timeoutCount}${reset} timed out`);
|
|
102
|
+
if (report.skippedCount > 0) parts.push(`${dim}${report.skippedCount}${reset} skipped`);
|
|
103
|
+
const total = report.successCount + report.failureCount + report.timeoutCount + report.skippedCount;
|
|
104
|
+
w.write(` ${dim}(${parts.join(", ")}, ${bold}${total}${reset}${dim} total)${reset}\n\n`);
|
|
143
105
|
}
|
|
144
106
|
function printReport(report, writer = process.stdout) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
107
|
+
writer.write("\n");
|
|
108
|
+
writer.write(` ${bgBlue}${bold}${white} WORKFLOW DETERMINISM CHECK ${reset}\n`);
|
|
109
|
+
printWorkflowTypes(report, writer);
|
|
110
|
+
printErrors(report, writer);
|
|
111
|
+
printWarnings(report, writer);
|
|
112
|
+
printSummaryBanner(report, writer);
|
|
151
113
|
}
|
|
152
|
-
//#
|
|
114
|
+
//#endregion
|
|
115
|
+
export { printReport };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,122 +1,82 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const env_1 = require("@diia-inhouse/env");
|
|
11
|
-
const checkWorkflowDeterminism_1 = require("./checkWorkflowDeterminism");
|
|
12
|
-
const syncTemporalSchedules_1 = require("./syncTemporalSchedules");
|
|
13
|
-
const updateTemporalSchedule_1 = require("./updateTemporalSchedule");
|
|
2
|
+
import { CheckWorkflowDeterminismCommand } from "./checkWorkflowDeterminism.js";
|
|
3
|
+
import { SyncTemporalSchedulesCommand } from "./syncTemporalSchedules.js";
|
|
4
|
+
import { UpdateTemporalScheduleCommand } from "./updateTemporalSchedule.js";
|
|
5
|
+
import { EnvService } from "@diia-inhouse/env";
|
|
6
|
+
import { DiiaLogger } from "@diia-inhouse/diia-logger";
|
|
7
|
+
import yargs from "yargs";
|
|
8
|
+
import { hideBin } from "yargs/helpers";
|
|
9
|
+
//#region src/cli/index.ts
|
|
14
10
|
async function main() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type: 'string',
|
|
84
|
-
default: 'worker/workflows',
|
|
85
|
-
describe: 'Path to workflows directory',
|
|
86
|
-
})
|
|
87
|
-
.option('taskQueue', {
|
|
88
|
-
type: 'string',
|
|
89
|
-
describe: 'Task queue name',
|
|
90
|
-
})
|
|
91
|
-
.option('historyDir', {
|
|
92
|
-
type: 'string',
|
|
93
|
-
describe: 'Path to directory with dumped history JSON files (skips Temporal server connection)',
|
|
94
|
-
})
|
|
95
|
-
.option('limit', {
|
|
96
|
-
type: 'number',
|
|
97
|
-
describe: 'Max number of history files to check (default: all)',
|
|
98
|
-
})
|
|
99
|
-
.positional('workflowId', {
|
|
100
|
-
type: 'string',
|
|
101
|
-
describe: 'Specific workflow ID to check (optional)',
|
|
102
|
-
})
|
|
103
|
-
.example('diia-workflow check-determinism', 'Check recent completed or failed workflows for determinism issues')
|
|
104
|
-
.example('diia-workflow check-determinism my-workflow-id', 'Check a specific workflow by ID for determinism issues')
|
|
105
|
-
.example('diia-workflow check-determinism --historyDir ./temporal-dumps', 'Check determinism against local history files'), async (argv) => {
|
|
106
|
-
const logger = new diia_logger_1.default();
|
|
107
|
-
const envService = new env_1.EnvService(logger);
|
|
108
|
-
await envService.init();
|
|
109
|
-
try {
|
|
110
|
-
const command = new checkWorkflowDeterminism_1.CheckWorkflowDeterminismCommand(logger, envService);
|
|
111
|
-
await (argv.historyDir
|
|
112
|
-
? command.runFromFiles(argv.workflowsPath, argv.historyDir, argv.limit)
|
|
113
|
-
: command.run(argv.workflowsPath, argv.taskQueue, argv.workflowId));
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
await envService.onDestroy();
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
.help().argv;
|
|
11
|
+
await yargs(hideBin(process.argv)).command("sync-schedules", "Sync schedules with Temporal server", (args) => args.option("schedulesPath", {
|
|
12
|
+
type: "string",
|
|
13
|
+
default: "worker/schedules",
|
|
14
|
+
describe: "Path to schedules directory"
|
|
15
|
+
}).option("taskQueue", {
|
|
16
|
+
type: "string",
|
|
17
|
+
describe: "Task queue name"
|
|
18
|
+
}), async (argv) => {
|
|
19
|
+
const logger = new DiiaLogger();
|
|
20
|
+
const envService = new EnvService(logger);
|
|
21
|
+
await envService.init();
|
|
22
|
+
try {
|
|
23
|
+
await new SyncTemporalSchedulesCommand(logger, envService).run(argv.schedulesPath, argv.taskQueue);
|
|
24
|
+
} finally {
|
|
25
|
+
await envService.onDestroy();
|
|
26
|
+
}
|
|
27
|
+
}).command("update-schedule <scheduleId> <updateJson>", "Update a temporal schedule", (args) => args.positional("scheduleId", {
|
|
28
|
+
type: "string",
|
|
29
|
+
describe: "ID of the schedule to update"
|
|
30
|
+
}).positional("updateJson", {
|
|
31
|
+
type: "string",
|
|
32
|
+
describe: "JSON object containing fields to update"
|
|
33
|
+
}).example("diia-workflow update-schedule my-schedule '{\"spec\": {\"intervals\": [{\"every\": \"300s\"}]}}'", "Change a schedule to run every 5 minutes").example("diia-workflow update-schedule my-schedule '{\"state\": {\"paused\": true}}'", "Pause a schedule").example("diia-workflow update-schedule my-schedule '{\"state\": {\"paused\": false}}'", "Resume a paused schedule").example("diia-workflow update-schedule my-schedule '{\"action\": {\"args\": [{\"param\": \"new-arg1\"}]}}'", "Update the arguments passed to the workflow").example("diia-workflow update-schedule my-schedule '{\n \"spec\": {\"intervals\": [{\"every\": \"600s\"}]},\n \"state\": {\"paused\": false},\n \"action\": {\"args\": [{\"param\": \"new-arg1\"}]}\n}'", "Update multiple fields in a single command"), async (argv) => {
|
|
34
|
+
if (!argv.scheduleId) throw new Error("scheduleId is required");
|
|
35
|
+
if (!argv.updateJson) throw new Error("updateJson is required");
|
|
36
|
+
let updateData;
|
|
37
|
+
try {
|
|
38
|
+
updateData = JSON.parse(argv.updateJson);
|
|
39
|
+
if (typeof updateData !== "object" || updateData === null) throw new Error("Update data must be a valid JSON object");
|
|
40
|
+
} catch (err) {
|
|
41
|
+
throw new Error(`Invalid JSON format. Please provide a valid JSON object. Error: ${err.message}`, { cause: err });
|
|
42
|
+
}
|
|
43
|
+
if (Object.keys(updateData).length === 0) throw new Error("Update data cannot be empty");
|
|
44
|
+
const logger = new DiiaLogger();
|
|
45
|
+
const envService = new EnvService(logger);
|
|
46
|
+
await envService.init();
|
|
47
|
+
try {
|
|
48
|
+
await new UpdateTemporalScheduleCommand(logger, envService).run(argv.scheduleId, updateData);
|
|
49
|
+
} finally {
|
|
50
|
+
await envService.onDestroy();
|
|
51
|
+
}
|
|
52
|
+
}).command("check-determinism [workflowId]", "Check completed or failed workflows for determinism issues", (args) => args.option("workflowsPath", {
|
|
53
|
+
type: "string",
|
|
54
|
+
default: "worker/workflows",
|
|
55
|
+
describe: "Path to workflows directory"
|
|
56
|
+
}).option("taskQueue", {
|
|
57
|
+
type: "string",
|
|
58
|
+
describe: "Task queue name"
|
|
59
|
+
}).option("historyDir", {
|
|
60
|
+
type: "string",
|
|
61
|
+
describe: "Path to directory with dumped history JSON files (skips Temporal server connection)"
|
|
62
|
+
}).option("limit", {
|
|
63
|
+
type: "number",
|
|
64
|
+
describe: "Max number of history files to check (default: all)"
|
|
65
|
+
}).positional("workflowId", {
|
|
66
|
+
type: "string",
|
|
67
|
+
describe: "Specific workflow ID to check (optional)"
|
|
68
|
+
}).example("diia-workflow check-determinism", "Check recent completed or failed workflows for determinism issues").example("diia-workflow check-determinism my-workflow-id", "Check a specific workflow by ID for determinism issues").example("diia-workflow check-determinism --historyDir ./temporal-dumps", "Check determinism against local history files"), async (argv) => {
|
|
69
|
+
const logger = new DiiaLogger();
|
|
70
|
+
const envService = new EnvService(logger);
|
|
71
|
+
await envService.init();
|
|
72
|
+
try {
|
|
73
|
+
const command = new CheckWorkflowDeterminismCommand(logger, envService);
|
|
74
|
+
await (argv.historyDir ? command.runFromFiles(argv.workflowsPath, argv.historyDir, argv.limit) : command.run(argv.workflowsPath, argv.taskQueue, argv.workflowId));
|
|
75
|
+
} finally {
|
|
76
|
+
await envService.onDestroy();
|
|
77
|
+
}
|
|
78
|
+
}).help().argv;
|
|
120
79
|
}
|
|
121
|
-
|
|
122
|
-
//#
|
|
80
|
+
main();
|
|
81
|
+
//#endregion
|
|
82
|
+
export {};
|