Skip to content

Commit

Permalink
feat(core): Node version available in expression (#9350)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed May 10, 2024
1 parent dc5994b commit a00467c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,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);
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export const MAPPING_PARAMS = [
'$today',
'$vars',
'$workflow',
'$nodeVersion',
];

export const DEFAULT_STICKY_HEIGHT = 160;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,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 = [
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ export class I18nClass {
$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<string, string | undefined>;

proxyVars: Record<string, string | undefined> = {
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/workflow/src/WorkflowDataProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit a00467c

Please sign in to comment.