refactor: remove updateConnection operation (breaking change)

Remove UpdateConnectionOperation completely as planned for v2.16.0.
This is a breaking change - users should use removeConnection + addConnection
or the new rewireConnection operation instead.

Changes:
- Remove UpdateConnectionOperation type definition
- Remove validateUpdateConnection and applyUpdateConnection methods
- Remove updateConnection cases from validation/apply switches
- Remove updateConnection tests (4 tests)
- Remove UpdateConnectionOperation import from tests

All 137 tests passing.

Related: #272 Phase 1

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-10-06 07:25:32 +02:00
parent 34bafe240d
commit c6e0e528d1
3 changed files with 2 additions and 236 deletions

View File

@@ -20,7 +20,6 @@ import {
DisableNodeOperation,
AddConnectionOperation,
RemoveConnectionOperation,
UpdateConnectionOperation,
RewireConnectionOperation,
UpdateSettingsOperation,
UpdateNameOperation,
@@ -224,8 +223,6 @@ export class WorkflowDiffEngine {
return this.validateAddConnection(workflow, operation);
case 'removeConnection':
return this.validateRemoveConnection(workflow, operation);
case 'updateConnection':
return this.validateUpdateConnection(workflow, operation);
case 'rewireConnection':
return this.validateRewireConnection(workflow, operation as RewireConnectionOperation);
case 'updateSettings':
@@ -271,9 +268,6 @@ export class WorkflowDiffEngine {
case 'removeConnection':
this.applyRemoveConnection(workflow, operation);
break;
case 'updateConnection':
this.applyUpdateConnection(workflow, operation);
break;
case 'rewireConnection':
this.applyRewireConnection(workflow, operation as RewireConnectionOperation);
break;
@@ -461,40 +455,6 @@ export class WorkflowDiffEngine {
return null;
}
private validateUpdateConnection(workflow: Workflow, operation: UpdateConnectionOperation): string | null {
const sourceNode = this.findNode(workflow, operation.source, operation.source);
const targetNode = this.findNode(workflow, operation.target, operation.target);
if (!sourceNode) {
return `Source node not found: ${operation.source}`;
}
if (!targetNode) {
return `Target node not found: ${operation.target}`;
}
// Check if connection exists to update
const existingConnections = workflow.connections[sourceNode.name];
if (!existingConnections) {
return `No connections found from "${sourceNode.name}"`;
}
// Check if any connection to target exists
let hasConnection = false;
Object.values(existingConnections).forEach(outputs => {
outputs.forEach(connections => {
if (connections.some(c => c.node === targetNode.name)) {
hasConnection = true;
}
});
});
if (!hasConnection) {
return `No connection exists from "${sourceNode.name}" to "${targetNode.name}"`;
}
return null;
}
private validateRewireConnection(workflow: Workflow, operation: RewireConnectionOperation): string | null {
// Validate source node exists
const sourceNode = this.findNode(workflow, operation.source, operation.source);
@@ -743,53 +703,6 @@ export class WorkflowDiffEngine {
}
}
private applyUpdateConnection(workflow: Workflow, operation: UpdateConnectionOperation): void {
// Validate that updates object exists and is an object
if (!operation.updates || typeof operation.updates !== 'object') {
throw new Error(
`updateConnection operation requires 'updates' object.\n\n` +
`You provided: ${JSON.stringify(operation, null, 2)}\n\n` +
`The 'updates' property is missing or invalid. ` +
`This operation modifies connection properties (output type, input type, indices), ` +
`not connection targets.\n\n` +
`Correct format:\n` +
`{\n` +
` type: "updateConnection",\n` +
` source: "IF",\n` +
` target: "EmailNode",\n` +
` updates: {\n` +
` sourceOutput: "false" // Change from one output to another\n` +
` }\n` +
`}\n\n` +
`💡 Note: If you want to change which node a connection goes to, ` +
`use removeConnection + addConnection instead:\n` +
`[\n` +
` {type: "removeConnection", source: "${operation.source}", target: "${operation.target}"},\n` +
` {type: "addConnection", source: "${operation.source}", target: "NewTarget"}\n` +
`]`
);
}
// Implement as remove + add with the updated properties
this.applyRemoveConnection(workflow, {
type: 'removeConnection',
source: operation.source,
target: operation.target,
sourceOutput: operation.updates.sourceOutput,
targetInput: operation.updates.targetInput
});
this.applyAddConnection(workflow, {
type: 'addConnection',
source: operation.source,
target: operation.target,
sourceOutput: operation.updates.sourceOutput,
targetInput: operation.updates.targetInput,
sourceIndex: operation.updates.sourceIndex,
targetIndex: operation.updates.targetIndex
});
}
/**
* Rewire a connection from one target to another
* This is a semantic wrapper around removeConnection + addConnection