MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / initNode

Function initNode

packages/components/src/agentflowv2Generator.ts:456–540  ·  view source on GitHub ↗
(nodeData: Record<string, any>, newNodeId: string)

Source from the content-addressed store, hash-verified

454}
455
456const initNode = (nodeData: Record<string, any>, newNodeId: string): NodeData => {
457 const inputParams = []
458 const incoming = nodeData.inputs ? nodeData.inputs.length : 0
459
460 // Inputs
461 for (let i = 0; i < incoming; i += 1) {
462 const newInput = {
463 ...nodeData.inputs[i],
464 id: `${newNodeId}-input-${nodeData.inputs[i].name}-${nodeData.inputs[i].type}`
465 }
466 inputParams.push(newInput)
467 }
468
469 // Credential
470 if (nodeData.credential) {
471 const newInput = {
472 ...nodeData.credential,
473 id: `${newNodeId}-input-${nodeData.credential.name}-${nodeData.credential.type}`
474 }
475 inputParams.unshift(newInput)
476 }
477
478 // Outputs
479 let outputAnchors = initializeOutputAnchors(nodeData, newNodeId)
480
481 /* Initial
482 inputs = [
483 {
484 label: 'field_label_1',
485 name: 'string'
486 },
487 {
488 label: 'field_label_2',
489 name: 'CustomType'
490 }
491 ]
492
493 => Convert to inputs, inputParams, inputAnchors
494
495 => inputs = { 'field': 'defaultvalue' } // Turn into inputs object with default values
496
497 => // For inputs that are part of whitelistTypes
498 inputParams = [
499 {
500 label: 'field_label_1',
501 name: 'string'
502 }
503 ]
504
505 => // For inputs that are not part of whitelistTypes
506 inputAnchors = [
507 {
508 label: 'field_label_2',
509 name: 'CustomType'
510 }
511 ]
512 */
513

Callers 1

generateNodesDataFunction · 0.70

Calls 4

initializeOutputAnchorsFunction · 0.70
showHideInputAnchorsFunction · 0.70
showHideInputParamsFunction · 0.70

Tested by

no test coverage detected