@@ -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 ;
@@ -79,7 +79,7 @@ export const duplicateNodes = (
7979
8080 if ( isTaskNode ( node ) ) {
8181 const oldTaskId = nodeIdToTaskId ( oldNodeId ) ;
82- const newTaskId = getUniqueTaskName ( graphSpec , oldTaskId ) ;
82+ const newTaskId = getUniqueTaskId ( graphSpec , oldTaskId ) ;
8383 const newNodeId = taskIdToNodeId ( newTaskId ) ;
8484
8585 nodeIdMap [ oldNodeId ] = newNodeId ;
@@ -107,9 +107,8 @@ export const duplicateNodes = (
107107 ( input ) => input . name === node . data . label ,
108108 ) ;
109109
110- const newInputId = getUniqueInputName ( componentSpec , inputSpec ?. name ) ;
111-
112- const newNodeId = inputNameToNodeId ( newInputId ) ;
110+ const newInputName = getUniqueInputName ( componentSpec , inputSpec ?. name ) ;
111+ const newNodeId = inputNameToNodeId ( newInputName ) ;
113112
114113 nodeIdMap [ oldNodeId ] = newNodeId ;
115114
@@ -122,19 +121,21 @@ export const duplicateNodes = (
122121
123122 const newInputSpec = {
124123 ...inputSpec ,
125- name : newInputId ,
124+ name : newInputName ,
126125 annotations : updatedAnnotations ,
127126 } ;
128127
129- newInputs [ newInputId ] = newInputSpec ;
128+ newInputs [ newInputName ] = newInputSpec ;
130129 } else if ( isOutputNode ( node ) ) {
131130 const outputSpec = componentSpec . outputs ?. find (
132131 ( output ) => output . name === node . data . label ,
133132 ) ;
134133
135- const newOutputId = getUniqueOutputName ( componentSpec , outputSpec ?. name ) ;
136-
137- const newNodeId = outputNameToNodeId ( newOutputId ) ;
134+ const newOutputName = getUniqueOutputName (
135+ componentSpec ,
136+ outputSpec ?. name ,
137+ ) ;
138+ const newNodeId = outputNameToNodeId ( newOutputName ) ;
138139
139140 nodeIdMap [ oldNodeId ] = newNodeId ;
140141
@@ -147,11 +148,11 @@ export const duplicateNodes = (
147148
148149 const newOutputSpec = {
149150 ...outputSpec ,
150- name : newOutputId ,
151+ name : newOutputName ,
151152 annotations : updatedAnnotations ,
152153 } ;
153154
154- newOutputs [ newOutputId ] = newOutputSpec ;
155+ newOutputs [ newOutputName ] = newOutputSpec ;
155156 }
156157 } ) ;
157158
@@ -197,8 +198,8 @@ export const duplicateNodes = (
197198 if ( connection !== "none" ) {
198199 /* Reconfigure Outputs */
199200 Object . entries ( newOutputs ) . forEach ( ( output ) => {
200- const [ outputId ] = output ;
201- const newNodeId = outputNameToNodeId ( outputId ) ;
201+ const [ outputName ] = output ;
202+ const newNodeId = outputNameToNodeId ( outputName ) ;
202203 const oldNodeId = Object . keys ( nodeIdMap ) . find (
203204 ( key ) => nodeIdMap [ key ] === newNodeId ,
204205 ) ;
@@ -207,13 +208,13 @@ export const duplicateNodes = (
207208 return ;
208209 }
209210
210- const oldOutputId = nodeIdToOutputName ( oldNodeId ) ;
211+ const oldOutputName = nodeIdToOutputName ( oldNodeId ) ;
211212
212213 if ( ! graphSpec . outputValues ) {
213214 return ;
214215 }
215216
216- const outputValue = graphSpec . outputValues [ oldOutputId ] ;
217+ const outputValue = graphSpec . outputValues [ oldOutputName ] ;
217218
218219 if ( ! outputValue ) {
219220 return ;
@@ -248,7 +249,7 @@ export const duplicateNodes = (
248249 ( ! isInternal && connection === "external" ) ||
249250 connection === "all"
250251 ) {
251- updatedGraphOutputs [ outputId ] = updatedOutputValue ;
252+ updatedGraphOutputs [ outputName ] = updatedOutputValue ;
252253 }
253254 } ) ;
254255 }
@@ -313,9 +314,9 @@ export const duplicateNodes = (
313314
314315 return newNode ;
315316 } else if ( isInputNode ( originalNode ) ) {
316- const newInputId = nodeIdToInputName ( newNodeId ) ;
317+ const newInputName = nodeIdToInputName ( newNodeId ) ;
317318 const newInputSpec = updatedInputs . find (
318- ( input ) => input . name === newInputId ,
319+ ( input ) => input . name === newInputName ,
319320 ) ;
320321
321322 if ( ! newInputSpec ) {
@@ -343,9 +344,9 @@ export const duplicateNodes = (
343344
344345 return newNode ;
345346 } else if ( isOutputNode ( originalNode ) ) {
346- const newOutputId = nodeIdToOutputName ( newNodeId ) ;
347+ const newOutputName = nodeIdToOutputName ( newNodeId ) ;
347348 const newOutputSpec = updatedOutputs . find (
348- ( output ) => output . name === newOutputId ,
349+ ( output ) => output . name === newOutputName ,
349350 ) ;
350351
351352 if ( ! newOutputSpec ) {
@@ -412,9 +413,11 @@ export const duplicateNodes = (
412413
413414 updatedGraphSpec . tasks [ taskId ] = newTaskSpec ;
414415 } else if ( isInputNode ( node ) ) {
415- const inputId = nodeIdToInputName ( node . id ) ;
416+ const newInputName = nodeIdToInputName ( node . id ) ;
416417
417- const inputSpec = updatedInputs . find ( ( input ) => input . name === inputId ) ;
418+ const inputSpec = updatedInputs . find (
419+ ( input ) => input . name === newInputName ,
420+ ) ;
418421
419422 if ( ! inputSpec ) {
420423 return ;
@@ -433,17 +436,17 @@ export const duplicateNodes = (
433436 } ;
434437
435438 const updatedInputIndex = updatedInputs . findIndex (
436- ( input ) => input . name === inputId ,
439+ ( input ) => input . name === newInputName ,
437440 ) ;
438441
439442 if ( updatedInputIndex !== - 1 ) {
440443 updatedInputs [ updatedInputIndex ] = newInputSpec ;
441444 }
442445 } else if ( isOutputNode ( node ) ) {
443- const outputId = nodeIdToOutputName ( node . id ) ;
446+ const newOutputName = nodeIdToOutputName ( node . id ) ;
444447
445448 const outputSpec = updatedOutputs . find (
446- ( output ) => output . name === outputId ,
449+ ( output ) => output . name === newOutputName ,
447450 ) ;
448451
449452 if ( ! outputSpec ) {
@@ -463,7 +466,7 @@ export const duplicateNodes = (
463466 } ;
464467
465468 const updatedOutputIndex = updatedOutputs . findIndex (
466- ( output ) => output . name === outputId ,
469+ ( output ) => output . name === newOutputName ,
467470 ) ;
468471
469472 if ( updatedOutputIndex !== - 1 ) {
@@ -522,25 +525,25 @@ function reconfigureConnections(
522525
523526 newArgId = newTaskId ;
524527 } else if ( "graphInput" in argument ) {
525- const oldInputId = argument . graphInput . inputName ;
526- oldNodeId = inputNameToNodeId ( oldInputId ) ;
528+ const oldInputName = argument . graphInput . inputName ;
529+ oldNodeId = inputNameToNodeId ( oldInputName ) ;
527530
528531 if ( ! ( "inputs" in componentSpec ) ) {
529532 throw new Error ( "ComponentSpec does not contain inputs." ) ;
530533 }
531534
532535 const inputs = componentSpec . inputs || [ ] ;
533- isExternal = inputs . some ( ( input ) => input . name === oldInputId ) ;
536+ isExternal = inputs . some ( ( input ) => input . name === oldInputName ) ;
534537
535538 const newNodeId = nodeIdMap [ oldNodeId ] ;
536539
537540 if ( ! newNodeId ) {
538541 return reconfigureExternalConnection ( taskSpec , argKey , mode ) ;
539542 }
540543
541- const newInputId = nodeIdToInputName ( newNodeId ) ;
544+ const newInputName = nodeIdToInputName ( newNodeId ) ;
542545
543- newArgId = newInputId ;
546+ newArgId = newInputName ;
544547 }
545548
546549 if ( ! newArgId ) {
0 commit comments