use assert instead of defaulting

This commit is contained in:
Laila Los
2023-01-19 10:38:10 +01:00
parent a0d58eaefc
commit 6f6242d9c0
@@ -2,6 +2,7 @@ import ELK from "elkjs/lib/elk.bundled.js";
import { useWorkflowStateStore } from "@/stores/workflowEditorStateStore";
import type { Step } from "@/stores/workflowStepStore";
import { useConnectionStore } from "@/stores/workflowConnectionStore";
import { assertDefined } from "@/utils/assertions";
const elk = new ELK();
@@ -67,11 +68,14 @@ export async function autoLayout(steps: { [index: string]: Step }) {
},
};
});
const position = stateStore.stepPosition[step.id];
assertDefined(position, `No StepPosition with step id ${step.id} found in workflowStateStore`);
return {
id: stepId,
height: (position?.height ?? 0) + 20,
width: (position?.width ?? 0) + 60,
height: position.height + 20,
width: position.width + 60,
ports: inputs.concat(outputs),
};
});