(workflowId: string)
| 1275 | } |
| 1276 | |
| 1277 | export async function listWorkflowVersions(workflowId: string): Promise<{ |
| 1278 | versions: Array<{ |
| 1279 | id: string |
| 1280 | version: number |
| 1281 | name: string | null |
| 1282 | description: string | null |
| 1283 | isActive: boolean |
| 1284 | createdAt: Date |
| 1285 | createdBy: string | null |
| 1286 | deployedByName: string | null |
| 1287 | }> |
| 1288 | }> { |
| 1289 | const { user } = await import('@sim/db') |
| 1290 | |
| 1291 | const rows = await db |
| 1292 | .select({ |
| 1293 | id: workflowDeploymentVersion.id, |
| 1294 | version: workflowDeploymentVersion.version, |
| 1295 | name: workflowDeploymentVersion.name, |
| 1296 | description: workflowDeploymentVersion.description, |
| 1297 | isActive: workflowDeploymentVersion.isActive, |
| 1298 | createdAt: workflowDeploymentVersion.createdAt, |
| 1299 | createdBy: workflowDeploymentVersion.createdBy, |
| 1300 | deployedByName: user.name, |
| 1301 | }) |
| 1302 | .from(workflowDeploymentVersion) |
| 1303 | .leftJoin(user, eq(workflowDeploymentVersion.createdBy, user.id)) |
| 1304 | .where(eq(workflowDeploymentVersion.workflowId, workflowId)) |
| 1305 | .orderBy(desc(workflowDeploymentVersion.version)) |
| 1306 | |
| 1307 | return { |
| 1308 | versions: rows.map((row) => ({ |
| 1309 | ...row, |
| 1310 | deployedByName: row.deployedByName ?? (row.createdBy === 'admin-api' ? 'Admin' : null), |
| 1311 | })), |
| 1312 | } |
| 1313 | } |
no test coverage detected