mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
refactor(core): Extract ExecuteContext out of NodeExecutionFunctions (no-changelog) (#11853)
This commit is contained in:
committed by
GitHub
parent
3aa72f613f
commit
75e2b6fd9e
@@ -4,7 +4,6 @@ import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
IDataObject,
|
||||
IExecuteData,
|
||||
IGetNodeParameterOptions,
|
||||
INode,
|
||||
INodeExecutionData,
|
||||
IRunExecutionData,
|
||||
@@ -13,7 +12,6 @@ import type {
|
||||
IWebhookFunctions,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
NodeConnectionType,
|
||||
NodeParameterValueType,
|
||||
WebhookType,
|
||||
Workflow,
|
||||
WorkflowExecuteMode,
|
||||
@@ -23,11 +21,8 @@ import { ApplicationError, createDeferredPromise } from 'n8n-workflow';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import {
|
||||
copyBinaryFile,
|
||||
getAdditionalKeys,
|
||||
getBinaryHelperFunctions,
|
||||
getCredentials,
|
||||
getInputConnectionData,
|
||||
getNodeParameter,
|
||||
getNodeWebhookUrl,
|
||||
getRequestHelperFunctions,
|
||||
returnJsonArray,
|
||||
@@ -47,9 +42,28 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
|
||||
mode: WorkflowExecuteMode,
|
||||
private readonly webhookData: IWebhookData,
|
||||
private readonly closeFunctions: CloseFunction[],
|
||||
private readonly runExecutionData: IRunExecutionData | null,
|
||||
runExecutionData: IRunExecutionData | null,
|
||||
) {
|
||||
super(workflow, node, additionalData, mode);
|
||||
let connectionInputData: INodeExecutionData[] = [];
|
||||
let executionData: IExecuteData | undefined;
|
||||
|
||||
if (runExecutionData?.executionData !== undefined) {
|
||||
executionData = runExecutionData.executionData.nodeExecutionStack[0];
|
||||
if (executionData !== undefined) {
|
||||
connectionInputData = executionData.data.main[0]!;
|
||||
}
|
||||
}
|
||||
|
||||
super(
|
||||
workflow,
|
||||
node,
|
||||
additionalData,
|
||||
mode,
|
||||
runExecutionData,
|
||||
0,
|
||||
connectionInputData,
|
||||
executionData,
|
||||
);
|
||||
|
||||
this.helpers = {
|
||||
createDeferredPromise,
|
||||
@@ -71,7 +85,7 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
|
||||
}
|
||||
|
||||
async getCredentials<T extends object = ICredentialDataDecryptedObject>(type: string) {
|
||||
return await getCredentials<T>(this.workflow, this.node, type, this.additionalData, this.mode);
|
||||
return await this._getCredentials<T>(type);
|
||||
}
|
||||
|
||||
getBodyData() {
|
||||
@@ -116,7 +130,7 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
|
||||
this.node,
|
||||
this.additionalData,
|
||||
this.mode,
|
||||
getAdditionalKeys(this.additionalData, this.mode, null),
|
||||
this.additionalKeys,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,13 +158,12 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
|
||||
node: this.node,
|
||||
source: null,
|
||||
};
|
||||
const runIndex = 0;
|
||||
|
||||
return await getInputConnectionData.call(
|
||||
this,
|
||||
this.workflow,
|
||||
runExecutionData,
|
||||
runIndex,
|
||||
this.runIndex,
|
||||
connectionInputData,
|
||||
{} as ITaskDataConnections,
|
||||
this.additionalData,
|
||||
@@ -161,73 +174,4 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
|
||||
itemIndex,
|
||||
);
|
||||
}
|
||||
|
||||
evaluateExpression(expression: string, evaluateItemIndex?: number) {
|
||||
const itemIndex = evaluateItemIndex ?? 0;
|
||||
const runIndex = 0;
|
||||
|
||||
let connectionInputData: INodeExecutionData[] = [];
|
||||
let executionData: IExecuteData | undefined;
|
||||
|
||||
if (this.runExecutionData?.executionData !== undefined) {
|
||||
executionData = this.runExecutionData.executionData.nodeExecutionStack[0];
|
||||
|
||||
if (executionData !== undefined) {
|
||||
connectionInputData = executionData.data.main[0]!;
|
||||
}
|
||||
}
|
||||
|
||||
const additionalKeys = getAdditionalKeys(this.additionalData, this.mode, this.runExecutionData);
|
||||
|
||||
return this.workflow.expression.resolveSimpleParameterValue(
|
||||
`=${expression}`,
|
||||
{},
|
||||
this.runExecutionData,
|
||||
runIndex,
|
||||
itemIndex,
|
||||
this.node.name,
|
||||
connectionInputData,
|
||||
this.mode,
|
||||
additionalKeys,
|
||||
executionData,
|
||||
);
|
||||
}
|
||||
|
||||
getNodeParameter(
|
||||
parameterName: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
fallbackValue?: any,
|
||||
options?: IGetNodeParameterOptions,
|
||||
): NodeParameterValueType | object {
|
||||
const itemIndex = 0;
|
||||
const runIndex = 0;
|
||||
|
||||
let connectionInputData: INodeExecutionData[] = [];
|
||||
let executionData: IExecuteData | undefined;
|
||||
|
||||
if (this.runExecutionData?.executionData !== undefined) {
|
||||
executionData = this.runExecutionData.executionData.nodeExecutionStack[0];
|
||||
|
||||
if (executionData !== undefined) {
|
||||
connectionInputData = executionData.data.main[0]!;
|
||||
}
|
||||
}
|
||||
|
||||
const additionalKeys = getAdditionalKeys(this.additionalData, this.mode, this.runExecutionData);
|
||||
|
||||
return getNodeParameter(
|
||||
this.workflow,
|
||||
this.runExecutionData,
|
||||
runIndex,
|
||||
connectionInputData,
|
||||
this.node,
|
||||
parameterName,
|
||||
itemIndex,
|
||||
this.mode,
|
||||
additionalKeys,
|
||||
executionData,
|
||||
fallbackValue,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user