(
sessionId: string,
turnId: string,
allowed: readonly TurnRecord['status'][],
action: string,
)
| 5388 | } |
| 5389 | |
| 5390 | private async requireTurnForAction( |
| 5391 | sessionId: string, |
| 5392 | turnId: string, |
| 5393 | allowed: readonly TurnRecord['status'][], |
| 5394 | action: string, |
| 5395 | ): Promise<TurnRecord> { |
| 5396 | const turn = (await this.getSessionView(sessionId)).turns.find( |
| 5397 | (candidate) => candidate.turnId === turnId, |
| 5398 | ); |
| 5399 | if (!turn) throw new Error(`Cannot ${action}: unknown turn ${turnId}`); |
| 5400 | if (!allowed.includes(turn.status)) { |
| 5401 | throw new Error(`Cannot ${action}: turn ${turnId} is ${turn.status}`); |
| 5402 | } |
| 5403 | return turn; |
| 5404 | } |
| 5405 | |
| 5406 | private async getSessionView( |
| 5407 | sessionId: string, |
nothing calls this directly
no test coverage detected