fix: address code review issues for form trigger improvements

- Add form-data as direct dependency (was only in devDependencies)
- Add TypeScript interfaces (FormFieldValue, FormFieldOption) replacing any types
- Add FORM_FIELD_TYPES constants for type-safe switch statements
- Add isValidBase64() validation for file uploads with size limits
- Add MAX_FILE_SIZE_BYTES (10MB) constant with validation
- Update form-handler.test.ts for FormData instead of JSON
- Update trigger-detector.test.ts for chat URL /chat suffix

Conceived by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-12-01 22:10:42 +01:00
parent 3cbb02650b
commit f65514381f
5 changed files with 477 additions and 230 deletions

View File

@@ -242,7 +242,7 @@ describe('Trigger Detector', () => {
expect(url).toContain('/form/');
});
it('should build chat URL correctly', () => {
it('should build chat URL correctly with /chat suffix', () => {
const baseUrl = 'https://n8n.example.com';
const trigger = {
type: 'chat' as const,
@@ -259,7 +259,8 @@ describe('Trigger Detector', () => {
const url = buildTriggerUrl(baseUrl, trigger, 'production');
expect(url).toBe('https://n8n.example.com/webhook/ai-chat');
// Chat triggers use /webhook/<webhookId>/chat endpoint
expect(url).toBe('https://n8n.example.com/webhook/ai-chat/chat');
});
});