/** * Declarative mapping of n8n node types onto @pikku/addon-graph functions whose * contract is a plain single-value transform — the input is assembled by a 1:1 * field mapping (n8n param → addon input field), each value lowered like any * other expression (ref / template / literal). * * Array-stream transforms (aggregate / limit / sort …) feed their `items`/`item` * input from a pathless predecessor ref (`fromPredecessor`), and their per-row * config from n8n `fixedCollection`s (`fromCollection`). `merge` stays absent — * n8n Merge is graph topology (multiple inputs join a node), not a transform. */ /** One addon input field sourced from an n8n parameter. */ export interface NativeFieldSpec { /** n8n parameter key(s); the first present value wins. */ from?: string | string[]; /** * n8n resource-locator parameter key(s) — reads the locator's `.value` * (a literal id, a URL, or an `={{…}}` expression) rather than the whole * `{ __rl, mode, value }` wrapper. First present locator wins. */ fromRL?: string | string[]; /** * Source the whole output of the node's data predecessor as this field — * `ref(predecessorNodeId)`. This is how n8n's implicit incoming item stream * maps onto an array-transform addon's `items` input. */ fromPredecessor?: boolean; /** * Source an array of refs to ALL graph-node predecessors — the multiple input * streams that feed a join node (n8n Merge → `[ref(a), ref(b), …]`). Emits * nothing when the node has no graph predecessors. */ fromAllPredecessors?: boolean; /** * Source a single property of the data predecessor's item — `ref(predId, * )` — where the property name is read from the n8n parameter `param` * (n8n's `dataPropertyName` idiom: the field on the incoming item that holds * the string a text node operates on). Falls back to `default` when the param * is absent or an expression rather than a plain property path. */ fromPredecessorPath?: { param: string; default: string; }; /** Source this node's own graph id as a string literal (e.g. a step name). */ fromNodeId?: boolean; /** * Source this field from an n8n `fixedCollection` — the nested `{ outer: { * inner: [ … ] } }` shape n8n uses for repeatable config rows (sort fields, * key-rename pairs, summarize aggregations). `path` is the dot-path to the * inner array. With `map`, each row is projected into an object (addon key → * n8n row key, optionally remapping enum values); with `pick`, each row * contributes a single scalar (`first` keeps only the first row's value). */ fromCollection?: { /** Dot-path to the inner array, e.g. `sortFieldsUi.sortField`. */ path: string; /** Project each row into an object: addon key → n8n row key or `{ from, values }`. */ map?: Record; asConst?: boolean; }>; /** Or pick one scalar per row (→ an array, or a single value with `first`). */ pick?: string; /** With `pick`, keep only the first row's scalar. */ first?: boolean; }; /** * Remap the resolved string value through this table before emitting — for * n8n→addon enum translation (e.g. n8n dateTime `addToDate` → addon `add`, * crypto `SHA256` → `sha256`). A value absent from the table passes through * unchanged. Applies to `from` / `fromRL` scalar sources. */ values?: Record; /** Fallback when none of the source keys are present. */ default?: unknown; /** Preserve a string literal's enum type (`"x" as const`) rather than widen. */ asConst?: boolean; } /** * Some n8n nodes write their single result under a user-named output field * (n8n's "Output Field Name"), whereas the addon returns it under a fixed key. * A downstream `$node["X"].json.` must therefore resolve to the * addon's key, not the n8n name — e.g. dateTime's `formattedDate` → `result`. */ export interface NativeOutputAliasSpec { /** * n8n parameter key(s) holding the custom output-field name (dot-paths * supported, e.g. `options.outputFieldName`); the first present value wins. */ from?: string | string[]; /** n8n's default output-field name when the param is absent, e.g. `formattedDate`. */ default: string; /** The addon output key the aliased field resolves to, e.g. `result`. */ to: string; } export interface NativeNodeSpec { /** The @pikku/addon-graph RPC name, e.g. `graph:stopAndError`. */ rpc: string; /** addon input field → n8n source parameter. */ fields: Record; /** * Guard: only treat the node as this native mapping when it returns true. * Used when a single n8n node type has modes we can't all map (e.g. Wait's * non-interval resume modes). */ applies?: (parameters: Record) => boolean; /** * A downstream ref into this node's named output field → the addon output key. * See NativeOutputAliasSpec. */ outputAlias?: NativeOutputAliasSpec; /** * This operation returns an array of per-item records (a "read"/"list"), so a * single downstream consumer of its `$json` is n8n's implicit per-item loop. * The importer lowers that edge into a `graph:fanout` node. Only set on * rpcs that return the post-processed per-item shape (e.g. `readRows`, * `listRecordItems`), never the raw REST envelope. */ collection?: boolean; } export declare function nativeSpecFor(typeShort: string, parameters?: Record): NativeNodeSpec | undefined; /** * The output-field alias for a native node instance: the n8n output-field name * this node writes to (custom or default) → the addon output key. Returns * undefined when the node type declares no alias. */ export declare function nativeOutputAliasFor(typeShort: string, parameters: Record): { field: string; to: string; } | undefined;