mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Initial Code Task Runners support (no-changelog) (#10698)
Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,9 @@ import {
|
||||
type INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import set from 'lodash/set';
|
||||
import Container from 'typedi';
|
||||
import { TaskRunnersConfig } from '@n8n/config';
|
||||
|
||||
import { javascriptCodeDescription } from './descriptions/JavascriptCodeDescription';
|
||||
import { pythonCodeDescription } from './descriptions/PythonCodeDescription';
|
||||
import { JavaScriptSandbox } from './JavaScriptSandbox';
|
||||
@@ -92,6 +95,8 @@ export class Code implements INodeType {
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions) {
|
||||
const runnersConfig = Container.get(TaskRunnersConfig);
|
||||
|
||||
const nodeMode = this.getNodeParameter('mode', 0) as CodeExecutionMode;
|
||||
const workflowMode = this.getMode();
|
||||
|
||||
@@ -102,6 +107,22 @@ export class Code implements INodeType {
|
||||
: 'javaScript';
|
||||
const codeParameterName = language === 'python' ? 'pythonCode' : 'jsCode';
|
||||
|
||||
if (!runnersConfig.disabled && language === 'javaScript') {
|
||||
// TODO: once per item
|
||||
const code = this.getNodeParameter(codeParameterName, 0) as string;
|
||||
const items = await this.startJob<INodeExecutionData[]>(
|
||||
{ javaScript: 'javascript', python: 'python' }[language] ?? language,
|
||||
{
|
||||
code,
|
||||
nodeMode,
|
||||
workflowMode,
|
||||
},
|
||||
0,
|
||||
);
|
||||
|
||||
return [items];
|
||||
}
|
||||
|
||||
const getSandbox = (index = 0) => {
|
||||
const code = this.getNodeParameter(codeParameterName, index) as string;
|
||||
const context = getSandboxContext.call(this, index);
|
||||
|
||||
Reference in New Issue
Block a user