( request: QuestionRequest, answers: Record<string, unknown>, )
| 247 | } |
| 248 | |
| 249 | export function toOpenCodeQuestionAnswers( |
| 250 | request: QuestionRequest, |
| 251 | answers: Record<string, unknown>, |
| 252 | ): Array<QuestionAnswer> { |
| 253 | return request.questions.map((question, index) => { |
| 254 | const raw = |
| 255 | answers[openCodeQuestionId(index, question)] ?? |
| 256 | answers[question.header] ?? |
| 257 | answers[question.question]; |
| 258 | if (Array.isArray(raw)) { |
| 259 | return raw.filter((value): value is string => typeof value === "string"); |
| 260 | } |
| 261 | if (typeof raw === "string") { |
| 262 | return raw.trim().length > 0 ? [raw] : []; |
| 263 | } |
| 264 | return []; |
| 265 | }); |
| 266 | } |
| 267 | |
| 268 | function ensureRuntimeError( |
| 269 | operation: OpenCodeRuntimeError["operation"], |
no test coverage detected