@@ -32,7 +32,7 @@ import { convertTaskCallbacksToNodeCallbacks } from "@/utils/nodes/taskCallbackU
3232import {
3333 getUniqueInputName ,
3434 getUniqueOutputName ,
35- getUniqueTaskName ,
35+ getUniqueTaskId ,
3636} from "@/utils/unique" ;
3737
3838const OFFSET = 10 ;
@@ -78,7 +78,7 @@ export const duplicateNodes = (
7878
7979 if ( isTaskNode ( node ) ) {
8080 const oldTaskId = nodeIdToTaskId ( oldNodeId ) ;
81- const newTaskId = getUniqueTaskName ( graphSpec , oldTaskId ) ;
81+ const newTaskId = getUniqueTaskId ( graphSpec , oldTaskId ) ;
8282 const newNodeId = taskIdToNodeId ( newTaskId ) ;
8383
8484 nodeIdMap [ oldNodeId ] = newNodeId ;
@@ -101,9 +101,8 @@ export const duplicateNodes = (
101101 ( input ) => input . name === node . data . label ,
102102 ) ;
103103
104- const newInputId = getUniqueInputName ( componentSpec , inputSpec ?. name ) ;
105-
106- const newNodeId = inputNameToNodeId ( newInputId ) ;
104+ const newInputName = getUniqueInputName ( componentSpec , inputSpec ?. name ) ;
105+ const newNodeId = inputNameToNodeId ( newInputName ) ;
107106
108107 nodeIdMap [ oldNodeId ] = newNodeId ;
109108
@@ -116,19 +115,21 @@ export const duplicateNodes = (
116115
117116 const newInputSpec = {
118117 ...inputSpec ,
119- name : newInputId ,
118+ name : newInputName ,
120119 annotations : updatedAnnotations ,
121120 } ;
122121
123- newInputs [ newInputId ] = newInputSpec ;
122+ newInputs [ newInputName ] = newInputSpec ;
124123 } else if ( isOutputNode ( node ) ) {
125124 const outputSpec = componentSpec . outputs ?. find (
126125 ( output ) => output . name === node . data . label ,
127126 ) ;
128127
129- const newOutputId = getUniqueOutputName ( componentSpec , outputSpec ?. name ) ;
130-
131- const newNodeId = outputNameToNodeId ( newOutputId ) ;
128+ const newOutputName = getUniqueOutputName (
129+ componentSpec ,
130+ outputSpec ?. name ,
131+ ) ;
132+ const newNodeId = outputNameToNodeId ( newOutputName ) ;
132133
133134 nodeIdMap [ oldNodeId ] = newNodeId ;
134135
@@ -141,11 +142,11 @@ export const duplicateNodes = (
141142
142143 const newOutputSpec = {
143144 ...outputSpec ,
144- name : newOutputId ,
145+ name : newOutputName ,
145146 annotations : updatedAnnotations ,
146147 } ;
147148
148- newOutputs [ newOutputId ] = newOutputSpec ;
149+ newOutputs [ newOutputName ] = newOutputSpec ;
149150 }
150151 } ) ;
151152
@@ -191,8 +192,8 @@ export const duplicateNodes = (
191192 if ( connection !== "none" ) {
192193 /* Reconfigure Outputs */
193194 Object . entries ( newOutputs ) . forEach ( ( output ) => {
194- const [ outputId ] = output ;
195- const newNodeId = outputNameToNodeId ( outputId ) ;
195+ const [ outputName ] = output ;
196+ const newNodeId = outputNameToNodeId ( outputName ) ;
196197 const oldNodeId = Object . keys ( nodeIdMap ) . find (
197198 ( key ) => nodeIdMap [ key ] === newNodeId ,
198199 ) ;
@@ -201,13 +202,13 @@ export const duplicateNodes = (
201202 return ;
202203 }
203204
204- const oldOutputId = nodeIdToOutputName ( oldNodeId ) ;
205+ const oldOutputName = nodeIdToOutputName ( oldNodeId ) ;
205206
206207 if ( ! graphSpec . outputValues ) {
207208 return ;
208209 }
209210
210- const outputValue = graphSpec . outputValues [ oldOutputId ] ;
211+ const outputValue = graphSpec . outputValues [ oldOutputName ] ;
211212
212213 if ( ! outputValue ) {
213214 return ;
@@ -242,7 +243,7 @@ export const duplicateNodes = (
242243 ( ! isInternal && connection === "external" ) ||
243244 connection === "all"
244245 ) {
245- updatedGraphOutputs [ outputId ] = updatedOutputValue ;
246+ updatedGraphOutputs [ outputName ] = updatedOutputValue ;
246247 }
247248 } ) ;
248249 }
@@ -307,9 +308,9 @@ export const duplicateNodes = (
307308
308309 return newNode ;
309310 } else if ( isInputNode ( originalNode ) ) {
310- const newInputId = nodeIdToInputName ( newNodeId ) ;
311+ const newInputName = nodeIdToInputName ( newNodeId ) ;
311312 const newInputSpec = updatedInputs . find (
312- ( input ) => input . name === newInputId ,
313+ ( input ) => input . name === newInputName ,
313314 ) ;
314315
315316 if ( ! newInputSpec ) {
@@ -337,9 +338,9 @@ export const duplicateNodes = (
337338
338339 return newNode ;
339340 } else if ( isOutputNode ( originalNode ) ) {
340- const newOutputId = nodeIdToOutputName ( newNodeId ) ;
341+ const newOutputName = nodeIdToOutputName ( newNodeId ) ;
341342 const newOutputSpec = updatedOutputs . find (
342- ( output ) => output . name === newOutputId ,
343+ ( output ) => output . name === newOutputName ,
343344 ) ;
344345
345346 if ( ! newOutputSpec ) {
@@ -406,9 +407,11 @@ export const duplicateNodes = (
406407
407408 updatedGraphSpec . tasks [ taskId ] = newTaskSpec ;
408409 } else if ( isInputNode ( node ) ) {
409- const inputId = nodeIdToInputName ( node . id ) ;
410+ const newInputName = nodeIdToInputName ( node . id ) ;
410411
411- const inputSpec = updatedInputs . find ( ( input ) => input . name === inputId ) ;
412+ const inputSpec = updatedInputs . find (
413+ ( input ) => input . name === newInputName ,
414+ ) ;
412415
413416 if ( ! inputSpec ) {
414417 return ;
@@ -427,17 +430,17 @@ export const duplicateNodes = (
427430 } ;
428431
429432 const updatedInputIndex = updatedInputs . findIndex (
430- ( input ) => input . name === inputId ,
433+ ( input ) => input . name === newInputName ,
431434 ) ;
432435
433436 if ( updatedInputIndex !== - 1 ) {
434437 updatedInputs [ updatedInputIndex ] = newInputSpec ;
435438 }
436439 } else if ( isOutputNode ( node ) ) {
437- const outputId = nodeIdToOutputName ( node . id ) ;
440+ const newOutputName = nodeIdToOutputName ( node . id ) ;
438441
439442 const outputSpec = updatedOutputs . find (
440- ( output ) => output . name === outputId ,
443+ ( output ) => output . name === newOutputName ,
441444 ) ;
442445
443446 if ( ! outputSpec ) {
@@ -457,7 +460,7 @@ export const duplicateNodes = (
457460 } ;
458461
459462 const updatedOutputIndex = updatedOutputs . findIndex (
460- ( output ) => output . name === outputId ,
463+ ( output ) => output . name === newOutputName ,
461464 ) ;
462465
463466 if ( updatedOutputIndex !== - 1 ) {
@@ -516,25 +519,25 @@ function reconfigureConnections(
516519
517520 newArgId = newTaskId ;
518521 } else if ( "graphInput" in argument ) {
519- const oldInputId = argument . graphInput . inputName ;
520- oldNodeId = inputNameToNodeId ( oldInputId ) ;
522+ const oldInputName = argument . graphInput . inputName ;
523+ oldNodeId = inputNameToNodeId ( oldInputName ) ;
521524
522525 if ( ! ( "inputs" in componentSpec ) ) {
523526 throw new Error ( "ComponentSpec does not contain inputs." ) ;
524527 }
525528
526529 const inputs = componentSpec . inputs || [ ] ;
527- isExternal = inputs . some ( ( input ) => input . name === oldInputId ) ;
530+ isExternal = inputs . some ( ( input ) => input . name === oldInputName ) ;
528531
529532 const newNodeId = nodeIdMap [ oldNodeId ] ;
530533
531534 if ( ! newNodeId ) {
532535 return reconfigureExternalConnection ( taskSpec , argKey , mode ) ;
533536 }
534537
535- const newInputId = nodeIdToInputName ( newNodeId ) ;
538+ const newInputName = nodeIdToInputName ( newNodeId ) ;
536539
537- newArgId = newInputId ;
540+ newArgId = newInputName ;
538541 }
539542
540543 if ( ! newArgId ) {
0 commit comments