| 335 | } |
| 336 | |
| 337 | export async function readDispatch(dispatchId: string): Promise<DispatchRow | null> { |
| 338 | const [row] = await db |
| 339 | .select() |
| 340 | .from(tableRunDispatches) |
| 341 | .where(eq(tableRunDispatches.id, dispatchId)) |
| 342 | .limit(1) |
| 343 | if (!row) return null |
| 344 | return { |
| 345 | id: row.id, |
| 346 | tableId: row.tableId, |
| 347 | workspaceId: row.workspaceId, |
| 348 | requestId: row.requestId, |
| 349 | mode: row.mode as DispatchMode, |
| 350 | scope: row.scope as DispatchScope, |
| 351 | status: row.status as DispatchStatus, |
| 352 | cursor: row.cursor, |
| 353 | limit: (row.limit as DispatchLimit | null) ?? null, |
| 354 | processedCount: row.processedCount, |
| 355 | isManualRun: row.isManualRun, |
| 356 | triggeredByUserId: row.triggeredByUserId, |
| 357 | requestedAt: row.requestedAt, |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /** Drive `dispatcherStep` to completion. Shared between the trigger.dev task |
| 362 | * wrapper (`tableRunDispatcherTask`) and the in-process inline path so both |