Your favorite shift management application!
feat(admin): instance-wide announcements on auth pages and dashboard (#223)
panteL191bb6eb2cd2
diff --git a/.env.example b/.env.exampleindex 01a1137..36f46fd 100644--- a/.env.example+++ b/.env.example@@ -240,6 +240,11 @@ ALLOW_USER_REGISTRATION=true # Enable/disable new user signups# RATE_LIMIT_CUSTOM_FIELD_MUTATIONS_REQUESTS=30 # Field create/update/delete/reorder# RATE_LIMIT_CUSTOM_FIELD_MUTATIONS_WINDOW=3600 # 1 hour+# RATE_LIMIT_ANNOUNCEMENTS_REQUESTS=120 # Public announcement reads+# RATE_LIMIT_ANNOUNCEMENTS_WINDOW=60 # 1 minute+# RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS=20 # Announcement create/update/delete+# RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS_WINDOW=60 # 1 minute+# Admin Panel (per admin user)# RATE_LIMIT_ADMIN_USER_MUTATIONS=10 # User ban/unban/delete/edit# RATE_LIMIT_ADMIN_USER_MUTATIONS_WINDOW=60 # 1 minutediff --git a/CLAUDE.md b/CLAUDE.mdindex 2c8864a..e07a6f1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -77,6 +77,8 @@ Two separate permission layers, deliberately:The first registered user is promoted to superadmin (`lib/auth/first-user.ts`).+Instance announcements (`announcements`) are admin-authored notices shown on the auth pages and above the calendar. `lib/announcement-status.ts` holds the pure, database-free pieces — the tone and placement catalogs, `getAnnouncementStatus()` and `isVisibleNow()`, the named JS expression of the enabled-flag-and-window rule that `getVisibleAnnouncements()`'s SQL `where` clause separately re-implements — so client components can import them without pulling `lib/db` into the browser bundle; `lib/announcements.ts` re-exports those and adds `sanitizeAnnouncementInput()` and the `getVisibleAnnouncements()` query itself. `GET /api/announcements` is public (listed in `proxy.ts`) and returns only what is visible right now; the admin CRUD routes under `app/api/admin/announcements/**` gate on `canManageSystemSettings`. Dismissal is per browser in `localStorage`, never server state.+### External calendar sync`syncExternalCalendar()` in `app/api/external-syncs/[id]/sync/route.ts` is the single implementation, exported so the auto-sync service reuses it; the route handler is just the manual entry point. It normalises `webcal://`, fetches with a 10s abort, parses with `ical.js`, expands recurrences, splits multi-day events, and diffs against existing shifts using a fingerprint (`createEventFingerprint` / `needsUpdate` in `lib/external-calendar-utils.ts`) so unchanged events are not rewritten. Every run appends a `syncLogs` row with created/updated/deleted counts, which is what drives the sync notification dialog.diff --git a/app/admin/announcements/page.tsx b/app/admin/announcements/page.tsxnew file mode 100644index 0000000..94fb186--- /dev/null+++ b/app/admin/announcements/page.tsx@@ -0,0 +1,137 @@+"use client";++import { useState } from "react";+import { useTranslations } from "next-intl";+import { Plus } from "lucide-react";+import { Button } from "@/components/ui/button";+import { FullscreenLoader } from "@/components/fullscreen-loader";+import { AdminPageHeader } from "@/components/admin/admin-kit";+import { AnnouncementTable } from "@/components/admin/announcement-table";+import { AnnouncementEditSheet } from "@/components/admin/announcement-edit-sheet";+import { ConfirmNameDeleteDialog } from "@/components/admin/confirm-name-delete-dialog";+import {+ useAdminAnnouncements,+ useAdminAnnouncementActions,+ type AdminAnnouncement,+} from "@/hooks/useAdminAnnouncements";++export default function AdminAnnouncementsPage() {+ const t = useTranslations();+ const { announcements, isLoading } = useAdminAnnouncements();+ const { createAnnouncement, updateAnnouncement, deleteAnnouncement, isSaving } =+ useAdminAnnouncementActions();+ // null means create mode; the sheet's `open` prop lives separately below so+ // closing never has to clear this — that would tie it to the same state+ // that flips `open` false, see `sheetKey` below.+ const [editing, setEditing] = useState<AdminAnnouncement | null>(null);+ const [sheetOpen, setSheetOpen] = useState(false);+ // Bumped only when opening for create/edit, never when closing: used solely as+ // the sheet's `key` so every open gets a fresh form (even reopening the same+ // target), while every close path leaves the key — and the exit animation —+ // undisturbed.+ const [sheetKey, setSheetKey] = useState(0);+ const [deleting, setDeleting] = useState<AdminAnnouncement | null>(null);++ const openCreate = () => {+ setEditing(null);+ setSheetKey((key) => key + 1);+ setSheetOpen(true);+ };++ const openEdit = (announcement: AdminAnnouncement) => {+ setEditing(announcement);+ setSheetKey((key) => key + 1);+ setSheetOpen(true);+ };++ if (isLoading) return <FullscreenLoader />;++ return (+ <div className="flex flex-col gap-4">+ <AdminPageHeader+ title={t("admin.announcements.title")}+ subtitle={t("admin.announcements.description")}+ actions={+ <Button+ variant="outline"+ onClick={openCreate}+ className="h-[38px] gap-2 rounded-[9px] font-semibold"+ >+ <Plus className="size-4" />+ {t("admin.announcements.create")}+ </Button>+ }+ mobileActions={+ <button+ type="button"+ onClick={openCreate}+ aria-label={t("admin.announcements.create")}+ className="flex size-[34px] items-center justify-center rounded-[9px] border border-line text-fg-secondary"+ >+ <Plus className="size-[17px]" />+ </button>+ }+ />++ {announcements.length === 0 ? (+ <div className="rounded-[11px] border border-line bg-surface-card px-4 py-8 text-center">+ <p className="text-[14px] font-semibold text-fg-strong">+ {t("admin.announcements.empty")}+ </p>+ <p className="mt-1 text-[12.5px] text-fg-secondary">+ {t("admin.announcements.emptyHint")}+ </p>+ </div>+ ) : (+ <AnnouncementTable+ announcements={announcements}+ onEdit={openEdit}+ onDelete={(announcement) => setDeleting(announcement)}+ />+ )}++ <AnnouncementEditSheet+ key={sheetKey}+ open={sheetOpen}+ onOpenChange={setSheetOpen}+ announcement={editing}+ isSaving={isSaving}+ onSubmit={async (payload) => {+ if (editing) {+ await updateAnnouncement({ id: editing.id, ...payload });+ } else {+ await createAnnouncement(payload);+ }+ }}+ />++ {deleting && (+ <ConfirmNameDeleteDialog+ open+ onOpenChange={(open) => {+ if (!open) setDeleting(null);+ }}+ name={deleting.title}+ idPrefix="announcement-delete"+ title={t("admin.announcements.deleteTitle")}+ description={t("admin.announcements.deleteDescription")}+ warning={t("admin.announcements.deleteWarning")}+ understoodLabel={t("admin.announcements.deleteUnderstood")}+ confirmationLabel={t("admin.announcements.deleteConfirmationLabel")}+ confirmationHint={t("admin.announcements.deleteConfirmationHint", {+ name: deleting.title,+ })}+ confirmLabel={t("admin.announcements.deleteConfirm")}+ onConfirm={async () => {+ try {+ await deleteAnnouncement(deleting.id);+ setDeleting(null);+ } catch {+ // Already toasted by the mutation's onError; keep the dialog open so the user can retry.+ }+ }}+ />+ )}+ </div>+ );+}diff --git a/app/api/admin/announcements/[id]/route.ts b/app/api/admin/announcements/[id]/route.tsnew file mode 100644index 0000000..3dc3489--- /dev/null+++ b/app/api/admin/announcements/[id]/route.ts@@ -0,0 +1,111 @@+import { NextRequest, NextResponse } from "next/server";+import { eq } from "drizzle-orm";+import { db } from "@/lib/db";+import { announcements } from "@/lib/db/schema";+import { sanitizeAnnouncementInput } from "@/lib/announcements";+import { rateLimit } from "@/lib/rate-limiter";+import {+ logAdminAction,+ type AdminAnnouncementDeletedMetadata,+ type AdminAnnouncementUpdatedMetadata,+} from "@/lib/audit-log";+import { requireAnnouncementAccess } from "../route";++/**+ * Admin Announcement Item API+ *+ * PATCH /api/admin/announcements/[id]+ * DELETE /api/admin/announcements/[id]+ *+ * Permission: Admin or Superadmin (canManageSystemSettings)+ */+function forAudit(row: typeof announcements.$inferSelect) {+ return {+ title: row.title,+ tone: row.tone,+ showOnAuth: row.showOnAuth,+ showOnDashboard: row.showOnDashboard,+ enabled: row.enabled,+ startsAt: row.startsAt,+ endsAt: row.endsAt,+ };+}++export async function PATCH(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {+ const access = await requireAnnouncementAccess(request);+ if (access.error) return access.error;+ const currentUser = access.currentUser;++ const rateLimitResponse = rateLimit(request, currentUser.id, "admin-announcement-mutations");+ if (rateLimitResponse) return rateLimitResponse;++ const { id } = await params;++ try {+ const [existing] = await db.select().from(announcements).where(eq(announcements.id, id)).limit(1);+ if (!existing) {+ return NextResponse.json({ error: "Announcement not found" }, { status: 404 });+ }++ // The sheet always submits the whole announcement, so the same sanitiser+ // covers create and update -- no partial-patch branch to keep in sync.+ const parsed = sanitizeAnnouncementInput(await request.json());+ if (!parsed.ok) {+ return NextResponse.json({ error: parsed.error }, { status: 400 });+ }++ const [updated] = await db+ .update(announcements)+ .set(parsed.value)+ .where(eq(announcements.id, id))+ .returning();++ await logAdminAction<AdminAnnouncementUpdatedMetadata>({+ action: "admin.announcement.update",+ userId: currentUser.id,+ resourceType: "announcement",+ resourceId: id,+ metadata: { before: forAudit(existing), after: forAudit(updated) },+ request,+ });++ return NextResponse.json({ announcement: updated });+ } catch (err) {+ console.error("Failed to update announcement:", err);+ return NextResponse.json({ error: "Failed to update announcement" }, { status: 500 });+ }+}++export async function DELETE(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {+ const access = await requireAnnouncementAccess(request);+ if (access.error) return access.error;+ const currentUser = access.currentUser;++ const rateLimitResponse = rateLimit(request, currentUser.id, "admin-announcement-mutations");+ if (rateLimitResponse) return rateLimitResponse;++ const { id } = await params;++ try {+ const [existing] = await db.select().from(announcements).where(eq(announcements.id, id)).limit(1);+ if (!existing) {+ return NextResponse.json({ error: "Announcement not found" }, { status: 404 });+ }++ await db.delete(announcements).where(eq(announcements.id, id));++ await logAdminAction<AdminAnnouncementDeletedMetadata>({+ action: "admin.announcement.delete",+ userId: currentUser.id,+ resourceType: "announcement",+ resourceId: id,+ metadata: { title: existing.title },+ request,+ });++ return NextResponse.json({ success: true });+ } catch (err) {+ console.error("Failed to delete announcement:", err);+ return NextResponse.json({ error: "Failed to delete announcement" }, { status: 500 });+ }+}diff --git a/app/api/admin/announcements/route.ts b/app/api/admin/announcements/route.tsnew file mode 100644index 0000000..475ad68--- /dev/null+++ b/app/api/admin/announcements/route.ts@@ -0,0 +1,131 @@+import { NextRequest, NextResponse } from "next/server";+import { desc, eq, sql } from "drizzle-orm";+import { db } from "@/lib/db";+import { announcements, user as userTable } from "@/lib/db/schema";+import {+ getValidatedAdminUser,+ isErrorResponse,+ type AdminUser,+} from "@/lib/auth/admin-helpers";+import { canManageSystemSettings } from "@/lib/auth/admin";+import { sanitizeAnnouncementInput } from "@/lib/announcements";+import { rateLimit } from "@/lib/rate-limiter";+import { logAdminAction, type AdminAnnouncementCreatedMetadata } from "@/lib/audit-log";++/**+ * Admin Announcements API+ *+ * GET /api/admin/announcements -- every row, including disabled and expired+ * POST /api/admin/announcements+ *+ * Permission: Admin or Superadmin (canManageSystemSettings)+ */+/** Timestamps defaulted by SQLite are "YYYY-MM-DD HH:MM:SS" text in UTC; app-written ones are unix seconds. */+function toDate(value: unknown): Date {+ if (typeof value === "number") return new Date(value * 1000);+ if (typeof value === "string") {+ if (/^\d+$/.test(value)) return new Date(Number(value) * 1000);+ const utc = new Date(`${value.replace(" ", "T")}Z`);+ return isNaN(utc.getTime()) ? new Date(value) : utc;+ }+ return new Date();+}++// Same column can hold either shape (see toDate above); normalise to seconds+// here too so ORDER BY reflects actual time rather than SQLite's storage-class+// ordering (INTEGER before TEXT), which would otherwise separate the two.+const createdAtEpoch = sql`case when typeof(${announcements.createdAt}) = 'text' then cast(strftime('%s', ${announcements.createdAt}) as integer) else ${announcements.createdAt} end`;++export type AnnouncementAccess =+ | { error: NextResponse; currentUser?: undefined }+ | { error?: undefined; currentUser: AdminUser };++export async function requireAnnouncementAccess(+ request: NextRequest+): Promise<AnnouncementAccess> {+ const currentUser = await getValidatedAdminUser(request);+ if (isErrorResponse(currentUser)) {+ return { error: currentUser };+ }+ if (!canManageSystemSettings(currentUser)) {+ return { error: NextResponse.json({ error: "Admin access required" }, { status: 403 }) };+ }+ return { currentUser };+}++export async function GET(request: NextRequest) {+ const access = await requireAnnouncementAccess(request);+ if (access.error) return access.error;++ try {+ const rows = await db+ .select({+ id: announcements.id,+ title: announcements.title,+ body: announcements.body,+ tone: announcements.tone,+ showOnAuth: announcements.showOnAuth,+ showOnDashboard: announcements.showOnDashboard,+ enabled: announcements.enabled,+ startsAt: announcements.startsAt,+ endsAt: announcements.endsAt,+ createdAt: sql<unknown>`${announcements.createdAt}`,+ createdByName: userTable.name,+ })+ .from(announcements)+ .leftJoin(userTable, eq(announcements.createdBy, userTable.id))+ .orderBy(desc(createdAtEpoch));++ const items = rows.map((row) => ({ ...row, createdAt: toDate(row.createdAt) }));++ return NextResponse.json({ announcements: items });+ } catch (err) {+ console.error("Failed to list announcements:", err);+ return NextResponse.json({ error: "Failed to list announcements" }, { status: 500 });+ }+}++export async function POST(request: NextRequest) {+ const access = await requireAnnouncementAccess(request);+ if (access.error) return access.error;+ const currentUser = access.currentUser;++ const rateLimitResponse = rateLimit(request, currentUser.id, "admin-announcement-mutations");+ if (rateLimitResponse) return rateLimitResponse;++ try {+ const parsed = sanitizeAnnouncementInput(await request.json());+ if (!parsed.ok) {+ return NextResponse.json({ error: parsed.error }, { status: 400 });+ }++ const [created] = await db+ .insert(announcements)+ .values({ ...parsed.value, createdBy: currentUser.id })+ .returning();++ await logAdminAction<AdminAnnouncementCreatedMetadata>({+ action: "admin.announcement.create",+ userId: currentUser.id,+ resourceType: "announcement",+ resourceId: created.id,+ metadata: {+ announcement: {+ title: created.title,+ tone: created.tone,+ showOnAuth: created.showOnAuth,+ showOnDashboard: created.showOnDashboard,+ enabled: created.enabled,+ startsAt: created.startsAt,+ endsAt: created.endsAt,+ },+ },+ request,+ });++ return NextResponse.json({ announcement: created }, { status: 201 });+ } catch (err) {+ console.error("Failed to create announcement:", err);+ return NextResponse.json({ error: "Failed to create announcement" }, { status: 500 });+ }+}diff --git a/app/api/announcements/route.ts b/app/api/announcements/route.tsnew file mode 100644index 0000000..ec3f6d0--- /dev/null+++ b/app/api/announcements/route.ts@@ -0,0 +1,33 @@+import { NextRequest, NextResponse } from "next/server";+import {+ ANNOUNCEMENT_PLACEMENTS,+ getVisibleAnnouncements,+ type AnnouncementPlacement,+} from "@/lib/announcements";+import { rateLimit } from "@/lib/rate-limiter";++/**+ * Public Announcements API+ *+ * GET /api/announcements?placement=auth|dashboard+ *+ * No session required -- the auth pages call it while logged out. Returns only+ * announcements visible right now; the browser never decides visibility.+ */+export async function GET(request: NextRequest) {+ const rateLimitResponse = rateLimit(request, null, "announcements");+ if (rateLimitResponse) return rateLimitResponse;++ const placement = request.nextUrl.searchParams.get("placement");+ if (!ANNOUNCEMENT_PLACEMENTS.includes(placement as AnnouncementPlacement)) {+ return NextResponse.json({ error: "Invalid placement" }, { status: 400 });+ }++ try {+ const announcements = await getVisibleAnnouncements(placement as AnnouncementPlacement);+ return NextResponse.json({ announcements });+ } catch (error) {+ console.error("Failed to load announcements:", error);+ return NextResponse.json({ error: "Failed to load announcements" }, { status: 500 });+ }+}diff --git a/components/admin/admin-sidebar.tsx b/components/admin/admin-sidebar.tsxindex 569498e..d418aad 100644--- a/components/admin/admin-sidebar.tsx+++ b/components/admin/admin-sidebar.tsx@@ -11,6 +11,7 @@ import {Crown,FolderClosed,LayoutDashboard,+ Megaphone,ScrollText,Users,type LucideIcon,@@ -29,7 +30,7 @@ export interface AdminSection {icon: LucideIcon;}-/** The four admin areas, shared by sidebar, tab bar, breadcrumb and dashboard. */+/** The five admin areas, shared by sidebar, tab bar, breadcrumb and dashboard. */export function useAdminSections(): AdminSection[] {const t = useTranslations();return [@@ -42,6 +43,12 @@ export function useAdminSections(): AdminSection[] {icon: FolderClosed,},{ href: "/admin/logs", label: t("admin.auditLogs"), shortLabel: t("adminShell.logsShort"), icon: ScrollText },+ {+ href: "/admin/announcements",+ label: t("admin.announcementsMenu"),+ shortLabel: t("adminShell.announcementsShort"),+ icon: Megaphone,+ },];}@@ -49,7 +56,7 @@ export function isActiveSection(pathname: string, href: string) {return href === "/admin" ? pathname === "/admin" : pathname.startsWith(href);}-/** Desktop area list (13a–13f): account row, the four areas, back to the app. */+/** Desktop area list (13a–13f): account row, the five areas, back to the app. */export function AdminSidebar() {const t = useTranslations();const locale = useLocale();@@ -166,7 +173,7 @@ export function AdminMobileNav() {const sections = useAdminSections();return (- <nav className="grid shrink-0 grid-cols-4 gap-1 border-t border-line bg-background px-3 pb-[max(8px,env(safe-area-inset-bottom))] pt-2 lg:hidden">+ <nav className="grid shrink-0 grid-cols-5 gap-1 border-t border-line bg-background px-3 pb-[max(8px,env(safe-area-inset-bottom))] pt-2 lg:hidden">{sections.map((section) => {const active = isActiveSection(pathname, section.href);return (diff --git a/components/admin/announcement-edit-sheet.tsx b/components/admin/announcement-edit-sheet.tsxnew file mode 100644index 0000000..1af5869--- /dev/null+++ b/components/admin/announcement-edit-sheet.tsx@@ -0,0 +1,157 @@+"use client";++import { useTranslations } from "next-intl";+import { Input } from "@/components/ui/input";+import { Textarea } from "@/components/ui/textarea";+import { BaseSheet } from "@/components/ui/base-sheet";+import { ChoiceChips, Field, ToggleRow, inputClass, textareaClass } from "@/components/form-kit";+import {+ BODY_MAX_LENGTH,+ TITLE_MAX_LENGTH,+ type AnnouncementTone,+} from "@/lib/announcement-status";+import { useAnnouncementForm } from "@/hooks/useAnnouncementForm";+import type { AdminAnnouncement, AnnouncementPayload } from "@/hooks/useAdminAnnouncements";++/** `datetime-local` wants "YYYY-MM-DDTHH:mm" in local time, not an ISO string. */+function toLocalInput(value: string | null): string {+ if (!value) return "";+ const date = new Date(value);+ const pad = (n: number) => String(n).padStart(2, "0");+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;+}++function fromLocalInput(value: string): string | null {+ if (!value) return null;+ const date = new Date(value);+ return Number.isNaN(date.getTime()) ? null : date.toISOString();+}++export function AnnouncementEditSheet({+ open,+ onOpenChange,+ announcement,+ onSubmit,+ isSaving,+}: {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ announcement: AdminAnnouncement | null;+ onSubmit: (payload: AnnouncementPayload) => Promise<void>;+ isSaving: boolean;+}) {+ const t = useTranslations();+ const { form, patch, error, validate } = useAnnouncementForm(announcement);++ const handleSave = async () => {+ const payload = validate();+ if (!payload) return;+ try {+ await onSubmit(payload);+ onOpenChange(false);+ } catch {+ // Already toasted by the mutation's onError; keep the sheet open so the user can retry.+ }+ };++ return (+ <BaseSheet+ open={open}+ onOpenChange={onOpenChange}+ title={+ announcement+ ? t("admin.announcements.editTitle")+ : t("admin.announcements.createTitle")+ }+ description={t("admin.announcements.formDescription")}+ showSaveButton+ onSave={handleSave}+ isSaving={isSaving}+ saveDisabled={!form.title.trim()}+ >+ <div className="flex flex-col gap-4">+ <Field label={t("admin.announcements.fieldTitle")} htmlFor="announcement-title">+ <Input+ id="announcement-title"+ value={form.title}+ maxLength={TITLE_MAX_LENGTH}+ onChange={(event) => patch({ title: event.target.value })}+ placeholder={t("admin.announcements.fieldTitlePlaceholder")}+ className={inputClass}+ />+ </Field>++ <Field label={t("admin.announcements.fieldBody")} htmlFor="announcement-body">+ <Textarea+ id="announcement-body"+ value={form.body ?? ""}+ maxLength={BODY_MAX_LENGTH}+ rows={4}+ onChange={(event) => patch({ body: event.target.value || null })}+ placeholder={t("admin.announcements.fieldBodyPlaceholder")}+ className={textareaClass}+ />+ </Field>++ <Field label={t("admin.announcements.fieldTone")}>+ <ChoiceChips<AnnouncementTone>+ value={form.tone}+ onChange={(tone) => patch({ tone })}+ options={[+ { value: "info", label: t("admin.announcements.toneInfo") },+ { value: "warning", label: t("admin.announcements.toneWarning") },+ { value: "danger", label: t("admin.announcements.toneDanger") },+ ]}+ />+ </Field>++ <ToggleRow+ id="announcement-show-auth"+ title={t("admin.announcements.showOnAuth")}+ description={t("admin.announcements.showOnAuthHint")}+ checked={form.showOnAuth}+ onCheckedChange={(showOnAuth) => patch({ showOnAuth })}+ />+ <ToggleRow+ id="announcement-show-dashboard"+ title={t("admin.announcements.showOnDashboard")}+ description={t("admin.announcements.showOnDashboardHint")}+ checked={form.showOnDashboard}+ onCheckedChange={(showOnDashboard) => patch({ showOnDashboard })}+ />+ <ToggleRow+ id="announcement-enabled"+ title={t("admin.announcements.enabled")}+ description={t("admin.announcements.enabledHint")}+ checked={form.enabled}+ onCheckedChange={(enabled) => patch({ enabled })}+ />++ <Field+ label={t("admin.announcements.startsAt")}+ htmlFor="announcement-starts-at"+ hint={t("admin.announcements.windowHint")}+ >+ <Input+ id="announcement-starts-at"+ type="datetime-local"+ value={toLocalInput(form.startsAt)}+ onChange={(event) => patch({ startsAt: fromLocalInput(event.target.value) })}+ className={inputClass}+ />+ </Field>+ <Field label={t("admin.announcements.endsAt")} htmlFor="announcement-ends-at">+ <Input+ id="announcement-ends-at"+ type="datetime-local"+ value={toLocalInput(form.endsAt)}+ onChange={(event) => patch({ endsAt: fromLocalInput(event.target.value) })}+ className={inputClass}+ />+ </Field>++ {error && <p className="text-[12px] text-danger">{error}</p>}+ </div>+ </BaseSheet>+ );+}diff --git a/components/admin/announcement-table.tsx b/components/admin/announcement-table.tsxnew file mode 100644index 0000000..a97bbfe--- /dev/null+++ b/components/admin/announcement-table.tsx@@ -0,0 +1,107 @@+"use client";++import { useFormatter, useTranslations } from "next-intl";+import { Pencil, Trash2 } from "lucide-react";+import { Pill, RowIconButton } from "@/components/form-kit";+// Client-safe module: lib/announcements.ts pulls in lib/db and cannot be+// imported (as a value) from client components.+import { getAnnouncementStatus, type AnnouncementStatus, type AnnouncementTone } from "@/lib/announcement-status";+import type { AdminAnnouncement } from "@/hooks/useAdminAnnouncements";++// Capitalised suffixes for the admin.announcements.status*/tone* keys. Kept+// separate from the t() call site so the i18n scanner still sees the static+// prefix + interpolation shape (its documented `admin.role${role}` idiom)+// instead of an opaque variable it can't resolve.+const STATUS_SUFFIX: Record<AnnouncementStatus, string> = {+ active: "Active",+ scheduled: "Scheduled",+ expired: "Expired",+ off: "Off",+};++const TONE_SUFFIX: Record<AnnouncementTone, string> = {+ info: "Info",+ warning: "Warning",+ danger: "Danger",+};++function toDate(value: string | null): Date | null {+ return value ? new Date(value) : null;+}++export function AnnouncementTable({+ announcements,+ onEdit,+ onDelete,+}: {+ announcements: AdminAnnouncement[];+ onEdit: (announcement: AdminAnnouncement) => void;+ onDelete: (announcement: AdminAnnouncement) => void;+}) {+ const t = useTranslations();+ const format = useFormatter();++ return (+ <div className="flex flex-col gap-2">+ {announcements.map((announcement) => {+ const status = getAnnouncementStatus({+ enabled: announcement.enabled,+ startsAt: toDate(announcement.startsAt),+ endsAt: toDate(announcement.endsAt),+ });++ return (+ <div+ key={announcement.id}+ className="flex items-start gap-3 rounded-[11px] border border-line bg-surface-card px-3 py-2.5"+ >+ <div className="min-w-0 flex-1">+ <div className="flex flex-wrap items-center gap-2">+ <span className="truncate text-[14px] font-semibold text-fg-strong">+ {announcement.title}+ </span>+ <Pill>{t(`admin.announcements.status${STATUS_SUFFIX[status]}`)}</Pill>+ <Pill>{t(`admin.announcements.tone${TONE_SUFFIX[announcement.tone]}`)}</Pill>+ </div>+ {announcement.body && (+ <p className="mt-0.5 line-clamp-2 text-[12.5px] text-fg-secondary">+ {announcement.body}+ </p>+ )}+ <p className="mt-1 text-[12px] text-fg-tertiary">+ {[+ announcement.showOnAuth ? t("admin.announcements.showOnAuth") : null,+ announcement.showOnDashboard ? t("admin.announcements.showOnDashboard") : null,+ ]+ .filter(Boolean)+ .join(" · ")}+ {" · "}+ {t("admin.announcements.createdBy", {+ name: announcement.createdByName ?? t("admin.announcements.unknownAuthor"),+ })}+ {" · "}+ {format.dateTime(new Date(announcement.createdAt), {+ dateStyle: "medium",+ timeStyle: "short",+ })}+ </p>+ </div>+ <div className="flex shrink-0 gap-1">+ <RowIconButton+ icon={Pencil}+ label={t("admin.announcements.edit")}+ onClick={() => onEdit(announcement)}+ />+ <RowIconButton+ icon={Trash2}+ label={t("admin.announcements.delete")}+ onClick={() => onDelete(announcement)}+ tone="danger"+ />+ </div>+ </div>+ );+ })}+ </div>+ );+}diff --git a/components/admin/audit-describe.ts b/components/admin/audit-describe.tsindex 2c328a6..27c347c 100644--- a/components/admin/audit-describe.ts+++ b/components/admin/audit-describe.ts@@ -22,6 +22,12 @@ function count(metadata: unknown, key: string): number {return Number.isFinite(value) ? value : 0;}+// text() only reads a top-level key; announcement metadata nests fields under+// "announcement"/"before"/"after", so this reaches one level down.+function nested(metadata: unknown, outer: string, inner: string): string {+ return text(field(metadata, outer), inner);+}+/*** Plain-language summary of an audit entry, built from its action and metadata.* Falls back to the raw action name when the metadata lacks what a sentence needs.@@ -77,6 +83,16 @@ export function useAuditDescription() {return t("adminAudit.describe.logsDeleted", { count: count(m, "deletedCount") });case "admin.system_settings.update":return t("adminAudit.describe.systemSettingsUpdated");+ case "admin.announcement.create":+ return t("adminAudit.describe.announcementCreated", {+ title: nested(m, "announcement", "title"),+ });+ case "admin.announcement.update":+ return t("adminAudit.describe.announcementUpdated", {+ title: nested(m, "after", "title"),+ });+ case "admin.announcement.delete":+ return t("adminAudit.describe.announcementDeleted", { title: text(m, "title") });case "admin.telemetry_consent":return field(m, "after") === true? t("adminAudit.describe.telemetryEnabled")diff --git a/components/announcement-banners.tsx b/components/announcement-banners.tsxnew file mode 100644index 0000000..f00f87b--- /dev/null+++ b/components/announcement-banners.tsx@@ -0,0 +1,93 @@+"use client";++import { useEffect, useState } from "react";+import { useTranslations } from "next-intl";+import { Megaphone, OctagonAlert, TriangleAlert, X } from "lucide-react";+import { StatusBanner } from "@/components/status-banner";+import { useAnnouncements } from "@/hooks/useAnnouncements";+import type { AnnouncementPlacement, AnnouncementTone } from "@/lib/announcements";+import { cn, readStorage, writeStorage } from "@/lib/utils";++const DISMISS_KEY = "dismissed-announcements";+// One list across both placements, so dismissing on the dashboard doesn't+// resurrect on /login and vice versa. Capped rather than pruned against+// whichever placement happens to be mounted, which would erase the other+// placement's dismissals.+const MAX_DISMISSED = 100;++const TONE_ICONS: Record<AnnouncementTone, typeof Megaphone> = {+ info: Megaphone,+ warning: TriangleAlert,+ danger: OctagonAlert,+};++function readDismissed(): string[] {+ const raw = readStorage(DISMISS_KEY);+ if (!raw) return [];+ try {+ const parsed = JSON.parse(raw);+ return Array.isArray(parsed) ? parsed.filter((id): id is string => typeof id === "string") : [];+ } catch {+ return [];+ }+}++export function AnnouncementBanners({+ placement,+ className,+}: {+ placement: AnnouncementPlacement;+ className?: string;+}) {+ const t = useTranslations();+ const announcements = useAnnouncements(placement);+ const [dismissed, setDismissed] = useState<string[]>([]);+ // Storage is only read after mount: reading during render would make the+ // server and the first client render disagree.+ const [hydrated, setHydrated] = useState(false);++ // Legitimate hydration pattern: reading storage only after mount, not during render.+ useEffect(() => {+ // eslint-disable-next-line react-hooks/set-state-in-effect+ setDismissed(readDismissed());+ setHydrated(true);+ }, []);++ if (!hydrated) return null;++ const visible = announcements.filter((a) => !dismissed.includes(a.id));+ if (visible.length === 0) return null;++ const dismiss = (id: string) => {+ setDismissed((prev) => {+ const next = [...prev, id].slice(-MAX_DISMISSED);+ writeStorage(DISMISS_KEY, JSON.stringify(next));+ return next;+ });+ };++ return (+ <div className={cn("flex flex-col gap-2", className)}>+ {visible.map((announcement) => (+ <StatusBanner+ key={announcement.id}+ tone={announcement.tone}+ icon={TONE_ICONS[announcement.tone]}+ title={announcement.title}+ action={+ <button+ type="button"+ onClick={() => dismiss(announcement.id)}+ aria-label={t("announcements.dismiss")}+ className="rounded-md p-1 text-fg-tertiary transition-colors hover:bg-surface-sunken hover:text-fg-strong"+ >+ <X className="size-4" />+ </button>+ }+ >+ {announcement.body && <span className="whitespace-pre-line">{announcement.body}</span>}+ </StatusBanner>+ ))}+ </div>+ );+}diff --git a/components/auth-shell.tsx b/components/auth-shell.tsxindex dbec209..618ab3a 100644--- a/components/auth-shell.tsx+++ b/components/auth-shell.tsx@@ -13,6 +13,7 @@ import {startOfWeek,} from "date-fns";import { CalendarDays, Eye, EyeOff } from "lucide-react";+import { AnnouncementBanners } from "@/components/announcement-banners";import { Input } from "@/components/ui/input";import { useClientValue } from "@/hooks/useMediaQuery";import { useVersionInfo } from "@/hooks/useVersionInfo";@@ -63,6 +64,7 @@ export function AuthShell({<main className="flex flex-1 justify-center px-4 py-8 sm:py-12 lg:items-center lg:p-9"><div className="flex w-full max-w-[380px] flex-col gap-[18px]">+ <AnnouncementBanners placement="auth" /><div><h1 className="text-[21px] font-semibold tracking-[-0.02em] text-fg-strong">{title}diff --git a/components/calendar-workspace.tsx b/components/calendar-workspace.tsxindex e8e81ec..7464ebf 100644--- a/components/calendar-workspace.tsx+++ b/components/calendar-workspace.tsx@@ -13,6 +13,7 @@ import { ListSort, ShiftListView } from "@/components/shift-list-view";import { DayInspector, DayActions, DayViewModel } from "@/components/day-inspector";import { MobileDayFooter, MobileDaySheet, MobileStatsSheet } from "@/components/mobile-day-sheet";import { MobilePresetBar, StampDock, orderStampPresets } from "@/components/stamp-dock";+import { AnnouncementBanners } from "@/components/announcement-banners";import { GuestBanner } from "@/components/guest-banner";import { ReadOnlyBanner } from "@/components/read-only-banner";import { StatusBanner } from "@/components/status-banner";@@ -308,6 +309,7 @@ export function CalendarWorkspace({{header}<div className="flex min-h-0 flex-1"><main className="relative flex min-w-0 flex-1 flex-col pb-[18px]">+ <AnnouncementBanners placement="dashboard" className="px-[18px] pt-3.5" />{hasBanner && <div className="flex flex-col gap-2 px-[18px] pt-3.5">{banners}</div>}<div className={isOnline ? "contents" : "contents [&>div]:opacity-60"}>{surface}</div>{stampingEnabled && (@@ -330,6 +332,7 @@ export function CalendarWorkspace({{header}{/* In list mode the list brings its own scroller, so <main> must not scroll too */}<main className={cn("flex min-h-0 flex-1 flex-col", viewMode !== "list" && "overflow-y-auto")}>+ <AnnouncementBanners placement="dashboard" className="px-3 pt-3" />{hasBanner && <div className="flex flex-col gap-2 px-3 pt-3">{banners}</div>}<div className="flex items-center gap-2 px-3.5 pb-[9px] pt-3"><h1 className="min-w-0 flex-1 truncate text-[19px] font-semibold tracking-[-0.015em] text-fg-strong">diff --git a/docs/ADMIN_PANEL.md b/docs/ADMIN_PANEL.mdindex 191c64b..03f61f6 100644--- a/docs/ADMIN_PANEL.md+++ b/docs/ADMIN_PANEL.md@@ -10,7 +10,8 @@ This guide covers the admin panel features in BetterShift, including user manage4. [User Management](#user-management)5. [Calendar Management](#calendar-management)6. [Audit Logs](#audit-logs)-7. [Rate Limiting](#rate-limiting)+7. [Announcements](#announcements)+8. [Rate Limiting](#rate-limiting)---@@ -28,8 +29,8 @@ Or navigate directly to `/admin`.### Navigation-- **Desktop**: a sidebar on the left links to Dashboard, Users, Calendars, and Audit Logs.-- **Phone**: the same four areas are reached through a bottom tab bar instead of a sidebar.+- **Desktop**: a sidebar on the left links to Dashboard, Users, Calendars, Audit Logs, and Announcements.+- **Phone**: the same five areas are reached through a bottom tab bar instead of a sidebar.- Viewing or editing a single user or calendar opens as a side panel over the current list, not as a separate page — the list stays where you left it underneath.---@@ -256,6 +257,41 @@ Consider exporting logs before deletion for compliance purposes.---+## Announcements++Location: `/admin/announcements`++Announcements are short, admin-authored notices shown on the login/register pages and above the calendar. Unlike most content in BetterShift, a title and body are written once and shown as-is to every viewer — they are not translated per locale.++### Managing Announcements++Creating, editing and deleting announcements requires the same permission as system settings: **admin** or **superadmin** (`canManageSystemSettings`). There is no separate role tier for this section.++### Placement++Each announcement targets one or both of:++- **Auth pages** — shown on the login and registration pages, for logged-out visitors+- **Dashboard** — shown above the calendar, for signed-in users++At least one placement must be selected; an announcement with neither is rejected as a mistake rather than saved.++### Tone++Three tones control the banner's icon and color: **Info**, **Warning**, and **Danger**.++### Enabled Flag and Scheduling Window++- The **Enabled** toggle takes an announcement out of rotation without deleting it.+- An optional start and end date can further restrict visibility to a date range; either side may be left blank, and when both are set the end must be after the start.+- The table shows each announcement's combined status: **Active**, **Scheduled** (before its start date), **Expired** (past its end date), or **Off** (disabled).++### Dismissal++Dismissing an announcement's banner (the × button) is stored per browser in `localStorage`, not on the server, as one shared list of dismissed ids covering both the auth and dashboard placements — dismissing on one surface hides that announcement on the other too. There is no admin-side way to see who dismissed an announcement or to reset dismissals centrally — a browser that already dismissed an announcement keeps it hidden even if the announcement is later edited, disabled and re-enabled, or temporarily outside its window, until local storage is cleared or the dismissed list (capped at the 100 most recent ids) evicts that id.++---+## Rate LimitingAdmin operations are rate-limited to prevent abuse:@@ -276,6 +312,10 @@ RATE_LIMIT_ADMIN_BULK_OPERATIONS_WINDOW=300# Calendar mutations: 10 per minuteRATE_LIMIT_ADMIN_CALENDAR_MUTATIONS=10RATE_LIMIT_ADMIN_CALENDAR_MUTATIONS_WINDOW=60++# Announcement create/update/delete: 20 per minute+RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS=20+RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS_WINDOW=60```---diff --git a/drizzle/0030_stiff_vision.sql b/drizzle/0030_stiff_vision.sqlnew file mode 100644index 0000000..e08b286--- /dev/null+++ b/drizzle/0030_stiff_vision.sql@@ -0,0 +1,15 @@+CREATE TABLE `announcements` (+ `id` text PRIMARY KEY NOT NULL,+ `title` text NOT NULL,+ `body` text,+ `tone` text DEFAULT 'info' NOT NULL,+ `show_on_auth` integer DEFAULT true NOT NULL,+ `show_on_dashboard` integer DEFAULT true NOT NULL,+ `enabled` integer DEFAULT true NOT NULL,+ `starts_at` integer,+ `ends_at` integer,+ `created_by` text,+ `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,+ `updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,+ FOREIGN KEY (`created_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null+);diff --git a/drizzle/meta/0030_snapshot.json b/drizzle/meta/0030_snapshot.jsonnew file mode 100644index 0000000..8b543d8--- /dev/null+++ b/drizzle/meta/0030_snapshot.json@@ -0,0 +1,2661 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "b310cc51-48d7-4f2c-a03b-f411b6bb880b",+ "prevId": "a11e9068-3b63-4179-9a3e-955658e05445",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "announcements": {+ "name": "announcements",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tone": {+ "name": "tone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'info'"+ },+ "show_on_auth": {+ "name": "show_on_auth",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "show_on_dashboard": {+ "name": "show_on_dashboard",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "enabled": {+ "name": "enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "starts_at": {+ "name": "starts_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ends_at": {+ "name": "ends_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "announcements_created_by_user_id_fk": {+ "name": "announcements_created_by_user_id_fk",+ "tableFrom": "announcements",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "audit_logs": {+ "name": "audit_logs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'info'"+ },+ "is_user_visible": {+ "name": "is_user_visible",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "timestamp": {+ "name": "timestamp",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "audit_logs_userId_timestamp_idx": {+ "name": "audit_logs_userId_timestamp_idx",+ "columns": [+ "user_id",+ "timestamp"+ ],+ "isUnique": false+ },+ "audit_logs_action_timestamp_idx": {+ "name": "audit_logs_action_timestamp_idx",+ "columns": [+ "action",+ "timestamp"+ ],+ "isUnique": false+ },+ "audit_logs_userVisible_userId_timestamp_idx": {+ "name": "audit_logs_userVisible_userId_timestamp_idx",+ "columns": [+ "is_user_visible",+ "user_id",+ "timestamp"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "audit_logs_user_id_user_id_fk": {+ "name": "audit_logs_user_id_user_id_fk",+ "tableFrom": "audit_logs",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_access_tokens": {+ "name": "calendar_access_tokens",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bundle_id": {+ "name": "bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage_count": {+ "name": "usage_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "is_active": {+ "name": "is_active",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ }+ },+ "indexes": {+ "calendar_access_tokens_token_unique": {+ "name": "calendar_access_tokens_token_unique",+ "columns": [+ "token"+ ],+ "isUnique": true+ },+ "calendar_access_tokens_token_idx": {+ "name": "calendar_access_tokens_token_idx",+ "columns": [+ "token"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_calendarId_isActive_idx": {+ "name": "calendar_access_tokens_calendarId_isActive_idx",+ "columns": [+ "calendar_id",+ "is_active"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_createdBy_idx": {+ "name": "calendar_access_tokens_createdBy_idx",+ "columns": [+ "created_by"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_bundleId_idx": {+ "name": "calendar_access_tokens_bundleId_idx",+ "columns": [+ "bundle_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendar_access_tokens_calendar_id_calendars_id_fk": {+ "name": "calendar_access_tokens_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk": {+ "name": "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "calendar_permission_bundles",+ "columnsFrom": [+ "bundle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "calendar_access_tokens_created_by_user_id_fk": {+ "name": "calendar_access_tokens_created_by_user_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_custom_fields": {+ "name": "calendar_custom_fields",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "required": {+ "name": "required",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "show_in_calendar": {+ "name": "show_in_calendar",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_custom_fields_calendarId_idx": {+ "name": "calendar_custom_fields_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_custom_fields_calendarId_key_idx": {+ "name": "calendar_custom_fields_calendarId_key_idx",+ "columns": [+ "calendar_id",+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "calendar_custom_fields_calendar_id_calendars_id_fk": {+ "name": "calendar_custom_fields_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_custom_fields",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_custom_fields_created_by_user_id_fk": {+ "name": "calendar_custom_fields_created_by_user_id_fk",+ "tableFrom": "calendar_custom_fields",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_notes": {+ "name": "calendar_notes",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'note'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recurring_pattern": {+ "name": "recurring_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'none'"+ },+ "recurring_interval": {+ "name": "recurring_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "calendar_notes_calendar_id_calendars_id_fk": {+ "name": "calendar_notes_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_notes",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_notes_created_by_user_id_fk": {+ "name": "calendar_notes_created_by_user_id_fk",+ "tableFrom": "calendar_notes",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_permission_bundles": {+ "name": "calendar_permission_bundles",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "seed_key": {+ "name": "seed_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_permission_bundles_calendarId_idx": {+ "name": "calendar_permission_bundles_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_permission_bundles_calendarId_seedKey_idx": {+ "name": "calendar_permission_bundles_calendarId_seedKey_idx",+ "columns": [+ "calendar_id",+ "seed_key"+ ],+ "isUnique": true,+ "where": "\"calendar_permission_bundles\".\"seed_key\" is not null"+ }+ },+ "foreignKeys": {+ "calendar_permission_bundles_calendar_id_calendars_id_fk": {+ "name": "calendar_permission_bundles_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_permission_bundles",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_shares": {+ "name": "calendar_shares",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bundle_id": {+ "name": "bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "shared_by": {+ "name": "shared_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_shares_calendarId_idx": {+ "name": "calendar_shares_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_shares_userId_idx": {+ "name": "calendar_shares_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "calendar_shares_bundleId_idx": {+ "name": "calendar_shares_bundleId_idx",+ "columns": [+ "bundle_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendar_shares_calendar_id_calendars_id_fk": {+ "name": "calendar_shares_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_shares_user_id_user_id_fk": {+ "name": "calendar_shares_user_id_user_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_shares_bundle_id_calendar_permission_bundles_id_fk": {+ "name": "calendar_shares_bundle_id_calendar_permission_bundles_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "calendar_permission_bundles",+ "columnsFrom": [+ "bundle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "calendar_shares_shared_by_user_id_fk": {+ "name": "calendar_shares_shared_by_user_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "user",+ "columnsFrom": [+ "shared_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendars": {+ "name": "calendars",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "owner_id": {+ "name": "owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "guest_bundle_id": {+ "name": "guest_bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "signups_enabled": {+ "name": "signups_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "split_shifts_enabled": {+ "name": "split_shifts_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "view_settings": {+ "name": "view_settings",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendars_ownerId_idx": {+ "name": "calendars_ownerId_idx",+ "columns": [+ "owner_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendars_owner_id_user_id_fk": {+ "name": "calendars_owner_id_user_id_fk",+ "tableFrom": "calendars",+ "tableTo": "user",+ "columnsFrom": [+ "owner_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "external_syncs": {+ "name": "external_syncs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'icloud'"+ },+ "calendar_url": {+ "name": "calendar_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "display_mode": {+ "name": "display_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'normal'"+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "auto_sync_interval": {+ "name": "auto_sync_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "is_one_time_import": {+ "name": "is_one_time_import",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "last_synced_at": {+ "name": "last_synced_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "external_syncs_calendar_id_calendars_id_fk": {+ "name": "external_syncs_calendar_id_calendars_id_fk",+ "tableFrom": "external_syncs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "preset_custom_field_values": {+ "name": "preset_custom_field_values",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "field_id": {+ "name": "field_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "preset_custom_field_values_presetId_idx": {+ "name": "preset_custom_field_values_presetId_idx",+ "columns": [+ "preset_id"+ ],+ "isUnique": false+ },+ "preset_custom_field_values_presetId_fieldId_idx": {+ "name": "preset_custom_field_values_presetId_fieldId_idx",+ "columns": [+ "preset_id",+ "field_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "preset_custom_field_values_preset_id_shift_presets_id_fk": {+ "name": "preset_custom_field_values_preset_id_shift_presets_id_fk",+ "tableFrom": "preset_custom_field_values",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "preset_custom_field_values_field_id_calendar_custom_fields_id_fk": {+ "name": "preset_custom_field_values_field_id_calendar_custom_fields_id_fk",+ "tableFrom": "preset_custom_field_values",+ "tableTo": "calendar_custom_fields",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "preset_time_segments": {+ "name": "preset_time_segments",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "preset_time_segments_presetId_idx": {+ "name": "preset_time_segments_presetId_idx",+ "columns": [+ "preset_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "preset_time_segments_preset_id_shift_presets_id_fk": {+ "name": "preset_time_segments_preset_id_shift_presets_id_fk",+ "tableFrom": "preset_time_segments",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "impersonated_by": {+ "name": "impersonated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "session_token_unique": {+ "name": "session_token_unique",+ "columns": [+ "token"+ ],+ "isUnique": true+ },+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_custom_field_values": {+ "name": "shift_custom_field_values",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "field_id": {+ "name": "field_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "shift_custom_field_values_shiftId_idx": {+ "name": "shift_custom_field_values_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ },+ "shift_custom_field_values_shiftId_fieldId_idx": {+ "name": "shift_custom_field_values_shiftId_fieldId_idx",+ "columns": [+ "shift_id",+ "field_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "shift_custom_field_values_shift_id_shifts_id_fk": {+ "name": "shift_custom_field_values_shift_id_shifts_id_fk",+ "tableFrom": "shift_custom_field_values",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_custom_field_values_field_id_calendar_custom_fields_id_fk": {+ "name": "shift_custom_field_values_field_id_calendar_custom_fields_id_fk",+ "tableFrom": "shift_custom_field_values",+ "tableTo": "calendar_custom_fields",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_presets": {+ "name": "shift_presets",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "group_name": {+ "name": "group_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "default_signup_capacity": {+ "name": "default_signup_capacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shift_presets_calendar_id_calendars_id_fk": {+ "name": "shift_presets_calendar_id_calendars_id_fk",+ "tableFrom": "shift_presets",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_presets_created_by_user_id_fk": {+ "name": "shift_presets_created_by_user_id_fk",+ "tableFrom": "shift_presets",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_signups": {+ "name": "shift_signups",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signed_up_by": {+ "name": "signed_up_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "shift_signups_shiftId_idx": {+ "name": "shift_signups_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ },+ "shift_signups_userId_idx": {+ "name": "shift_signups_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "shift_signups_shiftId_userId_idx": {+ "name": "shift_signups_shiftId_userId_idx",+ "columns": [+ "shift_id",+ "user_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "shift_signups_shift_id_shifts_id_fk": {+ "name": "shift_signups_shift_id_shifts_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_signups_user_id_user_id_fk": {+ "name": "shift_signups_user_id_user_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_signups_signed_up_by_user_id_fk": {+ "name": "shift_signups_signed_up_by_user_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "user",+ "columnsFrom": [+ "signed_up_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_time_segments": {+ "name": "shift_time_segments",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "shift_time_segments_shiftId_idx": {+ "name": "shift_time_segments_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "shift_time_segments_shift_id_shifts_id_fk": {+ "name": "shift_time_segments_shift_id_shifts_id_fk",+ "tableFrom": "shift_time_segments",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shifts": {+ "name": "shifts",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "signup_capacity": {+ "name": "signup_capacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_event_id": {+ "name": "external_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "synced_from_external": {+ "name": "synced_from_external",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shifts_calendar_id_calendars_id_fk": {+ "name": "shifts_calendar_id_calendars_id_fk",+ "tableFrom": "shifts",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shifts_preset_id_shift_presets_id_fk": {+ "name": "shifts_preset_id_shift_presets_id_fk",+ "tableFrom": "shifts",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "shifts_external_sync_id_external_syncs_id_fk": {+ "name": "shifts_external_sync_id_external_syncs_id_fk",+ "tableFrom": "shifts",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shifts_created_by_user_id_fk": {+ "name": "shifts_created_by_user_id_fk",+ "tableFrom": "shifts",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "sync_logs": {+ "name": "sync_logs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "external_sync_name": {+ "name": "external_sync_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shifts_created": {+ "name": "shifts_created",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_updated": {+ "name": "shifts_updated",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_deleted": {+ "name": "shifts_deleted",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'auto'"+ },+ "is_read": {+ "name": "is_read",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "synced_at": {+ "name": "synced_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "sync_logs_calendar_id_calendars_id_fk": {+ "name": "sync_logs_calendar_id_calendars_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_logs_external_sync_id_external_syncs_id_fk": {+ "name": "sync_logs_external_sync_id_external_syncs_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "system_settings": {+ "name": "system_settings",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false,+ "default": "'default'"+ },+ "update_check_enabled": {+ "name": "update_check_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "update_banner_visibility": {+ "name": "update_banner_visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'all'"+ },+ "allow_guest_access": {+ "name": "allow_guest_access",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "telemetry_enabled": {+ "name": "telemetry_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "telemetry_instance_id": {+ "name": "telemetry_instance_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "telemetry_consented_schema": {+ "name": "telemetry_consented_schema",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "telemetry_decided_at": {+ "name": "telemetry_decided_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "banned": {+ "name": "banned",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "ban_reason": {+ "name": "ban_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ban_expires": {+ "name": "ban_expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "must_change_password": {+ "name": "must_change_password",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "user_email_unique": {+ "name": "user_email_unique",+ "columns": [+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user_calendar_subscriptions": {+ "name": "user_calendar_subscriptions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'subscribed'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'guest'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_calendar_subscriptions_userId_idx": {+ "name": "user_calendar_subscriptions_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "user_calendar_subscriptions_calendarId_idx": {+ "name": "user_calendar_subscriptions_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "user_calendar_subscriptions_status_idx": {+ "name": "user_calendar_subscriptions_status_idx",+ "columns": [+ "status"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "user_calendar_subscriptions_user_id_user_id_fk": {+ "name": "user_calendar_subscriptions_user_id_user_id_fk",+ "tableFrom": "user_calendar_subscriptions",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_calendar_subscriptions_calendar_id_calendars_id_fk": {+ "name": "user_calendar_subscriptions_calendar_id_calendars_id_fk",+ "tableFrom": "user_calendar_subscriptions",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user_preferences": {+ "name": "user_preferences",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "view_settings": {+ "name": "view_settings",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preferences_user_id_user_id_fk": {+ "name": "user_preferences_user_id_user_id_fk",+ "tableFrom": "user_preferences",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "verification": {+ "name": "verification",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}\ No newline at end of filediff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex dd96c6e..a97ba14 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -211,6 +211,13 @@"when": 1789845766565,"tag": "0029_red_night_thrasher","breakpoints": true+ },+ {+ "idx": 30,+ "version": "6",+ "when": 1789920055862,+ "tag": "0030_stiff_vision",+ "breakpoints": true}]}\ No newline at end of filediff --git a/hooks/useAdminAnnouncements.ts b/hooks/useAdminAnnouncements.tsnew file mode 100644index 0000000..dbc3841--- /dev/null+++ b/hooks/useAdminAnnouncements.ts@@ -0,0 +1,170 @@+"use client";++import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { useTranslations } from "next-intl";+import { toast } from "sonner";+import { queryKeys } from "@/lib/query-keys";+import { handleRateLimitError } from "@/lib/rate-limit-client";+import type { AnnouncementTone } from "@/lib/announcements";++// Same shape as in hooks/useCalendarBundles.ts: carries the 429 response so+// onError can render the rate-limit toast instead of the generic one.+class RateLimitError extends Error {+ constructor(public response: Response) {+ super("Rate limit exceeded");+ this.name = "RateLimitError";+ }+}++async function throwIfFailed(response: Response) {+ if (response.ok) return;+ if (response.status === 429) throw new RateLimitError(response);+ throw new Error(await response.text());+}++export interface AdminAnnouncement {+ id: string;+ title: string;+ body: string | null;+ tone: AnnouncementTone;+ showOnAuth: boolean;+ showOnDashboard: boolean;+ enabled: boolean;+ startsAt: string | null;+ endsAt: string | null;+ createdAt: string;+ createdByName: string | null;+}++export interface AnnouncementPayload {+ title: string;+ body: string | null;+ tone: AnnouncementTone;+ showOnAuth: boolean;+ showOnDashboard: boolean;+ enabled: boolean;+ startsAt: string | null;+ endsAt: string | null;+}++async function fetchAdminAnnouncements(): Promise<AdminAnnouncement[]> {+ const response = await fetch("/api/admin/announcements");+ if (!response.ok) throw new Error(`Fetch admin announcements failed: ${response.status}`);+ const data = await response.json();+ return data.announcements ?? [];+}++export function useAdminAnnouncements() {+ const { data, isLoading } = useQuery({+ queryKey: queryKeys.admin.announcements,+ queryFn: fetchAdminAnnouncements,+ });+ return { announcements: data ?? [], isLoading };+}++export function useAdminAnnouncementActions() {+ const t = useTranslations();+ const queryClient = useQueryClient();++ const invalidate = () => {+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.announcements });+ // The reader lists are served by a different route and must refetch too.+ queryClient.invalidateQueries({ queryKey: queryKeys.announcements.all });+ };++ /** Cancels the in-flight list query, snapshots it and applies `patch`. */+ const snapshotAndPatch = async (patch: (list: AdminAnnouncement[]) => AdminAnnouncement[]) => {+ await queryClient.cancelQueries({ queryKey: queryKeys.admin.announcements });+ const previous = queryClient.getQueryData<AdminAnnouncement[]>(queryKeys.admin.announcements);+ queryClient.setQueryData<AdminAnnouncement[]>(queryKeys.admin.announcements, (old) =>+ patch(old ?? [])+ );+ return previous;+ };++ const restore = (previous: AdminAnnouncement[] | undefined) =>+ queryClient.setQueryData(queryKeys.admin.announcements, previous);++ const createMutation = useMutation({+ mutationFn: async (payload: AnnouncementPayload) => {+ const response = await fetch("/api/admin/announcements", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(payload),+ });+ await throwIfFailed(response);+ return response.json();+ },+ onMutate: async (payload) => {+ const optimistic: AdminAnnouncement = {+ id: `optimistic-${Date.now()}`,+ ...payload,+ createdAt: new Date().toISOString(),+ createdByName: null,+ };+ return { previous: await snapshotAndPatch((list) => [optimistic, ...list]) };+ },+ onError: async (err, variables, context) => {+ restore(context?.previous);+ if (err instanceof RateLimitError) {+ await handleRateLimitError(err.response, t);+ return;+ }+ toast.error(t("admin.announcements.saveError"));+ },+ onSettled: invalidate,+ });++ const updateMutation = useMutation({+ mutationFn: async ({ id, ...payload }: AnnouncementPayload & { id: string }) => {+ const response = await fetch(`/api/admin/announcements/${id}`, {+ method: "PATCH",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(payload),+ });+ await throwIfFailed(response);+ return response.json();+ },+ onMutate: async ({ id, ...payload }) => ({+ previous: await snapshotAndPatch((list) =>+ list.map((item) => (item.id === id ? { ...item, ...payload } : item))+ ),+ }),+ onError: async (err, variables, context) => {+ restore(context?.previous);+ if (err instanceof RateLimitError) {+ await handleRateLimitError(err.response, t);+ return;+ }+ toast.error(t("admin.announcements.saveError"));+ },+ onSettled: invalidate,+ });++ const deleteMutation = useMutation({+ mutationFn: async (id: string) => {+ const response = await fetch(`/api/admin/announcements/${id}`, { method: "DELETE" });+ await throwIfFailed(response);+ return response.json();+ },+ onMutate: async (id) => ({+ previous: await snapshotAndPatch((list) => list.filter((item) => item.id !== id)),+ }),+ onError: async (err, variables, context) => {+ restore(context?.previous);+ if (err instanceof RateLimitError) {+ await handleRateLimitError(err.response, t);+ return;+ }+ toast.error(t("admin.announcements.deleteError"));+ },+ onSettled: invalidate,+ });++ return {+ createAnnouncement: createMutation.mutateAsync,+ updateAnnouncement: updateMutation.mutateAsync,+ deleteAnnouncement: deleteMutation.mutateAsync,+ isSaving: createMutation.isPending || updateMutation.isPending || deleteMutation.isPending,+ };+}diff --git a/hooks/useAnnouncementForm.ts b/hooks/useAnnouncementForm.tsnew file mode 100644index 0000000..53862f8--- /dev/null+++ b/hooks/useAnnouncementForm.ts@@ -0,0 +1,65 @@+"use client";++import { useState } from "react";+import { useTranslations } from "next-intl";+import type { AdminAnnouncement, AnnouncementPayload } from "@/hooks/useAdminAnnouncements";++const EMPTY: AnnouncementPayload = {+ title: "",+ body: null,+ tone: "info",+ showOnAuth: true,+ showOnDashboard: true,+ enabled: true,+ startsAt: null,+ endsAt: null,+};++function initialFormFor(announcement: AdminAnnouncement | null): AnnouncementPayload {+ if (!announcement) return EMPTY;+ return {+ title: announcement.title,+ body: announcement.body,+ tone: announcement.tone,+ showOnAuth: announcement.showOnAuth,+ showOnDashboard: announcement.showOnDashboard,+ enabled: announcement.enabled,+ startsAt: announcement.startsAt,+ endsAt: announcement.endsAt,+ };+}++/**+ * Owns the announcement create/edit form's state and save-time validation.+ * The owning sheet is remounted by its parent (via `key`) whenever the+ * create/edit target changes, so the initial state below only has to run+ * once per mount — no reset-on-open effect needed here.+ */+export function useAnnouncementForm(announcement: AdminAnnouncement | null) {+ const t = useTranslations();+ const [form, setForm] = useState<AnnouncementPayload>(() => initialFormFor(announcement));+ const [error, setError] = useState<string | null>(null);++ const patch = (next: Partial<AnnouncementPayload>) =>+ setForm((current) => ({ ...current, ...next }));++ /** Sanitizes and validates on save; returns the payload to submit, or null (with `error` set). */+ const validate = (): AnnouncementPayload | null => {+ if (!form.title.trim()) {+ setError(t("admin.announcements.errorTitleRequired"));+ return null;+ }+ if (!form.showOnAuth && !form.showOnDashboard) {+ setError(t("admin.announcements.errorNoPlacement"));+ return null;+ }+ if (form.startsAt && form.endsAt && new Date(form.endsAt) <= new Date(form.startsAt)) {+ setError(t("admin.announcements.errorWindow"));+ return null;+ }+ setError(null);+ return { ...form, title: form.title.trim() };+ };++ return { form, patch, error, validate };+}diff --git a/hooks/useAnnouncements.ts b/hooks/useAnnouncements.tsnew file mode 100644index 0000000..95d4391--- /dev/null+++ b/hooks/useAnnouncements.ts@@ -0,0 +1,31 @@+"use client";++import { useQuery } from "@tanstack/react-query";+import { queryKeys } from "@/lib/query-keys";+import type { AnnouncementPlacement, PublicAnnouncement } from "@/lib/announcements";++async function fetchAnnouncements(+ placement: AnnouncementPlacement+): Promise<PublicAnnouncement[]> {+ const response = await fetch(`/api/announcements?placement=${placement}`);+ if (!response.ok) {+ throw new Error(`Fetch /api/announcements failed: ${response.status}`);+ }+ const data = await response.json();+ return data.announcements ?? [];+}++/** Announcements are supplementary: a failure returns an empty list, never an error state. */+export function useAnnouncements(placement: AnnouncementPlacement): PublicAnnouncement[] {+ const { data } = useQuery({+ queryKey: queryKeys.announcements.byPlacement(placement),+ queryFn: () => fetchAnnouncements(placement),+ staleTime: 60 * 1000,+ retry: 1,+ // A page load, focus and reconnect already cover the liveness this needs;+ // the global background interval would otherwise poll every open tab forever.+ refetchInterval: false,+ });++ return data ?? [];+}diff --git a/lib/announcement-status.ts b/lib/announcement-status.tsnew file mode 100644index 0000000..8f9c453--- /dev/null+++ b/lib/announcement-status.ts@@ -0,0 +1,35 @@+// Pure, DB-free announcement helpers so client components (e.g. the admin+// table) can import them without pulling in lib/db and its better-sqlite3+// dependency into the browser bundle.++export const ANNOUNCEMENT_TONES = ["info", "warning", "danger"] as const;+export type AnnouncementTone = (typeof ANNOUNCEMENT_TONES)[number];++export const TITLE_MAX_LENGTH = 120;+export const BODY_MAX_LENGTH = 1000;++export type AnnouncementStatus = "active" | "scheduled" | "expired" | "off";++interface VisibilityFields {+ enabled: boolean;+ startsAt: Date | null;+ endsAt: Date | null;+}++export function getAnnouncementStatus(+ row: VisibilityFields,+ now: Date = new Date()+): AnnouncementStatus {+ if (!row.enabled) return "off";+ if (row.startsAt && row.startsAt.getTime() > now.getTime()) return "scheduled";+ if (row.endsAt && row.endsAt.getTime() <= now.getTime()) return "expired";+ return "active";+}++/** The named single-rule form of the visibility check; expressed in JS, mirrored in SQL by getVisibleAnnouncements(). */+export function isVisibleNow(row: VisibilityFields, now: Date = new Date()): boolean {+ return getAnnouncementStatus(row, now) === "active";+}++export const ANNOUNCEMENT_PLACEMENTS = ["auth", "dashboard"] as const;+export type AnnouncementPlacement = (typeof ANNOUNCEMENT_PLACEMENTS)[number];diff --git a/lib/announcements.ts b/lib/announcements.tsnew file mode 100644index 0000000..9eb7fea--- /dev/null+++ b/lib/announcements.ts@@ -0,0 +1,134 @@+import { and, desc, eq, gt, isNull, lte, or } from "drizzle-orm";+import { db } from "@/lib/db";+import { announcements } from "@/lib/db/schema";+import {+ ANNOUNCEMENT_PLACEMENTS,+ ANNOUNCEMENT_TONES,+ BODY_MAX_LENGTH,+ TITLE_MAX_LENGTH,+ getAnnouncementStatus,+ isVisibleNow,+ type AnnouncementPlacement,+ type AnnouncementStatus,+ type AnnouncementTone,+} from "@/lib/announcement-status";++// Re-exported so existing server-side consumers keep importing from this+// module; client components should import these from lib/announcement-status+// directly to avoid pulling lib/db into the browser bundle.+export {+ ANNOUNCEMENT_PLACEMENTS,+ ANNOUNCEMENT_TONES,+ BODY_MAX_LENGTH,+ TITLE_MAX_LENGTH,+ getAnnouncementStatus,+ isVisibleNow,+};+export type { AnnouncementPlacement, AnnouncementStatus, AnnouncementTone };++/** Exactly what the public route returns -- no creator, no timestamps. */+export interface PublicAnnouncement {+ id: string;+ title: string;+ body: string | null;+ tone: AnnouncementTone;+}++export interface AnnouncementInput {+ title: string;+ body: string | null;+ tone: AnnouncementTone;+ showOnAuth: boolean;+ showOnDashboard: boolean;+ enabled: boolean;+ startsAt: Date | null;+ endsAt: Date | null;+}++export type AnnouncementInputError =+ | "INVALID_BODY_PAYLOAD"+ | "TITLE_REQUIRED"+ | "TITLE_TOO_LONG"+ | "BODY_TOO_LONG"+ | "INVALID_TONE"+ | "NO_PLACEMENT"+ | "INVALID_STARTS_AT"+ | "INVALID_ENDS_AT"+ | "INVALID_WINDOW";++/** undefined means "present but unparseable", which the caller rejects. */+function parseTimestamp(value: unknown): Date | null | undefined {+ if (value === null || value === undefined || value === "") return null;+ if (typeof value !== "string" && typeof value !== "number") return undefined;+ const date = new Date(value);+ return Number.isNaN(date.getTime()) ? undefined : date;+}++export function sanitizeAnnouncementInput(+ raw: unknown+): { ok: true; value: AnnouncementInput } | { ok: false; error: AnnouncementInputError } {+ if (typeof raw !== "object" || raw === null) {+ return { ok: false, error: "INVALID_BODY_PAYLOAD" };+ }+ const input = raw as Record<string, unknown>;++ const title = typeof input.title === "string" ? input.title.trim() : "";+ if (!title) return { ok: false, error: "TITLE_REQUIRED" };+ if (title.length > TITLE_MAX_LENGTH) return { ok: false, error: "TITLE_TOO_LONG" };++ const trimmedBody = typeof input.body === "string" ? input.body.trim() : "";+ if (trimmedBody.length > BODY_MAX_LENGTH) return { ok: false, error: "BODY_TOO_LONG" };+ const body = trimmedBody === "" ? null : trimmedBody;++ if (!ANNOUNCEMENT_TONES.includes(input.tone as AnnouncementTone)) {+ return { ok: false, error: "INVALID_TONE" };+ }+ const tone = input.tone as AnnouncementTone;++ const showOnAuth = input.showOnAuth === true;+ const showOnDashboard = input.showOnDashboard === true;+ // An announcement with neither placement can never be seen; that is a mistake,+ // not a configuration.+ if (!showOnAuth && !showOnDashboard) return { ok: false, error: "NO_PLACEMENT" };++ const enabled = input.enabled !== false;++ const startsAt = parseTimestamp(input.startsAt);+ if (startsAt === undefined) return { ok: false, error: "INVALID_STARTS_AT" };+ const endsAt = parseTimestamp(input.endsAt);+ if (endsAt === undefined) return { ok: false, error: "INVALID_ENDS_AT" };+ if (startsAt && endsAt && endsAt.getTime() <= startsAt.getTime()) {+ return { ok: false, error: "INVALID_WINDOW" };+ }++ return {+ ok: true,+ value: { title, body, tone, showOnAuth, showOnDashboard, enabled, startsAt, endsAt },+ };+}++export async function getVisibleAnnouncements(+ placement: AnnouncementPlacement+): Promise<PublicAnnouncement[]> {+ const now = new Date();+ const placementColumn =+ placement === "auth" ? announcements.showOnAuth : announcements.showOnDashboard;++ return db+ .select({+ id: announcements.id,+ title: announcements.title,+ body: announcements.body,+ tone: announcements.tone,+ })+ .from(announcements)+ .where(+ and(+ eq(announcements.enabled, true),+ eq(placementColumn, true),+ or(isNull(announcements.startsAt), lte(announcements.startsAt, now)),+ or(isNull(announcements.endsAt), gt(announcements.endsAt, now))+ )+ )+ .orderBy(desc(announcements.createdAt));+}diff --git a/lib/audit-log.ts b/lib/audit-log.tsindex f30e7ba..66eb31f 100644--- a/lib/audit-log.ts+++ b/lib/audit-log.ts@@ -179,6 +179,30 @@ export interface AdminTelemetryConsentMetadata {schemaVersion: number;}+// Title only: an announcement body can be long and an audit log is exportable.+interface AuditedAnnouncement {+ title: string;+ tone: string;+ showOnAuth: boolean;+ showOnDashboard: boolean;+ enabled: boolean;+ startsAt: Date | null;+ endsAt: Date | null;+}++export interface AdminAnnouncementCreatedMetadata {+ announcement: AuditedAnnouncement;+}++export interface AdminAnnouncementUpdatedMetadata {+ before: AuditedAnnouncement;+ after: AuditedAnnouncement;+}++export interface AdminAnnouncementDeletedMetadata {+ title: string;+}+// Outcome only: the endpoint URL can be private and must not reach an exportable log.// Shared by the admin button and the daily timer.export interface TelemetrySendMetadata {@@ -266,6 +290,9 @@ export type AuditLogMetadata =| AdminPasswordResetMetadata| AdminSystemSettingsUpdatedMetadata| AdminTelemetryConsentMetadata+ | AdminAnnouncementCreatedMetadata+ | AdminAnnouncementUpdatedMetadata+ | AdminAnnouncementDeletedMetadata| TelemetrySendMetadata| CalendarBundleCreatedMetadata| CalendarBundleUpdatedMetadatadiff --git a/lib/db/schema.ts b/lib/db/schema.tsindex 033a917..4d54b2d 100644--- a/lib/db/schema.ts+++ b/lib/db/schema.ts@@ -558,6 +558,36 @@ export const calendarNotes = sqliteTable("calendar_notes", {.default(sql`CURRENT_TIMESTAMP`),});+export const announcements = sqliteTable("announcements", {+ id: text("id")+ .primaryKey()+ .$defaultFn(() => crypto.randomUUID()),+ title: text("title").notNull(),+ body: text("body"),+ tone: text("tone", { enum: ["info", "warning", "danger"] })+ .notNull()+ .default("info"),+ showOnAuth: integer("show_on_auth", { mode: "boolean" }).notNull().default(true),+ showOnDashboard: integer("show_on_dashboard", { mode: "boolean" })+ .notNull()+ .default(true),+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),+ // Both null means the enabled flag alone decides visibility.+ startsAt: integer("starts_at", { mode: "timestamp" }),+ endsAt: integer("ends_at", { mode: "timestamp" }),+ // null = no known creator, see calendarNotes.createdBy above.+ createdBy: text("created_by").references(() => user.id, {+ onDelete: "set null",+ }),+ createdAt: integer("created_at", { mode: "timestamp" })+ .notNull()+ .default(sql`CURRENT_TIMESTAMP`),+ updatedAt: integer("updated_at", { mode: "timestamp" })+ .notNull()+ .default(sql`CURRENT_TIMESTAMP`)+ .$onUpdate(() => new Date()),+});+export const syncLogs = sqliteTable("sync_logs", {id: text("id").primaryKey()@@ -915,6 +945,13 @@ export const auditLogsRelations = relations(auditLogs, ({ one }) => ({}),}));+export const announcementsRelations = relations(announcements, ({ one }) => ({+ createdByUser: one(user, {+ fields: [announcements.createdBy],+ references: [user.id],+ }),+}));+export const calendarAccessTokensRelations = relations(calendarAccessTokens,({ one }) => ({diff --git a/lib/query-keys.ts b/lib/query-keys.tsindex 7d663f5..d545dc9 100644--- a/lib/query-keys.ts+++ b/lib/query-keys.ts@@ -43,6 +43,10 @@ export const queryKeys = {byCalendar: (calendarId: string) => ["external-syncs", calendarId] as const,logs: (calendarId: string) => ["sync-logs", calendarId] as const,},+ announcements: {+ all: ["announcements"] as const,+ byPlacement: (placement: string) => ["announcements", placement] as const,+ },// Admin Dataadmin: {@@ -65,6 +69,7 @@ export const queryKeys = {auditLogsAll: ["admin", "audit-logs"] as const,auditLogs: (filters?: object) => ["admin", "audit-logs", filters] as const,systemSettings: ["admin", "system-settings"] as const,+ announcements: ["admin", "announcements"] as const,telemetryPayload: (profile: string) =>["admin", "telemetry-payload", profile] as const,},diff --git a/lib/rate-limiter.ts b/lib/rate-limiter.tsindex d0bee22..e1dec5f 100644--- a/lib/rate-limiter.ts+++ b/lib/rate-limiter.ts@@ -206,6 +206,19 @@ const config = {parseInt(process.env.RATE_LIMIT_CUSTOM_FIELD_MUTATIONS_WINDOW || "3600", 10) *1000, // 1 hour},+ // Read-only, unauthenticated: every page load on /login and the dashboard hits+ // it, so the ceiling is high -- it exists to stop scraping loops, not traffic.+ announcements: {+ requests: parseInt(process.env.RATE_LIMIT_ANNOUNCEMENTS_REQUESTS || "120", 10),+ windowMs:+ parseInt(process.env.RATE_LIMIT_ANNOUNCEMENTS_WINDOW || "60", 10) * 1000, // 1 minute+ },+ // Announcement create/update/delete from the admin panel -- low volume by nature.+ adminAnnouncementMutations: {+ requests: parseInt(process.env.RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS || "20", 10),+ windowMs:+ parseInt(process.env.RATE_LIMIT_ADMIN_ANNOUNCEMENT_MUTATIONS_WINDOW || "60", 10) * 1000, // 1 minute+ },// Admin telemetry payload preview; the collector's own cache keeps repeat// calls cheap, this just bounds the burst.telemetryPayload: {@@ -247,6 +260,8 @@ const limitsByType = {"admin-calendar-mutations": config.adminCalendarMutations,"bundle-mutations": config.bundleMutations,"custom-field-mutations": config.customFieldMutations,+ announcements: config.announcements,+ "admin-announcement-mutations": config.adminAnnouncementMutations,"telemetry-payload": config.telemetryPayload,"telemetry-send": config.telemetrySend,} as const;diff --git a/messages/cs.json b/messages/cs.jsonindex 073d0f5..da3bd78 100644--- a/messages/cs.json+++ b/messages/cs.json@@ -496,6 +496,7 @@"usersMenu": "Uživatelé","calendarsMenu": "Kalendáře","auditLogs": "Protokoly auditu",+ "announcementsMenu": "Oznámení","backToApp": "Zpět do aplikace","superadminBadge": "Superadmin","expandSidebar": "Rozbalit postranní panel",@@ -687,6 +688,53 @@"sendSuccess": "Telemetrie odeslána","sendFailed": "Odeslání se nezdařilo. Telemetrický server je nedostupný nebo požadavek odmítl.","sendUnavailable": "Odeslání není možné: telemetrie je vypnutá, souhlas je zastaralý nebo jde o vývojové sestavení."+ },+ "announcements": {+ "title": "Oznámení",+ "description": "Upozornění zobrazená všem na přihlašovacích stránkách a v přehledu.",+ "create": "Nové oznámení",+ "edit": "Upravit",+ "delete": "Smazat",+ "empty": "Zatím žádná oznámení",+ "emptyHint": "Vytvořte oznámení, abyste oslovili všechny uživatele této instance.",+ "statusActive": "Aktivní",+ "statusScheduled": "Naplánováno",+ "statusExpired": "Vypršelo",+ "statusOff": "Vypnuto",+ "toneInfo": "Info",+ "toneWarning": "Varování",+ "toneDanger": "Kritické",+ "showOnAuth": "Přihlašovací stránky",+ "showOnDashboard": "Přehled",+ "createdBy": "od {name}",+ "unknownAuthor": "Neznámý",+ "saveError": "Oznámení se nepodařilo uložit",+ "deleteError": "Oznámení se nepodařilo smazat",+ "createTitle": "Nové oznámení",+ "editTitle": "Upravit oznámení",+ "formDescription": "Titulek a text se zobrazí přesně tak, jak je zde zadáte — nepřekládají se.",+ "fieldTitle": "Titulek",+ "fieldTitlePlaceholder": "např. Údržba v sobotu",+ "fieldBody": "Text",+ "fieldBodyPlaceholder": "Nepovinný text s podrobnostmi",+ "fieldTone": "Typ",+ "showOnAuthHint": "Zobrazí se na přihlašovací a registrační stránce, i bez účtu.",+ "showOnDashboardHint": "Zobrazí se nad kalendářem všem přihlášeným uživatelům i hostům.",+ "enabled": "Aktivní",+ "enabledHint": "Vypnuté oznámení se nikde nezobrazí, bez ohledu na časové okno.",+ "startsAt": "Zobrazit od",+ "endsAt": "Zobrazit do",+ "windowHint": "Nepovinné. Bez okna rozhoduje jen přepínač Aktivní.",+ "errorTitleRequired": "Zadejte titulek",+ "errorNoPlacement": "Vyberte alespoň jedno místo zobrazení",+ "errorWindow": "Konec musí být později než začátek",+ "deleteTitle": "Smazat oznámení",+ "deleteDescription": "Oznámení bude trvale odstraněno a okamžitě zmizí všem.",+ "deleteWarning": "Tento krok nelze vrátit zpět.",+ "deleteUnderstood": "Rozumím, že oznámení bude trvale odstraněno.",+ "deleteConfirmationLabel": "Zadejte titulek pro potvrzení",+ "deleteConfirmationHint": "Zadejte „{name}“ pro odemčení mazání.",+ "deleteConfirm": "Trvale smazat"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Logy",+ "announcementsShort": "Oznámení","breadcrumb": "Drobečková navigace"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# kalendář smazán} few {# kalendáře smazány} other {# kalendářů smazáno}}","logsDeleted": "{count, plural, one {# záznam protokolu smazán} few {# záznamy protokolu smazány} other {# záznamů protokolu smazáno}}","systemSettingsUpdated": "Systémová nastavení změněna",+ "announcementCreated": "Oznámení „{title}“ vytvořeno",+ "announcementUpdated": "Oznámení „{title}“ upraveno",+ "announcementDeleted": "Oznámení „{title}“ smazáno","calendarUpdated": "Kalendář „{calendar}“ upraven","calendarDeleted": "Kalendář „{calendar}“ smazán","calendarCreated": "Kalendář „{calendar}“ vytvořen",@@ -1292,5 +1344,8 @@"accept": "Odeslat","decline": "Neodesílat"}+ },+ "announcements": {+ "dismiss": "Skrýt oznámení"}}diff --git a/messages/de.json b/messages/de.jsonindex f87de65..d7a48b9 100644--- a/messages/de.json+++ b/messages/de.json@@ -496,6 +496,7 @@"usersMenu": "Benutzer","calendarsMenu": "Kalender","auditLogs": "Audit-Logs",+ "announcementsMenu": "Ankündigungen","backToApp": "Zurück zur App","superadminBadge": "Superadmin","expandSidebar": "Seitenleiste ausklappen",@@ -687,6 +688,53 @@"sendSuccess": "Telemetriedaten gesendet","sendFailed": "Senden fehlgeschlagen. Der Telemetrie-Server ist nicht erreichbar oder hat die Anfrage abgelehnt.","sendUnavailable": "Senden nicht möglich: Telemetrie ist aus, die Zustimmung ist veraltet oder dies ist ein Entwicklungs-Build."+ },+ "announcements": {+ "title": "Ankündigungen",+ "description": "Hinweise, die allen auf den Anmeldeseiten und im Dashboard angezeigt werden.",+ "create": "Neue Ankündigung",+ "edit": "Bearbeiten",+ "delete": "Löschen",+ "empty": "Noch keine Ankündigungen",+ "emptyHint": "Lege eine Ankündigung an, um alle Nutzer dieser Instanz zu erreichen.",+ "statusActive": "Aktiv",+ "statusScheduled": "Geplant",+ "statusExpired": "Abgelaufen",+ "statusOff": "Aus",+ "toneInfo": "Info",+ "toneWarning": "Warnung",+ "toneDanger": "Kritisch",+ "showOnAuth": "Anmeldeseiten",+ "showOnDashboard": "Dashboard",+ "createdBy": "von {name}",+ "unknownAuthor": "Unbekannt",+ "saveError": "Ankündigung konnte nicht gespeichert werden",+ "deleteError": "Ankündigung konnte nicht gelöscht werden",+ "createTitle": "Neue Ankündigung",+ "editTitle": "Ankündigung bearbeiten",+ "formDescription": "Titel und Text erscheinen genau so, wie du sie hier eingibst — sie werden nicht übersetzt.",+ "fieldTitle": "Titel",+ "fieldTitlePlaceholder": "z. B. Wartungsarbeiten am Samstag",+ "fieldBody": "Text",+ "fieldBodyPlaceholder": "Optionaler Fließtext mit den Details",+ "fieldTone": "Art",+ "showOnAuthHint": "Sichtbar auf der Anmelde- und Registrierungsseite, auch ohne Konto.",+ "showOnDashboardHint": "Sichtbar über dem Kalender für alle angemeldeten Nutzer und Gäste.",+ "enabled": "Aktiv",+ "enabledHint": "Ausgeschaltet wird die Ankündigung nirgends angezeigt, unabhängig vom Zeitfenster.",+ "startsAt": "Sichtbar ab",+ "endsAt": "Sichtbar bis",+ "windowHint": "Optional. Ohne Angabe entscheidet allein der Aktiv-Schalter.",+ "errorTitleRequired": "Bitte gib einen Titel ein",+ "errorNoPlacement": "Wähle mindestens einen Anzeigeort",+ "errorWindow": "Das Ende muss nach dem Beginn liegen",+ "deleteTitle": "Ankündigung löschen",+ "deleteDescription": "Die Ankündigung wird dauerhaft entfernt und verschwindet sofort für alle.",+ "deleteWarning": "Dieser Schritt kann nicht rückgängig gemacht werden.",+ "deleteUnderstood": "Ich habe verstanden, dass die Ankündigung endgültig gelöscht wird.",+ "deleteConfirmationLabel": "Titel zur Bestätigung eingeben",+ "deleteConfirmationHint": "Gib „{name}“ ein, um das Löschen freizuschalten.",+ "deleteConfirm": "Endgültig löschen"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Logs",+ "announcementsShort": "Ankündigungen","breadcrumb": "Navigationspfad"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# Kalender} other {# Kalender}} gelöscht","logsDeleted": "{count, plural, one {# Protokolleintrag} other {# Protokolleinträge}} gelöscht","systemSettingsUpdated": "Systemeinstellungen geändert",+ "announcementCreated": "Ankündigung „{title}“ erstellt",+ "announcementUpdated": "Ankündigung „{title}“ bearbeitet",+ "announcementDeleted": "Ankündigung „{title}“ gelöscht","calendarUpdated": "Kalender „{calendar}“ bearbeitet","calendarDeleted": "Kalender „{calendar}“ gelöscht","calendarCreated": "Kalender „{calendar}“ angelegt",@@ -1292,5 +1344,8 @@"accept": "Senden","decline": "Nicht senden"}+ },+ "announcements": {+ "dismiss": "Ankündigung ausblenden"}}diff --git a/messages/en.json b/messages/en.jsonindex 642ad21..374cc83 100644--- a/messages/en.json+++ b/messages/en.json@@ -496,6 +496,7 @@"usersMenu": "Users","calendarsMenu": "Calendars","auditLogs": "Audit Logs",+ "announcementsMenu": "Announcements","backToApp": "Back to App","superadminBadge": "Superadmin","expandSidebar": "Expand Sidebar",@@ -687,6 +688,53 @@"sendSuccess": "Telemetry sent","sendFailed": "Sending failed. The telemetry server is unreachable or rejected the request.","sendUnavailable": "Cannot send: telemetry is off, the consent is outdated, or this is a development build."+ },+ "announcements": {+ "title": "Announcements",+ "description": "Notices shown to everyone on the sign-in pages and the dashboard.",+ "create": "New announcement",+ "edit": "Edit",+ "delete": "Delete",+ "empty": "No announcements yet",+ "emptyHint": "Create an announcement to reach everyone on this instance.",+ "statusActive": "Active",+ "statusScheduled": "Scheduled",+ "statusExpired": "Expired",+ "statusOff": "Off",+ "toneInfo": "Info",+ "toneWarning": "Warning",+ "toneDanger": "Critical",+ "showOnAuth": "Sign-in pages",+ "showOnDashboard": "Dashboard",+ "createdBy": "by {name}",+ "unknownAuthor": "Unknown",+ "saveError": "Could not save the announcement",+ "deleteError": "Could not delete the announcement",+ "createTitle": "New announcement",+ "editTitle": "Edit announcement",+ "formDescription": "Title and text appear exactly as you type them — they are not translated.",+ "fieldTitle": "Title",+ "fieldTitlePlaceholder": "e.g. Maintenance on Saturday",+ "fieldBody": "Text",+ "fieldBodyPlaceholder": "Optional details",+ "fieldTone": "Type",+ "showOnAuthHint": "Visible on the sign-in and registration pages, even without an account.",+ "showOnDashboardHint": "Visible above the calendar for everyone signed in, and for guests.",+ "enabled": "Active",+ "enabledHint": "Switched off, the announcement is shown nowhere, whatever the time window says.",+ "startsAt": "Visible from",+ "endsAt": "Visible until",+ "windowHint": "Optional. Without a window, the active switch alone decides.",+ "errorTitleRequired": "Please enter a title",+ "errorNoPlacement": "Pick at least one place to show it",+ "errorWindow": "The end must be after the start",+ "deleteTitle": "Delete announcement",+ "deleteDescription": "The announcement is removed permanently and disappears for everyone immediately.",+ "deleteWarning": "This cannot be undone.",+ "deleteUnderstood": "I understand the announcement will be permanently deleted.",+ "deleteConfirmationLabel": "Type the title to confirm",+ "deleteConfirmationHint": "Type “{name}” to unlock deletion.",+ "deleteConfirm": "Delete permanently"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Logs",+ "announcementsShort": "Announcements","breadcrumb": "Breadcrumb"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# calendar} other {# calendars}} deleted","logsDeleted": "{count, plural, one {# log entry} other {# log entries}} deleted","systemSettingsUpdated": "System settings changed",+ "announcementCreated": "Announcement “{title}” created",+ "announcementUpdated": "Announcement “{title}” edited",+ "announcementDeleted": "Announcement “{title}” deleted","calendarUpdated": "Calendar “{calendar}” edited","calendarDeleted": "Calendar “{calendar}” deleted","calendarCreated": "Calendar “{calendar}” created",@@ -1292,5 +1344,8 @@"accept": "Send","decline": "Don't send"}+ },+ "announcements": {+ "dismiss": "Dismiss announcement"}}diff --git a/messages/es.json b/messages/es.jsonindex 3b031b0..7c36f65 100644--- a/messages/es.json+++ b/messages/es.json@@ -496,6 +496,7 @@"usersMenu": "Usuarios","calendarsMenu": "Calendarios","auditLogs": "Registros de auditoría",+ "announcementsMenu": "Anuncios","backToApp": "Volver a la App","superadminBadge": "Superadmin","expandSidebar": "Expandir barra lateral",@@ -687,6 +688,53 @@"sendSuccess": "Telemetría enviada","sendFailed": "Error al enviar. El servidor de telemetría no está accesible o rechazó la solicitud.","sendUnavailable": "No se puede enviar: la telemetría está desactivada, el consentimiento está desactualizado o es una compilación de desarrollo."+ },+ "announcements": {+ "title": "Anuncios",+ "description": "Avisos que se muestran a todos en las páginas de inicio de sesión y en el tablero.",+ "create": "Nuevo anuncio",+ "edit": "Editar",+ "delete": "Eliminar",+ "empty": "Aún no hay anuncios",+ "emptyHint": "Crea un anuncio para llegar a todos los usuarios de esta instancia.",+ "statusActive": "Activo",+ "statusScheduled": "Programado",+ "statusExpired": "Caducado",+ "statusOff": "Desactivado",+ "toneInfo": "Información",+ "toneWarning": "Advertencia",+ "toneDanger": "Crítico",+ "showOnAuth": "Páginas de inicio de sesión",+ "showOnDashboard": "Tablero",+ "createdBy": "por {name}",+ "unknownAuthor": "Desconocido",+ "saveError": "No se pudo guardar el anuncio",+ "deleteError": "No se pudo eliminar el anuncio",+ "createTitle": "Nuevo anuncio",+ "editTitle": "Editar anuncio",+ "formDescription": "El título y el texto aparecen exactamente como los escribes aquí: no se traducen.",+ "fieldTitle": "Título",+ "fieldTitlePlaceholder": "p. ej. Mantenimiento el sábado",+ "fieldBody": "Texto",+ "fieldBodyPlaceholder": "Texto opcional con los detalles",+ "fieldTone": "Tipo",+ "showOnAuthHint": "Visible en las páginas de inicio de sesión y registro, incluso sin cuenta.",+ "showOnDashboardHint": "Visible sobre el calendario para todos los usuarios conectados y los invitados.",+ "enabled": "Activo",+ "enabledHint": "Desactivado, el anuncio no se muestra en ningún lugar, sea cual sea la ventana de tiempo.",+ "startsAt": "Visible desde",+ "endsAt": "Visible hasta",+ "windowHint": "Opcional. Sin ventana, solo decide el interruptor de activo.",+ "errorTitleRequired": "Introduce un título",+ "errorNoPlacement": "Elige al menos un lugar donde mostrarlo",+ "errorWindow": "El final debe ser posterior al inicio",+ "deleteTitle": "Eliminar anuncio",+ "deleteDescription": "El anuncio se elimina permanentemente y desaparece de inmediato para todos.",+ "deleteWarning": "Esta acción no se puede deshacer.",+ "deleteUnderstood": "Entiendo que el anuncio se eliminará de forma permanente.",+ "deleteConfirmationLabel": "Escribe el título para confirmar",+ "deleteConfirmationHint": "Escribe «{name}» para habilitar la eliminación.",+ "deleteConfirm": "Eliminar definitivamente"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Registros",+ "announcementsShort": "Anuncios","breadcrumb": "Ruta de navegación"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# calendario eliminado} other {# calendarios eliminados}}","logsDeleted": "{count, plural, one {# entrada de registro eliminada} other {# entradas de registro eliminadas}}","systemSettingsUpdated": "Configuración del sistema modificada",+ "announcementCreated": "Anuncio «{title}» creado",+ "announcementUpdated": "Anuncio «{title}» editado",+ "announcementDeleted": "Anuncio «{title}» eliminado","calendarUpdated": "Calendario «{calendar}» editado","calendarDeleted": "Calendario «{calendar}» eliminado","calendarCreated": "Calendario «{calendar}» creado",@@ -1292,5 +1344,8 @@"accept": "Enviar","decline": "No enviar"}+ },+ "announcements": {+ "dismiss": "Ocultar anuncio"}}diff --git a/messages/fr.json b/messages/fr.jsonindex 8440380..ed538af 100755--- a/messages/fr.json+++ b/messages/fr.json@@ -496,6 +496,7 @@"usersMenu": "Utilisateurs","calendarsMenu": "Calendriers","auditLogs": "Journaux d'audit",+ "announcementsMenu": "Annonces","backToApp": "Retour à l'application","superadminBadge": "Superadmin","expandSidebar": "Développer la barre latérale",@@ -687,6 +688,53 @@"sendSuccess": "Télémétrie envoyée","sendFailed": "Échec de l'envoi. Le serveur de télémétrie est injoignable ou a refusé la requête.","sendUnavailable": "Envoi impossible : la télémétrie est désactivée, le consentement est obsolète ou il s'agit d'une version de développement."+ },+ "announcements": {+ "title": "Annonces",+ "description": "Messages affichés à tous sur les pages de connexion et le tableau de bord.",+ "create": "Nouvelle annonce",+ "edit": "Modifier",+ "delete": "Supprimer",+ "empty": "Aucune annonce pour l'instant",+ "emptyHint": "Créez une annonce pour joindre tous les utilisateurs de cette instance.",+ "statusActive": "Active",+ "statusScheduled": "Planifiée",+ "statusExpired": "Expirée",+ "statusOff": "Désactivée",+ "toneInfo": "Info",+ "toneWarning": "Avertissement",+ "toneDanger": "Critique",+ "showOnAuth": "Pages de connexion",+ "showOnDashboard": "Tableau de bord",+ "createdBy": "par {name}",+ "unknownAuthor": "Inconnu",+ "saveError": "Impossible d'enregistrer l'annonce",+ "deleteError": "Impossible de supprimer l'annonce",+ "createTitle": "Nouvelle annonce",+ "editTitle": "Modifier l'annonce",+ "formDescription": "Le titre et le texte apparaissent exactement comme vous les saisissez ici : ils ne sont pas traduits.",+ "fieldTitle": "Titre",+ "fieldTitlePlaceholder": "p. ex. Maintenance samedi",+ "fieldBody": "Texte",+ "fieldBodyPlaceholder": "Texte optionnel avec les détails",+ "fieldTone": "Type",+ "showOnAuthHint": "Visible sur les pages de connexion et d'inscription, même sans compte.",+ "showOnDashboardHint": "Visible au-dessus du calendrier pour tous les utilisateurs connectés et les invités.",+ "enabled": "Active",+ "enabledHint": "Désactivée, l'annonce n'est affichée nulle part, quelle que soit la période définie.",+ "startsAt": "Visible à partir de",+ "endsAt": "Visible jusqu'à",+ "windowHint": "Facultatif. Sans période définie, seul l'interrupteur Active décide.",+ "errorTitleRequired": "Veuillez saisir un titre",+ "errorNoPlacement": "Choisissez au moins un endroit où l'afficher",+ "errorWindow": "La fin doit être après le début",+ "deleteTitle": "Supprimer l'annonce",+ "deleteDescription": "L'annonce est supprimée définitivement et disparaît immédiatement pour tout le monde.",+ "deleteWarning": "Cette action est irréversible.",+ "deleteUnderstood": "Je comprends que l'annonce sera supprimée définitivement.",+ "deleteConfirmationLabel": "Saisissez le titre pour confirmer",+ "deleteConfirmationHint": "Saisissez « {name} » pour débloquer la suppression.",+ "deleteConfirm": "Supprimer définitivement"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Journaux",+ "announcementsShort": "Annonces","breadcrumb": "Fil d’Ariane"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# calendrier supprimé} other {# calendriers supprimés}}","logsDeleted": "{count, plural, one {# entrée de journal supprimée} other {# entrées de journal supprimées}}","systemSettingsUpdated": "Paramètres système modifiés",+ "announcementCreated": "Annonce « {title} » créée",+ "announcementUpdated": "Annonce « {title} » modifiée",+ "announcementDeleted": "Annonce « {title} » supprimée","calendarUpdated": "Calendrier « {calendar} » modifié","calendarDeleted": "Calendrier « {calendar} » supprimé","calendarCreated": "Calendrier « {calendar} » créé",@@ -1292,5 +1344,8 @@"accept": "Envoyer","decline": "Ne pas envoyer"}+ },+ "announcements": {+ "dismiss": "Masquer l'annonce"}}diff --git a/messages/it.json b/messages/it.jsonindex 51f9779..afe7f0c 100644--- a/messages/it.json+++ b/messages/it.json@@ -496,6 +496,7 @@"usersMenu": "Utenti","calendarsMenu": "Calendari","auditLogs": "Log di Audit",+ "announcementsMenu": "Annunci","backToApp": "Torna all'App","superadminBadge": "Superadmin","expandSidebar": "Espandi Barra Laterale",@@ -687,6 +688,53 @@"sendSuccess": "Telemetria inviata","sendFailed": "Invio non riuscito. Il server di telemetria non è raggiungibile o ha rifiutato la richiesta.","sendUnavailable": "Impossibile inviare: la telemetria è disattivata, il consenso non è aggiornato oppure si tratta di una build di sviluppo."+ },+ "announcements": {+ "title": "Annunci",+ "description": "Avvisi mostrati a tutti nelle pagine di accesso e nella dashboard.",+ "create": "Nuovo annuncio",+ "edit": "Modifica",+ "delete": "Elimina",+ "empty": "Nessun annuncio ancora",+ "emptyHint": "Crea un annuncio per raggiungere tutti gli utenti di questa istanza.",+ "statusActive": "Attivo",+ "statusScheduled": "Programmato",+ "statusExpired": "Scaduto",+ "statusOff": "Disattivato",+ "toneInfo": "Info",+ "toneWarning": "Avviso",+ "toneDanger": "Critico",+ "showOnAuth": "Pagine di accesso",+ "showOnDashboard": "Dashboard",+ "createdBy": "di {name}",+ "unknownAuthor": "Sconosciuto",+ "saveError": "Impossibile salvare l'annuncio",+ "deleteError": "Impossibile eliminare l'annuncio",+ "createTitle": "Nuovo annuncio",+ "editTitle": "Modifica annuncio",+ "formDescription": "Titolo e testo compaiono esattamente come li scrivi qui: non vengono tradotti.",+ "fieldTitle": "Titolo",+ "fieldTitlePlaceholder": "es. Manutenzione sabato",+ "fieldBody": "Testo",+ "fieldBodyPlaceholder": "Testo opzionale con i dettagli",+ "fieldTone": "Tipo",+ "showOnAuthHint": "Visibile nelle pagine di accesso e registrazione, anche senza account.",+ "showOnDashboardHint": "Visibile sopra il calendario per tutti gli utenti connessi e gli ospiti.",+ "enabled": "Attivo",+ "enabledHint": "Se disattivato, l'annuncio non viene mostrato da nessuna parte, indipendentemente dalla finestra temporale.",+ "startsAt": "Visibile da",+ "endsAt": "Visibile fino a",+ "windowHint": "Opzionale. Senza una finestra, decide solo l'interruttore Attivo.",+ "errorTitleRequired": "Inserisci un titolo",+ "errorNoPlacement": "Scegli almeno un punto in cui mostrarlo",+ "errorWindow": "La fine deve essere successiva all'inizio",+ "deleteTitle": "Elimina annuncio",+ "deleteDescription": "L'annuncio viene rimosso definitivamente e scompare immediatamente per tutti.",+ "deleteWarning": "Questa azione non può essere annullata.",+ "deleteUnderstood": "Ho capito che l'annuncio verrà eliminato definitivamente.",+ "deleteConfirmationLabel": "Digita il titolo per confermare",+ "deleteConfirmationHint": "Digita «{name}» per abilitare l'eliminazione.",+ "deleteConfirm": "Elimina definitivamente"}},"appearance": {@@ -1016,6 +1064,7 @@},"adminShell": {"logsShort": "Log",+ "announcementsShort": "Annunci","breadcrumb": "Percorso di navigazione"},"adminDashboard": {@@ -1065,6 +1114,9 @@"calendarsDeleted": "{count, plural, one {# calendario eliminato} other {# calendari eliminati}}","logsDeleted": "{count, plural, one {# voce di log eliminata} other {# voci di log eliminate}}","systemSettingsUpdated": "Impostazioni di sistema modificate",+ "announcementCreated": "Annuncio «{title}» creato",+ "announcementUpdated": "Annuncio «{title}» modificato",+ "announcementDeleted": "Annuncio «{title}» eliminato","calendarUpdated": "Calendario «{calendar}» modificato","calendarDeleted": "Calendario «{calendar}» eliminato","calendarCreated": "Calendario «{calendar}» creato",@@ -1292,5 +1344,8 @@"accept": "Invia","decline": "Non inviare"}+ },+ "announcements": {+ "dismiss": "Nascondi annuncio"}}diff --git a/proxy.ts b/proxy.tsindex 3806032..4c32339 100644--- a/proxy.ts+++ b/proxy.ts@@ -297,6 +297,7 @@ export async function proxy(request: NextRequest) {"/api/auth", // Better Auth API routes"/api/version", // Version info (always public)"/api/releases", // Changelog/releases (always public)+ "/api/announcements", // Instance announcements (shown on the logged-out auth pages)"/api/health", // Health check endpoint"/manifest.json", // Browsers fetch the PWA manifest without cookies];