mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
fix: resolve all TypeScript linting errors
- Fix searchTemplatesByMetadata calls to pass limit/offset as separate params - Fix syntax errors with brace placement in test files - Add type annotations for implicit any types - All tests passing and TypeScript compilation successful
This commit is contained in:
@@ -246,10 +246,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
// Verify metadata was updated
|
||||
const templates = repository.searchTemplatesByMetadata({
|
||||
category: 'test',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'test'}, 10, 0);
|
||||
|
||||
expect(templates).toHaveLength(1);
|
||||
expect(templates[0].id).toBe(1);
|
||||
@@ -281,10 +278,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
// Verify both templates were updated
|
||||
const templates = repository.searchTemplatesByMetadata({
|
||||
category: 'batch_test',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'batch_test'}, 10, 0);
|
||||
|
||||
expect(templates).toHaveLength(2);
|
||||
expect(templates.map(t => t.id).sort()).toEqual([1, 2]);
|
||||
@@ -292,10 +286,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should search templates by category', () => {
|
||||
const templates = repository.searchTemplatesByMetadata({
|
||||
category: 'automation',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'automation'}, 10, 0);
|
||||
|
||||
expect(templates.length).toBeGreaterThan(0);
|
||||
expect(templates[0]).toHaveProperty('id');
|
||||
@@ -304,16 +295,10 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should search templates by complexity', () => {
|
||||
const simpleTemplates = repository.searchTemplatesByMetadata({
|
||||
complexity: 'simple',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
complexity: 'simple'}, 10, 0);
|
||||
|
||||
const complexTemplates = repository.searchTemplatesByMetadata({
|
||||
complexity: 'complex',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
complexity: 'complex'}, 10, 0);
|
||||
|
||||
expect(simpleTemplates).toHaveLength(1);
|
||||
expect(complexTemplates).toHaveLength(1);
|
||||
@@ -323,16 +308,10 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should search templates by setup time', () => {
|
||||
const quickTemplates = repository.searchTemplatesByMetadata({
|
||||
maxSetupMinutes: 30,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
maxSetupMinutes: 30}, 10, 0);
|
||||
|
||||
const longTemplates = repository.searchTemplatesByMetadata({
|
||||
minSetupMinutes: 60,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
minSetupMinutes: 60}, 10, 0);
|
||||
|
||||
expect(quickTemplates).toHaveLength(1); // Only 15 min template (45 min > 30)
|
||||
expect(longTemplates).toHaveLength(1); // 120 min template
|
||||
@@ -340,16 +319,10 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should search templates by required service', () => {
|
||||
const slackTemplates = repository.searchTemplatesByMetadata({
|
||||
requiredService: 'slack',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
requiredService: 'slack'}, 10, 0);
|
||||
|
||||
const openaiTemplates = repository.searchTemplatesByMetadata({
|
||||
requiredService: 'OpenAI',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
requiredService: 'OpenAI'}, 10, 0);
|
||||
|
||||
expect(slackTemplates).toHaveLength(1);
|
||||
expect(openaiTemplates).toHaveLength(1);
|
||||
@@ -357,16 +330,10 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should search templates by target audience', () => {
|
||||
const developerTemplates = repository.searchTemplatesByMetadata({
|
||||
targetAudience: 'developers',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
targetAudience: 'developers'}, 10, 0);
|
||||
|
||||
const marketerTemplates = repository.searchTemplatesByMetadata({
|
||||
targetAudience: 'marketers',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
targetAudience: 'marketers'}, 10, 0);
|
||||
|
||||
expect(developerTemplates).toHaveLength(2);
|
||||
expect(marketerTemplates).toHaveLength(2);
|
||||
@@ -376,10 +343,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
const filteredTemplates = repository.searchTemplatesByMetadata({
|
||||
complexity: 'medium',
|
||||
targetAudience: 'marketers',
|
||||
maxSetupMinutes: 60,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
maxSetupMinutes: 60}, 10, 0);
|
||||
|
||||
expect(filteredTemplates).toHaveLength(1);
|
||||
expect(filteredTemplates[0].id).toBe(3);
|
||||
@@ -487,10 +451,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
describe('Service Layer Integration', () => {
|
||||
it('should search templates with metadata through service', async () => {
|
||||
const results = await service.searchTemplatesByMetadata({
|
||||
complexity: 'simple',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
complexity: 'simple'}, 10, 0);
|
||||
|
||||
expect(results).toHaveProperty('items');
|
||||
expect(results).toHaveProperty('total');
|
||||
@@ -519,10 +480,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should return templates with metadata information', async () => {
|
||||
const results = await service.searchTemplatesByMetadata({
|
||||
category: 'automation',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'automation'}, 10, 0);
|
||||
|
||||
expect(results.items.length).toBeGreaterThan(0);
|
||||
|
||||
@@ -545,10 +503,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
maliciousInputs.forEach(input => {
|
||||
expect(() => {
|
||||
repository.searchTemplatesByMetadata({
|
||||
...input,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
...input}, 10, 0);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -571,10 +526,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
|
||||
it('should handle empty search results gracefully', () => {
|
||||
const results = repository.searchTemplatesByMetadata({
|
||||
category: 'nonexistent_category',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'nonexistent_category'}, 10, 0);
|
||||
|
||||
expect(results).toHaveLength(0);
|
||||
});
|
||||
@@ -583,10 +535,8 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
// Test extreme values
|
||||
const results = repository.searchTemplatesByMetadata({
|
||||
maxSetupMinutes: 0,
|
||||
minSetupMinutes: 999999,
|
||||
limit: 0,
|
||||
offset: -1
|
||||
});
|
||||
minSetupMinutes: 999999
|
||||
}, 0, -1); // offset -1 to test edge case
|
||||
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
});
|
||||
@@ -596,10 +546,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
it('should handle large result sets efficiently', () => {
|
||||
// Test with maximum limit
|
||||
const startTime = Date.now();
|
||||
const results = repository.searchTemplatesByMetadata({
|
||||
limit: 100,
|
||||
offset: 0
|
||||
});
|
||||
const results = repository.searchTemplatesByMetadata({}, 100, 0);
|
||||
const endTime = Date.now();
|
||||
|
||||
expect(endTime - startTime).toBeLessThan(1000); // Should complete within 1 second
|
||||
@@ -607,7 +554,7 @@ describe('Template Metadata Operations - Integration Tests', () => {
|
||||
});
|
||||
|
||||
it('should handle concurrent metadata updates', () => {
|
||||
const updates = [];
|
||||
const updates: any[] = [];
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
updates.push(() => {
|
||||
|
||||
@@ -463,7 +463,7 @@ describe('MetadataGenerator', () => {
|
||||
const userMessage = request.body.messages[1].content;
|
||||
|
||||
// Should limit to top 10 groups
|
||||
const summaryLine = userMessage.split('\n').find(line =>
|
||||
const summaryLine = userMessage.split('\n').find((line: string) =>
|
||||
line.includes('Nodes Used (50)')
|
||||
);
|
||||
|
||||
|
||||
@@ -122,10 +122,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: maliciousCategory,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: maliciousCategory}, 10, 0);
|
||||
|
||||
// Should use parameterized queries, not inject SQL
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
@@ -149,10 +146,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
requiredService: maliciousService,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
requiredService: maliciousService}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
const expectedParam = JSON.stringify(maliciousService).slice(1, -1);
|
||||
@@ -172,10 +166,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
targetAudience: maliciousAudience,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
targetAudience: maliciousAudience}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
const expectedParam = JSON.stringify(maliciousAudience).slice(1, -1);
|
||||
@@ -195,10 +186,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: specialChars,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: specialChars}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
const expectedParam = JSON.stringify(specialChars).slice(1, -1);
|
||||
@@ -216,12 +204,9 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
// Try to inject through numeric parameters
|
||||
repository.searchTemplatesByMetadata({
|
||||
maxSetupMinutes: 999999999, // Large number
|
||||
minSetupMinutes: -999999999, // Negative number
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
repository.searchTemplatesByMetadata({maxSetupMinutes: 999999999, // Large number
|
||||
minSetupMinutes: -999999999 // Negative number
|
||||
}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
// capturedParams[0] is the first call's parameters array
|
||||
@@ -365,10 +350,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: undefined as any,
|
||||
complexity: null as any,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
complexity: null as any}, 10, 0);
|
||||
|
||||
// Should not break and should exclude undefined/null filters
|
||||
const prepareCall = mockAdapter.prepare.mock.calls[0][0];
|
||||
@@ -385,10 +367,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: '',
|
||||
requiredService: '',
|
||||
targetAudience: '',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
targetAudience: ''}, 10, 0);
|
||||
|
||||
// Empty strings should still be processed (might be valid searches)
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
@@ -407,10 +386,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
maxSetupMinutes: Number.MAX_SAFE_INTEGER,
|
||||
minSetupMinutes: Number.MIN_SAFE_INTEGER,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
minSetupMinutes: Number.MIN_SAFE_INTEGER}, 10, 0);
|
||||
|
||||
// Should handle extreme values without breaking
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
@@ -428,10 +404,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: unicodeCategory,
|
||||
targetAudience: emojiAudience,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
targetAudience: emojiAudience}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
const expectedCategoryParam = JSON.stringify(unicodeCategory).slice(1, -1);
|
||||
@@ -449,10 +422,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: 'test',
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: 'test'}, 10, 0);
|
||||
|
||||
const prepareCall = mockAdapter.prepare.mock.calls[0][0];
|
||||
|
||||
@@ -524,10 +494,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
stmt._setMockResults([]);
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
limit: 999999999, // Very large limit
|
||||
offset: 0
|
||||
});
|
||||
repository.searchTemplatesByMetadata({}, 999999999, 0); // Very large limit
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
// Check if parameters were captured
|
||||
@@ -548,10 +515,7 @@ describe('TemplateRepository - Security Tests', () => {
|
||||
mockAdapter.prepare = vi.fn().mockReturnValue(stmt);
|
||||
|
||||
repository.searchTemplatesByMetadata({
|
||||
category: veryLongString,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
});
|
||||
category: veryLongString}, 10, 0);
|
||||
|
||||
const capturedParams = stmt._getCapturedParams();
|
||||
expect(capturedParams[0][0]).toContain(veryLongString);
|
||||
|
||||
Reference in New Issue
Block a user