Your favorite shift management application!
feat: add shift signups and calendar member visibility (#198)
panteL7d1ba3fe2205
diff --git a/app/api/calendars/[id]/members/route.ts b/app/api/calendars/[id]/members/route.tsnew file mode 100644index 0000000..dc8beaa--- /dev/null+++ b/app/api/calendars/[id]/members/route.ts@@ -0,0 +1,41 @@+import { NextRequest, NextResponse } from "next/server";+import { getSessionUser } from "@/lib/auth/sessions";+import { canEditCalendar, getCalendarMembers } from "@/lib/auth/permissions";++// GET minimal member list (owner + shares) for a calendar.+// Used to pick who to add to a shift's signup list — deliberately narrower+// than /api/users/search, which is an admin-only global directory lookup.+export async function GET(+ request: NextRequest,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id: calendarId } = await params;+ const user = await getSessionUser(request.headers);++ const hasAccess = await canEditCalendar(user?.id, calendarId);+ if (!hasAccess) {+ return NextResponse.json(+ { error: "Insufficient permissions. Write access required." },+ { status: 403 }+ );+ }++ const members = await getCalendarMembers(calendarId);++ if (!members) {+ return NextResponse.json(+ { error: "Calendar not found" },+ { status: 404 }+ );+ }++ return NextResponse.json(members);+ } catch (error) {+ console.error("Failed to fetch calendar members:", error);+ return NextResponse.json(+ { error: "Failed to fetch calendar members" },+ { status: 500 }+ );+ }+}diff --git a/app/api/calendars/[id]/route.ts b/app/api/calendars/[id]/route.tsindex c2d38b9..4f83757 100644--- a/app/api/calendars/[id]/route.ts+++ b/app/api/calendars/[id]/route.ts@@ -79,7 +79,14 @@ export async function PATCH(const { id } = await params;const user = await getSessionUser(request.headers);const body = await request.json();- const { name, color, guestPermission, viewSettings } = body;+ const {+ name,+ color,+ guestPermission,+ viewSettings,+ allowSelfSignup,+ signupsEnabled,+ } = body;if (viewSettings !== undefined &&@@ -140,6 +147,20 @@ export async function PATCH(oldGuestPermission = existingCalendar.guestPermission;}}+ if (+ typeof allowSelfSignup === "boolean" &&+ allowSelfSignup !== existingCalendar.allowSelfSignup+ ) {+ updateData.allowSelfSignup = allowSelfSignup;+ changes.push("allowSelfSignup");+ }+ if (+ typeof signupsEnabled === "boolean" &&+ signupsEnabled !== existingCalendar.signupsEnabled+ ) {+ updateData.signupsEnabled = signupsEnabled;+ changes.push("signupsEnabled");+ }if (viewSettings === null && existingCalendar.viewSettings !== null) {updateData.viewSettings = null;changes.push("viewSettings");diff --git a/app/api/calendars/route.ts b/app/api/calendars/route.tsindex 5fa9493..e37be6c 100644--- a/app/api/calendars/route.ts+++ b/app/api/calendars/route.ts@@ -38,6 +38,8 @@ export async function GET(request: Request) {color: calendars.color,ownerId: calendars.ownerId,guestPermission: calendars.guestPermission,+ allowSelfSignup: calendars.allowSelfSignup,+ signupsEnabled: calendars.signupsEnabled,viewSettings: calendars.viewSettings,createdAt: calendars.createdAt,updatedAt: calendars.updatedAt,diff --git a/app/api/presets/[id]/route.ts b/app/api/presets/[id]/route.tsindex ecd7714..70daeef 100644--- a/app/api/presets/[id]/route.ts+++ b/app/api/presets/[id]/route.ts@@ -74,6 +74,7 @@ export async function PATCH(isSecondary,isAllDay,hideFromStats,+ defaultSignupCapacity,} = body;// groupName: undefined leaves it unchanged, null explicitly clears it,@@ -136,6 +137,10 @@ export async function PATCH(isSecondary: isSecondary !== undefined ? isSecondary : undefined,isAllDay: isAllDay !== undefined ? isAllDay : undefined,hideFromStats: hideFromStats !== undefined ? hideFromStats : undefined,+ defaultSignupCapacity:+ defaultSignupCapacity !== undefined+ ? defaultSignupCapacity+ : undefined,updatedAt: new Date(),}).where(eq(shiftPresets.id, id))diff --git a/app/api/presets/route.ts b/app/api/presets/route.tsindex 07d699b..687eb62 100644--- a/app/api/presets/route.ts+++ b/app/api/presets/route.ts@@ -73,6 +73,7 @@ export async function POST(request: NextRequest) {isSecondary,isAllDay,hideFromStats,+ defaultSignupCapacity,} = body;if (!calendarId || !title) {@@ -130,6 +131,10 @@ export async function POST(request: NextRequest) {isSecondary: isSecondary || false,isAllDay: isAllDay || false,hideFromStats: hideFromStats || false,+ defaultSignupCapacity:+ typeof defaultSignupCapacity === "number"+ ? defaultSignupCapacity+ : null,order: maxOrder + 1,}).returning();diff --git a/app/api/shifts/[id]/route.ts b/app/api/shifts/[id]/route.tsindex a09e88b..9311361 100644--- a/app/api/shifts/[id]/route.ts+++ b/app/api/shifts/[id]/route.ts@@ -27,6 +27,7 @@ export async function GET(notes: shifts.notes,isAllDay: shifts.isAllDay,isSecondary: shifts.isSecondary,+ signupCapacity: shifts.signupCapacity,createdAt: shifts.createdAt,updatedAt: shifts.updatedAt,calendar: {@@ -165,6 +166,12 @@ export async function PUT(notes: body.notes ?? existingShift.notes,isAllDay: body.isAllDay ?? existingShift.isAllDay,presetId: body.presetId ?? existingShift.presetId,+ signupCapacity:+ typeof body.signupCapacity === "number"+ ? body.signupCapacity+ : body.signupCapacity === null+ ? null+ : existingShift.signupCapacity,updatedAt: new Date(),}).where(eq(shifts.id, id))diff --git a/app/api/shifts/[id]/signups/[userId]/route.ts b/app/api/shifts/[id]/signups/[userId]/route.tsnew file mode 100644index 0000000..01468f0--- /dev/null+++ b/app/api/shifts/[id]/signups/[userId]/route.ts@@ -0,0 +1,55 @@+import { NextResponse } from "next/server";+import { db } from "@/lib/db";+import { shiftSignups } from "@/lib/db/schema";+import { eq, and } from "drizzle-orm";+import { getSessionUser } from "@/lib/auth/sessions";+import { getShiftSignupPermission } from "@/lib/auth/permissions";+import { canActOnSignup, getShiftOrNull } from "@/lib/shift-signups";++// DELETE withdraw a user from a shift's signup list+export async function DELETE(+ request: Request,+ { params }: { params: Promise<{ id: string; userId: string }> }+) {+ try {+ const { id: shiftId, userId: targetUserId } = await params;+ const user = await getSessionUser(request.headers);++ if (!user) {+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 });+ }++ const shift = await getShiftOrNull(shiftId);+ if (!shift) {+ return NextResponse.json({ error: "Shift not found" }, { status: 404 });+ }++ const permission = await getShiftSignupPermission(+ user.id,+ shift.calendarId+ );+ if (!canActOnSignup(permission, user.id, targetUserId)) {+ return NextResponse.json(+ { error: "Insufficient permissions" },+ { status: 403 }+ );+ }++ await db+ .delete(shiftSignups)+ .where(+ and(+ eq(shiftSignups.shiftId, shiftId),+ eq(shiftSignups.userId, targetUserId)+ )+ );++ return NextResponse.json({ success: true });+ } catch (error) {+ console.error("Failed to remove shift signup:", error);+ return NextResponse.json(+ { error: "Failed to remove shift signup" },+ { status: 500 }+ );+ }+}diff --git a/app/api/shifts/[id]/signups/route.ts b/app/api/shifts/[id]/signups/route.tsnew file mode 100644index 0000000..a13519d--- /dev/null+++ b/app/api/shifts/[id]/signups/route.ts@@ -0,0 +1,84 @@+import { NextResponse } from "next/server";+import { getSessionUser } from "@/lib/auth/sessions";+import { canViewCalendar } from "@/lib/auth/permissions";+import { addShiftSignup, getShiftOrNull, getShiftSignupUsers } from "@/lib/shift-signups";++// GET all signups for a shift+export async function GET(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id: shiftId } = await params;+ const user = await getSessionUser(request.headers);++ const shift = await getShiftOrNull(shiftId);+ if (!shift) {+ return NextResponse.json({ error: "Shift not found" }, { status: 404 });+ }++ const hasAccess = await canViewCalendar(user?.id, shift.calendarId);+ if (!hasAccess) {+ return NextResponse.json(+ { error: "Insufficient permissions" },+ { status: 403 }+ );+ }++ const signups = await getShiftSignupUsers(shiftId);+ return NextResponse.json(signups);+ } catch (error) {+ console.error("Failed to fetch shift signups:", error);+ return NextResponse.json(+ { error: "Failed to fetch shift signups" },+ { status: 500 }+ );+ }+}++// POST sign a user up for a shift. Omitting userId signs the caller up.+export async function POST(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id: shiftId } = await params;+ const user = await getSessionUser(request.headers);++ if (!user) {+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 });+ }++ const shift = await getShiftOrNull(shiftId);+ if (!shift) {+ return NextResponse.json({ error: "Shift not found" }, { status: 404 });+ }++ const body = await request.json().catch(() => ({}));+ const targetUserId: string = body.userId || user.id;++ const existing = await getShiftSignupUsers(shiftId);+ const existingIds = new Set(existing.map((s) => s.id));++ const result = await addShiftSignup(+ shiftId,+ shift.calendarId,+ user.id,+ targetUserId,+ existingIds,+ shift.signupCapacity+ );+ if (!result.ok) {+ return NextResponse.json({ error: result.error }, { status: result.status });+ }++ const signups = await getShiftSignupUsers(shiftId);+ return NextResponse.json(signups, { status: 201 });+ } catch (error) {+ console.error("Failed to create shift signup:", error);+ return NextResponse.json(+ { error: "Failed to create shift signup" },+ { status: 500 }+ );+ }+}diff --git a/app/api/shifts/route.ts b/app/api/shifts/route.tsindex 4292fd0..6cf273f 100644--- a/app/api/shifts/route.ts+++ b/app/api/shifts/route.ts@@ -4,7 +4,9 @@ import { calendars, shifts, externalSyncs } from "@/lib/db/schema";import { eq, and, gte, lte, or, isNull } from "drizzle-orm";import { getSessionUser } from "@/lib/auth/sessions";import { canViewCalendar, canEditCalendar } from "@/lib/auth/permissions";+import { addShiftSignup, withSignups } from "@/lib/shift-signups";import { parseLocalDate } from "@/lib/date-utils";+import type { CalendarMember } from "@/lib/types";// GET shifts for a calendar (with optional date filter)export async function GET(request: Request) {@@ -56,6 +58,7 @@ export async function GET(request: Request) {notes: shifts.notes,isAllDay: shifts.isAllDay,isSecondary: shifts.isSecondary,+ signupCapacity: shifts.signupCapacity,syncedFromExternal: shifts.syncedFromExternal,externalSyncId: shifts.externalSyncId,createdAt: shifts.createdAt,@@ -94,7 +97,7 @@ export async function GET(request: Request) {or(isNull(shifts.externalSyncId), eq(externalSyncs.isHidden, false))));- return NextResponse.json(result);+ return NextResponse.json(await withSignups(result));}const result = await query.where(@@ -104,7 +107,7 @@ export async function GET(request: Request) {or(isNull(shifts.externalSyncId), eq(externalSyncs.isHidden, false))));- return NextResponse.json(result);+ return NextResponse.json(await withSignups(result));} catch (error) {console.error("Failed to fetch shifts:", error);return NextResponse.json(@@ -129,6 +132,8 @@ export async function POST(request: Request) {presetId,isAllDay,isSecondary,+ signupCapacity,+ signupUserIds,} = body;if (!calendarId || !date || !title) {@@ -185,12 +190,39 @@ export async function POST(request: Request) {notes: notes || null,isAllDay: isAllDay || false,isSecondary: isSecondary || false,+ signupCapacity:+ typeof signupCapacity === "number" ? signupCapacity : null,createdAt: new Date(),updatedAt: new Date(),}).returning();- return NextResponse.json({ ...shift, calendar }, { status: 201 });+ // Best-effort: a shift the caller picked people for still gets created+ // even if one of those signups is no longer valid by the time we get here.+ let signups: CalendarMember[] = [];+ if (user && Array.isArray(signupUserIds) && signupUserIds.length > 0) {+ const existingIds = new Set<string>();+ const capacity = typeof signupCapacity === "number" ? signupCapacity : null;+ for (const targetUserId of signupUserIds) {+ if (typeof targetUserId !== "string") continue;+ await addShiftSignup(+ shift.id,+ calendarId,+ user.id,+ targetUserId,+ existingIds,+ capacity+ );+ }+ if (existingIds.size > 0) {+ [{ signups }] = await withSignups([shift]);+ }+ }++ return NextResponse.json(+ { ...shift, calendar, signups },+ { status: 201 }+ );} catch (error) {console.error("Failed to create shift:", error);return NextResponse.json(diff --git a/components/calendar-share-list.tsx b/components/calendar-share-list.tsxindex bae2cf7..c6f3123 100644--- a/components/calendar-share-list.tsx+++ b/components/calendar-share-list.tsx@@ -28,16 +28,23 @@ interface CalendarShareListProps {canManageShares: boolean;}-function PersonRow({+/** Avatar + name/email row shared by the calendar-share list and the shift-signup list. */+export function PersonRow({user,highlight,suffix,action,+ fallback = "…",+ showEmail = true,}: {- user: { name: string | null; email: string; image?: string | null };+ user: { name: string | null; email?: string; image?: string | null };highlight?: boolean;suffix?: ReactNode;- action: ReactNode;+ action?: ReactNode;+ /** Shown when the user has neither a name nor an email. */+ fallback?: ReactNode;+ /** Second line with the user's email below their name. */+ showEmail?: boolean;}) {return (<ListRow>@@ -54,10 +61,10 @@ function PersonRow({</Avatar><div className="min-w-0 flex-1"><div className="truncate text-[14px] font-semibold text-fg-strong">- {user.name || user.email || "…"}+ {user.name || user.email || fallback}{suffix}</div>- {user.name && user.email && (+ {showEmail && user.name && user.email && (<div className="truncate text-[12px] text-fg-tertiary">{user.email}</div>)}</div>diff --git a/components/calendar-share-management-sheet.tsx b/components/calendar-share-management-sheet.tsxindex 776bfd9..873c068 100644--- a/components/calendar-share-management-sheet.tsx+++ b/components/calendar-share-management-sheet.tsx@@ -2,17 +2,13 @@import { useState } from "react";import { useTranslations } from "next-intl";-import { Globe, Shield } from "lucide-react";import { Button } from "@/components/ui/button";import { PanelBody, PanelFooter } from "@/components/panel-dialog";import { SegmentedControl } from "@/components/segmented-control";-import { StatusBanner } from "@/components/status-banner";import { CalendarShareList } from "@/components/calendar-share-list";import { AccessLinksPanel } from "@/components/calendar-token-list";-import {- GuestPermissionSelector,- usePublicAccessNote,-} from "@/components/guest-permission-selector";+import { ToggleRow } from "@/components/form-kit";+import { GuestPermissionSelector } from "@/components/guest-permission-selector";import { useCalendars } from "@/hooks/useCalendars";import { useCalendarPermission } from "@/hooks/useCalendarPermission";import { useAuthFeatures } from "@/hooks/useAuthFeatures";@@ -33,20 +29,26 @@ export function SharingPanel({ calendarId, onClose, onDirtyChange }: SharingPaneconst t = useTranslations();const { calendars, updateCalendar } = useCalendars();const { canShare } = useCalendarPermission(calendarId);- const { isAuthEnabled, allowGuest } = useAuthFeatures();- const publicAccessNote = usePublicAccessNote();+ const { allowGuest } = useAuthFeatures();const [tab, setTab] = useState<SharingTab>("people");const linkForm = useAccessLinkForm(calendarId);useReportDirty(linkForm.dirty, onDirtyChange);const [optimisticGuest, setOptimisticGuest] = useState<GuestPermission | null>(null);+ const [optimisticAllowSelfSignup, setOptimisticAllowSelfSignup] = useState<+ boolean | null+ >(null);+ const [optimisticSignupsEnabled, setOptimisticSignupsEnabled] = useState<+ boolean | null+ >(null);const [saving, setSaving] = useState(false);const calendar = calendars.find((c) => c.id === calendarId);const guestPermission = optimisticGuest ?? calendar?.guestPermission ?? "none";-- // guestPermission also governs signed-in users without a share, so it is offered whenever auth is on.- const showPublicTab = isAuthEnabled;+ const allowSelfSignup =+ optimisticAllowSelfSignup ?? calendar?.allowSelfSignup ?? true;+ const signupsEnabled =+ optimisticSignupsEnabled ?? calendar?.signupsEnabled ?? true;const handleGuestPermissionChange = async (value: GuestPermission) => {if (!canShare || value === guestPermission) return;@@ -62,10 +64,41 @@ export function SharingPanel({ calendarId, onClose, onDirtyChange }: SharingPane}};+ const handleAllowSelfSignupChange = async (value: boolean) => {+ if (!canShare || value === allowSelfSignup) return;+ setOptimisticAllowSelfSignup(value);+ setSaving(true);+ try {+ await updateCalendar(calendarId, { allowSelfSignup: value });+ } catch {+ // updateCalendar already reported the error and rolled back the cache.+ } finally {+ setSaving(false);+ setOptimisticAllowSelfSignup(null);+ }+ };++ const handleSignupsEnabledChange = async (value: boolean) => {+ if (!canShare || value === signupsEnabled) return;+ setOptimisticSignupsEnabled(value);+ setSaving(true);+ try {+ await updateCalendar(calendarId, { signupsEnabled: value });+ } catch {+ // updateCalendar already reported the error and rolled back the cache.+ } finally {+ setSaving(false);+ setOptimisticSignupsEnabled(null);+ }+ };+const tabs: { value: SharingTab; label: string }[] = [{ value: "people", label: t("sharingSheet.tabPeople") },- ...(showPublicTab ? [{ value: "public" as const, label: t("share.public") }] : []),- { value: "links", label: t("share.links") },+ { value: "public", label: t("share.public") },+ // Access links are a pure guest-access mechanism, so they disappear once+ // ALLOW_GUEST_ACCESS is off — unlike public access, which remains useful+ // for signed-in users' calendar discovery regardless of that flag.+ ...(allowGuest ? [{ value: "links" as const, label: t("share.links") }] : []),];const activeTab = tabs.some((option) => option.value === tab) ? tab : "people";@@ -98,18 +131,26 @@ export function SharingPanel({ calendarId, onClose, onDirtyChange }: SharingPane{activeTab === "people" ? (<><CalendarShareList calendarId={calendarId} canManageShares={canShare} />- {showPublicTab &&- (guestPermission === "none" ? (- <StatusBanner tone="info" icon={Shield} title={t("sharingSheet.publicOffTitle")}>- {allowGuest- ? t("sharingSheet.publicOffBodyGuestsOn")- : t("sharingSheet.publicOffBodyGuestsOff")}- </StatusBanner>- ) : (- <StatusBanner tone="info" icon={Globe} title={t("sharingSheet.publicOnTitle")}>- {publicAccessNote(guestPermission, allowGuest)}- </StatusBanner>- ))}+ {canShare && (+ <ToggleRow+ id="signups-enabled"+ title={t("sharingSheet.signupsEnabledLabel")}+ description={t("sharingSheet.signupsEnabledDesc")}+ checked={signupsEnabled}+ onCheckedChange={handleSignupsEnabledChange}+ disabled={saving}+ />+ )}+ {canShare && signupsEnabled && (+ <ToggleRow+ id="allow-self-signup"+ title={t("sharingSheet.allowSelfSignupLabel")}+ description={t("sharingSheet.allowSelfSignupDesc")}+ checked={allowSelfSignup}+ onCheckedChange={handleAllowSelfSignupChange}+ disabled={saving}+ />+ )}</>) : (<>diff --git a/components/day-detail.tsx b/components/day-detail.tsxindex 800be85..f077d36 100644--- a/components/day-detail.tsx+++ b/components/day-detail.tsx@@ -9,6 +9,7 @@ import {RefreshCw,StickyNote,Trash2,+ UserPlus,} from "lucide-react";import {DropdownMenu,@@ -19,9 +20,60 @@ import {import { ShiftWithCalendar } from "@/lib/types";import { CalendarNote } from "@/lib/db/schema";import { getDateLocale } from "@/lib/locales";-import { formatHours, formatTimeRange, getShiftMinutes, shiftVars } from "@/lib/shift-display";+import {+ formatHours,+ formatSignupCapacityLabel,+ formatTimeRange,+ getShiftMinutes,+ shiftVars,+} from "@/lib/shift-display";import { PeriodSummary } from "@/hooks/useDaySummary";-import { cn } from "@/lib/utils";+import { cn, getUserInitials } from "@/lib/utils";+import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";+import { useAuth } from "@/hooks/useAuth";+import { useQuickSelfSignup, useShiftSignupPermission } from "@/hooks/useShiftSignups";++/** Compact avatar stack for who signed up; renders nothing when unused. */+function ShiftSignupBadge({+ shift,+ signupsEnabled,+}: {+ shift: ShiftWithCalendar;+ signupsEnabled: boolean;+}) {+ const t = useTranslations();+ const signups = shift.signups ?? [];+ const capacity = shift.signupCapacity ?? null;+ if (!signupsEnabled || (signups.length === 0 && capacity == null)) return null;++ const visible = signups.slice(0, 3);+ const overflow = signups.length - visible.length;+ const tooltip =+ capacity != null+ ? formatSignupCapacityLabel(t, signups.length, capacity).text+ : undefined;++ return (+ <div className="flex shrink-0 items-center -space-x-1.5" title={tooltip}>+ {visible.map((person) => (+ <Avatar key={person.id} className="size-5 border border-surface-card">+ {person.image && <AvatarImage src={person.image} alt="" />}+ <AvatarFallback className="bg-surface-sunken text-[9px] font-semibold text-fg-secondary">+ {getUserInitials({ name: person.name })}+ </AvatarFallback>+ </Avatar>+ ))}+ {overflow > 0 && (+ <span+ className="flex size-5 items-center justify-center rounded-full border border-surface-card bg-surface-sunken text-[9px] font-semibold text-fg-secondary"+ aria-label={t("shiftSignup.andMore", { count: overflow })}+ >+ +{overflow}+ </span>+ )}+ </div>+ );+}export function Kpi({label,@@ -73,8 +125,20 @@ export function ShiftDetailRow({const editable = canEdit && !synced;const minutes = getShiftMinutes(shift);+ const { user: currentUser } = useAuth();+ const { canManageOwn, signupsEnabled } = useShiftSignupPermission(shift.calendarId);+ const { signUpForShift, isPending: signingUp } = useQuickSelfSignup();+ const signups = shift.signups ?? [];+ const capacity = shift.signupCapacity ?? null;+ const alreadySignedUp = !!currentUser && signups.some((s) => s.id === currentUser.id);+ const isFull = capacity != null && signups.length >= capacity;+ const showQuickSignup = canManageOwn && !alreadySignedUp && !isFull;+return (- <div className="flex items-center gap-[11px] rounded-lg border border-line bg-surface-card px-3 py-[11px]">+ <div+ onClick={() => onEdit(shift)}+ className="flex cursor-pointer items-center gap-[11px] rounded-lg border border-line bg-surface-card px-3 py-[11px] transition-colors hover:bg-surface-panel"+ ><spanclassName="shift-rail h-[34px] w-1 shrink-0 rounded-full"style={shiftVars(shift.color)}@@ -90,6 +154,22 @@ export function ShiftDetailRow({<div className="mt-1 line-clamp-2 text-xs text-fg-secondary">{shift.notes}</div>)}</div>+ <ShiftSignupBadge shift={shift} signupsEnabled={signupsEnabled} />+ {showQuickSignup && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ signUpForShift(shift.id);+ }}+ disabled={signingUp}+ aria-label={t("shiftSignup.addSelf")}+ title={t("shiftSignup.addSelf")}+ className="flex size-7 shrink-0 items-center justify-center rounded-md text-fg-tertiary transition-colors hover:bg-surface-sunken disabled:opacity-40"+ >+ <UserPlus className="size-4" />+ </button>+ )}{synced && (<spanclassName="flex items-center gap-1 rounded-full bg-surface-sunken px-2 py-0.5 text-[11px] font-semibold text-fg-secondary"@@ -108,6 +188,7 @@ export function ShiftDetailRow({(actions === "menu" ? (<DropdownMenu><DropdownMenuTrigger+ onClick={(e) => e.stopPropagation()}className="flex size-7 items-center justify-center rounded-md text-fg-tertiary transition-colors hover:bg-surface-sunken"aria-label={t("calendarView.shiftActions")}>@@ -131,7 +212,10 @@ export function ShiftDetailRow({<div className="flex items-center"><buttontype="button"- onClick={() => onEdit(shift)}+ onClick={(e) => {+ e.stopPropagation();+ onEdit(shift);+ }}aria-label={t("shift.edit")}className="flex size-9 items-center justify-center rounded-md text-fg-secondary">@@ -139,7 +223,10 @@ export function ShiftDetailRow({</button><buttontype="button"- onClick={() => onDelete(shift)}+ onClick={(e) => {+ e.stopPropagation();+ onDelete(shift);+ }}aria-label={t("common.delete")}className="flex size-9 items-center justify-center rounded-md text-fg-secondary">diff --git a/components/month-grid.tsx b/components/month-grid.tsxindex c36d629..fa6b155 100644--- a/components/month-grid.tsx+++ b/components/month-grid.tsx@@ -12,9 +12,12 @@ import {DayLayoutOptions,DayShiftLayout,buildDayShiftLayout,+ formatSignupCapacityLabel,shiftVars,} from "@/lib/shift-display";import { cn } from "@/lib/utils";+import { useCalendars } from "@/hooks/useCalendars";+import { useAuthFeatures } from "@/hooks/useAuthFeatures";const WEEKDAY_KEYS = ["monday",@@ -158,6 +161,12 @@ export function MonthGrid({}: MonthGridProps) {const t = useTranslations();const locale = useLocale();+ const { calendars } = useCalendars();+ const { isAuthEnabled } = useAuthFeatures();+ const signupsEnabledById = useMemo(+ () => new Map(calendars.map((c) => [c.id, isAuthEnabled && (c.signupsEnabled ?? true)])),+ [calendars, isAuthEnabled]+ );const phone = variant === "phone";const desktop = variant === "desktop";// 2024-01-01 was a Monday@@ -174,6 +183,25 @@ export function MonthGrid({? Math.max(PHONE_MIN_ROW, (gridSize.height - (rows - 1) * PHONE_GAP) / rows): (gridSize.height - (rows - 1)) / rows;const colWidth = gridSize.width > 0 ? (gridSize.width - 8) / 7 : PHONE_FALLBACK_COL;+ // Compact "N" / "N/capacity" badge shared by the desktop chip and the compare row+ const signupBadge = (shift: ShiftWithCalendar) => {+ if (!(signupsEnabledById.get(shift.calendarId) ?? true)) return null;+ const count = shift.signups?.length ?? 0;+ const capacity = shift.signupCapacity ?? null;+ if (count === 0 && capacity == null) return null;+ const label = capacity != null ? formatSignupCapacityLabel(t, count, capacity) : null;+ return (+ <span+ className={cn(+ "shrink-0 rounded-[4px] px-1 font-mono text-[10px] leading-4",+ label?.isFull ? "bg-brand-soft text-brand-ink" : "bg-surface-sunken/70 text-fg-tertiary"+ )}+ title={label?.text}+ >+ {capacity != null ? `${count}/${capacity}` : count}+ </span>+ );+ };useEffect(() => () => {@@ -343,6 +371,7 @@ export function MonthGrid({</span>)}</span>+ {signupBadge(shift)}{time(shift)}</span>);@@ -536,6 +565,7 @@ export function MonthGrid({style={shiftVars(shift.color)}/><span className="min-w-0 flex-1 truncate">{shift.title}</span>+ {signupBadge(shift)}</span>))}{minimalGroups.map(({ sync, shifts: syncShifts }) => (diff --git a/components/preset-form.tsx b/components/preset-form.tsxindex 304ca5f..c800bb5 100644--- a/components/preset-form.tsx+++ b/components/preset-form.tsx@@ -7,6 +7,7 @@ import { CheckRow, ColorSwatches, Field, inputClass } from "@/components/form-kiimport { ShiftPreset } from "@/lib/db/schema";import { DEFAULT_COLOR } from "@/lib/constants";import type { PresetFormData } from "@/hooks/usePresets";+import { useAuthFeatures } from "@/hooks/useAuthFeatures";import { cn } from "@/lib/utils";export const EMPTY_PRESET_FORM: PresetFormData = {@@ -19,6 +20,7 @@ export const EMPTY_PRESET_FORM: PresetFormData = {isSecondary: false,isAllDay: false,hideFromStats: false,+ defaultSignupCapacity: null,};export function presetToFormData(preset: ShiftPreset): PresetFormData {@@ -32,6 +34,7 @@ export function presetToFormData(preset: ShiftPreset): PresetFormData {isSecondary: preset.isSecondary || false,isAllDay: preset.isAllDay || false,hideFromStats: preset.hideFromStats || false,+ defaultSignupCapacity: preset.defaultSignupCapacity ?? null,};}@@ -67,6 +70,7 @@ export function PresetFormCard({}: PresetFormCardProps) {const t = useTranslations();const id = useId();+ const { isAuthEnabled } = useAuthFeatures();const fieldClass = cn(inputClass, "bg-surface-card");return (@@ -127,7 +131,7 @@ export function PresetFormCard({disabled={disabled}/>- <Field label={t("form.notesLabel")} htmlFor={`${id}-notes`}>+ <Field label={t("form.notesLabel")} htmlFor={`${id}-notes`} optional><Inputid={`${id}-notes`}value={value.notes}@@ -138,7 +142,31 @@ export function PresetFormCard({/></Field>- <Field label={t("preset.group")} htmlFor={`${id}-group`}>+ {isAuthEnabled && (+ <Field+ label={t("presetSheet.defaultSignupCapacityLabel")}+ htmlFor={`${id}-signup-capacity`}+ hint={t("presetSheet.defaultSignupCapacityHint")}+ optional+ >+ <Input+ id={`${id}-signup-capacity`}+ type="number"+ min={1}+ inputMode="numeric"+ value={value.defaultSignupCapacity ?? ""}+ onChange={(e) =>+ onChange({+ defaultSignupCapacity: e.target.value === "" ? null : Number(e.target.value),+ })+ }+ className={fieldClass}+ disabled={disabled}+ />+ </Field>+ )}++ <Field label={t("preset.group")} htmlFor={`${id}-group`} optional><Inputid={`${id}-group`}list={`${id}-group-names`}diff --git a/components/shift-sheet.tsx b/components/shift-sheet.tsxindex 5189b14..b349471 100644--- a/components/shift-sheet.tsx+++ b/components/shift-sheet.tsx@@ -7,9 +7,11 @@ import { ShiftWithCalendar } from "@/lib/types";import { ShiftFormFields } from "@/components/shift-form-fields";import { PresetSelect } from "@/components/preset-select";import { ReadOnlyBanner } from "@/components/read-only-banner";+import { ShiftSignupList } from "@/components/shift-signup-list";import { useShiftForm } from "@/hooks/useShiftForm";import { useCalendarPermission } from "@/hooks/useCalendarPermission";import { formatDateToLocal, formatLongDate, parseLocalDate } from "@/lib/date-utils";+import { isTempId } from "@/lib/utils";interface ShiftSheetProps {open: boolean;@@ -31,6 +33,9 @@ export interface ShiftFormData {notes?: string;presetId?: string;isAllDay?: boolean;+ signupCapacity?: number | null;+ /** New shifts only: people to sign up immediately once the shift is created. */+ signupUserIds?: string[];}// presetId is left out: the form never changes it and does not load it@@ -43,6 +48,7 @@ function snapshot(data: ShiftFormData) {notes: data.notes || "",color: data.color,isAllDay: data.isAllDay || false,+ signupCapacity: data.signupCapacity ?? null,});}@@ -78,10 +84,14 @@ export function ShiftSheet({resetForm,} = useShiftForm({ open, shift, selectedDate, calendarId });const [selectedPresetId, setSelectedPresetId] = useState<string | null>(null);+ const [pendingSignupUserIds, setPendingSignupUserIds] = useState<string[]>([]);const [wasOpen, setWasOpen] = useState(open);if (open !== wasOpen) {setWasOpen(open);- if (open) setSelectedPresetId(null);+ if (open) {+ setSelectedPresetId(null);+ setPendingSignupUserIds([]);+ }}const initialSnapshot = useMemo(@@ -98,6 +108,7 @@ export function ShiftSheet({notes: shift.notes || "",color: shift.color,isAllDay: shift.isAllDay || false,+ signupCapacity: shift.signupCapacity ?? null,}): null,[shift]@@ -113,7 +124,8 @@ export function ShiftSheet({formData.title.trim() !== "" ||formData.notes?.trim() !== "" ||saveAsPreset ||- presetName.trim() !== ""+ presetName.trim() !== "" ||+ pendingSignupUserIds.length > 0);};@@ -127,6 +139,7 @@ export function ShiftSheet({...formData,startTime: formData.isAllDay ? "00:00" : formData.startTime,endTime: formData.isAllDay ? "23:59" : formData.endTime,+ ...(!shift ? { signupUserIds: pendingSignupUserIds } : {}),};await onSubmit(submitData);@@ -199,6 +212,23 @@ export function ShiftSheet({isEditing={!!shift}readOnly={isReadOnly}/>++ {/* Signups aren't gated by isReadOnly: a read-only member may still+ be allowed to sign themselves up when the calendar permits it. A+ new (unsaved) shift uses local pending state instead of the API. */}+ {calendarId && (+ <ShiftSignupList+ calendarId={calendarId}+ signupCapacity={formData.signupCapacity ?? null}+ onSignupCapacityChange={(value) =>+ setFormData({ ...formData, signupCapacity: value })+ }+ readOnly={isReadOnly}+ shiftId={shift && !isTempId(shift.id) ? shift.id : undefined}+ pendingUserIds={pendingSignupUserIds}+ onPendingUserIdsChange={setPendingSignupUserIds}+ />+ )}</div></BaseSheet>);diff --git a/components/shift-signup-list.tsx b/components/shift-signup-list.tsxnew file mode 100644index 0000000..77bfa80--- /dev/null+++ b/components/shift-signup-list.tsx@@ -0,0 +1,211 @@+"use client";++import { useMemo, useState } from "react";+import { useTranslations } from "next-intl";+import { Trash2, UserPlus } from "lucide-react";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Field, inputClass, Pill, RowIconButton, SectionLabel } from "@/components/form-kit";+import { PersonRow } from "@/components/calendar-share-list";+import { useAuth } from "@/hooks/useAuth";+import {+ useShiftSignupPermission,+ useShiftSignups,+ useCalendarMembers,+} from "@/hooks/useShiftSignups";+import { formatSignupCapacityLabel } from "@/lib/shift-display";+import type { CalendarMember, ShiftSignupUser } from "@/lib/types";++type SignupPerson = ShiftSignupUser | CalendarMember;++interface ShiftSignupListProps {+ calendarId: string;+ signupCapacity: number | null;+ onSignupCapacityChange: (value: number | null) => void;+ /** Whether the shift itself may be edited; gates the capacity field only. */+ readOnly: boolean;+ /** Existing shift: live signups via the API. Omit for a shift being created. */+ shiftId?: string;+ /** New shift being created: people picked so far, applied once it's saved. */+ pendingUserIds?: string[];+ onPendingUserIdsChange?: (userIds: string[]) => void;+}++export function ShiftSignupList({+ calendarId,+ signupCapacity,+ onSignupCapacityChange,+ readOnly,+ shiftId,+ pendingUserIds = [],+ onPendingUserIdsChange,+}: ShiftSignupListProps) {+ const t = useTranslations();+ const { user: currentUser } = useAuth();+ const { canManageOwn, canManageOthers, signupsEnabled } = useShiftSignupPermission(calendarId);+ const live = useShiftSignups(shiftId);+ const { members } = useCalendarMembers(calendarId, canManageOthers);+ const [pickedUserId, setPickedUserId] = useState("");++ const isPending = !shiftId;+ const memberById = useMemo(() => new Map(members.map((m) => [m.id, m])), [members]);++ const signupUsers: SignupPerson[] = isPending+ ? pendingUserIds.map((id) => {+ if (currentUser && id === currentUser.id) return currentUser;+ const member = memberById.get(id);+ return member ? { id: member.id, name: member.name, image: member.image } : { id, name: null };+ })+ : live.signups;++ const availableMembers = useMemo(() => {+ const pickedIds = new Set(signupUsers.map((s) => s.id));+ return members.filter((m) => !pickedIds.has(m.id));+ }, [members, signupUsers]);++ if (!signupsEnabled) return null;++ const capacity = typeof signupCapacity === "number" ? signupCapacity : null;+ const isFull =+ capacity != null &&+ formatSignupCapacityLabel(t, signupUsers.length, capacity).isFull;+ const selfSignedUp = !!currentUser && signupUsers.some((s) => s.id === currentUser.id);+ // Guests can never hold a signup regardless of allowSelfSignup, so the hint+ // (which explains that specific toggle) would be misleading for them.+ const showSelfSignupDisabledHint = !!currentUser && !canManageOwn && !selfSignedUp;++ const addUser = (userId: string) => {+ if (isPending) {+ onPendingUserIdsChange?.([...pendingUserIds, userId]);+ } else {+ live.signUp(currentUser && userId === currentUser.id ? undefined : userId);+ }+ };++ const removeUser = (userId: string) => {+ if (isPending) {+ onPendingUserIdsChange?.(pendingUserIds.filter((id) => id !== userId));+ } else {+ live.withdraw(userId);+ }+ };++ const handleAddOther = () => {+ if (!pickedUserId) return;+ addUser(pickedUserId);+ setPickedUserId("");+ };++ return (+ <section className="flex flex-col gap-2.5 rounded-[11px] border border-line bg-surface-panel p-3.5">+ <div className="flex items-center justify-between">+ <SectionLabel className="mb-0">{t("shiftSignup.title")}</SectionLabel>+ {capacity != null && (+ <Pill tone={isFull ? "warning" : "neutral"}>+ {isFull+ ? t("shiftSignup.full")+ : t("shiftSignup.capacityProgress", { count: signupUsers.length, capacity })}+ </Pill>+ )}+ </div>++ {!readOnly && (+ <Field+ label={t("shiftSheet.signupCapacityLabel")}+ htmlFor="signupCapacity"+ hint={t("shiftSheet.signupCapacityHint")}+ optional+ >+ <Input+ id="signupCapacity"+ type="number"+ min={1}+ inputMode="numeric"+ value={signupCapacity ?? ""}+ onChange={(e) =>+ onSignupCapacityChange(e.target.value === "" ? null : Number(e.target.value))+ }+ className={inputClass}+ />+ </Field>+ )}++ {signupUsers.length === 0 && (+ <p className="rounded-[11px] border border-dashed border-control px-3.5 py-3 text-center text-[13px] text-fg-tertiary">+ {t("shiftSignup.empty")}+ </p>+ )}++ {signupUsers.map((signup) => {+ const canRemoveThis = canManageOthers || (canManageOwn && signup.id === currentUser?.id);+ return (+ <PersonRow+ key={signup.id}+ user={signup}+ fallback={signup.id}+ showEmail={false}+ action={+ canRemoveThis ? (+ <RowIconButton+ icon={Trash2}+ label={t("shiftSignup.remove")}+ onClick={() => removeUser(signup.id)}+ tone="danger"+ />+ ) : undefined+ }+ />+ );+ })}++ {canManageOwn && !selfSignedUp && !isFull && (+ <Button+ type="button"+ variant="outline"+ size="sm"+ className="self-start"+ onClick={() => currentUser && addUser(currentUser.id)}+ >+ <UserPlus className="size-4" />+ {t("shiftSignup.addSelf")}+ </Button>+ )}++ {showSelfSignupDisabledHint && (+ <p className="text-[12px] text-fg-tertiary">{t("shiftSignup.selfSignupDisabled")}</p>+ )}++ {canManageOthers && !isFull && (+ <div className="flex flex-col gap-1.5">+ {availableMembers.length > 0 && (+ <div className="flex items-center gap-2">+ <Select value={pickedUserId} onValueChange={setPickedUserId}>+ <SelectTrigger className="h-9 flex-1 rounded-[9px]" aria-label={t("shiftSignup.addOther")}>+ <SelectValue placeholder={t("shiftSignup.addOtherPlaceholder")} />+ </SelectTrigger>+ <SelectContent>+ {availableMembers.map((member) => (+ <SelectItem key={member.id} value={member.id}>+ {member.name || member.id}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <Button type="button" size="sm" disabled={!pickedUserId} onClick={handleAddOther}>+ {t("shiftSignup.addOther")}+ </Button>+ </div>+ )}+ <p className="text-[12px] text-fg-tertiary">{t("shiftSignup.addOtherHint")}</p>+ </div>+ )}+ </section>+ );+}diff --git a/drizzle/0017_brainy_blonde_phantom.sql b/drizzle/0017_brainy_blonde_phantom.sqlnew file mode 100644index 0000000..ac7c077--- /dev/null+++ b/drizzle/0017_brainy_blonde_phantom.sql@@ -0,0 +1,17 @@+CREATE TABLE `shift_signups` (+ `id` text PRIMARY KEY NOT NULL,+ `shift_id` text NOT NULL,+ `user_id` text NOT NULL,+ `signed_up_by` text NOT NULL,+ `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,+ FOREIGN KEY (`shift_id`) REFERENCES `shifts`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`signed_up_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE INDEX `shift_signups_shiftId_idx` ON `shift_signups` (`shift_id`);--> statement-breakpoint+CREATE INDEX `shift_signups_userId_idx` ON `shift_signups` (`user_id`);--> statement-breakpoint+CREATE UNIQUE INDEX `shift_signups_shiftId_userId_idx` ON `shift_signups` (`shift_id`,`user_id`);--> statement-breakpoint+ALTER TABLE `calendars` ADD `allow_self_signup` integer DEFAULT true NOT NULL;--> statement-breakpoint+ALTER TABLE `shift_presets` ADD `default_signup_capacity` integer;--> statement-breakpoint+ALTER TABLE `shifts` ADD `signup_capacity` integer;\ No newline at end of filediff --git a/drizzle/0018_skinny_goblin_queen.sql b/drizzle/0018_skinny_goblin_queen.sqlnew file mode 100644index 0000000..e977a6b--- /dev/null+++ b/drizzle/0018_skinny_goblin_queen.sql@@ -0,0 +1 @@+ALTER TABLE `calendars` ADD `signups_enabled` integer DEFAULT true NOT NULL;\ No newline at end of filediff --git a/drizzle/meta/0017_snapshot.json b/drizzle/meta/0017_snapshot.jsonnew file mode 100644index 0000000..126c9cd--- /dev/null+++ b/drizzle/meta/0017_snapshot.json@@ -0,0 +1,1860 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "377214d6-9d75-4eeb-b3c0-57cb85cccc91",+ "prevId": "1a7d8029-d005-462a-92af-0ca22b4f8363",+ "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": {}+ },+ "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+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'read'"+ },+ "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+ }+ },+ "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_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_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_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"+ }+ },+ "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+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'read'"+ },+ "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+ }+ },+ "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_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_permission": {+ "name": "guest_permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'none'"+ },+ "allow_self_signup": {+ "name": "allow_self_signup",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "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": {}+ },+ "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_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+ },+ "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"+ }+ },+ "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": {}+ },+ "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_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"+ }+ },+ "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'"+ },+ "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+ }+ },+ "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/0018_snapshot.json b/drizzle/meta/0018_snapshot.jsonnew file mode 100644index 0000000..726b064--- /dev/null+++ b/drizzle/meta/0018_snapshot.json@@ -0,0 +1,1868 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "46c43bf1-957b-48a6-80b6-8bb2d5c9ac6c",+ "prevId": "377214d6-9d75-4eeb-b3c0-57cb85cccc91",+ "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": {}+ },+ "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+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'read'"+ },+ "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+ }+ },+ "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_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_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_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"+ }+ },+ "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+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'read'"+ },+ "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+ }+ },+ "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_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_permission": {+ "name": "guest_permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'none'"+ },+ "allow_self_signup": {+ "name": "allow_self_signup",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "signups_enabled": {+ "name": "signups_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "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": {}+ },+ "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_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+ },+ "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"+ }+ },+ "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": {}+ },+ "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_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"+ }+ },+ "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'"+ },+ "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+ }+ },+ "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 22a20e4..e57992d 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -120,6 +120,20 @@"when": 1789289621960,"tag": "0016_smart_maximus","breakpoints": true+ },+ {+ "idx": 17,+ "version": "6",+ "when": 1789298650520,+ "tag": "0017_brainy_blonde_phantom",+ "breakpoints": true+ },+ {+ "idx": 18,+ "version": "6",+ "when": 1789303001140,+ "tag": "0018_skinny_goblin_queen",+ "breakpoints": true}]}\ No newline at end of filediff --git a/hooks/useCalendars.ts b/hooks/useCalendars.tsindex e803656..a98147a 100644--- a/hooks/useCalendars.ts+++ b/hooks/useCalendars.ts@@ -18,6 +18,15 @@ import { queryKeys } from "@/lib/query-keys";import { BACKGROUND_REFETCH_INTERVAL } from "@/lib/query-client";import { ApiError } from "@/lib/api-error";+export interface CalendarUpdateInput {+ name?: string;+ color?: string;+ guestPermission?: "none" | "read" | "write";+ viewSettings?: CalendarViewSettings | null;+ allowSelfSignup?: boolean;+ signupsEnabled?: boolean;+}+// API functionsasync function fetchCalendarsApi(): Promise<CalendarWithCount[]> {const response = await fetch("/api/calendars");@@ -69,12 +78,7 @@ async function createCalendarApi(async function updateCalendarApi(calendarId: string,- updates: {- name?: string;- color?: string;- guestPermission?: "none" | "read" | "write";- viewSettings?: CalendarViewSettings | null;- }+ updates: CalendarUpdateInput): Promise<CalendarWithCount> {const response = await fetch(`/api/calendars/${calendarId}`, {method: "PATCH",@@ -252,12 +256,7 @@ export function useCalendars(initialCalendarId?: string | null) {Error,{calendarId: string;- updates: {- name?: string;- color?: string;- guestPermission?: "none" | "read" | "write";- viewSettings?: CalendarViewSettings | null;- };+ updates: CalendarUpdateInput;},UpdateCalendarContext>({@@ -376,12 +375,7 @@ export function useCalendars(initialCalendarId?: string | null) {// Wrapper for updateCalendar to maintain original signatureconst updateCalendar = async (calendarId: string,- updates: {- name?: string;- color?: string;- guestPermission?: "none" | "read" | "write";- viewSettings?: CalendarViewSettings | null;- }+ updates: CalendarUpdateInput) => {try {return await updateMutation.mutateAsync({ calendarId, updates });diff --git a/hooks/usePresets.ts b/hooks/usePresets.tsindex 4127109..83d2969 100644--- a/hooks/usePresets.ts+++ b/hooks/usePresets.ts@@ -18,6 +18,7 @@ export interface PresetFormData {isSecondary: boolean;isAllDay: boolean;hideFromStats: boolean;+ defaultSignupCapacity?: number | null;}// API functions@@ -114,6 +115,7 @@ function createOptimisticPreset(isSecondary: formData.isSecondary,isAllDay: formData.isAllDay,hideFromStats: formData.hideFromStats,+ defaultSignupCapacity: formData.defaultSignupCapacity ?? null,order: 999, // Will be corrected by servercreatedAt: new Date(),updatedAt: new Date(),diff --git a/hooks/useShiftForm.ts b/hooks/useShiftForm.tsindex 87d53cb..77c6165 100644--- a/hooks/useShiftForm.ts+++ b/hooks/useShiftForm.ts@@ -32,6 +32,7 @@ export function useShiftForm({notes: shift?.notes || "",color: shift?.color || DEFAULT_COLOR,isAllDay: false,+ signupCapacity: shift?.signupCapacity ?? null,});const { presets, createPreset } = usePresets(calendarId);@@ -66,6 +67,7 @@ export function useShiftForm({notes: preset.notes || "",color: preset.color,isAllDay: preset.isAllDay || false,+ signupCapacity: preset.defaultSignupCapacity ?? null,});};@@ -79,6 +81,7 @@ export function useShiftForm({notes: "",color: DEFAULT_COLOR,isAllDay: false,+ signupCapacity: null,});};@@ -93,6 +96,7 @@ export function useShiftForm({notes: "",color: DEFAULT_COLOR,isAllDay: false,+ signupCapacity: null,});setPresetName("");setSaveAsPreset(false);@@ -120,6 +124,7 @@ export function useShiftForm({notes: shift?.notes || "",color: shift?.color || DEFAULT_COLOR,isAllDay: shift?.isAllDay || false,+ signupCapacity: shift?.signupCapacity ?? null,};// Compare form data fields directly@@ -130,7 +135,8 @@ export function useShiftForm({formDataRef.current.title !== newFormData.title ||formDataRef.current.notes !== newFormData.notes ||formDataRef.current.color !== newFormData.color ||- formDataRef.current.isAllDay !== newFormData.isAllDay;+ formDataRef.current.isAllDay !== newFormData.isAllDay ||+ formDataRef.current.signupCapacity !== newFormData.signupCapacity;if (needsUpdate) {setFormData(newFormData);diff --git a/hooks/useShiftSignups.ts b/hooks/useShiftSignups.tsnew file mode 100644index 0000000..796196d--- /dev/null+++ b/hooks/useShiftSignups.ts@@ -0,0 +1,195 @@+import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";+import { useTranslations } from "next-intl";+import { toast } from "sonner";+import { queryKeys } from "@/lib/query-keys";+import { ApiError } from "@/lib/api-error";+import { ShiftSignupUser, CalendarMember } from "@/lib/types";+import { useAuth } from "@/hooks/useAuth";+import { useAuthFeatures } from "@/hooks/useAuthFeatures";+import { useCalendars } from "@/hooks/useCalendars";+import { useCalendarPermission } from "@/hooks/useCalendarPermission";++async function fetchSignupsApi(shiftId: string): Promise<ShiftSignupUser[]> {+ const response = await fetch(`/api/shifts/${shiftId}/signups`);+ if (!response.ok) {+ throw new ApiError(`Failed to fetch signups: ${response.statusText}`, response.status);+ }+ return response.json();+}++async function addSignupApi(+ shiftId: string,+ userId?: string+): Promise<{ data: ShiftSignupUser[] } | { error: string; status: number }> {+ const response = await fetch(`/api/shifts/${shiftId}/signups`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(userId ? { userId } : {}),+ });+ if (!response.ok) {+ const errorData = await response.json().catch(() => ({}));+ return { error: errorData.error || "Failed to add signup", status: response.status };+ }+ return { data: await response.json() };+}++async function removeSignupApi(+ shiftId: string,+ userId: string+): Promise<{ error: string; status: number } | null> {+ const response = await fetch(`/api/shifts/${shiftId}/signups/${userId}`, {+ method: "DELETE",+ });+ if (!response.ok) {+ const errorData = await response.json().catch(() => ({}));+ return { error: errorData.error || "Failed to remove signup", status: response.status };+ }+ return null;+}++// Maps a server error to the closest shiftSignup.errors.* translation.+function addErrorMessage(+ t: ReturnType<typeof useTranslations>,+ error: string,+ status: number+): string {+ if (status === 409 && /capacity/i.test(error)) return t("shiftSignup.errors.full");+ if (status === 409) return t("shiftSignup.errors.alreadySignedUp");+ if (status === 400) return t("shiftSignup.errors.noAccess");+ return t("shiftSignup.errors.addFailed");+}++/**+ * Client-side mirror of getShiftSignupPermission() on the server. Only a real+ * account may hold a signup, even when a share/access-token grants "write" on+ * the calendar to a guest — useCalendarPermission alone can't tell the two+ * apart, so this is the single place that adds the missing `!!user` check.+ */+export function useShiftSignupPermission(calendarId: string | undefined) {+ const { user } = useAuth();+ const { isAuthEnabled } = useAuthFeatures();+ const { calendars } = useCalendars();+ const calendarPermission = useCalendarPermission(calendarId);+ const calendar = calendars.find((c) => c.id === calendarId);+ // Signups tie a shift to a real account, so without auth there is no one to sign up.+ const signupsEnabled = isAuthEnabled && (calendar?.signupsEnabled ?? true);+ const allowSelfSignup = calendar?.allowSelfSignup ?? true;++ if (!user || !signupsEnabled) {+ return { canManageOwn: false, canManageOthers: false, signupsEnabled };+ }++ return {+ canManageOwn:+ calendarPermission.canView &&+ (calendarPermission.canEdit || allowSelfSignup),+ canManageOthers: calendarPermission.canEdit,+ signupsEnabled,+ };+}++/** Fire-and-forget self-signup for shift lists that don't render the full sheet. */+export function useQuickSelfSignup() {+ const t = useTranslations();+ const queryClient = useQueryClient();++ const mutation = useMutation({+ mutationFn: (shiftId: string) => addSignupApi(shiftId),+ onSuccess: (result, shiftId) => {+ if ("data" in result) {+ queryClient.setQueryData(queryKeys.shiftSignups.byShift(shiftId), result.data);+ } else {+ toast.error(addErrorMessage(t, result.error, result.status));+ }+ },+ onError: () => {+ toast.error(t("shiftSignup.errors.addFailed"));+ },+ onSettled: (_data, _error, shiftId) => {+ queryClient.invalidateQueries({ queryKey: queryKeys.shiftSignups.byShift(shiftId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.shifts.all });+ },+ });++ return {+ signUpForShift: (shiftId: string) => mutation.mutateAsync(shiftId),+ isPending: mutation.isPending,+ };+}++export function useShiftSignups(shiftId: string | undefined) {+ const t = useTranslations();+ const queryClient = useQueryClient();+ const queryKey = queryKeys.shiftSignups.byShift(shiftId!);++ const { data: signups = [], isLoading } = useQuery({+ queryKey,+ queryFn: () => fetchSignupsApi(shiftId!),+ enabled: !!shiftId,+ });++ const addMutation = useMutation({+ mutationFn: (userId?: string) => addSignupApi(shiftId!, userId),+ onSuccess: (result) => {+ if ("data" in result) {+ queryClient.setQueryData(queryKey, result.data);+ } else {+ toast.error(addErrorMessage(t, result.error, result.status));+ }+ },+ onError: () => {+ toast.error(t("shiftSignup.errors.addFailed"));+ },+ onSettled: () => {+ queryClient.invalidateQueries({ queryKey });+ queryClient.invalidateQueries({ queryKey: queryKeys.shifts.all });+ },+ });++ const removeMutation = useMutation({+ mutationFn: (userId: string) => removeSignupApi(shiftId!, userId),+ onSuccess: (result, userId) => {+ if (!result) {+ queryClient.setQueryData<ShiftSignupUser[]>(queryKey, (old = []) =>+ old.filter((u) => u.id !== userId)+ );+ } else {+ toast.error(t("shiftSignup.errors.removeFailed"));+ }+ },+ onError: () => {+ toast.error(t("shiftSignup.errors.removeFailed"));+ },+ onSettled: () => {+ queryClient.invalidateQueries({ queryKey });+ queryClient.invalidateQueries({ queryKey: queryKeys.shifts.all });+ },+ });++ return {+ signups,+ loading: isLoading,+ signUp: (userId?: string) => addMutation.mutateAsync(userId),+ withdraw: (userId: string) => removeMutation.mutateAsync(userId),+ isMutating: addMutation.isPending || removeMutation.isPending,+ };+}++async function fetchCalendarMembersApi(calendarId: string): Promise<CalendarMember[]> {+ const response = await fetch(`/api/calendars/${calendarId}/members`);+ if (!response.ok) {+ throw new ApiError(`Failed to fetch calendar members: ${response.statusText}`, response.status);+ }+ return response.json();+}++/** Owner + shared members of a calendar, used to assign someone else to a shift. */+export function useCalendarMembers(calendarId: string | undefined, enabled: boolean) {+ const { data: members = [], isLoading } = useQuery({+ queryKey: queryKeys.calendarMembers.byCalendar(calendarId!),+ queryFn: () => fetchCalendarMembersApi(calendarId!),+ enabled: !!calendarId && enabled,+ });++ return { members, loading: isLoading };+}diff --git a/lib/auth/permissions.ts b/lib/auth/permissions.tsindex 9feff34..05d0457 100644--- a/lib/auth/permissions.ts+++ b/lib/auth/permissions.ts@@ -11,6 +11,7 @@ import {getTokensFromCookie,validateAccessToken,} from "@/lib/auth/token-auth";+import type { CalendarMember } from "@/lib/types";/*** Calendar permission levels@@ -47,12 +48,28 @@ export async function getUserCalendarPermission(userId: string | null | undefined,calendarId: string): Promise<CalendarPermission | null> {+ return (await getUserCalendarPermissionWithCalendar(userId, calendarId))+ .permission;+}++/**+ * Same resolution as getUserCalendarPermission, but also returns the calendar+ * row it already fetched — lets callers that need calendar columns (e.g.+ * getShiftSignupPermission) avoid a second round trip for the same row.+ */+async function getUserCalendarPermissionWithCalendar(+ userId: string | null | undefined,+ calendarId: string+): Promise<{+ permission: CalendarPermission | null;+ calendar: typeof calendars.$inferSelect | null;+}> {// If auth is disabled, grant full owner access (backwards compatibility)if (!isAuthEnabled()) {const calendar = await db.query.calendars.findFirst({where: eq(calendars.id, calendarId),});- return calendar ? "owner" : null;+ return { permission: calendar ? "owner" : null, calendar: calendar ?? null };}// Fetch calendar first (needed for all checks)@@ -61,13 +78,13 @@ export async function getUserCalendarPermission(});if (!calendar) {- return null;+ return { permission: null, calendar: null };}// CRITICAL: Orphaned calendars (ownerId=null) are invisible to ALL users// They can only be accessed via dedicated admin panel API routesif (calendar.ownerId === null) {- return null;+ return { permission: null, calendar };}// If no user ID, check token and guest permissions@@ -75,19 +92,22 @@ export async function getUserCalendarPermission(// Check for access token first (higher priority than guest)const tokenPermission = await getTokenPermission(calendarId);if (tokenPermission) {- return tokenPermission;+ return { permission: tokenPermission, calendar };}// Guest access only works when explicitly enabledif (allowGuestAccess() && calendar.guestPermission !== "none") {- return calendar.guestPermission as CalendarPermission;+ return {+ permission: calendar.guestPermission as CalendarPermission,+ calendar,+ };}- return null;+ return { permission: null, calendar };}// Owner has full controlif (calendar.ownerId === userId) {- return "owner";+ return { permission: "owner", calendar };}// Check shared permissions (higher priority than tokens)@@ -99,13 +119,16 @@ export async function getUserCalendarPermission(});if (share) {- return share.permission as CalendarPermission;+ return {+ permission: share.permission as CalendarPermission,+ calendar,+ };}// Check for access token (authenticated users can also use tokens)const tokenPermission = await getTokenPermission(calendarId);if (tokenPermission) {- return tokenPermission;+ return { permission: tokenPermission, calendar };}// Check if user is subscribed to this public calendar@@ -120,10 +143,13 @@ export async function getUserCalendarPermission(// If subscribed and calendar has public access (guestPermission != "none"), return that permission// Authenticated users can always access public calendars, regardless of allowGuestAccess settingif (subscription && calendar.guestPermission !== "none") {- return calendar.guestPermission as CalendarPermission;+ return {+ permission: calendar.guestPermission as CalendarPermission,+ calendar,+ };}- return null;+ return { permission: null, calendar };}/**@@ -188,6 +214,48 @@ export async function canDeleteCalendar(return checkPermission(userId, calendarId, "owner");}+/**+ * Shift signup permission for a given user on a given calendar.+ * - canManageOwn: may add/remove themselves+ * - canManageOthers: may add/remove any other member+ *+ * Only logged-in users (userId set) can hold signups at all — guests never do,+ * even when a share/access-token grants them "write" on the calendar itself.+ * The calendar-wide signupsEnabled switch (owner/admin only) overrides+ * everything else. A "read"-level member can only self-manage, and only while+ * allowSelfSignup is on; write/admin/owner can always manage anyone.+ */+export async function getShiftSignupPermission(+ userId: string | null | undefined,+ calendarId: string+): Promise<{ canManageOwn: boolean; canManageOthers: boolean }> {+ if (!userId) {+ return { canManageOwn: false, canManageOthers: false };+ }++ const { permission, calendar } = await getUserCalendarPermissionWithCalendar(+ userId,+ calendarId+ );+ if (!permission) {+ return { canManageOwn: false, canManageOthers: false };+ }++ if (!calendar?.signupsEnabled) {+ return { canManageOwn: false, canManageOthers: false };+ }++ if (permission !== "read") {+ // owner / admin / write+ return { canManageOwn: true, canManageOthers: true };+ }++ return {+ canManageOwn: !!calendar.allowSelfSignup,+ canManageOthers: false,+ };+}+/*** Get all calendar IDs accessible to a user (or guest)* Returns array of calendar IDs with their permission levels@@ -472,6 +540,44 @@ export async function undismissCalendar(}}+/**+ * Minimal member list (owner + shares) for a calendar, deduped by user id.+ * Returns null if the calendar doesn't exist.+ */+export async function getCalendarMembers(+ calendarId: string+): Promise<CalendarMember[] | null> {+ const calendar = await db.query.calendars.findFirst({+ where: eq(calendars.id, calendarId),+ columns: { id: true },+ with: {+ owner: { columns: { id: true, name: true, image: true } },+ },+ });++ if (!calendar) {+ return null;+ }++ const shares = await db.query.calendarShares.findMany({+ where: eq(calendarShares.calendarId, calendarId),+ with: {+ user: { columns: { id: true, name: true, image: true } },+ },+ });++ const members = new Map<string, CalendarMember>();++ if (calendar.owner) {+ members.set(calendar.owner.id, calendar.owner);+ }+ for (const share of shares) {+ members.set(share.user.id, share.user);+ }++ return Array.from(members.values());+}+/*** Get all orphaned calendars (calendars with ownerId=null)* ADMIN-ONLY function - must check admin permissions before callingdiff --git a/lib/db/schema.ts b/lib/db/schema.tsindex ada245c..be79be6 100644--- a/lib/db/schema.ts+++ b/lib/db/schema.ts@@ -1,4 +1,10 @@-import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";+import {+ sqliteTable,+ text,+ integer,+ index,+ uniqueIndex,+} from "drizzle-orm/sqlite-core";import { sql, relations } from "drizzle-orm";import type {CalendarViewSettings,@@ -117,6 +123,16 @@ export const calendars = sqliteTable(}).notNull().default("none"),+ // Whether read-only members may sign themselves up for a shift without+ // write access. Owner/admin can turn this off to require assignment instead.+ allowSelfSignup: integer("allow_self_signup", { mode: "boolean" })+ .notNull()+ .default(true),+ // Master switch for the whole shift-signup feature on this calendar.+ // Owner/admin only; off hides capacity, signup lists and badges everywhere.+ signupsEnabled: integer("signups_enabled", { mode: "boolean" })+ .notNull()+ .default(true),// null = no own view; every user sees their personal viewviewSettings: text("view_settings", {mode: "json",@@ -271,6 +287,8 @@ export const shifts = sqliteTable("shifts", {isSecondary: integer("is_secondary", { mode: "boolean" }).notNull().default(false),+ // Target headcount for shift signups; null = unlimited+ signupCapacity: integer("signup_capacity"),externalEventId: text("external_event_id"),externalSyncId: text("external_sync_id").references(() => externalSyncs.id, {onDelete: "cascade",@@ -306,6 +324,8 @@ export const shiftPresets = sqliteTable("shift_presets", {hideFromStats: integer("hide_from_stats", { mode: "boolean" }).notNull().default(false),+ // Copied into signupCapacity on shifts created from this preset+ defaultSignupCapacity: integer("default_signup_capacity"),order: integer("order").notNull().default(0),createdAt: integer("created_at", { mode: "timestamp" }).notNull()@@ -428,6 +448,37 @@ export const calendarAccessTokens = sqliteTable(]);+export const shiftSignups = sqliteTable(+ "shift_signups",+ {+ id: text("id")+ .primaryKey()+ .$defaultFn(() => crypto.randomUUID()),+ shiftId: text("shift_id")+ .notNull()+ .references(() => shifts.id, { onDelete: "cascade" }),+ userId: text("user_id")+ .notNull()+ .references(() => user.id, { onDelete: "cascade" }),+ // Who created this signup: the user themself, or an admin/write-permission+ // user who assigned someone else. Distinct from userId for that reason.+ signedUpBy: text("signed_up_by")+ .notNull()+ .references(() => user.id, { onDelete: "cascade" }),+ createdAt: integer("created_at", { mode: "timestamp" })+ .notNull()+ .default(sql`CURRENT_TIMESTAMP`),+ },+ (table) => [+ index("shift_signups_shiftId_idx").on(table.shiftId),+ index("shift_signups_userId_idx").on(table.userId),+ uniqueIndex("shift_signups_shiftId_userId_idx").on(+ table.shiftId,+ table.userId+ ),+ ]+);+export type Calendar = typeof calendars.$inferSelect;export type NewCalendar = typeof calendars.$inferInsert;@@ -447,6 +498,8 @@ export type CalendarNote = typeof calendarNotes.$inferSelect;export type NewCalendarNote = typeof calendarNotes.$inferInsert;export type SyncLog = typeof syncLogs.$inferSelect;export type NewSyncLog = typeof syncLogs.$inferInsert;+export type ShiftSignup = typeof shiftSignups.$inferSelect;+export type NewShiftSignup = typeof shiftSignups.$inferInsert;// Better Auth typesexport type User = typeof user.$inferSelect;@@ -505,6 +558,33 @@ export const calendarsRelations = relations(calendars, ({ one, many }) => ({syncLogs: many(syncLogs),}));+export const shiftsRelations = relations(shifts, ({ one, many }) => ({+ calendar: one(calendars, {+ fields: [shifts.calendarId],+ references: [calendars.id],+ }),+ preset: one(shiftPresets, {+ fields: [shifts.presetId],+ references: [shiftPresets.id],+ }),+ signups: many(shiftSignups),+}));++export const shiftSignupsRelations = relations(shiftSignups, ({ one }) => ({+ shift: one(shifts, {+ fields: [shiftSignups.shiftId],+ references: [shifts.id],+ }),+ user: one(user, {+ fields: [shiftSignups.userId],+ references: [user.id],+ }),+ signedUpByUser: one(user, {+ fields: [shiftSignups.signedUpBy],+ references: [user.id],+ }),+}));+export const calendarSharesRelations = relations(calendarShares, ({ one }) => ({calendar: one(calendars, {fields: [calendarShares.calendarId],diff --git a/lib/query-keys.ts b/lib/query-keys.tsindex 6196bc3..e737aca 100644--- a/lib/query-keys.ts+++ b/lib/query-keys.ts@@ -17,6 +17,12 @@ export const queryKeys = {all: ["shifts"] as const,byCalendar: (calendarId: string) => ["shifts", calendarId] as const,},+ shiftSignups: {+ byShift: (shiftId: string) => ["shift-signups", shiftId] as const,+ },+ calendarMembers: {+ byCalendar: (calendarId: string) => ["calendar-members", calendarId] as const,+ },presets: {all: ["presets"] as const,byCalendar: (calendarId: string) => ["presets", calendarId] as const,diff --git a/lib/shift-display.ts b/lib/shift-display.tsindex f8e7bd0..7de97fb 100644--- a/lib/shift-display.ts+++ b/lib/shift-display.ts@@ -1,5 +1,6 @@import { CSSProperties } from "react";import { isSameDay } from "date-fns";+import { useTranslations } from "next-intl";import { ShiftWithCalendar } from "@/lib/types";import { ExternalSync, ShiftPreset } from "@/lib/db/schema";import { calculateShiftDuration } from "@/lib/date-utils";@@ -147,6 +148,19 @@ export function shiftVars(color?: string | null): CSSProperties {return { "--shift": color || undefined } as CSSProperties;}+/** "3/5 signed up · Full"-style label shared by every signup-capacity display. */+export function formatSignupCapacityLabel(+ t: ReturnType<typeof useTranslations>,+ count: number,+ capacity: number+): { text: string; isFull: boolean } {+ const isFull = count >= capacity;+ const text = `${t("shiftSignup.capacityProgress", { count, capacity })}${+ isFull ? ` · ${t("shiftSignup.full")}` : ""+ }`;+ return { text, isFull };+}+/** One-letter stamp code used where only a block fits (stamp dock, preset list, compare). */export function getShiftCode(title: string): string {const first = Array.from(title.trim())[0];diff --git a/lib/shift-signups.ts b/lib/shift-signups.tsnew file mode 100644index 0000000..ea5fe94--- /dev/null+++ b/lib/shift-signups.ts@@ -0,0 +1,150 @@+import { db } from "@/lib/db";+import { shifts, shiftSignups } from "@/lib/db/schema";+import { eq, inArray } from "drizzle-orm";+import {+ getShiftSignupPermission,+ getUserCalendarPermission,+} from "@/lib/auth/permissions";+import type { CalendarMember, ShiftSignupUser } from "@/lib/types";++export type AddShiftSignupResult =+ | { ok: true }+ | { ok: false; error: string; status: number };++type ShiftForSignups = {+ id: string;+ calendarId: string;+ signupCapacity: number | null;+};++/** Shared "fetch shift by id" for the signup routes, selecting only what they need. */+export async function getShiftOrNull(+ shiftId: string+): Promise<ShiftForSignups | null> {+ const [shift] = await db+ .select({+ id: shifts.id,+ calendarId: shifts.calendarId,+ signupCapacity: shifts.signupCapacity,+ })+ .from(shifts)+ .where(eq(shifts.id, shiftId));+ return shift ?? null;+}++/** All signups for a shift, resolved to their signed-up user. */+export async function getShiftSignupUsers(+ shiftId: string+): Promise<ShiftSignupUser[]> {+ const rows = await db.query.shiftSignups.findMany({+ where: eq(shiftSignups.shiftId, shiftId),+ with: {+ user: { columns: { id: true, name: true, email: true, image: true } },+ },+ orderBy: (signups, { asc }) => [asc(signups.createdAt)],+ });+ return rows.map((row) => row.user);+}++/** Whether requestingUserId may add/remove targetUserId's signup, given a resolved signup permission. */+export function canActOnSignup(+ permission: { canManageOwn: boolean; canManageOthers: boolean },+ requestingUserId: string,+ targetUserId: string+): boolean {+ return targetUserId === requestingUserId+ ? permission.canManageOwn+ : permission.canManageOthers;+}++/**+ * Adds one signup, enforcing the same rules for both the dedicated signups+ * route and initial signups passed along with shift creation. `existingUserIds`+ * is mutated on success so callers can loop over several target users while+ * keeping capacity/duplicate checks correct across the batch.+ */+export async function addShiftSignup(+ shiftId: string,+ calendarId: string,+ requestingUserId: string,+ targetUserId: string,+ existingUserIds: Set<string>,+ capacity: number | null+): Promise<AddShiftSignupResult> {+ const permission = await getShiftSignupPermission(+ requestingUserId,+ calendarId+ );+ if (!canActOnSignup(permission, requestingUserId, targetUserId)) {+ return { ok: false, error: "Insufficient permissions", status: 403 };+ }++ // The assigned user must already have access to the calendar, otherwise+ // they would have no way to see a shift they are signed up for.+ if (targetUserId !== requestingUserId) {+ const targetPermission = await getUserCalendarPermission(+ targetUserId,+ calendarId+ );+ if (!targetPermission) {+ return {+ ok: false,+ error: "Target user has no access to this calendar",+ status: 400,+ };+ }+ }++ if (existingUserIds.has(targetUserId)) {+ return {+ ok: false,+ error: "User is already signed up for this shift",+ status: 409,+ };+ }++ if (capacity != null && existingUserIds.size >= capacity) {+ return {+ ok: false,+ error: "Shift signup capacity reached",+ status: 409,+ };+ }++ await db.insert(shiftSignups).values({+ shiftId,+ userId: targetUserId,+ signedUpBy: requestingUserId,+ });+ existingUserIds.add(targetUserId);++ return { ok: true };+}++// Attaches each shift's signed-up members without N+1 queries.+export async function withSignups<T extends { id: string }>(+ shiftRows: T[]+): Promise<(T & { signups: CalendarMember[] })[]> {+ if (shiftRows.length === 0) return [];++ const rows = await db.query.shiftSignups.findMany({+ where: inArray(+ shiftSignups.shiftId,+ shiftRows.map((s) => s.id)+ ),+ with: { user: { columns: { id: true, name: true, image: true } } },+ orderBy: (signups, { asc }) => [asc(signups.createdAt)],+ });++ const byShiftId = new Map<string, CalendarMember[]>();+ for (const row of rows) {+ const list = byShiftId.get(row.shiftId) ?? [];+ list.push(row.user);+ byShiftId.set(row.shiftId, list);+ }++ return shiftRows.map((shift) => ({+ ...shift,+ signups: byShiftId.get(shift.id) ?? [],+ }));+}diff --git a/lib/types.ts b/lib/types.tsindex 2f559e1..138073f 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -9,6 +9,8 @@ export interface CalendarWithCount {color: string;ownerId?: string | null;guestPermission?: "none" | "read" | "write";+ allowSelfSignup?: boolean;+ signupsEnabled?: boolean;/** The calendar's own view; null means everyone sees their personal view */viewSettings?: CalendarViewSettings | null;createdAt: Date | null;@@ -39,6 +41,21 @@ export interface ShiftWithCalendar {isAllDay?: boolean;syncedFromExternal?: boolean;externalSyncId?: string | null;+ signupCapacity?: number | null;+ signups?: ShiftSignupUser[];createdAt: Date | null;updatedAt: Date | null;}++export interface ShiftSignupUser {+ id: string;+ name: string | null;+ email: string;+ image?: string | null;+}++export interface CalendarMember {+ id: string;+ name: string | null;+ image?: string | null;+}diff --git a/lib/utils.ts b/lib/utils.tsindex e64715b..cf1b60c 100644--- a/lib/utils.ts+++ b/lib/utils.ts@@ -59,6 +59,11 @@ export function generateTempId(): string {return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;}+/** Whether an id is an optimistic placeholder created via `temp-${generateTempId()}`. */+export function isTempId(id: string): boolean {+ return id.startsWith("temp-");+}+/** Up to two initials from a name, falling back to the e-mail. */export function getUserInitials(user: { name?: string | null; email?: string }): string {const source = user.name?.trim();diff --git a/messages/cs.json b/messages/cs.jsonindex d1cc215..69e4420 100644--- a/messages/cs.json+++ b/messages/cs.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "např. {example}","colorLabel": "Barva",- "notesLabel": "Poznámky (volitelné)",+ "notesLabel": "Poznámky","notesPlaceholder": "Další informace...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "Smazat tuto předvolbu? Tím se smažou i všechny směny vytvořené z této předvolby.","secondary": "Další","hideFromStats": "Skrýt ze statistik",- "group": "Skupina (volitelné)",+ "group": "Skupina","groupPlaceholder": "např. Pracovní den, Víkend...","selectGroupHint": "Vybrat všechny předvolby v této skupině","copiedSuffix": "kopie"@@ -800,7 +800,9 @@"delete": "Smazat předvolbu","dragHandle": "Přetažením změníte pořadí","secondarySection": "Pod „Další“",- "markAsSecondaryHint": "V liště šablon se zobrazí až po kliknutí na „Další“"+ "markAsSecondaryHint": "V liště šablon se zobrazí až po kliknutí na „Další“",+ "defaultSignupCapacityLabel": "Maximalni pocet osob",+ "defaultSignupCapacityHint": "Určuje, kolik lidí se může přihlásit na směny vytvořené z této šablony. Nechte prázdné pro neomezený počet. Při vytvoření směny se zkopíruje a lze ho u každé směny upravit."},"syncSheet": {"intervalPill": "Každých {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Vytvářet a mazat směny","permAdminDesc": "Navíc spravovat sdílení a nastavení","changePermission": "Změnit oprávnění pro {name}",- "publicOffTitle": "Veřejný přístup je vypnutý",- "publicOnTitle": "Veřejný přístup je zapnutý","accessNone": "Bez přístupu","guestNoneShort": "Jen pozvaní a odkazy","activeLinks": "Aktivní odkazy",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Všichni mohou upravovat","guestReadShortGuestsOff": "Přihlášení mohou prohlížet","guestWriteShortGuestsOff": "Přihlášení mohou upravovat",- "publicOffBodyGuestsOn": "Přístup mají jen pozvaní lidé a držitelé přístupového odkazu; odkazy fungují i bez účtu. Na kartě „Veřejné“ můžete kalendář zpřístupnit všem, i návštěvníkům bez účtu.",- "publicOffBodyGuestsOff": "Přístup mají jen pozvaní lidé a držitelé přístupového odkazu; příjemci odkazu se musí přihlásit, protože přístup pro hosty je na této instanci vypnutý. Na kartě „Veřejné“ můžete kalendář zpřístupnit přihlášeným uživatelům této instance.","linkInfoGuestsOn": "Odkaz otevře kalendář přímo, bez přihlášení. V seznamu ho můžete kdykoli zrušit — pak okamžitě přestane platit.",- "linkInfoGuestsOff": "Odkaz otevře kalendář přímo. Přístup pro hosty je na této instanci vypnutý, takže se příjemci musí přihlásit. V seznamu ho můžete kdykoli zrušit — pak okamžitě přestane platit."+ "linkInfoGuestsOff": "Odkaz otevře kalendář přímo. Přístup pro hosty je na této instanci vypnutý, takže se příjemci musí přihlásit. V seznamu ho můžete kdykoli zrušit — pak okamžitě přestane platit.",+ "allowSelfSignupLabel": "Samostatné přihlašování na směny",+ "allowSelfSignupDesc": "Členové jen se čtením se mohou sami přihlásit i odhlásit ze směny",+ "signupsEnabledLabel": "Povolit přihlašování na směny",+ "signupsEnabledDesc": "Umožní lidem přihlásit se na směny. Po vypnutí zmizí seznamy přihlášených, avatary i maximální počet osob."},"shiftSheet": {"start": "Začátek",@@ -875,7 +877,9 @@"duration": "Délka","allDay": "Celý den","noPreset": "Vlastní",- "createAction": "Vytvořit směnu"+ "createAction": "Vytvořit směnu",+ "signupCapacityLabel": "Maximalni pocet osob",+ "signupCapacityHint": "Určuje, kolik lidí se může přihlásit na tuto směnu. Nechte prázdné pro neomezený počet."},"noteSheet": {"createTitle": "Nový záznam",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} z {total}","label": "Stránky"+ },+ "shiftSignup": {+ "title": "Kdo dělá tuto směnu?",+ "addSelf": "Přihlásit se",+ "addOther": "Přidat osobu",+ "addOtherPlaceholder": "Vybrat osobu",+ "remove": "Odebrat",+ "empty": "Zatím se nikdo nepřihlásil",+ "capacityProgress": "{count} z {capacity}",+ "full": "Obsazeno",+ "selfSignupDisabled": "Vlastník kalendáře vypnul samostatné přihlašování",+ "andMore": "+{count} další",+ "errors": {+ "full": "Tato směna je již plně obsazena",+ "alreadySignedUp": "Tato osoba je již přihlášena",+ "noAccess": "Tato osoba nemá přístup ke kalendáři",+ "addFailed": "Přihlášení se nezdařilo",+ "removeFailed": "Odhlášení se nezdařilo"+ },+ "addOtherHint": "Nemůžete někoho najít? Nejdřív s ním sdílejte kalendář, pak ho tu budete moct vybrat."}}diff --git a/messages/de.json b/messages/de.jsonindex b18a3e8..0b93ec3 100644--- a/messages/de.json+++ b/messages/de.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "z.B. {example}","colorLabel": "Farbe",- "notesLabel": "Notizen (optional)",+ "notesLabel": "Notizen","notesPlaceholder": "Zusätzliche Informationen...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "Diese Vorlage löschen? Alle aus dieser Vorlage erstellten Schichten werden ebenfalls gelöscht.","secondary": "Weitere","hideFromStats": "Aus Statistik ausblenden",- "group": "Gruppe (optional)",+ "group": "Gruppe","groupPlaceholder": "z.B. Wochentag, Wochenende...","selectGroupHint": "Alle Vorlagen dieser Gruppe auswählen","copiedSuffix": "kopiert"@@ -800,7 +800,9 @@"delete": "Vorlage löschen","dragHandle": "Zum Sortieren ziehen","secondarySection": "Unter „Weitere“",- "markAsSecondaryHint": "Erscheint in der Vorlagenleiste erst nach Klick auf „Weitere“"+ "markAsSecondaryHint": "Erscheint in der Vorlagenleiste erst nach Klick auf „Weitere“",+ "defaultSignupCapacityLabel": "Maximale Anzahl Personen",+ "defaultSignupCapacityHint": "Legt fest, wie viele Personen sich für Schichten aus dieser Vorlage eintragen können. Leer lassen für unbegrenzt viele Anmeldungen. Wird beim Anlegen übernommen und kann pro Schicht angepasst werden."},"syncSheet": {"intervalPill": "Alle {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Schichten anlegen und löschen","permAdminDesc": "Zusätzlich Freigaben und Einstellungen verwalten","changePermission": "Berechtigung für {name} ändern",- "publicOffTitle": "Öffentlicher Zugang ist aus",- "publicOnTitle": "Öffentlicher Zugang ist an","accessNone": "Kein Zugriff","guestNoneShort": "Nur Eingeladene und Links","activeLinks": "Aktive Links",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Alle können ändern","guestReadShortGuestsOff": "Angemeldete können ansehen","guestWriteShortGuestsOff": "Angemeldete können ändern",- "publicOffBodyGuestsOn": "Zugriff haben nur eingeladene Personen und Inhaber eines Zugangslinks – Links funktionieren auch ohne Konto. Über den Reiter „Öffentlich“ kannst du den Kalender für alle freigeben, auch für Besucher ohne Konto.",- "publicOffBodyGuestsOff": "Zugriff haben nur eingeladene Personen und Inhaber eines Zugangslinks; Link-Empfänger müssen sich anmelden, weil der Gastzugang auf dieser Instanz aus ist. Über den Reiter „Öffentlich“ kannst du den Kalender für angemeldete Nutzer dieser Instanz freigeben.","linkInfoGuestsOn": "Der Link öffnet den Kalender direkt, ohne Anmeldung. Er lässt sich jederzeit in der Liste widerrufen — dann ist er sofort ungültig.",- "linkInfoGuestsOff": "Der Link öffnet den Kalender direkt. Weil der Gastzugang auf dieser Instanz aus ist, müssen sich Empfänger anmelden. Er lässt sich jederzeit in der Liste widerrufen — dann ist er sofort ungültig."+ "linkInfoGuestsOff": "Der Link öffnet den Kalender direkt. Weil der Gastzugang auf dieser Instanz aus ist, müssen sich Empfänger anmelden. Er lässt sich jederzeit in der Liste widerrufen — dann ist er sofort ungültig.",+ "allowSelfSignupLabel": "Selbstanmeldung für Schichten",+ "allowSelfSignupDesc": "Nutzer mit Nur-Lese-Zugriff dürfen sich selbst für Schichten ein- und austragen",+ "signupsEnabledLabel": "Schicht-Anmeldungen aktivieren",+ "signupsEnabledDesc": "Erlaubt, dass sich Personen für Schichten eintragen. Ausgeschaltet verschwinden Anmeldelisten, Avatare und die maximale Personenanzahl aus der Ansicht."},"shiftSheet": {"start": "Beginn",@@ -875,7 +877,9 @@"duration": "Dauer","allDay": "Ganztägig","noPreset": "Frei",- "createAction": "Schicht anlegen"+ "createAction": "Schicht anlegen",+ "signupCapacityLabel": "Maximale Anzahl Personen",+ "signupCapacityHint": "Legt fest, wie viele Personen sich für diese Schicht eintragen können. Leer lassen für unbegrenzt viele Anmeldungen."},"noteSheet": {"createTitle": "Neuer Eintrag",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} von {total}","label": "Seiten"+ },+ "shiftSignup": {+ "title": "Wer macht diese Schicht?",+ "addSelf": "Mich eintragen",+ "addOther": "Person hinzufügen",+ "addOtherPlaceholder": "Person auswählen",+ "remove": "Entfernen",+ "empty": "Noch niemand eingetragen",+ "capacityProgress": "{count} von {capacity}",+ "full": "Voll",+ "selfSignupDisabled": "Der Kalender-Owner hat die Selbstanmeldung deaktiviert",+ "andMore": "+{count} weitere",+ "errors": {+ "full": "Für diese Schicht sind bereits alle Plätze belegt",+ "alreadySignedUp": "Diese Person ist bereits eingetragen",+ "noAccess": "Diese Person hat keinen Zugriff auf den Kalender",+ "addFailed": "Eintragen ist fehlgeschlagen",+ "removeFailed": "Austragen ist fehlgeschlagen"+ },+ "addOtherHint": "Person nicht in der Liste? Teile den Kalender zuerst mit ihr, dann kannst du sie hier auswählen."}}diff --git a/messages/en.json b/messages/en.jsonindex 747c556..c4a8be8 100644--- a/messages/en.json+++ b/messages/en.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "e.g., {example}","colorLabel": "Color",- "notesLabel": "Notes (optional)",+ "notesLabel": "Notes","notesPlaceholder": "Additional information...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "Delete this preset? This will also delete all shifts created from this preset.","secondary": "More","hideFromStats": "Hide from statistics",- "group": "Group (optional)",+ "group": "Group","groupPlaceholder": "e.g. Weekday, Weekend...","selectGroupHint": "Select all presets in this group","copiedSuffix": "copied"@@ -800,7 +800,9 @@"delete": "Delete preset","dragHandle": "Drag to reorder","secondarySection": "Under “More”",- "markAsSecondaryHint": "Shows in the preset bar only after clicking “More”"+ "markAsSecondaryHint": "Shows in the preset bar only after clicking “More”",+ "defaultSignupCapacityLabel": "Maximum number of people",+ "defaultSignupCapacityHint": "Sets how many people can sign up for shifts created from this preset. Leave empty for unlimited signups. Copied when a shift is created and can be adjusted per shift."},"syncSheet": {"intervalPill": "Every {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Create and delete shifts","permAdminDesc": "Also manage sharing and settings","changePermission": "Change permission for {name}",- "publicOffTitle": "Public access is off",- "publicOnTitle": "Public access is on","accessNone": "No access","guestNoneShort": "Invited people and links only","activeLinks": "Active links",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Everyone can edit","guestReadShortGuestsOff": "Signed-in users can view","guestWriteShortGuestsOff": "Signed-in users can edit",- "publicOffBodyGuestsOn": "Only invited people and holders of an access link have access; links work without an account too. Use the “Public” tab to open the calendar to everyone, including visitors without an account.",- "publicOffBodyGuestsOff": "Only invited people and holders of an access link have access; link recipients need to sign in, because guest access is off on this instance. Use the “Public” tab to open the calendar to signed-in users of this instance.","linkInfoGuestsOn": "The link opens the calendar directly, without signing in. You can revoke it from the list at any time — it stops working immediately.",- "linkInfoGuestsOff": "The link opens the calendar directly. Guest access is off on this instance, so recipients need to sign in. You can revoke it from the list at any time — it stops working immediately."+ "linkInfoGuestsOff": "The link opens the calendar directly. Guest access is off on this instance, so recipients need to sign in. You can revoke it from the list at any time — it stops working immediately.",+ "allowSelfSignupLabel": "Self-signup for shifts",+ "allowSelfSignupDesc": "Read-only members may sign themselves up for and withdraw from shifts",+ "signupsEnabledLabel": "Enable shift signups",+ "signupsEnabledDesc": "Lets people sign up for shifts. Turning this off hides signup lists, avatars, and the maximum headcount everywhere."},"shiftSheet": {"start": "Start",@@ -875,7 +877,9 @@"duration": "Duration","allDay": "All day","noPreset": "Custom",- "createAction": "Create shift"+ "createAction": "Create shift",+ "signupCapacityLabel": "Maximum number of people",+ "signupCapacityHint": "Sets how many people can sign up for this shift. Leave empty for unlimited signups."},"noteSheet": {"createTitle": "New entry",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} of {total}","label": "Pages"+ },+ "shiftSignup": {+ "title": "Who's doing this shift?",+ "addSelf": "Sign me up",+ "addOther": "Add person",+ "addOtherPlaceholder": "Select a person",+ "remove": "Remove",+ "empty": "No one signed up yet",+ "capacityProgress": "{count} of {capacity}",+ "full": "Full",+ "selfSignupDisabled": "The calendar owner has turned off self-signup",+ "andMore": "+{count} more",+ "errors": {+ "full": "This shift is already fully booked",+ "alreadySignedUp": "This person is already signed up",+ "noAccess": "This person doesn't have access to the calendar",+ "addFailed": "Signing up failed",+ "removeFailed": "Withdrawing failed"+ },+ "addOtherHint": "Can't find someone? Share the calendar with them first, then you can pick them here."}}diff --git a/messages/es.json b/messages/es.jsonindex ec79325..73b0d1b 100644--- a/messages/es.json+++ b/messages/es.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "ej., {example}","colorLabel": "Color",- "notesLabel": "Notas (opcional)",+ "notesLabel": "Notas","notesPlaceholder": "Información adicional...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "¿Eliminar este preajuste? Esto también eliminará todos los turnos creados a partir de él.","secondary": "Más","hideFromStats": "Ocultar de las estadísticas",- "group": "Grupo (opcional)",+ "group": "Grupo","groupPlaceholder": "p. ej. Día laboral, Fin de semana...","selectGroupHint": "Seleccionar todos los preajustes de este grupo","copiedSuffix": "copiado"@@ -800,7 +800,9 @@"delete": "Eliminar preajuste","dragHandle": "Arrastrar para ordenar","secondarySection": "En «Más»",- "markAsSecondaryHint": "Aparece en la barra de plantillas solo al pulsar «Más»"+ "markAsSecondaryHint": "Aparece en la barra de plantillas solo al pulsar «Más»",+ "defaultSignupCapacityLabel": "Numero maximo de personas",+ "defaultSignupCapacityHint": "Define cuántas personas pueden inscribirse en turnos creados a partir de esta plantilla. Déjalo vacío para inscripciones ilimitadas. Se copia al crear el turno y puede ajustarse por turno."},"syncSheet": {"intervalPill": "Cada {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Crear y eliminar turnos","permAdminDesc": "Además gestionar compartidos y ajustes","changePermission": "Cambiar el permiso de {name}",- "publicOffTitle": "El acceso público está desactivado",- "publicOnTitle": "El acceso público está activado","accessNone": "Sin acceso","guestNoneShort": "Solo invitados y enlaces","activeLinks": "Enlaces activos",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Todos pueden editar","guestReadShortGuestsOff": "Usuarios con cuenta pueden ver","guestWriteShortGuestsOff": "Usuarios con cuenta pueden editar",- "publicOffBodyGuestsOn": "Solo tienen acceso las personas invitadas y quienes tengan un enlace de acceso; los enlaces también funcionan sin cuenta. En la pestaña «Público» puedes abrir el calendario a todos, incluso a visitantes sin cuenta.",- "publicOffBodyGuestsOff": "Solo tienen acceso las personas invitadas y quienes tengan un enlace de acceso; quienes reciban un enlace deben iniciar sesión, porque el acceso de invitados está desactivado en esta instancia. En la pestaña «Público» puedes abrir el calendario a los usuarios autenticados de esta instancia.","linkInfoGuestsOn": "El enlace abre el calendario directamente, sin iniciar sesión. Puedes revocarlo en la lista en cualquier momento; deja de funcionar al instante.",- "linkInfoGuestsOff": "El enlace abre el calendario directamente. El acceso de invitados está desactivado en esta instancia, así que los destinatarios deben iniciar sesión. Puedes revocarlo en la lista en cualquier momento; deja de funcionar al instante."+ "linkInfoGuestsOff": "El enlace abre el calendario directamente. El acceso de invitados está desactivado en esta instancia, así que los destinatarios deben iniciar sesión. Puedes revocarlo en la lista en cualquier momento; deja de funcionar al instante.",+ "allowSelfSignupLabel": "Autoinscripcion a turnos",+ "allowSelfSignupDesc": "Los miembros de solo lectura pueden inscribirse y darse de baja de turnos",+ "signupsEnabledLabel": "Activar inscripciones a turnos",+ "signupsEnabledDesc": "Permite que las personas se inscriban en turnos. Al desactivarlo desaparecen las listas de inscripción, los avatares y el número máximo de personas."},"shiftSheet": {"start": "Inicio",@@ -875,7 +877,9 @@"duration": "Duración","allDay": "Todo el día","noPreset": "Libre",- "createAction": "Crear turno"+ "createAction": "Crear turno",+ "signupCapacityLabel": "Numero maximo de personas",+ "signupCapacityHint": "Define cuántas personas pueden inscribirse en este turno. Déjalo vacío para inscripciones ilimitadas."},"noteSheet": {"createTitle": "Nueva entrada",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} de {total}","label": "Páginas"+ },+ "shiftSignup": {+ "title": "¿Quien hace este turno?",+ "addSelf": "Inscribirme",+ "addOther": "Anadir persona",+ "addOtherPlaceholder": "Selecciona una persona",+ "remove": "Quitar",+ "empty": "Todavia nadie se ha inscrito",+ "capacityProgress": "{count} de {capacity}",+ "full": "Completo",+ "selfSignupDisabled": "El propietario del calendario ha desactivado la autoinscripcion",+ "andMore": "+{count} mas",+ "errors": {+ "full": "Este turno ya esta completo",+ "alreadySignedUp": "Esta persona ya esta inscrita",+ "noAccess": "Esta persona no tiene acceso al calendario",+ "addFailed": "La inscripcion ha fallado",+ "removeFailed": "La baja ha fallado"+ },+ "addOtherHint": "¿No encuentras a alguien? Comparte primero el calendario con esa persona; luego podrás seleccionarla aquí."}}diff --git a/messages/fr.json b/messages/fr.jsonindex 4b80d26..02152f3 100755--- a/messages/fr.json+++ b/messages/fr.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "ex. : {example}","colorLabel": "Couleur",- "notesLabel": "Notes (facultatif)",+ "notesLabel": "Notes","notesPlaceholder": "Informations complémentaires...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "Supprimer ce modèle ? Tous les créneaux créés à partir de ce modèle seront également supprimés.","secondary": "Plus","hideFromStats": "Exclure des statistiques",- "group": "Groupe (facultatif)",+ "group": "Groupe","groupPlaceholder": "p. ex. Semaine, Week-end...","selectGroupHint": "Sélectionner tous les modèles de ce groupe","copiedSuffix": "copié"@@ -800,7 +800,9 @@"delete": "Supprimer le modèle","dragHandle": "Glisser pour réordonner","secondarySection": "Sous « Plus »",- "markAsSecondaryHint": "N’apparaît dans la barre de modèles qu’après un clic sur « Plus »"+ "markAsSecondaryHint": "N’apparaît dans la barre de modèles qu’après un clic sur « Plus »",+ "defaultSignupCapacityLabel": "Nombre maximum de personnes",+ "defaultSignupCapacityHint": "Définit combien de personnes peuvent s'inscrire aux gardes créées à partir de ce modèle. Laissez vide pour un nombre illimité. Copié à la création et modifiable pour chaque garde."},"syncSheet": {"intervalPill": "Toutes les {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Créer et supprimer des postes","permAdminDesc": "Gérer aussi les partages et les paramètres","changePermission": "Modifier l’autorisation de {name}",- "publicOffTitle": "L’accès public est désactivé",- "publicOnTitle": "L’accès public est activé","accessNone": "Aucun accès","guestNoneShort": "Invités et liens uniquement","activeLinks": "Liens actifs",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Tout le monde peut modifier","guestReadShortGuestsOff": "Les utilisateurs connectés peuvent voir","guestWriteShortGuestsOff": "Les utilisateurs connectés peuvent modifier",- "publicOffBodyGuestsOn": "Seules les personnes invitées et les détenteurs d’un lien d’accès y ont accès ; les liens fonctionnent aussi sans compte. L’onglet « Public » permet d’ouvrir le calendrier à tous, y compris aux visiteurs sans compte.",- "publicOffBodyGuestsOff": "Seules les personnes invitées et les détenteurs d’un lien d’accès y ont accès ; les destinataires d’un lien doivent se connecter, car l’accès invité est désactivé sur cette instance. L’onglet « Public » permet d’ouvrir le calendrier aux utilisateurs connectés de cette instance.","linkInfoGuestsOn": "Le lien ouvre directement le calendrier, sans connexion. Vous pouvez le révoquer à tout moment dans la liste ; il cesse alors immédiatement de fonctionner.",- "linkInfoGuestsOff": "Le lien ouvre directement le calendrier. L’accès invité est désactivé sur cette instance : les destinataires doivent se connecter. Vous pouvez le révoquer à tout moment dans la liste ; il cesse alors immédiatement de fonctionner."+ "linkInfoGuestsOff": "Le lien ouvre directement le calendrier. L’accès invité est désactivé sur cette instance : les destinataires doivent se connecter. Vous pouvez le révoquer à tout moment dans la liste ; il cesse alors immédiatement de fonctionner.",+ "allowSelfSignupLabel": "Inscription autonome aux gardes",+ "allowSelfSignupDesc": "Les membres en lecture seule peuvent s'inscrire et se desinscrire des gardes",+ "signupsEnabledLabel": "Activer les inscriptions aux gardes",+ "signupsEnabledDesc": "Permet aux personnes de s'inscrire aux gardes. La désactivation masque les listes d'inscription, les avatars et l'effectif maximal partout."},"shiftSheet": {"start": "Début",@@ -875,7 +877,9 @@"duration": "Durée","allDay": "Toute la journée","noPreset": "Libre",- "createAction": "Créer le créneau"+ "createAction": "Créer le créneau",+ "signupCapacityLabel": "Nombre maximum de personnes",+ "signupCapacityHint": "Définit combien de personnes peuvent s'inscrire à cette garde. Laissez vide pour un nombre illimité."},"noteSheet": {"createTitle": "Nouvelle entrée",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} sur {total}","label": "Pages"+ },+ "shiftSignup": {+ "title": "Qui fait cette garde ?",+ "addSelf": "M'inscrire",+ "addOther": "Ajouter une personne",+ "addOtherPlaceholder": "Selectionner une personne",+ "remove": "Retirer",+ "empty": "Personne ne s'est encore inscrit",+ "capacityProgress": "{count} sur {capacity}",+ "full": "Complet",+ "selfSignupDisabled": "Le proprietaire du calendrier a desactive l'inscription autonome",+ "andMore": "+{count} de plus",+ "errors": {+ "full": "Cette garde est deja complete",+ "alreadySignedUp": "Cette personne est deja inscrite",+ "noAccess": "Cette personne n'a pas acces au calendrier",+ "addFailed": "L'inscription a echoue",+ "removeFailed": "La desinscription a echoue"+ },+ "addOtherHint": "Vous ne trouvez pas quelqu'un ? Partagez d'abord le calendrier avec cette personne, vous pourrez ensuite la sélectionner ici."}}diff --git a/messages/it.json b/messages/it.jsonindex 3fc63b1..454b07c 100644--- a/messages/it.json+++ b/messages/it.json@@ -130,7 +130,7 @@"form": {"namePlaceholder": "es., {example}","colorLabel": "Colore",- "notesLabel": "Note (opzionale)",+ "notesLabel": "Note","notesPlaceholder": "Informazioni aggiuntive...","urlPlaceholder": "https://..."},@@ -208,7 +208,7 @@"deleteConfirm": "Eliminare questo preset? Verranno eliminati anche tutti i turni creati da questo preset.","secondary": "Altri","hideFromStats": "Nascondi dalle statistiche",- "group": "Gruppo (opzionale)",+ "group": "Gruppo","groupPlaceholder": "es. Giorno feriale, Fine settimana...","selectGroupHint": "Seleziona tutti i preset di questo gruppo","copiedSuffix": "copiato"@@ -800,7 +800,9 @@"delete": "Elimina preset","dragHandle": "Trascina per riordinare","secondarySection": "Sotto «Altri»",- "markAsSecondaryHint": "Compare nella barra dei modelli solo dopo aver cliccato «Altri»"+ "markAsSecondaryHint": "Compare nella barra dei modelli solo dopo aver cliccato «Altri»",+ "defaultSignupCapacityLabel": "Numero massimo di persone",+ "defaultSignupCapacityHint": "Stabilisce quante persone possono iscriversi ai turni creati da questo modello. Lascia vuoto per un numero illimitato. Viene copiato alla creazione e può essere modificato per ogni turno."},"syncSheet": {"intervalPill": "Ogni {interval}",@@ -835,8 +837,6 @@"permWriteDesc": "Creare ed eliminare turni","permAdminDesc": "Gestire anche condivisioni e impostazioni","changePermission": "Modifica il permesso di {name}",- "publicOffTitle": "L’accesso pubblico è disattivato",- "publicOnTitle": "L’accesso pubblico è attivo","accessNone": "Nessun accesso","guestNoneShort": "Solo invitati e link","activeLinks": "Link attivi",@@ -864,10 +864,12 @@"guestWriteShortGuestsOn": "Tutti possono modificare","guestReadShortGuestsOff": "Gli utenti autenticati possono vedere","guestWriteShortGuestsOff": "Gli utenti autenticati possono modificare",- "publicOffBodyGuestsOn": "Hanno accesso solo le persone invitate e chi possiede un link di accesso; i link funzionano anche senza account. Dalla scheda «Pubblico» puoi aprire il calendario a tutti, anche ai visitatori senza account.",- "publicOffBodyGuestsOff": "Hanno accesso solo le persone invitate e chi possiede un link di accesso; chi riceve un link deve accedere, perché l’accesso ospite è disattivato su questa istanza. Dalla scheda «Pubblico» puoi aprire il calendario agli utenti autenticati di questa istanza.","linkInfoGuestsOn": "Il link apre direttamente il calendario, senza accesso. Puoi revocarlo dalla lista in qualsiasi momento: smette subito di funzionare.",- "linkInfoGuestsOff": "Il link apre direttamente il calendario. L’accesso ospite è disattivato su questa istanza, quindi i destinatari devono accedere. Puoi revocarlo dalla lista in qualsiasi momento: smette subito di funzionare."+ "linkInfoGuestsOff": "Il link apre direttamente il calendario. L’accesso ospite è disattivato su questa istanza, quindi i destinatari devono accedere. Puoi revocarlo dalla lista in qualsiasi momento: smette subito di funzionare.",+ "allowSelfSignupLabel": "Iscrizione autonoma ai turni",+ "allowSelfSignupDesc": "I membri in sola lettura possono iscriversi e ritirarsi dai turni",+ "signupsEnabledLabel": "Attiva le iscrizioni ai turni",+ "signupsEnabledDesc": "Permette alle persone di iscriversi ai turni. Disattivandolo, elenchi di iscrizione, avatar e numero massimo di persone scompaiono ovunque."},"shiftSheet": {"start": "Inizio",@@ -875,7 +877,9 @@"duration": "Durata","allDay": "Tutto il giorno","noPreset": "Libero",- "createAction": "Crea turno"+ "createAction": "Crea turno",+ "signupCapacityLabel": "Numero massimo di persone",+ "signupCapacityHint": "Stabilisce quante persone possono iscriversi a questo turno. Lascia vuoto per un numero illimitato."},"noteSheet": {"createTitle": "Nuova voce",@@ -1074,5 +1078,25 @@"adminPagination": {"range": "{from}–{to} di {total}","label": "Pagine"+ },+ "shiftSignup": {+ "title": "Chi fa questo turno?",+ "addSelf": "Iscrivimi",+ "addOther": "Aggiungi persona",+ "addOtherPlaceholder": "Seleziona una persona",+ "remove": "Rimuovi",+ "empty": "Nessuno si e ancora iscritto",+ "capacityProgress": "{count} di {capacity}",+ "full": "Al completo",+ "selfSignupDisabled": "Il proprietario del calendario ha disattivato l'iscrizione autonoma",+ "andMore": "+{count} in piu",+ "errors": {+ "full": "Questo turno e gia al completo",+ "alreadySignedUp": "Questa persona e gia iscritta",+ "noAccess": "Questa persona non ha accesso al calendario",+ "addFailed": "L'iscrizione non e riuscita",+ "removeFailed": "Il ritiro non e riuscito"+ },+ "addOtherHint": "Non trovi qualcuno? Condividi prima il calendario con questa persona, poi potrai selezionarla qui."}}