| 1241 | * snapshot. Returns null when the version does not exist. |
| 1242 | */ |
| 1243 | export async function getWorkflowDeploymentVersion( |
| 1244 | workflowId: string, |
| 1245 | version: number |
| 1246 | ): Promise<{ |
| 1247 | id: string |
| 1248 | version: number |
| 1249 | name: string | null |
| 1250 | description: string | null |
| 1251 | isActive: boolean |
| 1252 | createdAt: Date |
| 1253 | state: unknown |
| 1254 | } | null> { |
| 1255 | const [row] = await db |
| 1256 | .select({ |
| 1257 | id: workflowDeploymentVersion.id, |
| 1258 | version: workflowDeploymentVersion.version, |
| 1259 | name: workflowDeploymentVersion.name, |
| 1260 | description: workflowDeploymentVersion.description, |
| 1261 | isActive: workflowDeploymentVersion.isActive, |
| 1262 | createdAt: workflowDeploymentVersion.createdAt, |
| 1263 | state: workflowDeploymentVersion.state, |
| 1264 | }) |
| 1265 | .from(workflowDeploymentVersion) |
| 1266 | .where( |
| 1267 | and( |
| 1268 | eq(workflowDeploymentVersion.workflowId, workflowId), |
| 1269 | eq(workflowDeploymentVersion.version, version) |
| 1270 | ) |
| 1271 | ) |
| 1272 | .limit(1) |
| 1273 | |
| 1274 | return row ?? null |
| 1275 | } |
| 1276 | |
| 1277 | export async function listWorkflowVersions(workflowId: string): Promise<{ |
| 1278 | versions: Array<{ |