( workflowId: string, blockId: string )
| 73 | } |
| 74 | |
| 75 | export async function blockExistsInDeployment( |
| 76 | workflowId: string, |
| 77 | blockId: string |
| 78 | ): Promise<boolean> { |
| 79 | try { |
| 80 | const [result] = await db |
| 81 | .select({ state: workflowDeploymentVersion.state }) |
| 82 | .from(workflowDeploymentVersion) |
| 83 | .where( |
| 84 | and( |
| 85 | eq(workflowDeploymentVersion.workflowId, workflowId), |
| 86 | eq(workflowDeploymentVersion.isActive, true) |
| 87 | ) |
| 88 | ) |
| 89 | .limit(1) |
| 90 | |
| 91 | if (!result?.state) { |
| 92 | return false |
| 93 | } |
| 94 | |
| 95 | const state = result.state as WorkflowState |
| 96 | return !!state.blocks?.[blockId] |
| 97 | } catch (error) { |
| 98 | logger.error(`Error checking block ${blockId} in deployment for workflow ${workflowId}:`, error) |
| 99 | return false |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | const DEPLOYED_STATE_CACHE_MAX_ENTRIES = 500 |
| 104 | const DEPLOYED_STATE_CACHE_TTL_MS = 5 * 60 * 1000 |
no test coverage detected