diff --git a/lib/api/live.ts b/lib/api/live.ts index 1a1feee..3fe5e35 100644 --- a/lib/api/live.ts +++ b/lib/api/live.ts @@ -34,6 +34,8 @@ import { ResourceSchema, AccessPolicySchema, WebhookEventLogSchema, + WebhookEventSchema, + PaginatedSchema, SiweAuthSessionSchema, Connection, ConnectionSchema, @@ -926,6 +928,7 @@ export class LiveAccessApi implements AccessApi { return await getJson>(`/v1/admin/events/paginated?${searchParams.toString()}`, { headers: this.authHeaders(), + schema: PaginatedSchema(WebhookEventSchema), }) } diff --git a/lib/api/types.ts b/lib/api/types.ts index 1ac2a6f..5d4ed1e 100644 --- a/lib/api/types.ts +++ b/lib/api/types.ts @@ -484,6 +484,14 @@ export interface WebhookEvent { status?: string } +export const WebhookEventSchema = z.object({ + id: z.string(), + type: z.string(), + payload: z.any(), + createdAt: z.string(), + status: z.string().optional(), +}) + export interface Paginated { data: T[] total: number @@ -491,6 +499,15 @@ export interface Paginated { limit: number } +export function PaginatedSchema(itemSchema: T) { + return z.object({ + data: z.array(itemSchema), + total: z.number(), + page: z.number(), + limit: z.number(), + }) +} + export interface AdminEventFilterParams { types?: string[] startDate?: string