Add OpenAPI docs, frontend, migrations, and API updates

- OpenAPI: add missing endpoints (add-from-url, subscriptions, public availability)
- OpenAPI: CalendarSubscription schema, Subscriptions tag
- Frontend app
- Migrations: count_for_availability, subscriptions_sync, user_preferences, calendar_settings
- Config, rate limit, auth, calendar, booking, ICS, availability, user service updates

Made-with: Cursor
This commit is contained in:
Michilis
2026-03-02 14:07:55 +00:00
parent 2cb9d72a7f
commit 75105b8b46
8120 changed files with 1486881 additions and 314 deletions

View File

@@ -1,28 +1,36 @@
-- name: CreateCalendar :one
INSERT INTO calendars (id, owner_id, name, color, is_public)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, owner_id, name, color, is_public, public_token, created_at, updated_at;
RETURNING id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at;
-- name: GetCalendarByID :one
SELECT id, owner_id, name, color, is_public, public_token, created_at, updated_at
SELECT id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at
FROM calendars
WHERE id = $1 AND deleted_at IS NULL;
-- name: ListCalendarsByUser :many
SELECT c.id, c.owner_id, c.name, c.color, c.is_public, c.created_at, c.updated_at, cm.role
SELECT c.id, c.owner_id, c.name, c.color, c.is_public, c.count_for_availability, c.default_reminder_minutes, c.sort_order, c.created_at, c.updated_at, cm.role
FROM calendars c
JOIN calendar_members cm ON cm.calendar_id = c.id
WHERE cm.user_id = $1 AND c.deleted_at IS NULL
ORDER BY c.created_at ASC;
ORDER BY c.sort_order ASC, c.created_at ASC;
-- name: ListCalendarsByOwnerForAvailability :many
SELECT id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at
FROM calendars
WHERE owner_id = $1 AND deleted_at IS NULL AND count_for_availability = true;
-- name: UpdateCalendar :one
UPDATE calendars
SET name = COALESCE(sqlc.narg('name')::TEXT, name),
color = COALESCE(sqlc.narg('color')::TEXT, color),
is_public = COALESCE(sqlc.narg('is_public')::BOOLEAN, is_public),
count_for_availability = COALESCE(sqlc.narg('count_for_availability')::BOOLEAN, count_for_availability),
default_reminder_minutes = COALESCE(sqlc.narg('default_reminder_minutes')::INTEGER, default_reminder_minutes),
sort_order = COALESCE(sqlc.narg('sort_order')::INTEGER, sort_order),
updated_at = now()
WHERE id = @id AND deleted_at IS NULL
RETURNING id, owner_id, name, color, is_public, public_token, created_at, updated_at;
RETURNING id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at;
-- name: SoftDeleteCalendar :exec
UPDATE calendars SET deleted_at = now(), updated_at = now()
@@ -32,10 +40,10 @@ WHERE id = $1 AND deleted_at IS NULL;
UPDATE calendars SET deleted_at = now(), updated_at = now()
WHERE owner_id = $1 AND deleted_at IS NULL;
-- name: GetCalendarByPublicToken :one
SELECT id, owner_id, name, color, is_public, public_token, created_at, updated_at
-- name: GetCalendarByToken :one
SELECT id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at
FROM calendars
WHERE public_token = $1 AND is_public = true AND deleted_at IS NULL;
WHERE public_token = $1 AND deleted_at IS NULL;
-- name: SetCalendarPublicToken :exec
UPDATE calendars

View File

@@ -1,8 +1,31 @@
-- name: CreateCalendarSubscription :one
INSERT INTO calendar_subscriptions (id, calendar_id, source_url)
VALUES ($1, $2, $3)
INSERT INTO calendar_subscriptions (id, calendar_id, source_url, sync_interval_minutes)
VALUES ($1, $2, $3, $4)
RETURNING *;
-- name: GetSubscriptionByCalendar :one
-- name: ListSubscriptionsByCalendar :many
SELECT * FROM calendar_subscriptions
WHERE calendar_id = $1;
WHERE calendar_id = $1
ORDER BY created_at ASC;
-- name: GetSubscriptionByID :one
SELECT * FROM calendar_subscriptions
WHERE id = $1;
-- name: DeleteSubscription :exec
DELETE FROM calendar_subscriptions
WHERE id = $1;
-- name: UpdateSubscriptionLastSynced :exec
UPDATE calendar_subscriptions
SET last_synced_at = now()
WHERE id = $1;
-- name: ListSubscriptionsDueForSync :many
SELECT s.id, s.calendar_id, s.source_url, c.owner_id
FROM calendar_subscriptions s
JOIN calendars c ON c.id = s.calendar_id AND c.deleted_at IS NULL
WHERE s.sync_interval_minutes IS NOT NULL
AND s.sync_interval_minutes > 0
AND (s.last_synced_at IS NULL
OR s.last_synced_at + make_interval(mins => s.sync_interval_minutes::numeric) <= now());

View File

@@ -4,21 +4,36 @@ VALUES ($1, $2, $3, $4)
RETURNING id, email, password_hash, timezone, is_active, created_at, updated_at;
-- name: GetUserByID :one
SELECT id, email, password_hash, timezone, is_active, created_at, updated_at
SELECT id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
default_event_duration_minutes, default_reminder_minutes, show_weekends,
working_hours_start, working_hours_end, notifications_email, created_at, updated_at
FROM users
WHERE id = $1 AND deleted_at IS NULL;
-- name: GetUserByEmail :one
SELECT id, email, password_hash, timezone, is_active, created_at, updated_at
SELECT id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
default_event_duration_minutes, default_reminder_minutes, show_weekends,
working_hours_start, working_hours_end, notifications_email, created_at, updated_at
FROM users
WHERE email = $1 AND deleted_at IS NULL;
-- name: UpdateUser :one
UPDATE users
SET timezone = COALESCE(sqlc.narg('timezone')::TEXT, timezone),
week_start_day = COALESCE(sqlc.narg('week_start_day')::SMALLINT, week_start_day),
date_format = COALESCE(sqlc.narg('date_format')::TEXT, date_format),
time_format = COALESCE(sqlc.narg('time_format')::TEXT, time_format),
default_event_duration_minutes = COALESCE(sqlc.narg('default_event_duration_minutes')::INTEGER, default_event_duration_minutes),
default_reminder_minutes = COALESCE(sqlc.narg('default_reminder_minutes')::INTEGER, default_reminder_minutes),
show_weekends = COALESCE(sqlc.narg('show_weekends')::BOOLEAN, show_weekends),
working_hours_start = COALESCE(sqlc.narg('working_hours_start')::TEXT, working_hours_start),
working_hours_end = COALESCE(sqlc.narg('working_hours_end')::TEXT, working_hours_end),
notifications_email = COALESCE(sqlc.narg('notifications_email')::BOOLEAN, notifications_email),
updated_at = now()
WHERE id = @id AND deleted_at IS NULL
RETURNING id, email, password_hash, timezone, is_active, created_at, updated_at;
RETURNING id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
default_event_duration_minutes, default_reminder_minutes, show_weekends,
working_hours_start, working_hours_end, notifications_email, created_at, updated_at;
-- name: SoftDeleteUser :exec
UPDATE users SET deleted_at = now(), is_active = false, updated_at = now()

View File

@@ -9,6 +9,15 @@ CREATE TABLE users (
password_hash TEXT NOT NULL,
timezone TEXT NOT NULL DEFAULT 'UTC',
is_active BOOLEAN NOT NULL DEFAULT true,
week_start_day SMALLINT NOT NULL DEFAULT 0,
date_format TEXT NOT NULL DEFAULT 'MM/dd/yyyy',
time_format TEXT NOT NULL DEFAULT '12h',
default_event_duration_minutes INTEGER NOT NULL DEFAULT 60,
default_reminder_minutes INTEGER NOT NULL DEFAULT 10,
show_weekends BOOLEAN NOT NULL DEFAULT true,
working_hours_start TEXT NOT NULL DEFAULT '09:00',
working_hours_end TEXT NOT NULL DEFAULT '17:00',
notifications_email BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted_at TIMESTAMPTZ
@@ -49,6 +58,9 @@ CREATE TABLE calendars (
color TEXT NOT NULL DEFAULT '#3B82F6',
is_public BOOLEAN NOT NULL DEFAULT false,
public_token TEXT,
count_for_availability BOOLEAN NOT NULL DEFAULT true,
default_reminder_minutes INTEGER,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted_at TIMESTAMPTZ
@@ -180,6 +192,7 @@ CREATE TABLE calendar_subscriptions (
calendar_id UUID NOT NULL REFERENCES calendars(id),
source_url TEXT NOT NULL,
last_synced_at TIMESTAMPTZ,
sync_interval_minutes INTEGER,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);