mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor: Migrate NodeConnectionType to const object type (no-changelog) (#14078)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { Document } from 'langchain/document';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
type INodeExecutionData,
|
||||
type IExecuteFunctions,
|
||||
type INodeType,
|
||||
@@ -42,21 +42,21 @@ export class VectorStoreInMemoryInsert implements INodeType {
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: [
|
||||
NodeConnectionType.Main,
|
||||
NodeConnectionTypes.Main,
|
||||
{
|
||||
displayName: 'Document',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiDocument,
|
||||
type: NodeConnectionTypes.AiDocument,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
{
|
||||
displayName:
|
||||
@@ -86,13 +86,13 @@ export class VectorStoreInMemoryInsert implements INodeType {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData(0);
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
const memoryKey = this.getNodeParameter('memoryKey', 0) as string;
|
||||
const clearStore = this.getNodeParameter('clearStore', 0) as boolean;
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
|
||||
| N8nJsonLoader
|
||||
| Array<Document<Record<string, unknown>>>;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type ISupplyDataFunctions,
|
||||
@@ -43,11 +43,11 @@ export class VectorStoreInMemoryLoad implements INodeType {
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.AiVectorStore],
|
||||
outputs: [NodeConnectionTypes.AiVectorStore],
|
||||
outputNames: ['Vector Store'],
|
||||
properties: [
|
||||
{
|
||||
@@ -63,7 +63,7 @@ export class VectorStoreInMemoryLoad implements INodeType {
|
||||
|
||||
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
itemIndex,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type INodeExecutionData,
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
@@ -51,21 +51,21 @@ export class VectorStorePineconeInsert implements INodeType {
|
||||
},
|
||||
],
|
||||
inputs: [
|
||||
NodeConnectionType.Main,
|
||||
NodeConnectionTypes.Main,
|
||||
{
|
||||
displayName: 'Document',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiDocument,
|
||||
type: NodeConnectionTypes.AiDocument,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
pineconeIndexRLC,
|
||||
{
|
||||
@@ -106,12 +106,12 @@ export class VectorStorePineconeInsert implements INodeType {
|
||||
|
||||
const credentials = await this.getCredentials('pineconeApi');
|
||||
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
|
||||
| N8nJsonLoader
|
||||
| Array<Document<Record<string, unknown>>>;
|
||||
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PineconeStoreParams } from '@langchain/pinecone';
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type ISupplyDataFunctions,
|
||||
@@ -54,11 +54,11 @@ export class VectorStorePineconeLoad implements INodeType {
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.AiVectorStore],
|
||||
outputs: [NodeConnectionTypes.AiVectorStore],
|
||||
outputNames: ['Vector Store'],
|
||||
properties: [
|
||||
pineconeIndexRLC,
|
||||
@@ -95,7 +95,7 @@ export class VectorStorePineconeLoad implements INodeType {
|
||||
|
||||
const credentials = await this.getCredentials('pineconeApi');
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
itemIndex,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type INodeExecutionData,
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
@@ -51,21 +51,21 @@ export class VectorStoreSupabaseInsert implements INodeType {
|
||||
},
|
||||
],
|
||||
inputs: [
|
||||
NodeConnectionType.Main,
|
||||
NodeConnectionTypes.Main,
|
||||
{
|
||||
displayName: 'Document',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiDocument,
|
||||
type: NodeConnectionTypes.AiDocument,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
{
|
||||
displayName:
|
||||
@@ -102,12 +102,12 @@ export class VectorStoreSupabaseInsert implements INodeType {
|
||||
const queryName = this.getNodeParameter('queryName', 0) as string;
|
||||
const credentials = await this.getCredentials('supabaseApi');
|
||||
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
|
||||
| N8nJsonLoader
|
||||
| Array<Document<Record<string, unknown>>>;
|
||||
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
const client = createClient(credentials.host as string, credentials.serviceRole as string);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type INodeTypeDescription,
|
||||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getMetadataFiltersValues } from '@utils/helpers';
|
||||
@@ -54,11 +54,11 @@ export class VectorStoreSupabaseLoad implements INodeType {
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.AiVectorStore],
|
||||
outputs: [NodeConnectionTypes.AiVectorStore],
|
||||
outputNames: ['Vector Store'],
|
||||
properties: [
|
||||
supabaseTableNameRLC,
|
||||
@@ -93,7 +93,7 @@ export class VectorStoreSupabaseLoad implements INodeType {
|
||||
|
||||
const credentials = await this.getCredentials('supabaseApi');
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type INodeExecutionData,
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
@@ -47,21 +47,21 @@ export class VectorStoreZepInsert implements INodeType {
|
||||
},
|
||||
],
|
||||
inputs: [
|
||||
NodeConnectionType.Main,
|
||||
NodeConnectionTypes.Main,
|
||||
{
|
||||
displayName: 'Document',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiDocument,
|
||||
type: NodeConnectionTypes.AiDocument,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Collection Name',
|
||||
@@ -117,12 +117,12 @@ export class VectorStoreZepInsert implements INodeType {
|
||||
apiUrl: string;
|
||||
}>('zepApi');
|
||||
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||
const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
|
||||
| N8nJsonLoader
|
||||
| Array<Document<Record<string, unknown>>>;
|
||||
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { IZepConfig } from '@langchain/community/vectorstores/zep';
|
||||
import { ZepVectorStore } from '@langchain/community/vectorstores/zep';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
NodeConnectionTypes,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type ISupplyDataFunctions,
|
||||
@@ -50,11 +50,11 @@ export class VectorStoreZepLoad implements INodeType {
|
||||
{
|
||||
displayName: 'Embedding',
|
||||
maxConnections: 1,
|
||||
type: NodeConnectionType.AiEmbedding,
|
||||
type: NodeConnectionTypes.AiEmbedding,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
outputs: [NodeConnectionType.AiVectorStore],
|
||||
outputs: [NodeConnectionTypes.AiVectorStore],
|
||||
outputNames: ['Vector Store'],
|
||||
properties: [
|
||||
{
|
||||
@@ -99,7 +99,7 @@ export class VectorStoreZepLoad implements INodeType {
|
||||
apiUrl: string;
|
||||
}>('zepApi');
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { DEFAULT_OPERATION_MODES } from '../constants';
|
||||
import type { VectorStoreNodeConstructorArgs, NodeOperationMode } from '../types';
|
||||
@@ -178,8 +178,8 @@ describe('Vector Store Utilities', () => {
|
||||
const retrieveOption = result.find((option) => option.value === 'retrieve');
|
||||
const retrieveAsToolOption = result.find((option) => option.value === 'retrieve-as-tool');
|
||||
|
||||
expect(retrieveOption?.outputConnectionType).toBe(NodeConnectionType.AiVectorStore);
|
||||
expect(retrieveAsToolOption?.outputConnectionType).toBe(NodeConnectionType.AiTool);
|
||||
expect(retrieveOption?.outputConnectionType).toBe(NodeConnectionTypes.AiVectorStore);
|
||||
expect(retrieveAsToolOption?.outputConnectionType).toBe(NodeConnectionTypes.AiTool);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
import type { INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
import type { NodeOperationMode } from './types';
|
||||
@@ -28,14 +28,14 @@ export const OPERATION_MODE_DESCRIPTIONS: INodePropertyOptions[] = [
|
||||
value: 'retrieve',
|
||||
description: 'Retrieve documents from vector store to be used as vector store with AI nodes',
|
||||
action: 'Retrieve documents for Chain/Tool as Vector Store',
|
||||
outputConnectionType: NodeConnectionType.AiVectorStore,
|
||||
outputConnectionType: NodeConnectionTypes.AiVectorStore,
|
||||
},
|
||||
{
|
||||
name: 'Retrieve Documents (As Tool for AI Agent)',
|
||||
value: 'retrieve-as-tool',
|
||||
description: 'Retrieve documents from vector store to be used as tool with AI nodes',
|
||||
action: 'Retrieve documents for AI Agent as Tool',
|
||||
outputConnectionType: NodeConnectionType.AiTool,
|
||||
outputConnectionType: NodeConnectionTypes.AiTool,
|
||||
},
|
||||
{
|
||||
name: 'Update Documents',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
@@ -66,18 +66,18 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
|
||||
inputs: `={{
|
||||
((parameters) => {
|
||||
const mode = parameters?.mode;
|
||||
const inputs = [{ displayName: "Embedding", type: "${NodeConnectionType.AiEmbedding}", required: true, maxConnections: 1}]
|
||||
const inputs = [{ displayName: "Embedding", type: "${NodeConnectionTypes.AiEmbedding}", required: true, maxConnections: 1}]
|
||||
|
||||
if (mode === 'retrieve-as-tool') {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
if (['insert', 'load', 'update'].includes(mode)) {
|
||||
inputs.push({ displayName: "", type: "${NodeConnectionType.Main}"})
|
||||
inputs.push({ displayName: "", type: "${NodeConnectionTypes.Main}"})
|
||||
}
|
||||
|
||||
if (['insert'].includes(mode)) {
|
||||
inputs.push({ displayName: "Document", type: "${NodeConnectionType.AiDocument}", required: true, maxConnections: 1})
|
||||
inputs.push({ displayName: "Document", type: "${NodeConnectionTypes.AiDocument}", required: true, maxConnections: 1})
|
||||
}
|
||||
return inputs
|
||||
})($parameter)
|
||||
@@ -87,13 +87,13 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
|
||||
const mode = parameters?.mode ?? 'retrieve';
|
||||
|
||||
if (mode === 'retrieve-as-tool') {
|
||||
return [{ displayName: "Tool", type: "${NodeConnectionType.AiTool}"}]
|
||||
return [{ displayName: "Tool", type: "${NodeConnectionTypes.AiTool}"}]
|
||||
}
|
||||
|
||||
if (mode === 'retrieve') {
|
||||
return [{ displayName: "Vector Store", type: "${NodeConnectionType.AiVectorStore}"}]
|
||||
return [{ displayName: "Vector Store", type: "${NodeConnectionTypes.AiVectorStore}"}]
|
||||
}
|
||||
return [{ displayName: "", type: "${NodeConnectionType.Main}"}]
|
||||
return [{ displayName: "", type: "${NodeConnectionTypes.Main}"}]
|
||||
})($parameter)
|
||||
}}`,
|
||||
properties: [
|
||||
@@ -106,7 +106,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
|
||||
options: getOperationModeOptions(args),
|
||||
},
|
||||
{
|
||||
...getConnectionHintNoticeField([NodeConnectionType.AiRetriever]),
|
||||
...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['retrieve'],
|
||||
@@ -232,7 +232,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
|
||||
|
||||
// Get the embeddings model connected to this node
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
@@ -274,7 +274,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
|
||||
|
||||
// Get the embeddings model connected to this node
|
||||
const embeddings = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiEmbedding,
|
||||
NodeConnectionTypes.AiEmbedding,
|
||||
0,
|
||||
)) as Embeddings;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { logAiEvent } from '@utils/helpers';
|
||||
import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
@@ -137,7 +137,7 @@ describe('handleInsertOperation', () => {
|
||||
|
||||
// Should get document input from connection
|
||||
expect(mockContext.getInputConnectionData).toHaveBeenCalledWith(
|
||||
NodeConnectionType.AiDocument,
|
||||
NodeConnectionTypes.AiDocument,
|
||||
0,
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { logAiEvent } from '@utils/helpers';
|
||||
import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
@@ -23,7 +23,7 @@ export async function handleInsertOperation<T extends VectorStore = VectorStore>
|
||||
const nodeVersion = context.getNode().typeVersion;
|
||||
// Get the input items and document data
|
||||
const items = context.getInputData();
|
||||
const documentInput = (await context.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||
const documentInput = (await context.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
|
||||
| N8nJsonLoader
|
||||
| N8nBinaryLoader
|
||||
| Array<Document<Record<string, unknown>>>;
|
||||
|
||||
Reference in New Issue
Block a user