convertSteps function exported
Last updated: 2026-03-05T10:53:28.863Z
Metrics
LOC: 74
Complexity: 23
Params: 1
Signature
convertSteps(recorded: RecordedStep[]): : FlowStep[]
Summary
Convert standalone RecordedStep[] into FlowStep[]. Useful when you only have steps without a full session.
Architecture violations
- [warning] max-cyclomatic-complexity: 'convertSteps' has cyclomatic complexity 23 (max 10)
Source Code
export function convertSteps(recorded: RecordedStep[]): FlowStep[] {
const result: FlowStep[] = [];
let prevTimestamp: number | null = null;
for (const rec of recorded) {
const action = mapActionType(rec.type);
if (!action) continue;
const flowStep: FlowStep = {
id: nextStepId(),
action,
label: rec.label,
};
// Selector
if (rec.selector) {
flowStep.selector = rec.selector;
}
if (rec.smartSelectors?.length) {
flowStep.smartSelectors = rec.smartSelectors;
}
// Value source for fill steps
if (action === "fill" && rec.value != null) {
const fieldType = isValidFieldType(rec.fieldType) ? rec.fieldType : null;
flowStep.valueSource = mapValueToSource(rec.value, fieldType);
}
// Navigation URL
if (action === "navigate" && rec.url) {
flowStep.url = rec.url;
}
// Select
if (action === "select" && rec.value != null) {
flowStep.selectText = rec.value;
}
// Key press
if (action === "press-key" && rec.key) {
flowStep.key = rec.key;
}
// Wait timeout
if (action === "wait") {
flowStep.waitTimeout = rec.waitTimeout ?? 10_000;
}
// Scroll
if (action === "scroll" && rec.scrollPosition) {
flowStep.scrollPosition = rec.scrollPosition;
}
// Assert
if (action === "assert") {
flowStep.assertion = mapAssertion(rec);
}
// Timing delta from previous step
if (prevTimestamp !== null && rec.timestamp > 0) {
const delta = rec.timestamp - prevTimestamp;
if (delta > 0) {
flowStep.delayBefore = delta;
}
}
if (rec.timestamp > 0) {
prevTimestamp = rec.timestamp;
}
result.push(flowStep);
}
return result;
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| mapActionType | calls |
| nextStepId | calls |
| isValidFieldType | calls |
| mapValueToSource | calls |
| mapAssertion | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| convertRecordingToFlow | calls |
| makeSession | uses |