umfangreiche Behebung von TS-Fehlern. "npm run types" läuft nun ohne Fehler durch

This commit is contained in:
Codex Agent
2025-11-21 07:45:21 +01:00
parent b6f6cdeffe
commit 07fe049b8a
25 changed files with 74 additions and 63 deletions

View File

@@ -1021,14 +1021,16 @@ function normalizeGuestNotification(raw: JsonValue): GuestNotificationSummary |
}
const record = raw as Record<string, JsonValue>;
const status = typeof record.status === 'string' ? record.status : null;
const audience = typeof record.audience_scope === 'string' ? record.audience_scope : null;
return {
id: Number(record.id ?? 0),
type: typeof record.type === 'string' ? record.type : 'broadcast',
title: typeof record.title === 'string' ? record.title : '',
body: typeof record.body === 'string' ? record.body : null,
status: (record.status as GuestNotificationSummary['status']) ?? 'active',
audience_scope: (record.audience_scope as GuestNotificationSummary['audience_scope']) ?? 'all',
status: status === 'draft' || status === 'archived' || status === 'active' ? status : 'active',
audience_scope: audience === 'guest' || audience === 'all' ? audience : 'all',
target_identifier: typeof record.target_identifier === 'string' ? record.target_identifier : null,
payload: (record.payload as Record<string, unknown>) ?? null,
priority: Number(record.priority ?? 0),
@@ -1384,7 +1386,7 @@ export async function sendGuestNotification(
body: JSON.stringify(payload),
});
const data = await jsonOrThrow<{ data?: JsonValue }>(response, 'Failed to send guest notification');
return normalizeGuestNotification(data.data ?? {}) ?? normalizeGuestNotification({
const fallback = normalizeGuestNotification({
id: 0,
type: payload.type ?? 'broadcast',
title: payload.title,
@@ -1397,6 +1399,14 @@ export async function sendGuestNotification(
created_at: new Date().toISOString(),
expires_at: null,
});
const normalized = normalizeGuestNotification(data.data ?? {}) ?? fallback;
if (!normalized) {
throw new Error('Failed to normalize guest notification');
}
return normalized;
}
export async function getEventPhotoboothStatus(slug: string): Promise<PhotoboothStatus> {