mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 13:39:44 +02:00
24 lines
973 B
TypeScript
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;
|
|
}
|