| 10 | |
| 11 | export const eventsApi = { |
| 12 | async query(opts: { page?: number; pageSize?: number; type?: string } = {}): Promise<EventQueryResult> { |
| 13 | const params = new URLSearchParams() |
| 14 | if (opts.page) params.set('page', String(opts.page)) |
| 15 | if (opts.pageSize) params.set('pageSize', String(opts.pageSize)) |
| 16 | if (opts.type) params.set('type', opts.type) |
| 17 | const qs = params.toString() |
| 18 | const res = await fetch(`/api/events${qs ? `?${qs}` : ''}`) |
| 19 | if (!res.ok) throw new Error('Failed to query events') |
| 20 | return res.json() |
| 21 | }, |
| 22 | |
| 23 | async recent(opts: { afterSeq?: number; limit?: number; type?: string } = {}): Promise<{ entries: EventLogEntry[]; lastSeq: number }> { |
| 24 | const params = new URLSearchParams() |