(value: unknown, path: string)
| 802 | } |
| 803 | |
| 804 | function parseEventCapture(value: unknown, path: string): ReproParseResult<ReproEventCapture> { |
| 805 | if (!isJsonObject(value)) { |
| 806 | return fail("ZR_REPRO_INVALID_BUNDLE", path, "eventCapture must be an object"); |
| 807 | } |
| 808 | const known = assertKnownFields(value, EVENT_CAPTURE_KEYS, path); |
| 809 | if (!known.ok) return known; |
| 810 | |
| 811 | const ordering = readString(value, "ordering", `${path}.ordering`); |
| 812 | if (!ordering.ok) return ordering; |
| 813 | if (ordering.value !== REPRO_EVENT_CAPTURE_ORDERING_POLL) { |
| 814 | return fail( |
| 815 | "ZR_REPRO_INVALID_BUNDLE", |
| 816 | `${path}.ordering`, |
| 817 | `eventCapture.ordering must be '${REPRO_EVENT_CAPTURE_ORDERING_POLL}'`, |
| 818 | ); |
| 819 | } |
| 820 | |
| 821 | const timing = readString(value, "timing", `${path}.timing`); |
| 822 | if (!timing.ok) return timing; |
| 823 | if (timing.value !== REPRO_EVENT_CAPTURE_TIMING_STEP_DELTA_MS) { |
| 824 | return fail( |
| 825 | "ZR_REPRO_INVALID_BUNDLE", |
| 826 | `${path}.timing`, |
| 827 | `eventCapture.timing must be '${REPRO_EVENT_CAPTURE_TIMING_STEP_DELTA_MS}'`, |
| 828 | ); |
| 829 | } |
| 830 | |
| 831 | const bounds = parseEventCaptureBounds(readField(value, "bounds"), `${path}.bounds`); |
| 832 | if (!bounds.ok) return bounds; |
| 833 | |
| 834 | const totals = parseEventCaptureTotals(readField(value, "totals"), `${path}.totals`); |
| 835 | if (!totals.ok) return totals; |
| 836 | |
| 837 | const truncation = parseEventCaptureTruncation( |
| 838 | readField(value, "truncation"), |
| 839 | `${path}.truncation`, |
| 840 | ); |
| 841 | if (!truncation.ok) return truncation; |
| 842 | |
| 843 | const batchesRaw = readArray(value, "batches", `${path}.batches`); |
| 844 | if (!batchesRaw.ok) return batchesRaw; |
| 845 | |
| 846 | const batches: ReproRecordedEventBatch[] = new Array<ReproRecordedEventBatch>( |
| 847 | batchesRaw.value.length, |
| 848 | ); |
| 849 | let sumEvents = 0; |
| 850 | let sumBytes = 0; |
| 851 | let capturedDroppedBatches = 0; |
| 852 | |
| 853 | for (let i = 0; i < batchesRaw.value.length; i++) { |
| 854 | const parsed = parseRecordedEventBatch(batchesRaw.value[i], `${path}.batches[${i}]`); |
| 855 | if (!parsed.ok) return parsed; |
| 856 | |
| 857 | if (parsed.value.step !== i) { |
| 858 | return fail( |
| 859 | "ZR_REPRO_INVALID_BUNDLE", |
| 860 | `${path}.batches[${i}].step`, |
| 861 | "batch step must match array order", |
no test coverage detected