( ctx: HistoryAuthCtx, params: Record<string, string | number | boolean>, label: string, )
| 43 | } |
| 44 | |
| 45 | async function fetchPage( |
| 46 | ctx: HistoryAuthCtx, |
| 47 | params: Record<string, string | number | boolean>, |
| 48 | label: string, |
| 49 | ): Promise<HistoryPage | null> { |
| 50 | const resp = await axios |
| 51 | .get<SessionEventsResponse>(ctx.baseUrl, { |
| 52 | headers: ctx.headers, |
| 53 | params, |
| 54 | timeout: 15000, |
| 55 | validateStatus: () => true, |
| 56 | }) |
| 57 | .catch(() => null) |
| 58 | if (!resp || resp.status !== 200) { |
| 59 | logForDebugging(`[${label}] HTTP ${resp?.status ?? 'error'}`) |
| 60 | return null |
| 61 | } |
| 62 | return { |
| 63 | events: Array.isArray(resp.data.data) ? resp.data.data : [], |
| 64 | firstId: resp.data.first_id, |
| 65 | hasMore: resp.data.has_more, |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Newest page: last `limit` events, chronological, via anchor_to_latest. |
no test coverage detected