refactor(core): Shovel around more of AI code (no-changelog) (#12218)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-12-16 13:46:19 +01:00
committed by GitHub
parent a8e7a05856
commit 2ce1644d01
138 changed files with 590 additions and 529 deletions
@@ -1,4 +1,5 @@
import type {
AINodeConnectionType,
CallbackManager,
CloseFunction,
IExecuteData,
@@ -149,7 +150,7 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
}
async getInputConnectionData(
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
itemIndex: number,
): Promise<unknown> {
return await getInputConnectionData.call(
@@ -1,5 +1,6 @@
import get from 'lodash/get';
import type {
AINodeConnectionType,
CloseFunction,
ExecutionBaseError,
IExecuteData,
@@ -12,10 +13,11 @@ import type {
ITaskDataConnections,
ITaskMetadata,
IWorkflowExecuteAdditionalData,
NodeConnectionType,
Workflow,
WorkflowExecuteMode,
} from 'n8n-workflow';
import { ApplicationError, NodeConnectionType, createDeferredPromise } from 'n8n-workflow';
import { createDeferredPromise } from 'n8n-workflow';
// eslint-disable-next-line import/no-cycle
import {
@@ -107,7 +109,7 @@ export class SupplyDataContext extends BaseExecuteContext implements ISupplyData
}
async getInputConnectionData(
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
itemIndex: number,
): Promise<unknown> {
return await getInputConnectionData.call(
@@ -137,7 +139,7 @@ export class SupplyDataContext extends BaseExecuteContext implements ISupplyData
/** @deprecated create a context object with inputData for every runIndex */
addInputData(
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
data: INodeExecutionData[][],
): { index: number } {
const nodeName = this.node.name;
@@ -166,9 +168,9 @@ export class SupplyDataContext extends BaseExecuteContext implements ISupplyData
/** @deprecated Switch to WorkflowExecute to store output on runExecutionData.resultData.runData */
addOutputData(
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
currentNodeRunIndex: number,
data: INodeExecutionData[][],
data: INodeExecutionData[][] | ExecutionBaseError,
metadata?: ITaskMetadata,
): void {
const nodeName = this.node.name;
@@ -192,17 +194,11 @@ export class SupplyDataContext extends BaseExecuteContext implements ISupplyData
async addExecutionDataFunctions(
type: 'input' | 'output',
data: INodeExecutionData[][] | ExecutionBaseError,
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
sourceNodeName: string,
currentNodeRunIndex: number,
metadata?: ITaskMetadata,
): Promise<void> {
if (connectionType === NodeConnectionType.Main) {
throw new ApplicationError('Setting type is not supported for main connection', {
extra: { type },
});
}
const {
additionalData,
runExecutionData,
@@ -258,23 +254,16 @@ export class SupplyDataContext extends BaseExecuteContext implements ISupplyData
}
runExecutionData.resultData.runData[nodeName][currentNodeRunIndex] = taskData;
if (additionalData.sendDataToUI) {
additionalData.sendDataToUI('nodeExecuteBefore', {
executionId: additionalData.executionId,
nodeName,
});
}
await additionalData.hooks?.executeHookFunctions('nodeExecuteBefore', [nodeName]);
} else {
// Outputs
taskData.executionTime = new Date().getTime() - taskData.startTime;
if (additionalData.sendDataToUI) {
additionalData.sendDataToUI('nodeExecuteAfter', {
executionId: additionalData.executionId,
nodeName,
data: taskData,
});
}
await additionalData.hooks?.executeHookFunctions('nodeExecuteAfter', [
nodeName,
taskData,
this.runExecutionData,
]);
if (get(runExecutionData, 'executionData.metadata', undefined) === undefined) {
runExecutionData.executionData!.metadata = {};
@@ -1,5 +1,6 @@
import type { Request, Response } from 'express';
import type {
AINodeConnectionType,
CloseFunction,
ICredentialDataDecryptedObject,
IDataObject,
@@ -11,7 +12,6 @@ import type {
IWebhookData,
IWebhookFunctions,
IWorkflowExecuteAdditionalData,
NodeConnectionType,
WebhookType,
Workflow,
WorkflowExecuteMode,
@@ -139,7 +139,7 @@ export class WebhookContext extends NodeExecutionContext implements IWebhookFunc
}
async getInputConnectionData(
connectionType: NodeConnectionType,
connectionType: AINodeConnectionType,
itemIndex: number,
): Promise<unknown> {
// To be able to use expressions like "$json.sessionId" set the