refactor(core): Extract trigger context out of NodeExecutionFunctions (no-changelog) (#11453)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-11-04 11:13:44 +01:00
committed by GitHub
parent e4aa1d01f3
commit 1be7de6180
7 changed files with 256 additions and 75 deletions

View File

@@ -1,6 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { ActiveWorkflows, InstanceSettings, NodeExecuteFunctions, PollContext } from 'n8n-core';
import {
ActiveWorkflows,
InstanceSettings,
NodeExecuteFunctions,
PollContext,
TriggerContext,
} from 'n8n-core';
import type {
ExecutionError,
IDeferredPromise,
@@ -325,18 +331,11 @@ export class ActiveWorkflowManager {
activation: WorkflowActivateMode,
): IGetExecuteTriggerFunctions {
return (workflow: Workflow, node: INode) => {
const returnFunctions = NodeExecuteFunctions.getExecuteTriggerFunctions(
workflow,
node,
additionalData,
mode,
activation,
);
returnFunctions.emit = (
const emit = (
data: INodeExecutionData[][],
responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
donePromise?: IDeferredPromise<IRun | undefined>,
): void => {
) => {
this.logger.debug(`Received trigger for workflow "${workflow.name}"`);
void this.workflowStaticDataService.saveStaticData(workflow);
@@ -360,7 +359,7 @@ export class ActiveWorkflowManager {
executePromise.catch((error: Error) => this.logger.error(error.message, { error }));
}
};
returnFunctions.emitError = (error: Error): void => {
const emitError = (error: Error): void => {
this.logger.info(
`The trigger node "${node.name}" of workflow "${workflowData.name}" failed with the error: "${error.message}". Will try to reactivate.`,
{
@@ -385,7 +384,7 @@ export class ActiveWorkflowManager {
this.addQueuedWorkflowActivation(activation, workflowData as WorkflowEntity);
};
return returnFunctions;
return new TriggerContext(workflow, node, additionalData, mode, activation, emit, emitError);
};
}