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

Function readDeployedState

apps/sim/lib/workspaces/fork/copy/deploy-bridge.ts:165–188  ·  view source on GitHub ↗
(
  workflowId: string,
  workspaceId: string
)

Source from the content-addressed store, hash-verified

163 * to current ids) are applied so copied references reflect current resources.
164 */
165export async function readDeployedState(
166 workflowId: string,
167 workspaceId: string
168): Promise<WorkflowState | null> {
169 // This reads the (unchanged) SOURCE workspace on the global pool. Callers like
170 // promote run it inside their transaction, so escape the tx context: the read
171 // must not join the promote's transaction (and the tripwire forbids global-pool
172 // queries inside a tx). Outside a transaction this is a no-op.
173 return runOutsideTransactionContext(async () => {
174 const version = await getActiveDeploymentVersionNumber(db, workflowId)
175 if (version == null) {
176 logger.warn('No active deployment for workflow during fork/promote', { workflowId })
177 return null
178 }
179 const data = await loadDeployedWorkflowState(workflowId, workspaceId)
180 return {
181 blocks: data.blocks,
182 edges: data.edges,
183 loops: data.loops,
184 parallels: data.parallels,
185 variables: (data.variables ?? {}) as Record<string, Variable>,
186 }
187 })
188}

Callers 2

getForkMappingViewFunction · 0.90
loadSourceDeployedStatesFunction · 0.85

Calls 4

warnMethod · 0.65

Tested by

no test coverage detected