refactor: Migrate NodeConnectionType to const object type (no-changelog) (#14078)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Alex Grozav
2025-03-21 14:01:26 +02:00
committed by GitHub
parent 7e8179b848
commit 8215e0b59f
703 changed files with 3104 additions and 3018 deletions

View File

@@ -348,6 +348,7 @@ export class Expression {
[Function, AsyncFunction].forEach(({ prototype }) =>
Object.defineProperty(prototype, 'constructor', { value: fnConstructors.mock }),
);
return evaluateExpression(expression, data);
} catch (error) {
if (isExpressionError(error)) throw error;

View File

@@ -1838,36 +1838,38 @@ export interface IPostReceiveSort extends IPostReceiveBase {
};
}
export const enum NodeConnectionType {
AiAgent = 'ai_agent',
AiChain = 'ai_chain',
AiDocument = 'ai_document',
AiEmbedding = 'ai_embedding',
AiLanguageModel = 'ai_languageModel',
AiMemory = 'ai_memory',
AiOutputParser = 'ai_outputParser',
AiRetriever = 'ai_retriever',
AiTextSplitter = 'ai_textSplitter',
AiTool = 'ai_tool',
AiVectorStore = 'ai_vectorStore',
Main = 'main',
}
export const NodeConnectionTypes = {
AiAgent: 'ai_agent',
AiChain: 'ai_chain',
AiDocument: 'ai_document',
AiEmbedding: 'ai_embedding',
AiLanguageModel: 'ai_languageModel',
AiMemory: 'ai_memory',
AiOutputParser: 'ai_outputParser',
AiRetriever: 'ai_retriever',
AiTextSplitter: 'ai_textSplitter',
AiTool: 'ai_tool',
AiVectorStore: 'ai_vectorStore',
Main: 'main',
} as const;
export type AINodeConnectionType = Exclude<NodeConnectionType, NodeConnectionType.Main>;
export type NodeConnectionType = (typeof NodeConnectionTypes)[keyof typeof NodeConnectionTypes];
export type AINodeConnectionType = Exclude<NodeConnectionType, typeof NodeConnectionTypes.Main>;
export const nodeConnectionTypes: NodeConnectionType[] = [
NodeConnectionType.AiAgent,
NodeConnectionType.AiChain,
NodeConnectionType.AiDocument,
NodeConnectionType.AiEmbedding,
NodeConnectionType.AiLanguageModel,
NodeConnectionType.AiMemory,
NodeConnectionType.AiOutputParser,
NodeConnectionType.AiRetriever,
NodeConnectionType.AiTextSplitter,
NodeConnectionType.AiTool,
NodeConnectionType.AiVectorStore,
NodeConnectionType.Main,
NodeConnectionTypes.AiAgent,
NodeConnectionTypes.AiChain,
NodeConnectionTypes.AiDocument,
NodeConnectionTypes.AiEmbedding,
NodeConnectionTypes.AiLanguageModel,
NodeConnectionTypes.AiMemory,
NodeConnectionTypes.AiOutputParser,
NodeConnectionTypes.AiRetriever,
NodeConnectionTypes.AiTextSplitter,
NodeConnectionTypes.AiTool,
NodeConnectionTypes.AiVectorStore,
NodeConnectionTypes.Main,
];
export interface INodeInputFilter {

View File

@@ -7,7 +7,7 @@ import get from 'lodash/get';
import isEqual from 'lodash/isEqual';
import { ApplicationError } from './errors/application.error';
import { NodeConnectionType } from './Interfaces';
import { NodeConnectionTypes } from './Interfaces';
import type {
FieldType,
IContextObject,
@@ -36,6 +36,7 @@ import type {
DisplayCondition,
NodeHint,
INodeExecutionData,
NodeConnectionType,
} from './Interfaces';
import { validateFilterParameter } from './NodeParameters/FilterParameter';
import {
@@ -327,7 +328,7 @@ export function isSubNodeType(
}
const outputTypes = getConnectionTypes(typeDescription.outputs);
return outputTypes
? outputTypes.filter((output) => output !== NodeConnectionType.Main).length > 0
? outputTypes.filter((output) => output !== NodeConnectionTypes.Main).length > 0
: false;
}
@@ -1217,7 +1218,7 @@ export function getNodeOutputs(
...outputs,
{
category: 'error',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
displayName: 'Error',
},
];
@@ -1726,5 +1727,5 @@ export function isTriggerNode(nodeTypeData: INodeTypeDescription) {
export function isExecutable(workflow: Workflow, node: INode, nodeTypeData: INodeTypeDescription) {
const outputs = getNodeOutputs(workflow, node, nodeTypeData);
const outputNames = getConnectionTypes(outputs);
return outputNames.includes(NodeConnectionType.Main) || isTriggerNode(nodeTypeData);
return outputNames.includes(NodeConnectionTypes.Main) || isTriggerNode(nodeTypeData);
}

View File

@@ -27,8 +27,9 @@ import type {
IObservableObject,
NodeParameterValueType,
INodeOutputConfiguration,
NodeConnectionType,
} from './Interfaces';
import { NodeConnectionType } from './Interfaces';
import { NodeConnectionTypes } from './Interfaces';
import * as NodeHelpers from './NodeHelpers';
import * as ObservableObject from './ObservableObject';
@@ -495,7 +496,7 @@ export class Workflow {
return currentHighest;
}
if (!this.connectionsByDestinationNode[nodeName].hasOwnProperty(NodeConnectionType.Main)) {
if (!this.connectionsByDestinationNode[nodeName].hasOwnProperty(NodeConnectionTypes.Main)) {
// Node does not have incoming connections of given type
return currentHighest;
}
@@ -515,7 +516,8 @@ export class Workflow {
let connectionsByIndex: IConnection[] | null;
for (
let connectionIndex = 0;
connectionIndex < this.connectionsByDestinationNode[nodeName][NodeConnectionType.Main].length;
connectionIndex <
this.connectionsByDestinationNode[nodeName][NodeConnectionTypes.Main].length;
connectionIndex++
) {
if (nodeConnectionIndex !== undefined && nodeConnectionIndex !== connectionIndex) {
@@ -523,7 +525,7 @@ export class Workflow {
continue;
}
connectionsByIndex =
this.connectionsByDestinationNode[nodeName][NodeConnectionType.Main][connectionIndex];
this.connectionsByDestinationNode[nodeName][NodeConnectionTypes.Main][connectionIndex];
// eslint-disable-next-line @typescript-eslint/no-loop-func
connectionsByIndex?.forEach((connection) => {
if (checkedNodes.includes(connection.node)) {
@@ -564,7 +566,7 @@ export class Workflow {
*/
getChildNodes(
nodeName: string,
type: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionType.Main,
type: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionTypes.Main,
depth = -1,
): string[] {
return this.getConnectedNodes(this.connectionsBySourceNode, nodeName, type, depth);
@@ -578,7 +580,7 @@ export class Workflow {
*/
getParentNodes(
nodeName: string,
type: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionType.Main,
type: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionTypes.Main,
depth = -1,
): string[] {
return this.getConnectedNodes(this.connectionsByDestinationNode, nodeName, type, depth);
@@ -594,7 +596,7 @@ export class Workflow {
getConnectedNodes(
connections: IConnections,
nodeName: string,
connectionType: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionType.Main,
connectionType: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN' = NodeConnectionTypes.Main,
depth = -1,
checkedNodesIncoming?: string[],
): string[] {
@@ -700,7 +702,7 @@ export class Workflow {
searchNodesBFS(connections: IConnections, sourceNode: string, maxDepth = -1): IConnectedNode[] {
const returnConns: IConnectedNode[] = [];
const type: NodeConnectionType = NodeConnectionType.Main;
const type: NodeConnectionType = NodeConnectionTypes.Main;
let queue: IConnectedNode[] = [];
queue.push({
name: sourceNode,
@@ -762,7 +764,7 @@ export class Workflow {
if (
!!outputs.find(
(output) =>
((output as INodeOutputConfiguration)?.type ?? output) !== NodeConnectionType.Main,
((output as INodeOutputConfiguration)?.type ?? output) !== NodeConnectionTypes.Main,
)
) {
// Get the first node which is connected to a non-main output
@@ -807,7 +809,7 @@ export class Workflow {
getNodeConnectionIndexes(
nodeName: string,
parentNodeName: string,
type: NodeConnectionType = NodeConnectionType.Main,
type: NodeConnectionType = NodeConnectionTypes.Main,
depth = -1,
checkedNodes?: string[],
): INodeConnection | undefined {

View File

@@ -25,7 +25,7 @@ import {
type NodeParameterValueType,
type WorkflowExecuteMode,
type ProxyInput,
NodeConnectionType,
NodeConnectionTypes,
} from './Interfaces';
import * as NodeHelpers from './NodeHelpers';
import { deepCopy } from './utils';
@@ -351,7 +351,7 @@ export class WorkflowDataProxy {
const nodeConnection = that.workflow.getNodeConnectionIndexes(
that.contextNodeName,
nodeName,
NodeConnectionType.Main,
NodeConnectionTypes.Main,
);
if (nodeConnection === undefined) {
@@ -970,7 +970,7 @@ export class WorkflowDataProxy {
const inputData =
that.runExecutionData?.resultData.runData[that.activeNodeName]?.[runIndex].inputOverride;
const placeholdersDataInputData =
inputData?.[NodeConnectionType.AiTool]?.[0]?.[itemIndex].json;
inputData?.[NodeConnectionTypes.AiTool]?.[0]?.[itemIndex].json;
if (Boolean(!placeholdersDataInputData)) {
throw new ExpressionError('No execution data available', {

View File

@@ -1,5 +1,6 @@
import {
NodeConnectionType,
NodeConnectionTypes,
type NodeConnectionType,
type INodeIssues,
type INode,
type INodeParameters,
@@ -3549,9 +3550,9 @@ describe('NodeHelpers', () => {
[false, null],
[false, { outputs: '={{random_expression}}' }],
[false, { outputs: [] }],
[false, { outputs: [NodeConnectionType.Main] }],
[true, { outputs: [NodeConnectionType.AiAgent] }],
[true, { outputs: [NodeConnectionType.Main, NodeConnectionType.AiAgent] }],
[false, { outputs: [NodeConnectionTypes.Main] }],
[true, { outputs: [NodeConnectionTypes.AiAgent] }],
[true, { outputs: [NodeConnectionTypes.Main, NodeConnectionTypes.AiAgent] }],
];
test.each(tests)('should return %p for %o', (expected, nodeType) => {
expect(isSubNodeType(nodeType)).toBe(expected);
@@ -4267,7 +4268,7 @@ describe('NodeHelpers', () => {
version: 1,
defaults: {},
inputs: [],
outputs: [NodeConnectionType.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: true,
@@ -4282,7 +4283,7 @@ describe('NodeHelpers', () => {
version: 1,
defaults: {},
inputs: [],
outputs: [NodeConnectionType.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: true,
@@ -4296,8 +4297,8 @@ describe('NodeHelpers', () => {
description: 'Regular node description',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: false,
@@ -4311,8 +4312,8 @@ describe('NodeHelpers', () => {
description: 'Empty group node description',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: false,
@@ -4327,8 +4328,8 @@ describe('NodeHelpers', () => {
description: 'Almost trigger node description',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: false,
@@ -4346,7 +4347,7 @@ describe('NodeHelpers', () => {
describe('isExecutable', () => {
const workflowMock = {
expression: {
getSimpleParameterValue: jest.fn().mockReturnValue([NodeConnectionType.Main]),
getSimpleParameterValue: jest.fn().mockReturnValue([NodeConnectionTypes.Main]),
},
} as unknown as Workflow;
@@ -4375,7 +4376,7 @@ describe('NodeHelpers', () => {
version: 1,
defaults: {},
inputs: [],
outputs: [NodeConnectionType.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: true,
@@ -4397,8 +4398,8 @@ describe('NodeHelpers', () => {
description: 'Node with Main output',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [],
},
expected: true,
@@ -4420,8 +4421,8 @@ describe('NodeHelpers', () => {
description: 'Node without Main output and not a trigger',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.AiAgent],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.AiAgent],
properties: [],
},
expected: false,
@@ -4443,8 +4444,8 @@ describe('NodeHelpers', () => {
description: 'Node with multiple output types including Main',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main, NodeConnectionType.AiAgent],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main, NodeConnectionTypes.AiAgent],
properties: [],
},
expected: true,
@@ -4467,7 +4468,7 @@ describe('NodeHelpers', () => {
version: 1,
defaults: {},
inputs: [],
outputs: [NodeConnectionType.AiTool], // Only AiTool output, no Main
outputs: [NodeConnectionTypes.AiTool], // Only AiTool output, no Main
properties: [],
},
expected: false,
@@ -4489,12 +4490,12 @@ describe('NodeHelpers', () => {
description: 'Node with dynamic outputs that resolve to only AiTool',
version: 1,
defaults: {},
inputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: '={{["ai_tool"]}}', // Dynamic expression that resolves to AiTool only
properties: [],
},
expected: false,
mockReturnValue: [NodeConnectionType.AiTool],
mockReturnValue: [NodeConnectionTypes.AiTool],
},
];

View File

@@ -1,7 +1,7 @@
import { mock } from 'jest-mock-extended';
import {
NodeConnectionType,
NodeConnectionTypes,
type IDataObject,
type INodeType,
type INodeTypeData,
@@ -62,8 +62,8 @@ const googleSheetsNode: LoadedClass<IVersionedNodeType> = {
defaults: {
name: 'Google Sheets',
},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'googleApi',
@@ -288,9 +288,9 @@ const googleSheetsNode: LoadedClass<IVersionedNodeType> = {
displayName: 'Google Sheets',
group: ['input', 'output'],
icon: 'file:googleSheets.svg',
inputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
name: 'googleSheets',
outputs: [NodeConnectionType.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
default: 'oAuth2',
@@ -553,8 +553,8 @@ const setNode: LoadedClass<INodeType> = {
name: 'Set',
color: '#0000FF',
},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
displayName: 'Value1',
@@ -590,7 +590,7 @@ const manualTriggerNode: LoadedClass<INodeType> = {
color: '#909298',
},
inputs: [],
outputs: [NodeConnectionType.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
displayName:
@@ -848,8 +848,8 @@ export class NodeTypes implements INodeTypes {
name: 'Set Multi',
color: '#0000FF',
},
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
displayName: 'Values',

View File

@@ -4,7 +4,7 @@ import { v5 as uuidv5, v3 as uuidv3, v4 as uuidv4, v1 as uuidv1 } from 'uuid';
import { STICKY_NODE_TYPE } from '@/Constants';
import { ApplicationError, ExpressionError, NodeApiError } from '@/errors';
import type { INode, INodeTypeDescription, IRun, IRunData } from '@/Interfaces';
import { NodeConnectionType, type IWorkflowBase } from '@/Interfaces';
import { type NodeConnectionType, NodeConnectionTypes, type IWorkflowBase } from '@/Interfaces';
import * as nodeHelpers from '@/NodeHelpers';
import {
ANONYMIZATION_CHARACTER as CHAR,
@@ -117,7 +117,7 @@ describe('generateNodesGraph', () => {
],
connections: {
'When clicking "Execute Workflow"': {
main: [[{ node: 'Google Sheets', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Google Sheets', type: NodeConnectionTypes.Main, index: 0 }]],
},
},
settings: { executionOrder: 'v1' },
@@ -221,7 +221,7 @@ describe('generateNodesGraph', () => {
],
connections: {
'When clicking "Execute Workflow"': {
main: [[{ node: 'Google Sheets', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Google Sheets', type: NodeConnectionTypes.Main, index: 0 }]],
},
},
settings: { executionOrder: 'v1' },
@@ -297,7 +297,7 @@ describe('generateNodesGraph', () => {
],
connections: {
'When clicking "Execute Workflow"': {
main: [[{ node: 'Google Sheets', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Google Sheets', type: NodeConnectionTypes.Main, index: 0 }]],
},
},
settings: { executionOrder: 'v1' },
@@ -375,7 +375,7 @@ describe('generateNodesGraph', () => {
],
connections: {
'When clicking "Execute Workflow"': {
main: [[{ node: 'Google Sheets', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Google Sheets', type: NodeConnectionTypes.Main, index: 0 }]],
},
},
settings: { executionOrder: 'v1' },
@@ -829,7 +829,7 @@ describe('generateNodesGraph', () => {
[
{
node: 'Chain',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -840,7 +840,7 @@ describe('generateNodesGraph', () => {
[
{
node: 'Chain',
type: NodeConnectionType.AiLanguageModel,
type: NodeConnectionTypes.AiLanguageModel,
index: 0,
},
],

View File

@@ -1,6 +1,6 @@
import { mock } from 'jest-mock-extended';
import { NodeConnectionType } from '@/Interfaces';
import { NodeConnectionTypes } from '@/Interfaces';
import type { IConnection } from '@/Interfaces';
import type {
IBinaryKeyData,
@@ -64,7 +64,7 @@ describe('Workflow', () => {
[
{
node: 'Set',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -75,7 +75,7 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -134,21 +134,21 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
[
{
node: 'Set',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
[
{
node: 'Set',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -159,7 +159,7 @@ describe('Workflow', () => {
[
{
node: 'Set2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -170,7 +170,7 @@ describe('Workflow', () => {
[
{
node: 'Set2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -234,7 +234,7 @@ describe('Workflow', () => {
[
{
node: 'Set',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -242,7 +242,7 @@ describe('Workflow', () => {
[
{
node: 'Switch',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -253,7 +253,7 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -264,12 +264,12 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
{
node: 'Switch',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -280,7 +280,7 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -323,7 +323,7 @@ describe('Workflow', () => {
[
{
node: 'AINode',
type: NodeConnectionType.AiAgent,
type: NodeConnectionTypes.AiAgent,
index: 0,
},
],
@@ -334,7 +334,7 @@ describe('Workflow', () => {
[
{
node: 'Set1',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -707,7 +707,7 @@ describe('Workflow', () => {
[
{
node: 'Node2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -738,7 +738,7 @@ describe('Workflow', () => {
[
{
node: 'Node2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -774,7 +774,7 @@ describe('Workflow', () => {
[
{
node: 'Node2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -805,7 +805,7 @@ describe('Workflow', () => {
[
{
node: 'Node2New',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -862,7 +862,7 @@ describe('Workflow', () => {
[
{
node: 'Node3',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -873,12 +873,12 @@ describe('Workflow', () => {
[
{
node: 'Node3',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
{
node: 'Node5',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -889,12 +889,12 @@ describe('Workflow', () => {
[
{
node: 'Node4',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
{
node: 'Node5',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -946,7 +946,7 @@ describe('Workflow', () => {
[
{
node: 'Node3New',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -957,12 +957,12 @@ describe('Workflow', () => {
[
{
node: 'Node3New',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
{
node: 'Node5',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -973,12 +973,12 @@ describe('Workflow', () => {
[
{
node: 'Node4',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
{
node: 'Node5',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -1558,7 +1558,7 @@ describe('Workflow', () => {
[
{
node: 'Node2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -1569,7 +1569,7 @@ describe('Workflow', () => {
[
{
node: 'Node3',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -1580,7 +1580,7 @@ describe('Workflow', () => {
[
{
node: 'Node2',
type: NodeConnectionType.Main,
type: NodeConnectionTypes.Main,
index: 0,
},
],
@@ -1884,10 +1884,10 @@ describe('Workflow', () => {
it('should return connections by destination node', () => {
const connections: IConnections = {
Node1: {
[NodeConnectionType.Main]: [
[NodeConnectionTypes.Main]: [
[
{ node: 'Node2', type: NodeConnectionType.Main, index: 0 },
{ node: 'Node3', type: NodeConnectionType.Main, index: 1 },
{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 },
{ node: 'Node3', type: NodeConnectionTypes.Main, index: 1 },
],
],
},
@@ -1895,12 +1895,14 @@ describe('Workflow', () => {
const result = Workflow.getConnectionsByDestination(connections);
expect(result).toEqual({
Node2: {
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
[NodeConnectionTypes.Main]: [
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
],
},
Node3: {
[NodeConnectionType.Main]: [
[NodeConnectionTypes.Main]: [
[],
[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }],
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
],
},
});
@@ -1909,9 +1911,11 @@ describe('Workflow', () => {
it('should handle multiple connection types', () => {
const connections: IConnections = {
Node1: {
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
[NodeConnectionType.AiAgent]: [
[{ node: 'Node3', type: NodeConnectionType.AiAgent, index: 0 }],
[NodeConnectionTypes.Main]: [
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
],
[NodeConnectionTypes.AiAgent]: [
[{ node: 'Node3', type: NodeConnectionTypes.AiAgent, index: 0 }],
],
},
};
@@ -1919,11 +1923,13 @@ describe('Workflow', () => {
const result = Workflow.getConnectionsByDestination(connections);
expect(result).toEqual({
Node2: {
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
[NodeConnectionTypes.Main]: [
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
],
},
Node3: {
[NodeConnectionType.AiAgent]: [
[{ node: 'Node1', type: NodeConnectionType.AiAgent, index: 0 }],
[NodeConnectionTypes.AiAgent]: [
[{ node: 'Node1', type: NodeConnectionTypes.AiAgent, index: 0 }],
],
},
});
@@ -1932,7 +1938,7 @@ describe('Workflow', () => {
it('should handle nodes with no connections', () => {
const connections: IConnections = {
Node1: {
[NodeConnectionType.Main]: [[]],
[NodeConnectionTypes.Main]: [[]],
},
};
@@ -1944,9 +1950,9 @@ describe('Workflow', () => {
it('should handle nodes with null connections', () => {
const connections: IConnections = {
Node1: {
[NodeConnectionType.Main]: [
[NodeConnectionTypes.Main]: [
null as unknown as IConnection[],
[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }],
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
],
},
};
@@ -1954,7 +1960,9 @@ describe('Workflow', () => {
const result = Workflow.getConnectionsByDestination(connections);
expect(result).toEqual({
Node2: {
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 1 }]],
[NodeConnectionTypes.Main]: [
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 1 }],
],
},
});
});
@@ -1962,20 +1970,24 @@ describe('Workflow', () => {
it('should handle nodes with multiple input connections', () => {
const connections: IConnections = {
Node1: {
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
[NodeConnectionTypes.Main]: [
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
],
},
Node3: {
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
[NodeConnectionTypes.Main]: [
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
],
},
};
const result = Workflow.getConnectionsByDestination(connections);
expect(result).toEqual({
Node2: {
[NodeConnectionType.Main]: [
[NodeConnectionTypes.Main]: [
[
{ node: 'Node1', type: NodeConnectionType.Main, index: 0 },
{ node: 'Node3', type: NodeConnectionType.Main, index: 0 },
{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 },
{ node: 'Node3', type: NodeConnectionTypes.Main, index: 0 },
],
],
},
@@ -2030,10 +2042,10 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
Node2: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2056,10 +2068,10 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
Node2: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2084,12 +2096,12 @@ describe('Workflow', () => {
const connections = {
Node3: {
main: [
[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }],
[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }],
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
],
},
TargetNode: {
main: [[{ node: 'Node3', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Node3', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2112,10 +2124,10 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
Node2: {
main: [[], [{ node: 'TargetNode', type: NodeConnectionType.Main, index: 1 }]],
main: [[], [{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 1 }]],
},
};
@@ -2141,13 +2153,13 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }]],
},
Node2: {
main: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }]],
},
TargetNode: {
main: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2169,10 +2181,10 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'NonExistentNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'NonExistentNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
TargetNode: {
main: [[{ node: 'NonExistentNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'NonExistentNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2195,10 +2207,10 @@ describe('Workflow', () => {
const connections = {
Node1: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
NonExistentNode: {
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
},
};
@@ -2272,7 +2284,7 @@ describe('Workflow', () => {
const result = SIMPLE_WORKFLOW.getNodeConnectionIndexes(
'Set',
'Start',
NodeConnectionType.Main,
NodeConnectionTypes.Main,
0,
);
expect(result).toBeUndefined();

View File

@@ -3,7 +3,8 @@ import { DateTime, Duration, Interval } from 'luxon';
import { ensureError } from '@/errors/ensure-error';
import { ExpressionError } from '@/errors/expression.error';
import {
NodeConnectionType,
NodeConnectionTypes,
type NodeConnectionType,
type IExecuteData,
type INode,
type IPinData,
@@ -38,7 +39,7 @@ const getProxyFromFixture = (
) => {
const taskData = run?.data.resultData.runData[activeNode]?.[opts?.runIndex ?? 0];
const lastNodeConnectionInputData =
taskData?.data?.[opts?.connectionType ?? NodeConnectionType.Main]?.[0];
taskData?.data?.[opts?.connectionType ?? NodeConnectionTypes.Main]?.[0];
let executeData: IExecuteData | undefined;
@@ -47,7 +48,7 @@ const getProxyFromFixture = (
data: taskData.data!,
node: workflow.nodes.find((node) => node.name === activeNode) as INode,
source: {
[opts?.connectionType ?? NodeConnectionType.Main]: taskData.source,
[opts?.connectionType ?? NodeConnectionTypes.Main]: taskData.source,
},
};
}
@@ -519,7 +520,7 @@ describe('WorkflowDataProxy', () => {
const fixture = loadFixture('from_ai_multiple_items');
const getFromAIProxy = (runIndex = 0) =>
getProxyFromFixture(fixture.workflow, fixture.run, 'Google Sheets1', 'manual', {
connectionType: NodeConnectionType.AiTool,
connectionType: NodeConnectionTypes.AiTool,
throwOnMissingExecutionData: false,
runIndex,
});
@@ -555,7 +556,7 @@ describe('WorkflowDataProxy', () => {
describe('$rawParameter', () => {
const fixture = loadFixture('rawParameter');
const proxy = getProxyFromFixture(fixture.workflow, fixture.run, 'Execute Workflow', 'manual', {
connectionType: NodeConnectionType.Main,
connectionType: NodeConnectionTypes.Main,
throwOnMissingExecutionData: false,
runIndex: 0,
});
@@ -582,7 +583,7 @@ describe('WorkflowDataProxy', () => {
'Execute Workflow',
'manual',
{
connectionType: NodeConnectionType.Main,
connectionType: NodeConnectionTypes.Main,
throwOnMissingExecutionData: false,
runIndex: 0,
},