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

+48
View File
@@ -202,6 +202,54 @@ profile from the Convivo app: the LinkedIn URL and the two visibility toggles
touch `is_admin`, `password`, `external_id`, etc.
- Returns the updated contact row.
### `sync_sessionize_event(p_event_id, p_payload)` → `jsonb`
**Service-role only** (the Sessionize sync sidecar — see [sidecar.md](./sidecar.md)).
Imports an event's Sessionize data 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). `p_payload` is
`{ speakers: [{email, full_name, external_id?}], sessions: [{external_id, title,
description?, room?, date, start_time, end_time, speakers: [email,...]}] }`.
- Guarded to the `service_role` caller (JWT role claim); granted to `service_role`
only — the apps cannot call it.
- **Idempotent:** re-running updates in place (contacts by email, sessions by
`external_id`, slots by date/start/end). Speaker links are **diffed** (insert the
new set, then delete only removed) so the `session_needs_speaker` trigger never
blocks a removal.
- Linking a speaker fires `session_speakers_speaker_promote`, which promotes an
existing registration to `speaker`. **No registrations are created** — the ticket
sync does that (checking `session_speakers` by email).
- Per-item failures are collected into `errors[]` (the run does not abort). Returns
a JSONB summary (`speakers_created/updated`, `sessions_created/updated`,
`slots_created`, `speakers_linked`, `errors`) and stamps `events.last_synced_at`.
- Writes a `sync_runs` audit row (see [schema.md](./schema.md)).
### `sync_sessionize_excel(p_event_id, p_payload)` → `jsonb`
**Service-role only** (the Sessionize sync sidecar's **Excel import** path — see
[sidecar.md](./sidecar.md)). Imports the Sessionize **"Sessions and speakers
(advanced)"** `.xlsx` export (parsed by the sidecar, which carries the speaker
**emails** the public API lacks). Same shape as `sync_sessionize_event` plus
`is_service_session` per session and `linkedin_url` per speaker, and it runs one
extra step:
1. **Speakers → contacts** (matched by email; also sets `linkedin_url`).
2. **Sessions + agenda** — slots are typed from `is_service_session`
(`service_session` for breaks/lunch/closing, else `session`), sessions
upserted by `external_id`, speaker links diffed.
3. **Speaker registrations** — for every speaker, creates a `speaker`
registration or updates an existing `attendee` one to `speaker`
(`on conflict (event_id, contact_email)`). **Never overrides `staff` /
`sponsor`** tickets. This is the "add the missing registrations for the
speakers" step the API sync deliberately leaves to the ticket sync.
- Guarded to the `service_role` caller; granted to `service_role` only.
- **Idempotent:** re-running updates in place (contacts by email, sessions by
`external_id`, slots by date/start/end, registrations by event+contact).
- Per-item failures are collected into `errors[]`. Returns a JSONB summary
(`speakers_created/updated`, `sessions_created/updated`, `slots_created`,
`speakers_linked`, `registrations_created/updated`, `errors`) and stamps
`events.last_synced_at`.
- Writes a `sync_runs` audit row with `source = 'sessionize_excel'`.
## Role helper functions
| Function | Returns | Meaning |