/** * n8n expression classifier. n8n stores an expression as a string value that * begins with `=` and interpolates `{{ … }}` blocks of JS. We lower them into * the three tiers the Pikku graph input mapper supports: * * - literal → a plain value * - ref → ref(nodeId, path) (pure single reference) * - template → template('… $0 …', [ref, …]) (literal text + pure refs) * - transform → not declaratively expressible; needs a generated function * (the original expression is preserved verbatim) */ export interface RefPart { nodeId: string; path?: string; } export type ClassifiedExpression = { kind: 'literal'; value: unknown; } | { kind: 'ref'; nodeId: string; path?: string; } | { kind: 'template'; parts: string[]; refs: RefPart[]; } | { kind: 'transform'; expression: string; }; export interface ExprContext { /** nodeId of the immediate predecessor — what `$json` refers to. */ predecessorNodeId?: string; /** All graph-node predecessors in order — the input streams of a join node. */ predecessorNodeIds?: string[]; /** Map from original n8n node NAME to sanitized graph nodeId. */ nameToNodeId: Record; /** * Sanitized nodeIds of trigger nodes. A trigger is not a graph node — its data * is the graph's implicit `trigger` input — so any reference to one lowers to * `ref('trigger', …)`, the only form the generated ref map accepts for it. */ triggerNodeIds?: Set; /** * Rewrite map for references at non-graph nodes (dropped No Op passthroughs) → * their terminal data source (`'trigger'` or a graph nodeId). See Topology. */ refRewrite?: Record; /** * Per graph nodeId: n8n output-field name → addon output key. A ref whose * leading path segment is a node's n8n output-field name is remapped onto the * addon key (e.g. dateTime `formattedDate` → `result`). See native-map. */ outputAliasByNodeId?: Record>; } /** * Classify a single n8n parameter value. */ export declare function classifyExpression(value: unknown, ctx: ExprContext): ClassifiedExpression;