(nodeData: INodeData, upsertHistory: Record<string, any>)
| 385 | * @param {Record<string, any>} upsertHistory |
| 386 | */ |
| 387 | export 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 |
no test coverage detected