import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { listChannelConfigs } from "yt-dlp-transcript-common/controller/channels"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { buildSchedulerStatusPayload as build, type SchedulerStatusPayload, } from "yt-dlp-transcript-common/views/schedulerStatus"; import { readSchedulerState } from "yt-dlp-transcript-common/jobs/syncSchedulerState"; import { resolveHeartbeatSeconds } from "./heartbeat"; // THE SHELL. The payload is `common/views/schedulerStatus.ts`; this reads the // four things it takes and nothing else. `resolveHeartbeatSeconds` is why the // split lands here rather than one file further down: it lives beside // `runTick`, a RUNNER, and a view may not name one. export async function buildSchedulerStatusPayload(): Promise { const paths = getPaths(); const settings = getSettings(); const state = await readSchedulerState(paths); const channels = (await listChannelConfigs(paths)).map((c) => ({ slug: c.slug, config: c.config, })); return build({ settings, now: Date.now(), state, channels, heartbeatSeconds: resolveHeartbeatSeconds(), }); }