( serverId: string, )
| 207 | |
| 208 | /** Fetch deployment jobs for a server: events → runs → rows (correct model: runs = jobs) */ |
| 209 | export const fetchDeploymentJobs = async ( |
| 210 | serverId: string, |
| 211 | ): Promise<DeploymentJobRow[]> => { |
| 212 | if (!signingKey) { |
| 213 | logger.warn("INNGEST_SIGNING_KEY not set, returning empty jobs list"); |
| 214 | return []; |
| 215 | } |
| 216 | if (!baseUrl) { |
| 217 | throw new Error("INNGEST_BASE_URL is required to list deployment jobs"); |
| 218 | } |
| 219 | |
| 220 | const events = await fetchInngestEvents(); |
| 221 | |
| 222 | const requestedForServer = events.filter( |
| 223 | (e) => |
| 224 | e.name === "deployment/requested" && |
| 225 | (e.data as Record<string, unknown>)?.serverId === serverId, |
| 226 | ); |
| 227 | // Limit to avoid too many run fetches |
| 228 | const toFetch = requestedForServer.slice(0, 50); |
| 229 | const runsByEventId = new Map<string, InngestRun[]>(); |
| 230 | |
| 231 | await Promise.all( |
| 232 | toFetch.map(async (ev) => { |
| 233 | const runs = await fetchInngestRunsForEvent(ev.id); |
| 234 | runsByEventId.set(ev.id, runs); |
| 235 | }), |
| 236 | ); |
| 237 | |
| 238 | return buildDeploymentRowsFromRuns(toFetch, runsByEventId, serverId); |
| 239 | }; |
no test coverage detected