feat: add sidecar service for Sessionize sync

- Introduced a new Node HTTP service (sidecar) to sync event agendas from Sessionize into Convivo.
- Implemented two import paths: API sync and Excel import for session and speaker data.
- Added necessary database migrations for sessionize integration, including new columns and audit tables.
- Created functions for handling speaker and session imports, ensuring proper error handling and logging.
- Established row-level security and grants for new functions to restrict access to service-role only.
This commit is contained in:
Lago committed 2026-08-24 20:47:29 +02:00
1 parent 8054d0ace2
commit f7aea663d8
31 files changed
+2729 -390

No files matched your search

+86 -4
View File
@@ -22,15 +22,26 @@ current phase.
> **Existing-sponsor link + Interfaces removal** (the in-place sponsor lookup can
> now link an existing sponsor, not just create one; the Pretix/Sessionize
> "Interfaces" feature — admin view, `sync-trigger` Edge Function, mock API, and
> the `sync_runs` table + sync RPCs — is removed).
> Remaining work is cross-cutting (real event clock, deployment, testing).
> the `sync_runs` table + sync RPCs — is removed), and
> **Sessionize sync sidecar** (the Sessionize interface is re-introduced as a
> Docker sidecar driven by a new admin Interfaces menu — on demand only, with a
> `sessionize_endpoint` field on events and a per-row Sync button), and
> **Sessionize Excel import + slots optionset + real seed** (the sidecar also
> imports the Sessionize "Sessions and speakers (advanced)" `.xlsx` — creating
> speaker contacts, session links, and `speaker` registrations by email; `slots.type`
> is now a `session`/`service_session` enum; the seed uses the real Global Power
> Platform Bootcamp (Austria) agenda + 50 attendees + 4 staff, with the event's
> endpoint set and speakers added via the Excel import).
> Remaining work is cross-cutting (real event clock, deployment, testing, and the
> ticket/Pretix sync that will consume the speaker links by email).
## Done
### Phase 0 — Dockerized Supabase core ✅
- Full schema (13 tables), RLS on every table, transactional points RPCs.
- Seed: 1 event, 6 slots, 18 sessions, 14 contacts, 13 registrations, 3 sponsors
(QR token = auth password).
- Seed: 1 real event (Power Platform Bootcamp AT), 10 slots, 22 sessions, 54
contacts (50 attendees + 4 staff), 54 registrations (QR token = auth password).
Speakers are added via the Excel import, not the seed.
- Runs via the Supabase CLI (`supabase start` / `supabase db reset`).
- Details: [backend/README.md](./backend/README.md).
@@ -155,6 +166,77 @@ rebuilt the views on the new model:
- `https://www.appe.at/assets/appe_full.png` as favicon + PWA icon (192/512)
for **both** apps. Updated `index.html` + `manifest.webmanifest` + `public/`.
## Sessionize sync sidecar — ✅ complete
A new round (migrations `20260831000000_sessionize_sidecar.sql` +
`20260832000000_slots_enum_excel_import.sql`, a new `apps/sidecar/` service +
admin UI), verified end-to-end. The Sessionize interface is **re-introduced with
a different architecture**: a Docker sidecar instead of the removed Edge Function
+ mock API. It runs **on demand only** (no scheduling). There are **two import
paths**: the **API sync** (`/run`) and the **Excel import** (`/import-excel`).
**Event field + per-row Sync.**
- `events.sessionize_endpoint` (the Sessionize API URL) is editable in the Events
create/edit modal; `events.last_synced_at` stamps the last run.
- Each event row has a **Sync** button (disabled-hint when no endpoint is set);
it runs a **blocking** sync and shows a result modal (counts + errors).
**The sidecar (`apps/sidecar/`, `:3002`).**
- Node 20; one runtime dep (**`xlsx`**, to parse the Excel export). `GET
/health`, `GET /status`, `POST /run` (blocking), `POST /import-excel`
(blocking, `multipart/form-data`).
- **API sync** (`/run`): reads the event's endpoint and fetches it **as-is** (the
public `/view/` endpoint needs no key). If `SESSIONIZE_API_KEY` is set it is
sent as `X-Sessionize-API-Key` (needed only for an `/api/` endpoint, which is
what returns speaker emails). Transforms, then calls the RPC.
- **Excel import** (`/import-excel`): the admin uploads the Sessionize **"Sessions
and speakers (advanced)"** `.xlsx` (generated on the fly by any organizer with
admin access to the event). The sidecar parses the two sheets (*Accepted
sessions* + *Accepted speakers*) and calls `sync_sessionize_excel`.
- It is the **first server-side holder of the service-role key** (compose env,
defaulting to the standard local key). See [backend/sidecar.md](./backend/sidecar.md).
- Wired into the admin via a same-origin `/sidecar/` proxy (nginx in Docker, Vite
in dev) — CORS-free, matching the existing Supabase proxy pattern.
**The RPCs.**
- `sync_sessionize_event(event_id, payload)` — **API sync**. `security definer`,
**service-role only** (JWT role claim; granted to `service_role` only). Imports,
in order: (1) speakers → contacts (matched by **email**), (2) sessions (upserted
by `external_id`), (3) the agenda (slots find-or-created by date/start/end +
`session_speakers` links, **diffed** so the `session_needs_speaker` trigger
never blocks a removal). **No registrations are created** — the public `/view/`
payload has no speaker emails, so speakers are skipped (reported).
- `sync_sessionize_excel(event_id, payload)` — **Excel import**. Same shape plus
`is_service_session` per session and `linkedin_url` per speaker, and one extra
step: (3) **a `speaker` registration for every speaker** (create, or update
`attendee`→`speaker`; never overrides `staff`/`sponsor`). The Excel carries
emails, so the contact-level match is reliable — this is the path that creates
the missing speaker contacts + registrations.
- Both are idempotent (re-run updates in place); per-item errors collected into
`errors[]`. Both write an event-scoped `sync_runs` audit row (admin-readable via
RLS; `source` = `sessionize` / `sessionize_excel`).
**Slots type optionset.**
- `slots.type` is now a Postgres **enum** (`slot_type`): exactly `session` /
`service_session` (not freetext). `service_session` = breaks / lunch / closing
(Sessionize's `isServiceSession`). The admin Schedule view shows **Session** /
**Service Session** and can create/edit slots (the `slots.id` sequence default
was added so the UI need not supply an id).
**Admin Interfaces menu.**
- New `🔌 Interfaces` view: sidecar status (online/running/last run), a **Run
sync** control (event picker + blocking run + result modal), an **Import
Excel** control (upload the `.xlsx` + a "How to get this file" tooltip), and a
**Recent runs** table from `sync_runs`.
**Seed (real data).**
- The seed now uses the **Global Power Platform Bootcamp (Austria)**: the real
agenda (22 sessions, 10 slots) from the Sessionize API, **50 made-up
attendees**, and **4 staff** (Amelia Hernandez, Sabrina Hota, Jose Lago, Markus
Franz — all `@appe.at`, `is_admin`, password `appe-admin-2026`). The event's
`sessionize_endpoint` is set. **Speakers are not seeded** — run the Excel
import to add them. See [backend/seed.md](./backend/seed.md).
## Existing-sponsor link + Interfaces removal — ✅ complete
A polish round (migration `20260830000000_remove_interfaces.sql` + app changes),