n8n/packages/@n8n/node-engine-compatibility/src/io.ts
Matsu 7be94a1184
chore: Update eslint configuration (#38307)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 14:40:35 +03:00

24 lines
973 B
TypeScript

import type { StepSlots } from '@n8n/engine';
import type { INodeExecutionData } from 'n8n-workflow';
import { isRecord } from './guards';
export function fromStepInputs(value: StepSlots): INodeExecutionData[][] {
return value.map((items) => {
if (!Array.isArray(items)) return [];
return items.map((item): INodeExecutionData => {
if (isRecord(item) && isRecord(item.json)) return item as unknown as INodeExecutionData;
if (isRecord(item)) return { json: item };
return { json: { value: item } };
});
});
}
export function toStepOutputs(outputs: INodeExecutionData[][]): StepSlots {
// v1 marks a branch "not taken" by producing zero items; the engine marks it
// with a null slot (dead edge), which is what makes skip propagation see the
// branch as dead. The collapse is v1 policy applied at the boundary — []
// stays representable inside the engine.
return outputs.map((slot) => (slot.length === 0 ? null : slot)) as unknown as StepSlots;
}