mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 09:34:07 -08:00
3a474552b2
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>
78 lines
1.7 KiB
TypeScript
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: '',
|
|
},
|
|
];
|