mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Linting fixes
This commit is contained in:
parent
16c9e50538
commit
579d8da99c
|
@ -12,8 +12,8 @@ import {
|
|||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { pineconeIndexSearch } from '../shared/createVectorStoreNode/methods/listSearch';
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
// This node is deprecated. Use VectorStorePinecone instead.
|
||||
|
|
|
@ -14,8 +14,8 @@ import { getMetadataFiltersValues } from '@utils/helpers';
|
|||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { pineconeIndexSearch } from '../shared/createVectorStoreNode/methods/listSearch';
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
|
||||
// This node is deprecated. Use VectorStorePinecone instead.
|
||||
export class VectorStorePineconeLoad implements INodeType {
|
||||
|
|
|
@ -12,8 +12,8 @@ import {
|
|||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { supabaseTableNameSearch } from '../shared/createVectorStoreNode/methods/listSearch';
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
// This node is deprecated. Use VectorStoreSupabase instead.
|
||||
|
|
|
@ -14,8 +14,8 @@ import { getMetadataFiltersValues } from '@utils/helpers';
|
|||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { supabaseTableNameSearch } from '../shared/createVectorStoreNode/methods/listSearch';
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
|
||||
// This node is deprecated. Use VectorStoreSupabase instead.
|
||||
export class VectorStoreSupabaseLoad implements INodeType {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import type { INodeProperties, INodePropertyOptions } from 'n8n-workflow';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
|
||||
import { DEFAULT_OPERATION_MODES } from '../constants';
|
||||
import type { VectorStoreNodeConstructorArgs, NodeOperationMode } from '../types';
|
||||
import {
|
||||
transformDescriptionForOperationMode,
|
||||
isUpdateSupported,
|
||||
getOperationModeOptions,
|
||||
} from '../utils';
|
||||
import type { VectorStoreNodeConstructorArgs, NodeOperationMode } from '../types';
|
||||
import { DEFAULT_OPERATION_MODES, OPERATION_MODE_DESCRIPTIONS } from '../constants';
|
||||
|
||||
describe('Vector Store Utilities', () => {
|
||||
describe('transformDescriptionForOperationMode', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type { INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
import type { NodeOperationMode } from './types';
|
||||
|
||||
export const DEFAULT_OPERATION_MODES: NodeOperationMode[] = [
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IExecuteFunctions } from 'n8n-workflow';
|
||||
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { logAiEvent } from '@utils/helpers';
|
||||
|
||||
|
@ -31,7 +33,7 @@ describe('handleLoadOperation', () => {
|
|||
};
|
||||
|
||||
mockContext = mock<IExecuteFunctions>();
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, itemIndex, fallbackValue) => {
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, _itemIndex, fallbackValue) => {
|
||||
if (typeof parameterName !== 'string') return fallbackValue;
|
||||
return nodeParameters[parameterName] ?? fallbackValue;
|
||||
});
|
||||
|
@ -87,9 +89,9 @@ describe('handleLoadOperation', () => {
|
|||
const result = await handleLoadOperation(mockContext, mockArgs, mockEmbeddings, 0);
|
||||
|
||||
expect(result[0].json.document).toHaveProperty('metadata');
|
||||
expect(result[0].json.document.metadata).toEqual({ test: 'metadata 1' });
|
||||
expect(result[0].json.document.pageContent).toEqual('test content 1');
|
||||
expect(result[0].json.score).toEqual(0.95);
|
||||
expect((result[0].json?.document as IDataObject)?.metadata).toEqual({ test: 'metadata 1' });
|
||||
expect((result[0].json?.document as IDataObject)?.pageContent).toEqual('test content 1');
|
||||
expect(result[0].json?.score).toEqual(0.95);
|
||||
});
|
||||
|
||||
it('should exclude document metadata when includeDocumentMetadata is false', async () => {
|
||||
|
@ -97,9 +99,9 @@ describe('handleLoadOperation', () => {
|
|||
|
||||
const result = await handleLoadOperation(mockContext, mockArgs, mockEmbeddings, 0);
|
||||
|
||||
expect(result[0].json.document).not.toHaveProperty('metadata');
|
||||
expect(result[0].json.document.pageContent).toEqual('test content 1');
|
||||
expect(result[0].json.score).toEqual(0.95);
|
||||
expect(result[0].json?.document).not.toHaveProperty('metadata');
|
||||
expect((result[0].json?.document as IDataObject)?.pageContent).toEqual('test content 1');
|
||||
expect(result[0].json?.score).toEqual(0.95);
|
||||
});
|
||||
|
||||
it('should use the topK parameter to limit results', async () => {
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('Vector Store Operation Handlers', () => {
|
|||
};
|
||||
|
||||
mockContext = mock<IExecuteFunctions & ISupplyDataFunctions>();
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, itemIndex, fallbackValue) => {
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, _itemIndex, fallbackValue) => {
|
||||
if (typeof parameterName !== 'string') return fallbackValue;
|
||||
return nodeParameters[parameterName] ?? fallbackValue;
|
||||
});
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { mock, MockProxy } from 'jest-mock-extended';
|
||||
import type { ISupplyDataFunctions } from 'n8n-workflow';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DynamicTool } from 'langchain/tools';
|
||||
import type { ISupplyDataFunctions } from 'n8n-workflow';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
import { handleRetrieveAsToolOperation } from '../retrieveAsToolOperation';
|
||||
import type { VectorStoreNodeConstructorArgs } from '../../types';
|
||||
import { handleRetrieveAsToolOperation } from '../retrieveAsToolOperation';
|
||||
|
||||
// Mock the helper functions
|
||||
jest.mock('@utils/helpers', () => ({
|
||||
|
@ -34,7 +37,7 @@ describe('handleRetrieveAsToolOperation', () => {
|
|||
};
|
||||
|
||||
mockContext = mock<ISupplyDataFunctions>();
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, itemIndex, fallbackValue) => {
|
||||
mockContext.getNodeParameter.mockImplementation((parameterName, _itemIndex, fallbackValue) => {
|
||||
if (typeof parameterName !== 'string') return fallbackValue;
|
||||
return nodeParameters[parameterName] ?? fallbackValue;
|
||||
});
|
||||
|
@ -68,7 +71,14 @@ describe('handleRetrieveAsToolOperation', () => {
|
|||
});
|
||||
|
||||
it('should create a dynamic tool with the correct name and description', async () => {
|
||||
const result = await handleRetrieveAsToolOperation(mockContext, mockArgs, mockEmbeddings, 0);
|
||||
const result = (await handleRetrieveAsToolOperation(
|
||||
mockContext,
|
||||
mockArgs,
|
||||
mockEmbeddings,
|
||||
0,
|
||||
)) as {
|
||||
response: DynamicTool;
|
||||
};
|
||||
|
||||
expect(result).toHaveProperty('response');
|
||||
expect(result.response).toBeInstanceOf(DynamicTool);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
|
@ -22,7 +23,7 @@ jest.mock('@utils/helpers', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('../../../processDocuments', () => ({
|
||||
processDocument: jest.fn().mockImplementation((documentInput, itemData, itemIndex) => {
|
||||
processDocument: jest.fn().mockImplementation((_documentInput, _itemData, itemIndex) => {
|
||||
const mockProcessed = [
|
||||
{
|
||||
pageContent: `updated content ${itemIndex}`,
|
||||
|
@ -76,7 +77,7 @@ describe('handleUpdateOperation', () => {
|
|||
|
||||
// Setup vector store mock
|
||||
mockVectorStore = mock<VectorStore>();
|
||||
mockVectorStore.addDocuments = jest.fn().mockResolvedValue(undefined);
|
||||
mockVectorStore.addDocuments.mockResolvedValue(undefined);
|
||||
|
||||
// Setup args mock
|
||||
mockArgs = {
|
||||
|
|
Loading…
Reference in a new issue