Class If<L, True, False, CC, IdsInContext>

Source
Expand description

Route items to different branches (true/false)

Constructors§

Source§

new If<
    L extends string,
    True extends unknown = null,
    False extends unknown = null,
    CC extends ChainContext = {},
    IdsInContext extends string[] = [],
>(
    id: L,
    props: IfProps,
): If<L, True, False, CC, IdsInContext>

Properties§

Source§

public readonly id: L

Unique identifier for this state

Source§

public readonly label: undefined | string

The node label

Source§

public position?: NodePosition

Position of the node in the n8n workflow editor canvas When undefined, the node will be placed automatically

default
undefined
Source§

props: IfProps

Source§

public size: NodeSize = DEFAULT_NODE_SIZE

Size of the node in the n8n workflow editor

default
DEFAULT_NODE_SIZE

Methods§

Source§

canTakeInput(
    _fromState: IChainable,
    _withConnectionOptions?: ConnectionOptions,
): boolean

Determines if this If node can accept additional input connections

Source§

clone<Id extends string>(
    id: Id,
    props?: NodeProps,
    cloneOptions?: { preserveChainConnections?: boolean },
): Omit<If<L, True, False, CC, IdsInContext>, "id"> & Node<
    Id,
    {},
>

Creates a deep copy of this node with a new ID and optional property overrides

Source§

false<N extends IChainable<string, any>>(
    next: IsNullable<False> extends true
        ? N
        : "false() node is already set ",
    connectionOptions?: Omit<ConnectionOptions, "from">,
): If<
    L,
    True,
    N["~context"],
    {
        [K in string
        | number
        | symbol]: (
            N extends Chain<C_CC, any, false>
                ? IgnoreContext<C_CC> extends true
                    ? Omit<CC, "json">
                    : Omit<CC, "json"> & C_CC
                : N extends Group<_, G_Chain_CC, any>
                    ? IgnoreContext<G_Chain_CC> extends true
                        ? Omit<CC, "json">
                        : Omit<CC, "json"> & G_Chain_CC
                    : N extends If<any, any, any, I_Chain_CC, any>
                        ? IgnoreContext<I_Chain_CC> extends true
                            ? Omit<CC, "json">
                            : Omit<CC & I_Chain_CC, "json">
                        : N extends IChainable<Id, C>
                            ? IgnoreContext<C> extends true
                                ? Omit<CC, "json">
                                : { [k in string]: C } & Omit<CC, "json"> & {
                                    json: C;
                                }
                            : CC
        )[K]
    },
    AddNodeIdToIds<N, IdsInContext>,
>

Connects a node or chain to execute when the If condition evaluates to false

Source§

getCredentials(): | undefined
| (undefined | Credentials<any>)[]

Returns the credentials required by this node

Source§

getLabel(): string

Gets the display label for this node

Source§

getParameters(): Promise<
    {
        conditions: | undefined
        | {
            combinator: ConditionCombinator;
            conditions: (
                | StringCondition
                | NumberCondition
                | DateTimeCondition
                | BooleanCondition
                | ArrayCondition
                | ObjectCondition
            )[];
            options: {
                caseSensitive: boolean;
                typeValidation: string;
                version: number;
            };
        };
        looseTypeValidation: undefined
        | boolean;
        options:
            | undefined
            | {
                ignoreCase?: boolean;
                looseTypeValidation?: boolean;
            };
    },
>

Retrieves the parameters configured for this node

Source§

getPath(): string

Gets the full path of this node including its parent workflow

Source§

listOutgoing(): IChainable<string, any>[]

Returns all states that are connected as next states from this state

Source§

toNode(): Promise<
    {
        alwaysOutputData: undefined
        | boolean;
        credentials:
            | undefined
            | { [type: string]: { id: string } };
        disabled: undefined | boolean;
        executeOnce: undefined | boolean;
        id: L;
        maxTries: undefined | number;
        name: string;
        notes: undefined | string;
        notesInFlow: undefined | boolean;
        onError:
            | undefined
            | "continueRegularOutput"
            | "continueErrorOutput";
        parameters: undefined
        | {};
        position: undefined | NodePosition;
        retryOnFail: undefined | boolean;
        type: string;
        typeVersion: number;
    },
>

Source§

true<N extends IChainable<string, any>>(
    next: IsNullable<True> extends true
        ? N
        : "true() node is already set ",
    connectionOptions?: Omit<ConnectionOptions, "from">,
): If<
    L,
    N["~context"],
    False,
    {
        [K in string
        | number
        | symbol]: (
            N extends Chain<C_CC, any, false>
                ? IgnoreContext<C_CC> extends true
                    ? Omit<CC, "json">
                    : Omit<CC, "json"> & C_CC
                : N extends Group<_, G_Chain_CC, any>
                    ? IgnoreContext<G_Chain_CC> extends true
                        ? Omit<CC, "json">
                        : Omit<CC, "json"> & G_Chain_CC
                    : N extends If<any, any, any, I_Chain_CC, any>
                        ? IgnoreContext<I_Chain_CC> extends true
                            ? Omit<CC, "json">
                            : Omit<CC & I_Chain_CC, "json">
                        : N extends IChainable<Id, C>
                            ? IgnoreContext<C> extends true
                                ? Omit<CC, "json">
                                : { [k in string]: C } & Omit<CC, "json"> & {
                                    json: C;
                                }
                            : CC
        )[K]
    },
    AddNodeIdToIds<N, IdsInContext>,
>

Connects a node or chain to execute when the If condition evaluates to true