(filter?: DebugQuery)
| 434 | } |
| 435 | |
| 436 | async function query(filter?: DebugQuery): Promise<readonly DebugRecord[]> { |
| 437 | const { headers, result } = await backend.debugQuery(filter ?? {}); |
| 438 | |
| 439 | if (result.recordsReturned === 0) { |
| 440 | return []; |
| 441 | } |
| 442 | |
| 443 | const records: DebugRecord[] = []; |
| 444 | |
| 445 | for (let i = 0; i < result.recordsReturned; i++) { |
| 446 | const offset = i * DEBUG_RECORD_HEADER_SIZE; |
| 447 | const headerResult = parseRecordHeader(headers, offset); |
| 448 | |
| 449 | if (!headerResult.ok) { |
| 450 | continue; |
| 451 | } |
| 452 | |
| 453 | const header = headerResult.value; |
| 454 | let payload: DebugPayload | null = null; |
| 455 | |
| 456 | if (header.payloadSize > 0) { |
| 457 | const payloadBytes = await backend.debugGetPayload(header.recordId); |
| 458 | if (payloadBytes) { |
| 459 | const payloadResult = parsePayload(header.category, payloadBytes); |
| 460 | if (payloadResult.ok) { |
| 461 | payload = payloadResult.value; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | records.push({ header, payload }); |
| 467 | } |
| 468 | |
| 469 | return records; |
| 470 | } |
| 471 | |
| 472 | async function getPayload<T extends DebugPayload>(recordId: bigint): Promise<T | null> { |
| 473 | const bytes = await backend.debugGetPayload(recordId); |
nothing calls this directly
no test coverage detected