MCPcopy Index your code
hub / github.com/simstudioai/sim / applyWorkflowVariablesToStore

Function applyWorkflowVariablesToStore

apps/sim/stores/workflow-diff/utils.ts:76–101  ·  view source on GitHub ↗
(
  workflowId: string,
  variables?: WorkflowState['variables'] | null
)

Source from the content-addressed store, hash-verified

74}
75
76export 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
103export function captureBaselineSnapshot(workflowId: string): WorkflowState {
104 const workflowStore = useWorkflowStore.getState()

Callers 2

utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected