mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Move execution engine code out of n8n-workflow (no-changelog) (#12147)
This commit is contained in:
committed by
GitHub
parent
73f0c4cca9
commit
5a055ed526
@@ -1,70 +1,16 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import get from 'lodash/get';
|
||||
import path from 'path';
|
||||
|
||||
import type {
|
||||
IExecuteSingleFunctions,
|
||||
IHttpRequestOptions,
|
||||
IN8nHttpFullResponse,
|
||||
IN8nHttpResponse,
|
||||
INode,
|
||||
INodeTypes,
|
||||
IRunExecutionData,
|
||||
} from '@/Interfaces';
|
||||
import type { Workflow } from '@/Workflow';
|
||||
import type { INodeTypes } from '@/Interfaces';
|
||||
|
||||
import { NodeTypes as NodeTypesClass } from './NodeTypes';
|
||||
|
||||
export function getExecuteSingleFunctions(
|
||||
workflow: Workflow,
|
||||
runExecutionData: IRunExecutionData,
|
||||
runIndex: number,
|
||||
node: INode,
|
||||
itemIndex: number,
|
||||
): IExecuteSingleFunctions {
|
||||
return mock<IExecuteSingleFunctions>({
|
||||
getItemIndex: () => itemIndex,
|
||||
getNodeParameter: (parameterName: string) => {
|
||||
return workflow.expression.getParameterValue(
|
||||
get(node.parameters, parameterName),
|
||||
runExecutionData,
|
||||
runIndex,
|
||||
itemIndex,
|
||||
node.name,
|
||||
[],
|
||||
'internal',
|
||||
{},
|
||||
);
|
||||
},
|
||||
getWorkflow: () => ({
|
||||
id: workflow.id,
|
||||
name: workflow.name,
|
||||
active: workflow.active,
|
||||
}),
|
||||
helpers: mock<IExecuteSingleFunctions['helpers']>({
|
||||
async httpRequest(
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IN8nHttpFullResponse | IN8nHttpResponse> {
|
||||
return {
|
||||
body: {
|
||||
headers: {},
|
||||
statusCode: 200,
|
||||
requestOptions,
|
||||
},
|
||||
};
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
let nodeTypesInstance: NodeTypesClass | undefined;
|
||||
|
||||
export function NodeTypes(): INodeTypes {
|
||||
if (nodeTypesInstance === undefined) {
|
||||
nodeTypesInstance = new NodeTypesClass();
|
||||
}
|
||||
|
||||
return nodeTypesInstance;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user