Class ExpressionBuilder<T, Path, TCurr>

Source

Constructors§

Source§

new ExpressionBuilder<
    T extends ChainContext = any,
    Path extends string = any,
    TCurr = TypeOfField<Path, T>,
>(
    path: Path,
    methodCalls?: string[],
    options?: ExpressionBuilderOptions,
): ExpressionBuilder<T, Path, TCurr>

Properties§

§filter: TCurr extends TElem[]
    ? (predicate: (item: TElem) => boolean) => this
    : "Expected array "...
§find: TCurr extends TElem[]
    ? (
        predicate: (item: TElem) => boolean,
    ) => ExpressionBuilder<T, `${Path}[${number}]`>
    : "Expected array "...
§first: TCurr extends any[]
    ? () => ExpressionBuilder<T, `${Path}[${number}]`>
    : "Expected array "...
§join: TCurr extends any[]
    ? (
        separator: string,
    ) => ExpressionBuilder<any, any, string>
    : "Expected array "...
§last: TCurr extends any[]
    ? () => ExpressionBuilder<T, `${Path}[${number}]`>
    : "Expected array "...
§split: TCurr extends string
    ? (
        separator: string,
    ) => ExpressionBuilder<any, any, string[]>
    : "Expected string "...
§toJsonString: { ... }...
§toLowerCase: TCurr extends string ? () => this : "Expected string "...
§toUpperCase: TCurr extends string ? () => this : "Expected string "...
§trim: TCurr extends string ? () => this : "Expected string "...
§public readonly type: TCurr...

The type of the current field Should only be used with typeof Returns null.

Methods§

Source§

apply<TOutput = unknown>(
    fn: (value: TCurr) => TOutput,
): ExpressionBuilder<T, Path, TOutput>

Apply an arbitrary transform function to the current value.

The function body is parsed and converted into a chain of method calls. The parameter type is inferred from the current field type, and the output type is inferred from the function's return type.

Example:

$("json.text").apply(text => text.toUpperCase().split(" ").join("-"))
// Results in: "={{ $json.text.toUpperCase().split(' ').join('-') }}"

Notes:

  • The input parameter of the function is typed as the current field type (TCurr).
  • The resulting ExpressionBuilder's output type will be inferred from the function return type.
  • Not all JS globals or helper functions may be available inside n8n expression evaluation.
Source§

call(
    methodName: string,
    ...args: any[],
): ExpressionBuilder<T, any>

Arbitrary method call

Source§

format(): string

Source§

getFullPath(): Path

Source§

getNodeId(): string

Source§

getPath(): string

Source§

mode(mode: "item"): this

Source§

noQuotes(value?: boolean): this

Source§

prefix(prefix: ExpressionPrefix): this

Source§

prop<P>(
    propertyName: P,
): ExpressionBuilder<T, `${Path}${P}`>

Source§

toExpression(): string

return ={{ format() }}

Source§

toJSON(): string