import type { INodeProperties } from 'n8n-workflow';
const commonDescription: INodeProperties = {
displayName: 'JavaScript',
name: 'jsCode',
type: 'string',
typeOptions: {
editor: 'codeNodeEditor',
editorLanguage: 'javaScript',
},
default: '',
description:
'JavaScript code to execute.
Tip: You can use luxon vars like $today
for dates and $jmespath
for querying JSON structures. Learn more.',
noDataExpression: true,
};
const v1Properties: INodeProperties[] = [
{
...commonDescription,
displayOptions: {
show: {
'@version': [1],
mode: ['runOnceForAllItems'],
},
},
},
{
...commonDescription,
displayOptions: {
show: {
'@version': [1],
mode: ['runOnceForEachItem'],
},
},
},
];
const v2Properties: INodeProperties[] = [
{
...commonDescription,
displayOptions: {
show: {
'@version': [2],
language: ['javaScript'],
mode: ['runOnceForAllItems'],
},
},
},
{
...commonDescription,
displayOptions: {
show: {
'@version': [2],
language: ['javaScript'],
mode: ['runOnceForEachItem'],
},
},
},
];
export const javascriptCodeDescription: INodeProperties[] = [
...v1Properties,
...v2Properties,
{
displayName:
'Type $
for a list of special vars/methods. Debug by using console.log()
statements and viewing their output in the browser console.',
name: 'notice',
type: 'notice',
displayOptions: {
show: {
language: ['javaScript'],
},
},
default: '',
},
];