Files
n8n-enterprise-unlocked/packages/frontend/editor-ui/src/utils/workflowUtils.ts
2025-08-28 09:39:32 +02:00

28 lines
863 B
TypeScript

import type { IWorkflowDb, INodeUi } from '@/Interface';
/**
* Removes execution data from workflow nodes and workflow-level execution data
* to ensure clean comparisons in diffs. This prevents execution status, run data,
* pinned data, and other runtime information from appearing in workflow difference
* comparisons.
*/
export function removeWorkflowExecutionData(
workflow: IWorkflowDb | undefined,
): IWorkflowDb | undefined {
if (!workflow) return workflow;
// Remove workflow-level execution data and clean up nodes
const { pinData, ...cleanWorkflow } = workflow;
const sanitizedWorkflow: IWorkflowDb = {
...cleanWorkflow,
nodes: workflow.nodes.map((node: INodeUi) => {
// Create a clean copy without execution-related data
const { issues, pinData, ...cleanNode } = node;
return cleanNode;
}),
};
return sanitizedWorkflow;
}