1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import { withErrors, ok } from "@/lib/api";
import { requireUser } from "@/lib/auth";
import { runOsa } from "@/lib/mac";
// GET /api/integrations/calendars โ names of local Calendar.app calendars,
// for the Settings picker. Returns [] if Calendar isn't reachable.
export const GET = withErrors(async (req) => {
await requireUser(req);
try {
const out = await runOsa(`tell application "Calendar" to get name of calendars`, 15_000);
const calendars = out
.trim()
.split(",")
.map((s) => s.trim())
.filter(Boolean);
return ok({ calendars });
} catch (err) {
return ok({ calendars: [], error: err instanceof Error ? err.message : "unavailable" });
}
});
|