feat(FN-2855): route scheduled tasks using effective node resolution
- Add an effective node resolver with task override, project default, and local fallback precedence. - Wire scheduler dispatch to persist effectiveNodeId/effectiveNodeSource and log resolved node routing. - Add coverage for effective node resolution and scheduler node routing integration behavior. - Stabilize workspace test resolution by adding @fusion/core and @fusion/plugin-sdk aliases across Vitest configs.
This commit is contained in:
27
packages/engine/src/effective-node.ts
Normal file
27
packages/engine/src/effective-node.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ProjectSettings, Task } from "@fusion/core";
|
||||
|
||||
export type EffectiveNodeSource = "task-override" | "project-default" | "local";
|
||||
|
||||
export interface EffectiveNode {
|
||||
nodeId: string | undefined;
|
||||
source: EffectiveNodeSource;
|
||||
}
|
||||
|
||||
function isSetNodeId(nodeId: string | null | undefined): nodeId is string {
|
||||
return typeof nodeId === "string" && nodeId.trim().length > 0;
|
||||
}
|
||||
|
||||
export function resolveEffectiveNode(
|
||||
task: Pick<Task, "nodeId">,
|
||||
settings: Pick<ProjectSettings, "defaultNodeId">,
|
||||
): EffectiveNode {
|
||||
if (isSetNodeId(task.nodeId)) {
|
||||
return { nodeId: task.nodeId, source: "task-override" };
|
||||
}
|
||||
|
||||
if (isSetNodeId(settings.defaultNodeId)) {
|
||||
return { nodeId: settings.defaultNodeId, source: "project-default" };
|
||||
}
|
||||
|
||||
return { nodeId: undefined, source: "local" };
|
||||
}
|
||||
Reference in New Issue
Block a user