n8n/packages/nodes-base/nodes/Code/descriptions/JavascriptCodeDescription.ts
Michael Kret 3a474552b2
feat(Set Node): Overhaul (#6348)
Github issue / Community forum post (link here to close automatically):
https://github.com/n8n-io/n8n/pull/6348

---------

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Marcus <marcus@n8n.io>
2023-09-19 13:16:35 +03:00

78 lines
1.7 KiB
TypeScript

import type { INodeProperties } from 'n8n-workflow';
const commonDescription: INodeProperties = {
displayName: 'JavaScript',
name: 'jsCode',
type: 'string',
typeOptions: {
editor: 'codeNodeEditor',
editorLanguage: 'javaScript',
rows: 5,
},
default: '',
description:
'JavaScript code to execute.<br><br>Tip: You can use luxon vars like <code>$today</code> for dates and <code>$jmespath</code> for querying JSON structures. <a href="https://docs.n8n.io/nodes/n8n-nodes-base.function">Learn more</a>.',
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 <code>$</code> for a list of <a target="_blank" href="https://docs.n8n.io/code-examples/methods-variables-reference/">special vars/methods</a>. Debug by using <code>console.log()</code> statements and viewing their output in the browser console.',
name: 'notice',
type: 'notice',
displayOptions: {
show: {
language: ['javaScript'],
},
},
default: '',
},
];