( nodeId: string, textValue: string, inputData: any, config?: unknown, executionContext?: FlowExecutionContext, )
| 2705 | } |
| 2706 | |
| 2707 | async function executeSaveChangesNode( |
| 2708 | nodeId: string, |
| 2709 | textValue: string, |
| 2710 | inputData: any, |
| 2711 | config?: unknown, |
| 2712 | executionContext?: FlowExecutionContext, |
| 2713 | ): Promise<NodeExecutionResult> { |
| 2714 | console.log(`SaveChanges Node ${nodeId}: Processing save configuration "${textValue}" with tables:`, { |
| 2715 | tableCount: inputData?.tables?.length, |
| 2716 | tableNames: inputData?.tables?.map((t: any) => t.name), |
| 2717 | }); |
| 2718 | |
| 2719 | // Parse configuration from textValue |
| 2720 | let packName = ""; |
| 2721 | let packedFileName = ""; |
| 2722 | let additionalConfig = ""; |
| 2723 | let flowExecutionId = ""; |
| 2724 | |
| 2725 | const parsedConfig = getNodeConfig<{ |
| 2726 | packName?: string; |
| 2727 | packedFileName?: string; |
| 2728 | additionalConfig?: string; |
| 2729 | flowExecutionId?: string; |
| 2730 | }>(config, textValue); |
| 2731 | if (parsedConfig) { |
| 2732 | packName = parsedConfig.packName || ""; |
| 2733 | packedFileName = parsedConfig.packedFileName || ""; |
| 2734 | additionalConfig = parsedConfig.additionalConfig || ""; |
| 2735 | flowExecutionId = parsedConfig.flowExecutionId || ""; |
| 2736 | } else { |
| 2737 | // If not JSON, treat textValue as additionalConfig |
| 2738 | additionalConfig = textValue.trim(); |
| 2739 | } |
| 2740 | |
| 2741 | console.log(`Save Changes Node ${nodeId}: Received inputData type:`, inputData?.type); |
| 2742 | console.log(`Save Changes Node ${nodeId}: inputData exists:`, !!inputData); |
| 2743 | |
| 2744 | // Handle Text input - save as text file |
| 2745 | if (inputData && inputData.type === "Text") { |
| 2746 | return await executeSaveTextNode(nodeId, inputData.text || "", packName, packedFileName); |
| 2747 | } |
| 2748 | |
| 2749 | // Handle TableSelection input - save table data |
| 2750 | if (inputData && inputData.type === "TableSelection") { |
| 2751 | const toSave = [] as NewPackedFile[]; |
| 2752 | |
| 2753 | for (const table of inputData.tables || []) { |
| 2754 | if (!table.table.schemaFields || !table.table.tableSchema) continue; |
| 2755 | |
| 2756 | toSave.push({ |
| 2757 | name: "", // Will be set after we determine pack name |
| 2758 | schemaFields: table.table.schemaFields, |
| 2759 | version: table.table.version, |
| 2760 | tableSchema: table.table.tableSchema, |
| 2761 | tableName: table.name, // Store table name for later use |
| 2762 | } as any); |
| 2763 | } |
| 2764 |
no test coverage detected