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:
@@ -14,7 +14,7 @@ import (
|
||||
const createCalendar = `-- 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
|
||||
`
|
||||
|
||||
type CreateCalendarParams struct {
|
||||
@@ -26,14 +26,17 @@ type CreateCalendarParams struct {
|
||||
}
|
||||
|
||||
type CreateCalendarRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateCalendar(ctx context.Context, arg CreateCalendarParams) (CreateCalendarRow, error) {
|
||||
@@ -52,6 +55,9 @@ func (q *Queries) CreateCalendar(ctx context.Context, arg CreateCalendarParams)
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.PublicToken,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
@@ -59,20 +65,23 @@ func (q *Queries) CreateCalendar(ctx context.Context, arg CreateCalendarParams)
|
||||
}
|
||||
|
||||
const getCalendarByID = `-- 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
|
||||
`
|
||||
|
||||
type GetCalendarByIDRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetCalendarByID(ctx context.Context, id pgtype.UUID) (GetCalendarByIDRow, error) {
|
||||
@@ -85,32 +94,38 @@ func (q *Queries) GetCalendarByID(ctx context.Context, id pgtype.UUID) (GetCalen
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.PublicToken,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getCalendarByPublicToken = `-- name: GetCalendarByPublicToken :one
|
||||
SELECT id, owner_id, name, color, is_public, public_token, created_at, updated_at
|
||||
const getCalendarByToken = `-- 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
|
||||
`
|
||||
|
||||
type GetCalendarByPublicTokenRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
type GetCalendarByTokenRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetCalendarByPublicToken(ctx context.Context, publicToken pgtype.Text) (GetCalendarByPublicTokenRow, error) {
|
||||
row := q.db.QueryRow(ctx, getCalendarByPublicToken, publicToken)
|
||||
var i GetCalendarByPublicTokenRow
|
||||
func (q *Queries) GetCalendarByToken(ctx context.Context, publicToken pgtype.Text) (GetCalendarByTokenRow, error) {
|
||||
row := q.db.QueryRow(ctx, getCalendarByToken, publicToken)
|
||||
var i GetCalendarByTokenRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
@@ -118,14 +133,69 @@ func (q *Queries) GetCalendarByPublicToken(ctx context.Context, publicToken pgty
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.PublicToken,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listCalendarsByOwnerForAvailability = `-- 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
|
||||
`
|
||||
|
||||
type ListCalendarsByOwnerForAvailabilityRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListCalendarsByOwnerForAvailability(ctx context.Context, ownerID pgtype.UUID) ([]ListCalendarsByOwnerForAvailabilityRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCalendarsByOwnerForAvailability, ownerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ListCalendarsByOwnerForAvailabilityRow{}
|
||||
for rows.Next() {
|
||||
var i ListCalendarsByOwnerForAvailabilityRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
&i.Name,
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.PublicToken,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listCalendarsByUser = `-- 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
|
||||
@@ -133,14 +203,17 @@ ORDER BY c.created_at ASC
|
||||
`
|
||||
|
||||
type ListCalendarsByUserRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
Role string `json:"role"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListCalendarsByUser(ctx context.Context, userID pgtype.UUID) ([]ListCalendarsByUserRow, error) {
|
||||
@@ -158,6 +231,9 @@ func (q *Queries) ListCalendarsByUser(ctx context.Context, userID pgtype.UUID) (
|
||||
&i.Name,
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Role,
|
||||
@@ -213,27 +289,36 @@ UPDATE calendars
|
||||
SET name = COALESCE($1::TEXT, name),
|
||||
color = COALESCE($2::TEXT, color),
|
||||
is_public = COALESCE($3::BOOLEAN, is_public),
|
||||
count_for_availability = COALESCE($4::BOOLEAN, count_for_availability),
|
||||
default_reminder_minutes = COALESCE($5::INTEGER, default_reminder_minutes),
|
||||
sort_order = COALESCE($6::INTEGER, sort_order),
|
||||
updated_at = now()
|
||||
WHERE id = $4 AND deleted_at IS NULL
|
||||
RETURNING id, owner_id, name, color, is_public, public_token, created_at, updated_at
|
||||
WHERE id = $7 AND deleted_at IS NULL
|
||||
RETURNING id, owner_id, name, color, is_public, public_token, count_for_availability, default_reminder_minutes, sort_order, created_at, updated_at
|
||||
`
|
||||
|
||||
type UpdateCalendarParams struct {
|
||||
Name pgtype.Text `json:"name"`
|
||||
Color pgtype.Text `json:"color"`
|
||||
IsPublic pgtype.Bool `json:"is_public"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Name pgtype.Text `json:"name"`
|
||||
Color pgtype.Text `json:"color"`
|
||||
IsPublic pgtype.Bool `json:"is_public"`
|
||||
CountForAvailability pgtype.Bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder pgtype.Int4 `json:"sort_order"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateCalendarRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicToken pgtype.Text `json:"public_token"`
|
||||
CountForAvailability bool `json:"count_for_availability"`
|
||||
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateCalendar(ctx context.Context, arg UpdateCalendarParams) (UpdateCalendarRow, error) {
|
||||
@@ -241,6 +326,9 @@ func (q *Queries) UpdateCalendar(ctx context.Context, arg UpdateCalendarParams)
|
||||
arg.Name,
|
||||
arg.Color,
|
||||
arg.IsPublic,
|
||||
arg.CountForAvailability,
|
||||
arg.DefaultReminderMinutes,
|
||||
arg.SortOrder,
|
||||
arg.ID,
|
||||
)
|
||||
var i UpdateCalendarRow
|
||||
@@ -251,6 +339,9 @@ func (q *Queries) UpdateCalendar(ctx context.Context, arg UpdateCalendarParams)
|
||||
&i.Color,
|
||||
&i.IsPublic,
|
||||
&i.PublicToken,
|
||||
&i.CountForAvailability,
|
||||
&i.DefaultReminderMinutes,
|
||||
&i.SortOrder,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user