diff --git a/docs/nodes.md b/docs/nodes.md index 9a5e4b5773..8c3b061474 100644 --- a/docs/nodes.md +++ b/docs/nodes.md @@ -163,7 +163,7 @@ const workflowName = $workflow.name; ``` -#### Method: evaluateExpression(expression: string, itemIndex: number) +#### Method: $evaluateExpression(expression: string, itemIndex: number) Evaluates a given string as expression. If no `itemIndex` is provided it uses by default in the Function-Node the data of item 0 and @@ -172,8 +172,8 @@ in the Function Item-Node the data of the current item. Example: ```javascript -items[0].json.variable1 = evaluateExpression('{{1+2}}'); -items[0].json.variable2 = evaluateExpression($node["Set"].json["myExpression"], 1); +items[0].json.variable1 = $evaluateExpression('{{1+2}}'); +items[0].json.variable2 = $evaluateExpression($node["Set"].json["myExpression"], 1); return items; ``` diff --git a/packages/cli/BREAKING-CHANGES.md b/packages/cli/BREAKING-CHANGES.md index 8a8e02eac3..969b258243 100644 --- a/packages/cli/BREAKING-CHANGES.md +++ b/packages/cli/BREAKING-CHANGES.md @@ -2,6 +2,23 @@ This list shows all the versions which include breaking changes and how to upgrade +## 0.62.0 + +### What changed? + +The function "evaluateExpression(...)" got renamed to "$evaluateExpression()" +in Function and FunctionItem Nodes to simplify code and to normalize function +names. + +### When is action necessary? + +If "evaluateExpression(...)" gets used in any Function or FunctionItem Node. + +### How to upgrade: + +Simply replace the "evaluateExpression(...)" with "$evaluateExpression(...)". + + ## 0.52.0 ### What changed? diff --git a/packages/nodes-base/nodes/Function.node.ts b/packages/nodes-base/nodes/Function.node.ts index 253a216650..7f5ea4c1ea 100644 --- a/packages/nodes-base/nodes/Function.node.ts +++ b/packages/nodes-base/nodes/Function.node.ts @@ -47,9 +47,6 @@ export class Function implements INodeType { // Define the global objects for the custom function const sandbox = { - evaluateExpression: (expression: string, itemIndex = 0) => { - return this.evaluateExpression(expression, itemIndex); - }, getNodeParameter: this.getNodeParameter, getWorkflowStaticData: this.getWorkflowStaticData, helpers: this.helpers, diff --git a/packages/nodes-base/nodes/FunctionItem.node.ts b/packages/nodes-base/nodes/FunctionItem.node.ts index 356e419477..6352fc3f98 100644 --- a/packages/nodes-base/nodes/FunctionItem.node.ts +++ b/packages/nodes-base/nodes/FunctionItem.node.ts @@ -48,9 +48,6 @@ export class FunctionItem implements INodeType { // Define the global objects for the custom function const sandbox = { - evaluateExpression: (expression: string, itemIndex: number | undefined) => { - return this.evaluateExpression(expression, itemIndex); - }, getBinaryData: (): IBinaryKeyData | undefined => { return item.binary; }, diff --git a/packages/workflow/src/Workflow.ts b/packages/workflow/src/Workflow.ts index a3d069058d..6c1c48ad56 100644 --- a/packages/workflow/src/Workflow.ts +++ b/packages/workflow/src/Workflow.ts @@ -899,9 +899,6 @@ export class Workflow { // Generate a data proxy which allows to query workflow data const dataProxy = new WorkflowDataProxy(this, runExecutionData, runIndex, itemIndex, activeNodeName, connectionInputData); const data = dataProxy.getDataProxy(); - data.$evaluateExpression = (expression: string) => { - return this.resolveSimpleParameterValue('=' + expression, runExecutionData, runIndex, itemIndex, activeNodeName, connectionInputData, returnObjectAsString); - }; // Execute the expression try { diff --git a/packages/workflow/src/WorkflowDataProxy.ts b/packages/workflow/src/WorkflowDataProxy.ts index aa30470b1c..8094991f3c 100644 --- a/packages/workflow/src/WorkflowDataProxy.ts +++ b/packages/workflow/src/WorkflowDataProxy.ts @@ -335,7 +335,10 @@ export class WorkflowDataProxy { $binary: {}, // Placeholder $data: {}, // Placeholder $env: this.envGetter(), - $evaluateExpression: (expression: string) => { }, // Placeholder + $evaluateExpression: (expression: string, itemIndex?: number) => { + itemIndex = itemIndex || that.itemIndex; + return that.workflow.getParameterValue('=' + expression, that.runExecutionData, that.runIndex, itemIndex, that.activeNodeName, that.connectionInputData); + }, $item: (itemIndex: number, runIndex?: number) => { const defaultReturnRunIndex = runIndex === undefined ? -1 : runIndex; const dataProxy = new WorkflowDataProxy(this.workflow, this.runExecutionData, this.runIndex, itemIndex, this.activeNodeName, this.connectionInputData, defaultReturnRunIndex);