MCPcopy
hub / github.com/FlowiseAI/Flowise / saveUpsertFlowData

Function saveUpsertFlowData

packages/server/src/utils/index.ts:387–437  ·  view source on GitHub ↗
(nodeData: INodeData, upsertHistory: Record<string, any>)

Source from the content-addressed store, hash-verified

385 * @param {Record<string, any>} upsertHistory
386 */
387export const saveUpsertFlowData = (nodeData: INodeData, upsertHistory: Record<string, any>): ICommonObject[] => {
388 const existingUpsertFlowData = upsertHistory['flowData'] ?? []
389 const paramValues: ICommonObject[] = []
390
391 for (const input in nodeData.inputs) {
392 const inputParam = nodeData.inputParams.find((inp) => inp.name === input)
393 if (!inputParam) continue
394
395 let paramValue: ICommonObject = {}
396
397 if (!nodeData.inputs[input]) {
398 continue
399 }
400 if (
401 typeof nodeData.inputs[input] === 'string' &&
402 nodeData.inputs[input].startsWith('{{') &&
403 nodeData.inputs[input].endsWith('}}')
404 ) {
405 continue
406 }
407 // Get file name instead of the base64 string
408 if (nodeData.category === 'Document Loaders' && nodeData.inputParams.find((inp) => inp.name === input)?.type === 'file') {
409 paramValue = {
410 label: inputParam?.label,
411 name: inputParam?.name,
412 type: inputParam?.type,
413 value: getFileName(nodeData.inputs[input])
414 }
415 paramValues.push(paramValue)
416 continue
417 }
418
419 paramValue = {
420 label: inputParam?.label,
421 name: inputParam?.name,
422 type: inputParam?.type,
423 value: nodeData.inputs[input]
424 }
425 paramValues.push(paramValue)
426 }
427
428 const newFlowData = {
429 label: nodeData.label,
430 name: nodeData.name,
431 category: nodeData.category,
432 id: nodeData.id,
433 paramValues
434 }
435 existingUpsertFlowData.push(newFlowData)
436 return existingUpsertFlowData
437}
438
439/**
440 * Check if doc loader should be bypassed, ONLY if doc loader is connected to a vector store

Callers 4

_createEmbeddingsObjectFunction · 0.90
_createVectorStoreObjectFunction · 0.90
buildFlowFunction · 0.85

Calls 1

getFileNameFunction · 0.70

Tested by

no test coverage detected