MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / updateOutdatedNodeData

Function updateOutdatedNodeData

packages/ui/src/utils/genericHelper.js:233–359  ·  view source on GitHub ↗
(newComponentNodeData, existingComponentNodeData, isAgentflow)

Source from the content-addressed store, hash-verified

231}
232
233export const updateOutdatedNodeData = (newComponentNodeData, existingComponentNodeData, isAgentflow) => {
234 const initNewComponentNodeData = initNode(newComponentNodeData, existingComponentNodeData.id, isAgentflow)
235
236 const isAgentFlowV2 = newComponentNodeData.category === 'Agent Flows' || existingComponentNodeData.category === 'Agent Flows'
237
238 // Update credentials with existing credentials
239 if (existingComponentNodeData.credential) {
240 initNewComponentNodeData.credential = existingComponentNodeData.credential
241 }
242
243 // Update inputs with existing inputs
244 if (existingComponentNodeData.inputs) {
245 for (const key in existingComponentNodeData.inputs) {
246 if (key in initNewComponentNodeData.inputs) {
247 initNewComponentNodeData.inputs[key] = existingComponentNodeData.inputs[key]
248 }
249 }
250 }
251
252 // Handle loadConfig parameters - preserve configuration objects
253 if (existingComponentNodeData.inputs && initNewComponentNodeData.inputParams) {
254 // Find parameters with loadConfig: true
255 const loadConfigParams = initNewComponentNodeData.inputParams.filter((param) => param.loadConfig === true)
256
257 for (const param of loadConfigParams) {
258 const configKey = `${param.name}Config`
259
260 // Preserve top-level config objects (e.g., agentModelConfig)
261 if (existingComponentNodeData.inputs[configKey]) {
262 initNewComponentNodeData.inputs[configKey] = existingComponentNodeData.inputs[configKey]
263 }
264 }
265
266 // Handle array parameters that might contain loadConfig items
267 const arrayParams = initNewComponentNodeData.inputParams.filter((param) => param.type === 'array' && param.array)
268
269 for (const arrayParam of arrayParams) {
270 if (existingComponentNodeData.inputs[arrayParam.name] && Array.isArray(existingComponentNodeData.inputs[arrayParam.name])) {
271 const existingArray = existingComponentNodeData.inputs[arrayParam.name]
272
273 // Find loadConfig parameters within the array definition
274 const arrayLoadConfigParams = arrayParam.array.filter((subParam) => subParam.loadConfig === true)
275
276 if (arrayLoadConfigParams.length > 0) {
277 // Process each array item to preserve config objects
278 const updatedArray = existingArray.map((existingItem) => {
279 if (typeof existingItem === 'object' && existingItem !== null) {
280 const updatedItem = { ...existingItem }
281
282 // Preserve config objects for each loadConfig parameter in the array
283 for (const loadConfigParam of arrayLoadConfigParams) {
284 const configKey = `${loadConfigParam.name}Config`
285 if (existingItem[configKey]) {
286 updatedItem[configKey] = existingItem[configKey]
287 }
288 }
289
290 return updatedItem

Callers 2

syncNodesFunction · 0.90
syncNodesFunction · 0.90

Calls 3

initNodeFunction · 0.70
showHideInputParamsFunction · 0.70
showHideInputAnchorsFunction · 0.70

Tested by

no test coverage detected