(workflowId: string, workspaceId: string)
| 15 | * @returns The workflow with merged state values or null if not found/not active |
| 16 | */ |
| 17 | export function getWorkflowWithValues(workflowId: string, workspaceId: string) { |
| 18 | const workflows = getWorkflows(workspaceId) |
| 19 | const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId |
| 20 | |
| 21 | const metadata = workflows.find((w) => w.id === workflowId) |
| 22 | if (!metadata) { |
| 23 | logger.warn(`Workflow ${workflowId} not found`) |
| 24 | return null |
| 25 | } |
| 26 | |
| 27 | // Since localStorage persistence has been removed, only return data for active workflow |
| 28 | if (workflowId !== activeWorkflowId) { |
| 29 | logger.warn(`Cannot get state for non-active workflow ${workflowId} - localStorage removed`) |
| 30 | return null |
| 31 | } |
| 32 | |
| 33 | // Use the current state from the store (only available for active workflow) |
| 34 | const workflowState: WorkflowState = useWorkflowStore.getState().getWorkflowState() |
| 35 | |
| 36 | // Merge the subblock values for this specific workflow |
| 37 | const mergedBlocks = mergeSubblockState(workflowState.blocks, workflowId) |
| 38 | |
| 39 | return { |
| 40 | id: workflowId, |
| 41 | name: metadata.name, |
| 42 | description: metadata.description, |
| 43 | workspaceId: metadata.workspaceId, |
| 44 | folderId: metadata.folderId, |
| 45 | state: { |
| 46 | blocks: mergedBlocks, |
| 47 | edges: workflowState.edges, |
| 48 | loops: workflowState.loops, |
| 49 | parallels: workflowState.parallels, |
| 50 | lastSaved: workflowState.lastSaved, |
| 51 | }, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | export type { WorkflowState } from '@/stores/workflows/workflow/types' |
no test coverage detected