/** * Per-item fan-out lowering. * * n8n runs every node once per incoming item, so a "read"/"list" node that * returns an array implicitly loops its downstream consumers. Pikku's graph is * declarative (one value per node, no ambient fan-out), so that edge is lowered * into an explicit `graph:fanout` node: the collection source stays a node, and * its single per-item consumer is pulled out of the graph flow and invoked once * per element as the fanout's `child`, with its `$json` references rebound to the * per-item `$item`. * * v1 is deliberately single-hop: it only lowers a collection source feeding * exactly one terminal consumer whose sole input is that source. Longer per-item * sub-chains are left untouched (and surfaced by the harness) until the child is * generalised to a synthesised per-item sub-graph. */ import type { NextValue, Topology } from './topology.js'; export interface FanoutMap { /** Synthetic `graph:fanout` node id inserted between the source and consumer. */ mapNodeId: string; /** The collection source whose array output is fanned out over. */ sourceNodeId: string; /** The absorbed consumer's nodeId — its input becomes the map's childInput. */ childNodeId: string; /** The rpc the map invokes once per item. */ childRpc: string; /** The map node's own successor (the consumer's original next), if any. */ next?: NextValue; } export interface FanoutPlan { maps: FanoutMap[]; /** Consumer nodeIds pulled out of the graph flow (invoked only as a child). */ absorbed: Set; /** Source nodeId → the map node its `next` must be rewritten to. */ sourceNext: Map; } export declare function planFanout(topo: Topology): FanoutPlan;