@qodalis/cli-server-jobs 2.3.0 → 2.4.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/package.json +2 -2
- package/public-api.d.mts +68 -51
- package/public-api.d.ts +68 -51
- package/public-api.js +51 -8
- package/public-api.js.map +1 -1
- package/public-api.mjs +50 -9
- package/public-api.mjs.map +1 -1
- package/umd/index.global.js +48 -7
package/public-api.mjs
CHANGED
|
@@ -166,6 +166,24 @@ function formatRelativeTime(isoString) {
|
|
|
166
166
|
if (diff < 864e5) return `${Math.round(diff / 36e5)}h ago`;
|
|
167
167
|
return `${Math.round(diff / 864e5)}d ago`;
|
|
168
168
|
}
|
|
169
|
+
function formatSpan(value) {
|
|
170
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
171
|
+
if (typeof value === "string") return value;
|
|
172
|
+
if (!Number.isFinite(value) || value < 0) return null;
|
|
173
|
+
const units = [[864e5, "d"], [36e5, "h"], [6e4, "m"], [1e3, "s"]];
|
|
174
|
+
for (const [size, unit] of units) {
|
|
175
|
+
if (value >= size && value % size === 0) return `${value / size}${unit}`;
|
|
176
|
+
}
|
|
177
|
+
return value >= 1e3 ? `${(value / 1e3).toFixed(1)}s` : `${value}ms`;
|
|
178
|
+
}
|
|
179
|
+
function formatRunning(job) {
|
|
180
|
+
const running = job.runningExecutionIds?.length ?? (job.currentExecutionId ? 1 : 0);
|
|
181
|
+
const max = job.maxConcurrentRuns ?? 1;
|
|
182
|
+
if (running === 0 && !job.queued) return null;
|
|
183
|
+
const parts = [max > 1 ? `${running}/${max} running` : `${running} running`];
|
|
184
|
+
if (job.queued) parts.push("1 queued");
|
|
185
|
+
return parts.join(", ");
|
|
186
|
+
}
|
|
169
187
|
function formatDuration(ms) {
|
|
170
188
|
if (ms == null) return "-";
|
|
171
189
|
if (ms < 1e3) return `${ms}ms`;
|
|
@@ -531,6 +549,11 @@ var CliJobsCommandProcessor = class {
|
|
|
531
549
|
t.t("cli.server.jobs.edit.help.change_job_step_step", "Change a job step by step: description, group, cron schedule or interval, max retries, timeout and overlap policy (skip, queue or cancel). Press Enter to keep a value and Ctrl+C or Escape to cancel; nothing changes until you confirm. A job on several servers needs --server.")
|
|
532
550
|
);
|
|
533
551
|
context.writer.writeln();
|
|
552
|
+
writeWrapped(
|
|
553
|
+
context,
|
|
554
|
+
t.t("cli.server.jobs.edit.help.max_concurrent_runs", "Max concurrent runs: how many runs of the job may go at the same time (1 by default). When that many are running, the overlap policy decides what happens to the next one.")
|
|
555
|
+
);
|
|
556
|
+
context.writer.writeln();
|
|
534
557
|
writeUsage(context, [
|
|
535
558
|
["server jobs edit <name|id>", ""]
|
|
536
559
|
]);
|
|
@@ -622,7 +645,7 @@ var CliJobsCommandProcessor = class {
|
|
|
622
645
|
j.name,
|
|
623
646
|
j.group ?? "-",
|
|
624
647
|
statusColor(j.status, context.writer),
|
|
625
|
-
j.schedule ?? (j.interval ? `every ${j.interval}
|
|
648
|
+
j.schedule ?? (formatSpan(j.interval) ? `every ${formatSpan(j.interval)}` : "-"),
|
|
626
649
|
formatRelativeTime(j.lastRunAt),
|
|
627
650
|
formatRelativeTime(j.nextRunAt),
|
|
628
651
|
formatDuration(j.lastRunDuration)
|
|
@@ -660,12 +683,16 @@ var CliJobsCommandProcessor = class {
|
|
|
660
683
|
["Status", statusColor(job.status, context.writer)],
|
|
661
684
|
[
|
|
662
685
|
"Schedule",
|
|
663
|
-
job.schedule ?? (job.interval ? `every ${job.interval}
|
|
686
|
+
job.schedule ?? (formatSpan(job.interval) ? `every ${formatSpan(job.interval)}` : "-")
|
|
664
687
|
],
|
|
665
688
|
["Max Retries", String(job.maxRetries)],
|
|
666
|
-
["Timeout", job.timeout
|
|
689
|
+
["Timeout", formatSpan(job.timeout) ?? "none"],
|
|
667
690
|
["Overlap Policy", job.overlapPolicy],
|
|
668
|
-
["
|
|
691
|
+
["Max Concurrent Runs", String(job.maxConcurrentRuns ?? 1)],
|
|
692
|
+
[
|
|
693
|
+
"Running",
|
|
694
|
+
job.runningExecutionIds && job.runningExecutionIds.length > 1 ? `${formatRunning(job)}: ${job.runningExecutionIds.join(", ")}` : formatRunning(job) && job.currentExecutionId ? `${formatRunning(job)} (${job.currentExecutionId})` : formatRunning(job) ?? "none"
|
|
695
|
+
],
|
|
669
696
|
["Next Run", formatRelativeTime(job.nextRunAt)],
|
|
670
697
|
["Last Run", formatRelativeTime(job.lastRunAt)],
|
|
671
698
|
[
|
|
@@ -909,7 +936,7 @@ var CliJobsCommandProcessor = class {
|
|
|
909
936
|
const newGroup = await ask(`Group [${job.group ?? "none"}]: `);
|
|
910
937
|
if (newGroup == null) return cancelled();
|
|
911
938
|
if (newGroup) update.group = newGroup;
|
|
912
|
-
const currentSchedule = job.schedule ?? (job.interval ? `interval: ${job.interval}
|
|
939
|
+
const currentSchedule = job.schedule ?? (formatSpan(job.interval) ? `interval: ${formatSpan(job.interval)}` : "none");
|
|
913
940
|
const newSchedule = await ask(
|
|
914
941
|
`Cron schedule [${currentSchedule}]: `
|
|
915
942
|
);
|
|
@@ -917,7 +944,7 @@ var CliJobsCommandProcessor = class {
|
|
|
917
944
|
if (newSchedule) update.schedule = newSchedule;
|
|
918
945
|
if (!newSchedule) {
|
|
919
946
|
const newInterval = await ask(
|
|
920
|
-
`Interval (e.g. 30s, 5m) [${job.interval
|
|
947
|
+
`Interval (e.g. 30s, 5m) [${formatSpan(job.interval) ?? "none"}]: `
|
|
921
948
|
);
|
|
922
949
|
if (newInterval == null) return cancelled();
|
|
923
950
|
if (newInterval) update.interval = newInterval;
|
|
@@ -931,7 +958,7 @@ var CliJobsCommandProcessor = class {
|
|
|
931
958
|
}
|
|
932
959
|
}
|
|
933
960
|
const newTimeout = await ask(
|
|
934
|
-
`Timeout (e.g. 5m, 1h) [${job.timeout
|
|
961
|
+
`Timeout (e.g. 5m, 1h) [${formatSpan(job.timeout) ?? "none"}]: `
|
|
935
962
|
);
|
|
936
963
|
if (newTimeout == null) return cancelled();
|
|
937
964
|
if (newTimeout) update.timeout = newTimeout;
|
|
@@ -942,6 +969,20 @@ var CliJobsCommandProcessor = class {
|
|
|
942
969
|
if (newOverlap && ["skip", "queue", "cancel"].includes(newOverlap.toLowerCase())) {
|
|
943
970
|
update.overlapPolicy = newOverlap.toLowerCase();
|
|
944
971
|
}
|
|
972
|
+
const newMax = await ask(
|
|
973
|
+
`Max concurrent runs [${job.maxConcurrentRuns ?? 1}]: `
|
|
974
|
+
);
|
|
975
|
+
if (newMax == null) return cancelled();
|
|
976
|
+
if (newMax) {
|
|
977
|
+
const parsed = Number(newMax);
|
|
978
|
+
if (Number.isInteger(parsed) && parsed >= 1) {
|
|
979
|
+
update.maxConcurrentRuns = parsed;
|
|
980
|
+
} else {
|
|
981
|
+
context.writer.writeWarning(
|
|
982
|
+
"Max concurrent runs must be a whole number of at least 1; kept as it was."
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
945
986
|
if (Object.keys(update).length === 0) {
|
|
946
987
|
context.writer.writeInfo("No changes made.");
|
|
947
988
|
return;
|
|
@@ -1175,7 +1216,7 @@ var CliJobNameCompletionProvider = class {
|
|
|
1175
1216
|
};
|
|
1176
1217
|
|
|
1177
1218
|
// src/lib/version.ts
|
|
1178
|
-
var LIBRARY_VERSION = "2.
|
|
1219
|
+
var LIBRARY_VERSION = "2.4.0";
|
|
1179
1220
|
var API_VERSION = 2;
|
|
1180
1221
|
var completionProvider = new CliJobNameCompletionProvider();
|
|
1181
1222
|
var jobsModule = {
|
|
@@ -1194,6 +1235,6 @@ var jobsModule = {
|
|
|
1194
1235
|
}
|
|
1195
1236
|
};
|
|
1196
1237
|
|
|
1197
|
-
export { API_VERSION, CliJobNameCompletionProvider, CliJobsCommandProcessor, CliJobsService, LIBRARY_VERSION, jobsModule };
|
|
1238
|
+
export { API_VERSION, CliJobNameCompletionProvider, CliJobsCommandProcessor, CliJobsService, LIBRARY_VERSION, formatRunning, formatSpan, jobsModule };
|
|
1198
1239
|
//# sourceMappingURL=public-api.mjs.map
|
|
1199
1240
|
//# sourceMappingURL=public-api.mjs.map
|