From cf1aec475b0f90f165c7ddb9573868ab82103736 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Thu, 9 May 2024 18:03:58 +0300 Subject: [PATCH 1/2] :zap: available in expressions --- .../CodeNodeEditor/completions/base.completions.ts | 4 ++++ packages/editor-ui/src/constants.ts | 1 + .../src/plugins/codemirror/completions/constants.ts | 5 +++++ packages/editor-ui/src/plugins/i18n/index.ts | 1 + packages/editor-ui/src/plugins/i18n/locales/en.json | 1 + packages/workflow/src/WorkflowDataProxy.ts | 2 ++ 6 files changed, 14 insertions(+) diff --git a/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts b/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts index f03470915b729..089ad7ce6a461 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts @@ -84,6 +84,10 @@ export const baseCompletions = defineComponent({ label: `${prefix}today`, info: this.$locale.baseText('codeNodeEditor.completer.$today'), }, + { + label: `${prefix}nodeVersion`, + info: this.$locale.baseText('codeNodeEditor.completer.$nodeVersion'), + }, { label: `${prefix}jmespath()`, info: this.$locale.baseText('codeNodeEditor.completer.$jmespath'), diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index aedd7743ab79f..389ac9f6e214d 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -516,6 +516,7 @@ export const MAPPING_PARAMS = [ '$resumeWebhookUrl', '$runIndex', '$today', + '$nodeVersion', '$vars', '$workflow', ]; diff --git a/packages/editor-ui/src/plugins/codemirror/completions/constants.ts b/packages/editor-ui/src/plugins/codemirror/completions/constants.ts index cb8b3aeb3fadd..2ea359bf91870 100644 --- a/packages/editor-ui/src/plugins/codemirror/completions/constants.ts +++ b/packages/editor-ui/src/plugins/codemirror/completions/constants.ts @@ -108,6 +108,11 @@ export const ROOT_DOLLAR_COMPLETIONS: Completion[] = [ section: METADATA_SECTION, info: i18n.rootVars.$today, }, + { + label: '$nodeVersion', + section: METADATA_SECTION, + info: i18n.rootVars.$nodeVersion, + }, { label: '$vars', section: METADATA_SECTION, diff --git a/packages/editor-ui/src/plugins/i18n/index.ts b/packages/editor-ui/src/plugins/i18n/index.ts index 1f2fe1395fb1e..294cab75b990b 100644 --- a/packages/editor-ui/src/plugins/i18n/index.ts +++ b/packages/editor-ui/src/plugins/i18n/index.ts @@ -373,6 +373,7 @@ export class I18nClass { $min: this.baseText('codeNodeEditor.completer.$min'), $runIndex: this.baseText('codeNodeEditor.completer.$runIndex'), $today: this.baseText('codeNodeEditor.completer.$today'), + $nodeVersion: this.baseText('codeNodeEditor.completer.$nodeVersion'), $vars: this.baseText('codeNodeEditor.completer.$vars'), $workflow: this.baseText('codeNodeEditor.completer.$workflow'), DateTime: this.baseText('codeNodeEditor.completer.dateTime'), diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index 548db56c76cd8..82c489b3d3f21 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -217,6 +217,7 @@ "codeNodeEditor.completer.$prevNode.runIndex": "The run of the node providing input data to the current one", "codeNodeEditor.completer.$runIndex": "The index of the current run of this node", "codeNodeEditor.completer.$today": "A timestamp representing the current day (at midnight, as a Luxon object)", + "codeNodeEditor.completer.$nodeVersion": "The type version of the current node", "codeNodeEditor.completer.$vars": "The variables defined in your instance", "codeNodeEditor.completer.$vars.varName": "Variable set on this n8n instance. All variables evaluate to strings.", "codeNodeEditor.completer.$secrets": "The external secrets connected to your instance", diff --git a/packages/workflow/src/WorkflowDataProxy.ts b/packages/workflow/src/WorkflowDataProxy.ts index e8a1091783fdf..4f29e64670479 100644 --- a/packages/workflow/src/WorkflowDataProxy.ts +++ b/packages/workflow/src/WorkflowDataProxy.ts @@ -995,6 +995,7 @@ export class WorkflowDataProxy { // Before resolving the pairedItem make sure that the requested node comes in the // graph before the current one const activeNode = that.workflow.getNode(that.activeNodeName); + let contextNode = that.contextNodeName; if (activeNode) { const parentMainInputNode = that.workflow.getParentMainInputNode(activeNode); @@ -1281,6 +1282,7 @@ export class WorkflowDataProxy { $thisItem: that.connectionInputData[that.itemIndex], $thisItemIndex: this.itemIndex, $thisRunIndex: this.runIndex, + $nodeVersion: that.workflow.getNode(that.activeNodeName)?.typeVersion, }; return new Proxy(base, { From 88b81506d477d95089e160ca5dd0f1a30bdff78d Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Fri, 10 May 2024 08:36:14 +0300 Subject: [PATCH 2/2] avoid breaking tests --- .../CodeNodeEditor/completions/base.completions.ts | 8 ++++---- packages/editor-ui/src/constants.ts | 2 +- .../src/plugins/codemirror/completions/constants.ts | 10 +++++----- packages/editor-ui/src/plugins/i18n/index.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts b/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts index 089ad7ce6a461..ed8687616bbd3 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/completions/base.completions.ts @@ -84,10 +84,6 @@ export const baseCompletions = defineComponent({ label: `${prefix}today`, info: this.$locale.baseText('codeNodeEditor.completer.$today'), }, - { - label: `${prefix}nodeVersion`, - info: this.$locale.baseText('codeNodeEditor.completer.$nodeVersion'), - }, { label: `${prefix}jmespath()`, info: this.$locale.baseText('codeNodeEditor.completer.$jmespath'), @@ -96,6 +92,10 @@ export const baseCompletions = defineComponent({ label: `${prefix}runIndex`, info: this.$locale.baseText('codeNodeEditor.completer.$runIndex'), }, + { + label: `${prefix}nodeVersion`, + info: this.$locale.baseText('codeNodeEditor.completer.$nodeVersion'), + }, ]; const options: Completion[] = TOP_LEVEL_COMPLETIONS_IN_BOTH_MODES.map(addVarType); diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index 389ac9f6e214d..0dc74a40a6d95 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -516,9 +516,9 @@ export const MAPPING_PARAMS = [ '$resumeWebhookUrl', '$runIndex', '$today', - '$nodeVersion', '$vars', '$workflow', + '$nodeVersion', ]; export const DEFAULT_STICKY_HEIGHT = 160; diff --git a/packages/editor-ui/src/plugins/codemirror/completions/constants.ts b/packages/editor-ui/src/plugins/codemirror/completions/constants.ts index 2ea359bf91870..b55fba66e327e 100644 --- a/packages/editor-ui/src/plugins/codemirror/completions/constants.ts +++ b/packages/editor-ui/src/plugins/codemirror/completions/constants.ts @@ -108,11 +108,6 @@ export const ROOT_DOLLAR_COMPLETIONS: Completion[] = [ section: METADATA_SECTION, info: i18n.rootVars.$today, }, - { - label: '$nodeVersion', - section: METADATA_SECTION, - info: i18n.rootVars.$nodeVersion, - }, { label: '$vars', section: METADATA_SECTION, @@ -138,6 +133,11 @@ export const ROOT_DOLLAR_COMPLETIONS: Completion[] = [ section: METHODS_SECTION, info: i18n.rootVars.$min, }, + { + label: '$nodeVersion', + section: METADATA_SECTION, + info: i18n.rootVars.$nodeVersion, + }, ]; export const STRING_RECOMMENDED_OPTIONS = [ diff --git a/packages/editor-ui/src/plugins/i18n/index.ts b/packages/editor-ui/src/plugins/i18n/index.ts index 294cab75b990b..c8c0bab310e8e 100644 --- a/packages/editor-ui/src/plugins/i18n/index.ts +++ b/packages/editor-ui/src/plugins/i18n/index.ts @@ -373,13 +373,13 @@ export class I18nClass { $min: this.baseText('codeNodeEditor.completer.$min'), $runIndex: this.baseText('codeNodeEditor.completer.$runIndex'), $today: this.baseText('codeNodeEditor.completer.$today'), - $nodeVersion: this.baseText('codeNodeEditor.completer.$nodeVersion'), $vars: this.baseText('codeNodeEditor.completer.$vars'), $workflow: this.baseText('codeNodeEditor.completer.$workflow'), DateTime: this.baseText('codeNodeEditor.completer.dateTime'), $request: this.baseText('codeNodeEditor.completer.$request'), $response: this.baseText('codeNodeEditor.completer.$response'), $pageCount: this.baseText('codeNodeEditor.completer.$pageCount'), + $nodeVersion: this.baseText('codeNodeEditor.completer.$nodeVersion'), } as const satisfies Record; proxyVars: Record = {