( workflowId: string, variables?: WorkflowState['variables'] | null )
| 74 | } |
| 75 | |
| 76 | export function applyWorkflowVariablesToStore( |
| 77 | workflowId: string, |
| 78 | variables?: WorkflowState['variables'] | null |
| 79 | ) { |
| 80 | const stampedVariables: Record<string, Variable> = {} |
| 81 | |
| 82 | Object.entries(variables || {}).forEach(([id, variable]) => { |
| 83 | if (!variable?.name) return |
| 84 | stampedVariables[id] = { |
| 85 | id: variable.id || id, |
| 86 | workflowId, |
| 87 | name: variable.name, |
| 88 | type: variable.type || 'plain', |
| 89 | value: Object.hasOwn(variable, 'value') ? variable.value : '', |
| 90 | } |
| 91 | }) |
| 92 | |
| 93 | useVariablesStore.setState((state) => ({ |
| 94 | variables: { |
| 95 | ...Object.fromEntries( |
| 96 | Object.entries(state.variables).filter(([, variable]) => variable.workflowId !== workflowId) |
| 97 | ), |
| 98 | ...stampedVariables, |
| 99 | }, |
| 100 | })) |
| 101 | } |
| 102 | |
| 103 | export function captureBaselineSnapshot(workflowId: string): WorkflowState { |
| 104 | const workflowStore = useWorkflowStore.getState() |
no outgoing calls
no test coverage detected