mirror of
https://github.com/n8n-io/n8n.git
synced 2026-07-29 20:15:00 +02:00
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
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.<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/integrations/builtin/core-nodes/n8n-nodes-base.code/">Learn more</a>.',
|
|
noDataExpression: true,
|
|
builderHint: {
|
|
propertyHint:
|
|
'The sandbox has NO network access: fetch(), axios, XMLHttpRequest and require of http modules are unavailable and fail at runtime. NEVER make HTTP requests here — use the HTTP Request node and process its output in this node instead.',
|
|
},
|
|
};
|
|
|
|
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: '',
|
|
},
|
|
];
|