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

@@ -1,6 +1,6 @@
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import { PromptTemplate } from '@langchain/core/prompts';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type {
ISupplyDataFunctions,
INodeType,
@@ -47,18 +47,18 @@ export class OutputParserAutofixing implements INodeType {
{
displayName: 'Model',
maxConnections: 1,
type: NodeConnectionType.AiLanguageModel,
type: NodeConnectionTypes.AiLanguageModel,
required: true,
},
{
displayName: 'Output Parser',
maxConnections: 1,
required: true,
type: NodeConnectionType.AiOutputParser,
type: NodeConnectionTypes.AiOutputParser,
},
],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiOutputParser],
outputs: [NodeConnectionTypes.AiOutputParser],
outputNames: ['Output Parser'],
properties: [
{
@@ -68,7 +68,7 @@ export class OutputParserAutofixing implements INodeType {
type: 'notice',
default: '',
},
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]),
getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{
displayName: 'Options',
name: 'options',
@@ -95,11 +95,11 @@ export class OutputParserAutofixing implements INodeType {
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel,
NodeConnectionTypes.AiLanguageModel,
itemIndex,
)) as BaseLanguageModel;
const outputParser = (await this.getInputConnectionData(
NodeConnectionType.AiOutputParser,
NodeConnectionTypes.AiOutputParser,
itemIndex,
)) as N8nStructuredOutputParser;
const prompt = this.getNodeParameter('options.prompt', itemIndex, NAIVE_FIX_PROMPT) as string;

View File

@@ -5,8 +5,12 @@ import { OutputParserException } from '@langchain/core/output_parsers';
import type { MockProxy } from 'jest-mock-extended';
import { mock } from 'jest-mock-extended';
import { normalizeItems } from 'n8n-core';
import type { ISupplyDataFunctions, IWorkflowDataProxyData } from 'n8n-workflow';
import { ApplicationError, NodeConnectionType, NodeOperationError } from 'n8n-workflow';
import type {
ISupplyDataFunctions,
IWorkflowDataProxyData,
NodeConnectionType,
} from 'n8n-workflow';
import { ApplicationError, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type {
N8nOutputFixingParser,
@@ -34,8 +38,8 @@ describe('OutputParserAutofixing', () => {
thisArg.addInputData.mockReturnValue({ index: 0 });
thisArg.addOutputData.mockReturnValue();
thisArg.getInputConnectionData.mockImplementation(async (type: NodeConnectionType) => {
if (type === NodeConnectionType.AiLanguageModel) return mockModel;
if (type === NodeConnectionType.AiOutputParser) return mockStructuredOutputParser;
if (type === NodeConnectionTypes.AiLanguageModel) return mockModel;
if (type === NodeConnectionTypes.AiOutputParser) return mockStructuredOutputParser;
throw new ApplicationError('Unexpected connection type');
});