Add v2 schedule API endpoint

This commit is contained in:
NeilClack
2026-09-11 18:16:04 -05:00
parent 4922e941ae
commit 545fb22910
3 changed files with 250 additions and 0 deletions
+32
View File
@@ -1,3 +1,5 @@
import { toHm } from '$lib/schedule-utils';
// Canonical solfeggio id <- Hz, mirroring the kiosk's `frequencyIdForHz()`
// map (radiantwave-rebuild src/audio/audio_downloader.cpp). v2 must emit these
// canonical ids (1-9), never the portal DB autoincrement ids, because
@@ -138,3 +140,33 @@ export function serializeColorPalette(palette: {
}): V2ColorPalette {
return { solfeggioFrequencyId: palette.solfeggioFrequencyId, colors: palette.colors };
}
export type V2ScheduleBlock = {
id: string;
startTime: string;
startMinutes: number;
endTime: string;
endMinutes: number;
proclamationIds: string[];
};
export type V2Schedule = {
email: string;
blocks: V2ScheduleBlock[];
};
/** Build a schedule Block for the kiosk. Only the selected Proclamation IDs are
* returned; the kiosk fetches proclamation content separately. */
export function serializeScheduleBlock(
block: { id: string; startMinutes: number; endMinutes: number },
proclamationIds: string[]
): V2ScheduleBlock {
return {
id: block.id,
startTime: toHm(block.startMinutes),
startMinutes: block.startMinutes,
endTime: toHm(block.endMinutes),
endMinutes: block.endMinutes,
proclamationIds
};
}