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

+72 -98
View File
@@ -1,23 +1,37 @@
# Seed Data & Demo Accounts
Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs on
`npm run db:reset` and is **idempotent** (`on conflict ... do nothing`).
`npm run db:reset` and is **idempotent** (`on conflict ... do nothing` /
`do update`).
The seed uses **real data** from a past event — the **Global Power Platform
Bootcamp (Austria)** — instead of random demo data:
- The **agenda** (slots + sessions) comes from the event's Sessionize public API
(`…/api/v2/4domszaq/view/All`): 22 sessions on 2026-02-20 (18 talks + 4 service
sessions: coffee break, lunch, a partner session, and the closing).
- The **speakers** are **not** seeded — they are imported from the Sessionize
**"Sessions and speakers (advanced)"** `.xlsx` via the admin **Interfaces →
Import Excel** control (see [sidecar.md](./sidecar.md)). That import creates the
speaker contacts, links them to sessions, and creates their `speaker`
registrations (matched by email).
## What it creates
| Data | Count | Notes |
|---|---|---|
| `auth.users` + `auth.identities` | 13 | 12 attendees + 1 admin; **QR token = bcrypt password** (attendees/staff) — the admin uses a real **password** instead |
| `contacts` | 14 | 13 registrants + 1 external keynote speaker (no token — tokens live on registrations) |
| `events` | 1 | **APPE 2026**, 2026-10-23, São Paulo, Brazil, **active** |
| `registrations` | 13 | one per contact (Elena has none); points + **QR token** scoped here |
| `sponsors` | 3 | Nubank (headline, paid), Acme Corp (gold, paid), Globant (community, unpaid) |
| `slots` | 6 | 23 Oct, 09:00–15:45 (see table below) |
| `sessions` | 18 | 3 per slot (Main Stage / Room A / Room B) |
| `session_speakers` | 22 | M:N session → contact |
| `leaderboard` | 10 | mirrored from `registrations`, **staff excluded** (13 registrants − 3 staff) |
| `points_log` | 16 | Ana's coherent breakdown + one `admin` entry per other user |
| Ana's demo state | — | 6 preferences, 2 check-ins, 4 connections, 1 feedback |
| `auth.users` + `auth.identities` | 54 | 50 attendees + 4 staff; **QR token = bcrypt password** (attendees), **`appe-admin-2026`** (staff) |
| `contacts` | 54 | 50 attendees + 4 staff (`is_admin = true`, `password = 'appe-admin-2026'`) |
| `events` | 1 | **Global Power Platform Bootcamp \| Austrian Power Platform Enthusiasts Edition**, 2026-02-20, Vienna, Austria, **active**, `sessionize_endpoint` set to `https://sessionize.com/api/v2/4domszaq/view/All` |
| `registrations` | 54 | 50 `attendee` + 4 `staff`; each with a `CVV-XXX-NNNN` QR token |
| `slots` | 10 | 2026-02-20, 09:15–17:00 (7 `session` + 3 `service_session`) |
| `sessions` | 22 | real titles/descriptions/rooms from the Sessionize API |
| `session_speakers` | 0 | **added by the Excel import** (not seeded) |
| `sponsors` | 0 | none for this event |
> **Speaker contacts are intentionally absent.** After `db:reset`, run the Excel
> import (Interfaces → Import Excel → choose the `.xlsx` → Import) to add the 21
> speakers: their contacts, session links, and `speaker` registrations.
> **GoTrue gotcha:** manually-inserted `auth.users` must have
> `confirmation_token`, `recovery_token`, `email_change_token_new`, and
@@ -25,101 +39,61 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
> grant can't scan a NULL `confirmation_token`. `phone` is left NULL (unique
> constraint).
> **Staff = admin (merged).** Bruno, Rita, and the APPE Admin have
> `is_admin = true` on their `contacts` row. Their registration `type` is
> `staff` (the ticket type shown on the lanyard).
> **Staff = admin (merged).** The four staff have `is_admin = true` on their
> `contacts` row (so they can open the APPE Admin console **and** generate the
> Sessionize export) and their registration `type` is `staff`.
## Slots
## Slots (2026-02-20)
| id | Type | Time |
|---|---|---|
| 1 | keynote | 09:00–09:45 |
| 2 | session | 10:00–10:45 |
| 3 | session | 11:30–12:15 |
| 4 | lunch_break | 13:15–14:00 |
| 5 | session | 14:00–14:45 |
| 6 | close_up | 15:00–15:45 |
| Type | Time |
|---|---|
| session | 09:15–10:00 (keynote) |
| service_session | 10:00–10:30 (coffee break) |
| session | 10:30–11:15 |
| session | 11:15–12:00 |
| service_session | 12:00–13:00 (lunch) |
| session | 13:00–13:45 |
| session | 13:45–14:30 |
| session | 14:30–15:15 |
| session | 15:15–16:00 |
| service_session | 16:00–17:00 (partner session + closing) |
> `type` is the `slot_type` **enum** (`session` / `service_session`) — see
> [schema.md](./schema.md#slots--schedule-blocks).
## Demo accounts
**Attendees** log in with **QR code** (typed or scanned) + **email** — the QR
token is the Auth password. **Staff** log in with **QR code + their staff
password** (the Convivo app shows a password field when a staff QR is detected;
the email comes from the resolved contact). The **APPE Admin** (and any staff
member you give one) can also log in with **email + password** in the admin app
(event-independent, so it works for any event). The password lives in
`contacts.password`; a trigger (`trg_contact_password_sync`) **auto-syncs** it as
the bcrypt hash in `auth.users.encrypted_password`, so just set
`contacts.password` in Supabase and it works with `signInWithPassword`
immediately.
password** in the Convivo app, or **email + password** in the admin app. All four
staff share the password **`appe-admin-2026`** (stored in `contacts.password`,
auto-synced to `auth.users.encrypted_password` by the `trg_contact_password_sync`
trigger).
| Person | Type | Login | Email | Start pts |
|---|---|---|---|---|
| **Ana Silva** | speaker | QR `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | QR `CVV-BRU-1177` + **password** `appe-admin-2026` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | QR `CVV-RIT-9034` + **password** `appe-admin-2026` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | **password** `appe-admin-2026` | admin@appe.at | 0 |
| Tomás Ribeiro | speaker | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | speaker | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | speaker | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 |
| Julia Santos | speaker | `CVV-JUL-3345` | julia.santos@ifood.com | 64 |
| Pedro Nunes | speaker | `CVV-PED-8801` | pedro.nunes@microsoft.com | 58 |
| Carla Mendes | speaker | `CVV-CAR-6623` | carla.mendes@quintoessencial.com | 52 |
| Diego Ferreira | speaker | `CVV-DIE-4458` | diego.ferreira@stone.com | 35 |
| Marina Costa | speaker | `CVV-MNA-2210` | marina.costa@olx.com | 28 |
| Lucas Oliveira | speaker | `CVV-LUC-9987` | lucas.oliveira@usp.br | 15 |
| Dr. Elena Vasquez | (external speaker) | — | elena.vasquez@keynote.com | — |
| Person | Type | Email | Login |
|---|---|---|---|
| **Amelia Hernandez** | staff (admin) | amelia@appe.at | `appe-admin-2026` |
| **Sabrina Hota** | staff (admin) | sabrina@appe.at | `appe-admin-2026` |
| **Jose Lago** | staff (admin) | jose@appe.at | `appe-admin-2026` |
| **Markus Franz** | staff (admin) | markus@appe.at | `appe-admin-2026` |
| 50 attendees | attendee | (made-up, e.g. lena.huber@gmail.com) | QR `CVV-ATT-1000`…`CVV-ATT-1049` |
> **Speaker auto-promote:** every seeded attendee who speaks in a session is
> typed `speaker` (the `session_speakers_speaker_promote` trigger promotes
> `attendee` → `speaker` on insert, so the seed states the final type). Only
> Bruno, Rita, and the APPE Admin are `staff` (the trigger never overrides an
> explicit staff/sponsor ticket).
>
> **Staff passwords:** Bruno and Rita have `contacts.password = 'appe-admin-2026'`
> so the Convivo **staff QR login** (QR + staff password) works out of the box.
> **Dr. Elena Vasquez** is an external keynote speaker: she has a `contacts` row
> (and speaks in `session_speakers`) but **no registration, no QR token, and no
> auth user**, so she can't log in — she only appears as a speaker on the agenda.
## Ana's demo state (so the app looks alive on first login)
Ana (`[email protected]`) is seeded with a coherent 40-point history:
- **Points breakdown** (`points_log`): 2× check-in (+10 each), 2× connection
(+5 each), 1× feedback (+10) = **40**.
- **Preferences** — one pick per slot (matches the mockup):
- Slot 1 → *Designing for Trust in AI Products*
- Slot 2 → *AI in Practice: Lessons from Production*
- Slot 3 → *Data Storytelling*
- Slot 4 → *Prototyping with AI*
- Slot 5 → *Community-Led Growth*
- Slot 6 → *Closing Panel: What's Next*
- **Check-ins** — checked into Slot 1 and Slot 2 (by staff Bruno).
- **Connections**:
- accepted with **Bruno** and **Rita**
- incoming (pending) from **Sofia**
- outgoing (pending) to **Julia**
- **Feedback** — rated Slot 1's *Designing for Trust in AI Products* 5★ with a
comment.
- **Speaker** — Ana is a speaker of Slot 6's *Open Space: Your Ideas* (so the
Agenda shows a "🎤 you" tag and the material-upload notice).
> Everyone else gets a single `admin` `points_log` entry for their starting points
> (so the Profile breakdown shows "Other"), and no other activity.
> **Speaker auto-promote:** the Excel import creates the speakers' registrations
> as `speaker` directly (and the `session_speakers_speaker_promote` trigger
> promotes any `attendee` that gets linked). The seed itself contains **no
> speakers** — only the 50 attendees and 4 staff.
## Suggested demo flow
1. Log in as **Ana** (attendee) → Home, Agenda, Leaderboard all populated.
2. Scan **Marco** (`CVV-MRC-7712`) → send a connection request.
3. Log in as **Bruno** (staff) → QR `CVV-BRU-1177` + staff password
`appe-admin-2026` → the Scan tab becomes **Check-in** → pick a session → scan
**Carla** (`CVV-CAR-6623`) → she gets +10. Flip the **check-in type toggle**
to **Welcome check-in** and scan **Tomás** (`CVV-TOM-5566`) → he's marked
present at the event (no points).
4. Watch the **Leaderboard** update live (Realtime).
5. Log in as **APPE Admin** (`[email protected]` / password `appe-admin-2026`) in the
admin app → Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity,
Events. (Staff Bruno/Rita can also open the admin app with their email + QR
token, since that is their Auth password.)
1. Log in as **Amelia** (staff/admin) in the admin app (`[email protected]` /
`appe-admin-2026`) → Dashboard shows the real event (54 registrations, 22
sessions).
2. **Interfaces → Import Excel** → choose the "Sessions and speakers
(advanced)" `.xlsx` → **Import** → the result modal shows the speakers
created, sessions updated, speaker links, and speaker registrations created.
3. **Schedule** → slots now show **Session** / **Service Session** types and the
sessions list their speakers.
4. **Events** → the event's **Sessionize endpoint** is set; the **Sync** button
runs the (keyless) API sync.
5. Log in as an **attendee** in the Convivo app (QR `CVV-ATT-1000` +
`[email protected]`) → Home/Agenda show the real agenda.