( workflowId: string, workspaceId: string )
| 163 | * to current ids) are applied so copied references reflect current resources. |
| 164 | */ |
| 165 | export 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 | } |
no test coverage detected