@nmakarov/cli-toolkit 0.70.0 → 0.72.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/cli-runner.cjs +77 -11
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +77 -11
- package/dist/cli-runner.js.map +1 -1
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js.map +1 -1
- package/dist/index.cjs +93 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +89 -11
- package/dist/index.js.map +1 -1
- package/dist/tasks.cjs +93 -11
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +89 -11
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/tasks.js
CHANGED
|
@@ -519,6 +519,9 @@ var DEFAULT_GROUP_MAX_INSTANCES = {
|
|
|
519
519
|
harvest: 1,
|
|
520
520
|
harvester: 0,
|
|
521
521
|
loader: 0,
|
|
522
|
+
toolkit: 0,
|
|
523
|
+
photocare: 0,
|
|
524
|
+
/** @deprecated use photocare */
|
|
522
525
|
photos: 0,
|
|
523
526
|
photosprocessor: 0,
|
|
524
527
|
ingest: 0
|
|
@@ -2700,6 +2703,67 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
2700
2703
|
"progressWithTimes",
|
|
2701
2704
|
"progressThrottleMs"
|
|
2702
2705
|
];
|
|
2706
|
+
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
2707
|
+
{
|
|
2708
|
+
key: "maxParallel",
|
|
2709
|
+
type: "number",
|
|
2710
|
+
label: "Max parallel",
|
|
2711
|
+
description: "Worker-lane concurrency (how many tasks claim at once)"
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
key: "pollMs",
|
|
2715
|
+
type: "number",
|
|
2716
|
+
label: "Poll ms",
|
|
2717
|
+
description: "Idle poll interval between claim attempts"
|
|
2718
|
+
},
|
|
2719
|
+
{
|
|
2720
|
+
key: "claimJitterMs",
|
|
2721
|
+
type: "number",
|
|
2722
|
+
label: "Claim jitter ms",
|
|
2723
|
+
description: "Random delay before worker claims (0 = off)"
|
|
2724
|
+
},
|
|
2725
|
+
{
|
|
2726
|
+
key: "scanLimit",
|
|
2727
|
+
type: "number",
|
|
2728
|
+
label: "Scan limit",
|
|
2729
|
+
description: "Max idle rows scanned per claim attempt"
|
|
2730
|
+
}
|
|
2731
|
+
];
|
|
2732
|
+
function mergeRuntimeParamSpecs(extra) {
|
|
2733
|
+
const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
|
|
2734
|
+
if (Array.isArray(extra)) {
|
|
2735
|
+
for (const raw of extra) {
|
|
2736
|
+
if (!raw || typeof raw !== "object") continue;
|
|
2737
|
+
const key = String(raw.key ?? "").trim();
|
|
2738
|
+
if (!key) continue;
|
|
2739
|
+
const prev = byKey.get(key) ?? {};
|
|
2740
|
+
const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
|
|
2741
|
+
byKey.set(key, {
|
|
2742
|
+
key,
|
|
2743
|
+
type,
|
|
2744
|
+
label: String(raw.label ?? prev.label ?? key),
|
|
2745
|
+
description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
|
|
2746
|
+
});
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
return Array.from(byKey.values());
|
|
2750
|
+
}
|
|
2751
|
+
function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
|
|
2752
|
+
const rt = ensureTasksRuntime(context);
|
|
2753
|
+
const out = {};
|
|
2754
|
+
for (const s of specs) {
|
|
2755
|
+
if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
|
|
2756
|
+
}
|
|
2757
|
+
return out;
|
|
2758
|
+
}
|
|
2759
|
+
function runtimeParamSpecsFromMetadata(metadata) {
|
|
2760
|
+
const meta = metadata && typeof metadata === "object" ? metadata : null;
|
|
2761
|
+
const raw = meta?.runtimeParams;
|
|
2762
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
2763
|
+
return mergeRuntimeParamSpecs();
|
|
2764
|
+
}
|
|
2765
|
+
return mergeRuntimeParamSpecs(raw);
|
|
2766
|
+
}
|
|
2703
2767
|
var CONTROL_LANE_TASK_NAMES = [
|
|
2704
2768
|
"stopRunner",
|
|
2705
2769
|
"stop",
|
|
@@ -2796,12 +2860,15 @@ async function applyRuntimeParam(context, key, value) {
|
|
|
2796
2860
|
const reg = context.servicesRegistry;
|
|
2797
2861
|
if (reg?.rowId && reg?.registryTable) {
|
|
2798
2862
|
try {
|
|
2799
|
-
const
|
|
2863
|
+
const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
|
|
2864
|
+
const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
|
|
2800
2865
|
for (const lk of LOOP_RUNTIME_KEYS) {
|
|
2801
|
-
if (runtime[lk] !== void 0
|
|
2866
|
+
if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
|
|
2867
|
+
runtimeSnapshot[lk] = runtime[lk];
|
|
2868
|
+
}
|
|
2802
2869
|
}
|
|
2803
2870
|
await updateServicesRegistryMetadata(context, reg, {
|
|
2804
|
-
runtime:
|
|
2871
|
+
runtime: runtimeSnapshot,
|
|
2805
2872
|
runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2806
2873
|
});
|
|
2807
2874
|
applied.push("servicesRegistry");
|
|
@@ -3694,18 +3761,25 @@ async function runTasksLoop(context, options) {
|
|
|
3694
3761
|
if (hbGroup) {
|
|
3695
3762
|
const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
|
|
3696
3763
|
const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
|
|
3697
|
-
const
|
|
3764
|
+
const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
|
|
3765
|
+
context.tasksRuntimeParamSpecs = runtimeParamSpecs;
|
|
3698
3766
|
const defaultMeta = {
|
|
3699
3767
|
component: "tasks-runner",
|
|
3700
3768
|
allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
|
|
3701
3769
|
paused: false,
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
}
|
|
3770
|
+
runtimeParams: runtimeParamSpecs,
|
|
3771
|
+
runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
|
|
3772
|
+
};
|
|
3773
|
+
const metadata = {
|
|
3774
|
+
...defaultMeta,
|
|
3775
|
+
...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
|
|
3708
3776
|
};
|
|
3777
|
+
if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
|
|
3778
|
+
metadata.runtimeParams = defaultMeta.runtimeParams;
|
|
3779
|
+
}
|
|
3780
|
+
if (!metadata.runtime || typeof metadata.runtime !== "object") {
|
|
3781
|
+
metadata.runtime = defaultMeta.runtime;
|
|
3782
|
+
}
|
|
3709
3783
|
registryReg = await registerInServicesRegistry(context, {
|
|
3710
3784
|
queueName,
|
|
3711
3785
|
target,
|
|
@@ -3715,7 +3789,7 @@ async function runTasksLoop(context, options) {
|
|
|
3715
3789
|
staleMs,
|
|
3716
3790
|
groupMaxInstances: options.runnerGroupMaxInstances,
|
|
3717
3791
|
enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
|
|
3718
|
-
metadata
|
|
3792
|
+
metadata
|
|
3719
3793
|
});
|
|
3720
3794
|
context.servicesRegistry = registryReg;
|
|
3721
3795
|
runnerIdentity = {
|
|
@@ -4029,6 +4103,7 @@ var TasksManager = class _TasksManager {
|
|
|
4029
4103
|
};
|
|
4030
4104
|
export {
|
|
4031
4105
|
AbstractTask,
|
|
4106
|
+
DEFAULT_RUNTIME_PARAM_SPECS,
|
|
4032
4107
|
LOGGER_RUNTIME_KEYS,
|
|
4033
4108
|
LOOP_RUNTIME_KEYS,
|
|
4034
4109
|
SERVICE_TASK_NAMES,
|
|
@@ -4063,6 +4138,7 @@ export {
|
|
|
4063
4138
|
listServicesRegistry,
|
|
4064
4139
|
matchesParsedPattern,
|
|
4065
4140
|
mergeAllowedTasksWithServiceTasks,
|
|
4141
|
+
mergeRuntimeParamSpecs,
|
|
4066
4142
|
nextTimeMatch,
|
|
4067
4143
|
normalizeAllowedTasks,
|
|
4068
4144
|
queueToTableNames,
|
|
@@ -4076,6 +4152,8 @@ export {
|
|
|
4076
4152
|
resolveSteps,
|
|
4077
4153
|
runNodeTaskScript,
|
|
4078
4154
|
runTasksLoop,
|
|
4155
|
+
runtimeParamSpecsFromMetadata,
|
|
4156
|
+
runtimeValuesForSpecs,
|
|
4079
4157
|
taskHistoryInsertFromQueueRow,
|
|
4080
4158
|
timeMatcher,
|
|
4081
4159
|
touchServicesRegistry as touchRunnerHeartbeat,
|