mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
feat: implement rewireConnection operation (Phase 1, Task 1)
Added intuitive rewireConnection operation for changing connection targets in a single semantic step: "rewire from X to Y" Changes: - Added RewireConnectionOperation type with from/to semantics - Implemented validation (checks source, from, to nodes and connection existence) - Implemented operation as remove + add wrapper - Added 8 comprehensive tests covering all scenarios - All 134 tests passing (126 Phase 0 + 8 new) Test Coverage: - Basic rewiring - Rewiring with sourceOutput specified - Preserving parallel connections - Error handling (source/from/to not found, connection doesn't exist) - IF node branch rewiring Expected Impact: 4/10 → 9/10 rating for rewiring tasks Related: Issue #272 Phase 1 implementation Phase 0 PR: #274 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,16 @@ export interface UpdateConnectionOperation extends DiffOperation {
|
||||
};
|
||||
}
|
||||
|
||||
export interface RewireConnectionOperation extends DiffOperation {
|
||||
type: 'rewireConnection';
|
||||
source: string; // Source node name or ID
|
||||
from: string; // Current target to rewire FROM
|
||||
to: string; // New target to rewire TO
|
||||
sourceOutput?: string; // Optional: which output to rewire (default: 'main')
|
||||
targetInput?: string; // Optional: which input type (default: 'main')
|
||||
sourceIndex?: number; // Optional: which source index (default: 0)
|
||||
}
|
||||
|
||||
// Workflow Metadata Operations
|
||||
export interface UpdateSettingsOperation extends DiffOperation {
|
||||
type: 'updateSettings';
|
||||
@@ -140,6 +150,7 @@ export type WorkflowDiffOperation =
|
||||
| AddConnectionOperation
|
||||
| RemoveConnectionOperation
|
||||
| UpdateConnectionOperation
|
||||
| RewireConnectionOperation
|
||||
| UpdateSettingsOperation
|
||||
| UpdateNameOperation
|
||||
| AddTagOperation
|
||||
@@ -187,8 +198,8 @@ export function isNodeOperation(op: WorkflowDiffOperation): op is
|
||||
}
|
||||
|
||||
export function isConnectionOperation(op: WorkflowDiffOperation): op is
|
||||
AddConnectionOperation | RemoveConnectionOperation | UpdateConnectionOperation | CleanStaleConnectionsOperation | ReplaceConnectionsOperation {
|
||||
return ['addConnection', 'removeConnection', 'updateConnection', 'cleanStaleConnections', 'replaceConnections'].includes(op.type);
|
||||
AddConnectionOperation | RemoveConnectionOperation | UpdateConnectionOperation | RewireConnectionOperation | CleanStaleConnectionsOperation | ReplaceConnectionsOperation {
|
||||
return ['addConnection', 'removeConnection', 'updateConnection', 'rewireConnection', 'cleanStaleConnections', 'replaceConnections'].includes(op.type);
|
||||
}
|
||||
|
||||
export function isMetadataOperation(op: WorkflowDiffOperation): op is
|
||||
|
||||
Reference in New Issue
Block a user