src/lib/dev-login-config.ts — startup assertion: throws if NODE_ENV=production + ENABLE_DEV_LOGIN=true, scoped to runtime (skipped during next build).
Container
scripts/migrate.mjs — runs Drizzle migrations against DATABASE_URL.
deploy/docker-entrypoint.sh — runs migrations then exec node server.js. Skip with RUN_MIGRATIONS=false.
Dockerfile — copies drizzle/, scripts/migrate.mjs, entrypoint into runner stage; ENTRYPOINT now points at the script.
Compose
deploy/compose.yaml — famapp now image: ${FAMAPP_IMAGE:-ghcr.io/ginnoir/famapp:latest} (build still works locally as fallback). Authentik pinned via AUTHENTIK_IMAGE_TAG (default 2024.12.3). New RUN_MIGRATIONS env passed through.
.env.production.example — documents FAMAPP_IMAGE, AUTHENTIK_IMAGE_TAG, RUN_MIGRATIONS.
CI/CD
.github/workflows/ci.yml — push/PR: typecheck + lint + format:check + build.
.github/workflows/release.yml — v* tag: build + push ghcr.io/ginnoir/famapp:vX.Y.Z, :X.Y, :latest to GHCR.
Docs
deploy/README.md — full deploy/rollback/release runbook.
CHANGELOG.md — release log seeded with an Unreleased entry.
docs/tasks/09-pre-deploy-checklist.md — task 09 reframed from one-shot removal to a recurring pre-deploy checklist.
STATUS.md — updated.
Verified: pnpm typecheck, pnpm format, pnpm build, and docker compose config all clean.
193 lines
6.6 KiB
TypeScript
193 lines
6.6 KiB
TypeScript
import type { ModuleManifest, WidgetContext } from "../_core/module";
|
|
import { z } from "zod";
|
|
import { listCalendars, listEvents, searchCalendars, searchEvents } from "./server/queries";
|
|
import {
|
|
loadCalendarForShare,
|
|
loadEventForShare,
|
|
type CalendarShareData,
|
|
type EventShareData,
|
|
} from "./server/share-queries";
|
|
import { CalendarSharedView, EventSharedView } from "./components/shared-view";
|
|
|
|
const calendarIdsSchema = z.union([z.literal("all"), z.array(z.string().uuid())]);
|
|
|
|
const upcomingConfigSchema = z.object({
|
|
calendarIds: calendarIdsSchema,
|
|
days: z.number().int().min(1).max(30),
|
|
});
|
|
|
|
const monthConfigSchema = z.object({ calendarIds: calendarIdsSchema });
|
|
|
|
async function UpcomingEventsWidget({ config }: { config: unknown; ctx: WidgetContext }) {
|
|
const parsed = upcomingConfigSchema.parse(config);
|
|
const now = new Date();
|
|
const end = new Date(now.getTime() + parsed.days * 24 * 60 * 60 * 1000);
|
|
const events = await listEvents({ from: now, to: end, calendarIds: parsed.calendarIds });
|
|
|
|
if (events.length === 0) {
|
|
return (
|
|
<p className="text-sm text-muted-foreground">
|
|
No events in the next {parsed.days} day{parsed.days !== 1 ? "s" : ""}
|
|
</p>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<ul className="space-y-2">
|
|
{events.slice(0, 8).map((event) => {
|
|
const start = new Date(event.startAt);
|
|
const label = event.allDay
|
|
? start.toLocaleDateString(undefined, { month: "short", day: "numeric" })
|
|
: start.toLocaleString(undefined, {
|
|
month: "short",
|
|
day: "numeric",
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
});
|
|
return (
|
|
<li key={event.id} className="flex items-start gap-2 text-sm">
|
|
<span className="mt-0.5 shrink-0 text-xs text-muted-foreground">{label}</span>
|
|
<span className="font-medium leading-snug">{event.title}</span>
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
);
|
|
}
|
|
|
|
async function MonthWidget({ config }: { config: unknown; ctx: WidgetContext }) {
|
|
const parsed = monthConfigSchema.parse(config);
|
|
const now = new Date();
|
|
const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
const monthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59);
|
|
const events = await listEvents({
|
|
from: monthStart,
|
|
to: monthEnd,
|
|
calendarIds: parsed.calendarIds,
|
|
});
|
|
|
|
const monthName = now.toLocaleDateString(undefined, { month: "long", year: "numeric" });
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
<p className="text-xs font-medium text-muted-foreground">{monthName}</p>
|
|
{events.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">No events this month</p>
|
|
) : (
|
|
<ul className="space-y-1">
|
|
{events.slice(0, 10).map((event) => {
|
|
const eventStart = new Date(event.startAt);
|
|
const day = eventStart.getDate();
|
|
return (
|
|
<li key={event.id} className="flex items-center gap-2 text-sm">
|
|
<span className="w-5 shrink-0 text-center text-xs font-semibold text-muted-foreground">
|
|
{day}
|
|
</span>
|
|
<span className="truncate">{event.title}</span>
|
|
</li>
|
|
);
|
|
})}
|
|
{events.length > 10 && (
|
|
<li className="text-xs text-muted-foreground">+{events.length - 10} more</li>
|
|
)}
|
|
</ul>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const manifest: ModuleManifest = {
|
|
id: "calendar",
|
|
name: "Calendar",
|
|
nav: { href: "/calendar", label: "Calendar", icon: "calendar" },
|
|
entities: [
|
|
{
|
|
type: "calendar.calendar",
|
|
label: { singular: "Calendar", plural: "Calendars" },
|
|
share: { canShare: true, defaultCapabilities: ["read"] },
|
|
search: { search: searchCalendars },
|
|
resolveUrl: (id) => `/calendar?id=${id}`,
|
|
loadForShare: (id) => loadCalendarForShare(id),
|
|
renderSharedView: ({ data }) => <CalendarSharedView data={data as CalendarShareData} />,
|
|
renderActivity: (entry) => {
|
|
const name = entry.payload?.name as string | undefined;
|
|
if (entry.action === "create") return `Created calendar${name ? ` "${name}"` : ""}`;
|
|
if (entry.action === "delete") return "Deleted calendar";
|
|
return `Updated calendar${name ? ` "${name}"` : ""}`;
|
|
},
|
|
},
|
|
{
|
|
type: "calendar.event",
|
|
label: { singular: "Event", plural: "Events" },
|
|
share: { canShare: true, defaultCapabilities: ["read"] },
|
|
reminder: { canRemind: true },
|
|
search: { search: searchEvents },
|
|
resolveUrl: (id) => `/calendar/events/${id}`,
|
|
loadForShare: (id) => loadEventForShare(id),
|
|
renderSharedView: ({ data }) => <EventSharedView data={data as EventShareData} />,
|
|
renderActivity: (entry) => {
|
|
const title = entry.payload?.title as string | undefined;
|
|
if (entry.action === "create") return `Created event${title ? ` "${title}"` : ""}`;
|
|
if (entry.action === "delete") return "Deleted event";
|
|
return `Updated event${title ? ` "${title}"` : ""}`;
|
|
},
|
|
},
|
|
],
|
|
dashboardWidgets: [
|
|
{
|
|
id: "calendar.upcoming",
|
|
title: "Upcoming events",
|
|
description: "Events from selected calendars over the next few days.",
|
|
category: "Calendar",
|
|
defaultSize: { w: 4, h: 3 },
|
|
minSize: { w: 3, h: 2 },
|
|
defaultPriority: 10,
|
|
configSchema: upcomingConfigSchema,
|
|
defaultConfig: { calendarIds: "all", days: 3 },
|
|
resolveConfigOptions: async () => ({
|
|
calendars: (await listCalendars()).map((calendar) => ({
|
|
id: calendar.id,
|
|
name: calendar.name,
|
|
visibility: calendar.visibility,
|
|
})),
|
|
}),
|
|
render: (props) => <UpcomingEventsWidget {...props} />,
|
|
},
|
|
{
|
|
id: "calendar.month",
|
|
title: "Month calendar",
|
|
description: "A compact month view for selected calendars.",
|
|
category: "Calendar",
|
|
defaultSize: { w: 6, h: 5 },
|
|
minSize: { w: 4, h: 4 },
|
|
defaultPriority: 20,
|
|
configSchema: monthConfigSchema,
|
|
defaultConfig: { calendarIds: "all" },
|
|
resolveConfigOptions: async () => ({
|
|
calendars: (await listCalendars()).map((calendar) => ({
|
|
id: calendar.id,
|
|
name: calendar.name,
|
|
visibility: calendar.visibility,
|
|
})),
|
|
}),
|
|
render: (props) => <MonthWidget {...props} />,
|
|
},
|
|
],
|
|
quickAdds: [
|
|
{
|
|
id: "calendar.new-event",
|
|
label: "New event",
|
|
icon: "calendar-plus",
|
|
url: "/calendar",
|
|
},
|
|
{
|
|
id: "calendar.new-calendar",
|
|
label: "New calendar",
|
|
icon: "calendar-days",
|
|
url: "/calendar",
|
|
},
|
|
],
|
|
};
|
|
|
|
export default manifest;
|