import type { INodeProperties } from 'n8n-workflow';
const commonDescription: INodeProperties = {
displayName: 'Python',
name: 'pythonCode',
type: 'string',
typeOptions: {
editor: 'codeNodeEditor',
editorLanguage: 'python',
},
default: '',
description:
'Python code to execute.
Tip: You can use built-in methods and variables like _today for dates and _jmespath for querying JSON structures. Learn more.',
noDataExpression: true,
};
const PRINT_INSTRUCTION =
'Debug by using print() statements and viewing their output in the browser console.';
export const pythonCodeDescription: INodeProperties[] = [
{
...commonDescription,
displayOptions: {
show: {
language: ['python', 'pythonNative'],
mode: ['runOnceForAllItems'],
},
},
},
{
...commonDescription,
displayOptions: {
show: {
language: ['python', 'pythonNative'],
mode: ['runOnceForEachItem'],
},
},
},
{
displayName: PRINT_INSTRUCTION,
name: 'notice',
type: 'notice',
displayOptions: {
show: {
language: ['python'],
},
},
default: '',
},
{
displayName: `${PRINT_INSTRUCTION}
The native Python option does not support _ syntax and helpers, except for _items in all-items mode and _item in per-item mode.`,
name: 'notice',
type: 'notice',
displayOptions: {
show: {
language: ['pythonNative'],
},
},
default: '',
},
];