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

+126 -5
View File
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { activateEvent, deactivateEvent, getAllEvents, upsertEvent } from '../lib/api';
import type { Event } from '../lib/types';
import { activateEvent, deactivateEvent, getAllEvents, runSessionizeSync, upsertEvent } from '../lib/api';
import type { Event, SyncResult } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Empty, Modal, Spinner, Toggle } from '../components/ui';
@@ -10,6 +10,8 @@ export function Events() {
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
const [modal, setModal] = useState<{ event: Event | null } | null>(null);
const [syncingId, setSyncingId] = useState<string | null>(null);
const [syncResult, setSyncResult] = useState<SyncResult | null>(null);
async function load() {
try {
@@ -36,6 +38,24 @@ export function Events() {
}
}
async function runSync(ev: Event) {
if (!ev.sessionize_endpoint) {
push('error', `Set a Sessionize endpoint for ${ev.name} first (Edit)`);
return;
}
setSyncingId(ev.id);
try {
const result = await runSessionizeSync(ev.id);
setSyncResult(result);
await load();
push('success', `Synced ${ev.name}`);
} catch (e) {
push('error', e instanceof Error ? e.message : 'Sync failed');
} finally {
setSyncingId(null);
}
}
if (error) return <Empty icon="⚠️" text={error} />;
if (!loaded)
return (
@@ -97,9 +117,23 @@ export function Events() {
/>
</td>
<td>
<button className="btn small" onClick={() => setModal({ event: ev })}>
Edit
</button>
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end' }}>
<button
className="btn small"
disabled={syncingId === ev.id}
onClick={() => runSync(ev)}
title={
ev.sessionize_endpoint
? 'Sync with Sessionize'
: 'Set a Sessionize endpoint first (Edit)'
}
>
{syncingId === ev.id ? 'Syncing…' : 'Sync'}
</button>
<button className="btn small" onClick={() => setModal({ event: ev })}>
Edit
</button>
</div>
</td>
</tr>
))}
@@ -120,6 +154,8 @@ export function Events() {
}}
/>
)}
{syncResult && <SyncResultModal result={syncResult} onClose={() => setSyncResult(null)} />}
</div>
);
}
@@ -137,6 +173,7 @@ function EventModal({
const [startDate, setStartDate] = useState(event ? event.start_date.slice(0, 10) : '');
const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : '');
const [location, setLocation] = useState(event?.location ?? '');
const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? '');
const [busy, setBusy] = useState(false);
async function save() {
@@ -148,6 +185,7 @@ function EventModal({
start_date: startDate,
end_date: endDate,
location: location.trim() || null,
sessionize_endpoint: endpoint.trim() || null,
});
onSaved(event ? 'Event updated' : 'Event created');
} catch (e) {
@@ -191,6 +229,89 @@ function EventModal({
<label>Location</label>
<input className="input" value={location} onChange={(e) => setLocation(e.target.value)} placeholder="—" />
</div>
<div className="field">
<label>Sessionize endpoint</label>
<input
className="input"
value={endpoint}
onChange={(e) => setEndpoint(e.target.value)}
placeholder="https://sessionize.com/api/v2/<id>/view/All"
/>
<div className="muted small" style={{ marginTop: 4 }}>
The Sessionize API URL (e.g. <code>…/api/v2/&lt;id&gt;/view/All</code>). Used by the
“Run sync” button. You can also import the .xlsx export in the Interfaces menu.
</div>
</div>
</Modal>
);
}
function SyncResultModal({ result, onClose }: { result: SyncResult; onClose: () => void }) {
const s = result.summary;
return (
<Modal
open
title={`Sessionize sync — ${result.event_name ?? result.event_id}`}
onClose={onClose}
footer={
<button className="btn primary" onClick={onClose}>
Close
</button>
}
>
{result.status === 'error' || !s ? (
<div className="pill red" style={{ display: 'inline-block', padding: '8px 12px' }}>
{result.error ?? 'Sync failed'}
</div>
) : (
<>
<div className="stat-grid">
<div className="stat">
<div className="val">{s.speakers_created}</div>
<div className="lbl">Speakers created</div>
</div>
<div className="stat">
<div className="val">{s.speakers_updated}</div>
<div className="lbl">Speakers updated</div>
</div>
<div className="stat">
<div className="val">{s.sessions_created}</div>
<div className="lbl">Sessions created</div>
</div>
<div className="stat">
<div className="val">{s.sessions_updated}</div>
<div className="lbl">Sessions updated</div>
</div>
<div className="stat">
<div className="val">{s.slots_created}</div>
<div className="lbl">Slots created</div>
</div>
<div className="stat">
<div className="val">{s.speakers_linked}</div>
<div className="lbl">Speaker links</div>
</div>
</div>
{result.skipped_speakers && result.skipped_speakers.length > 0 && (
<div className="muted small">
Skipped {result.skipped_speakers.length} speaker(s) without an email: {result.skipped_speakers.join(', ')}
</div>
)}
{s.errors.length > 0 && (
<div style={{ marginTop: 12 }}>
<div className="pill red" style={{ display: 'inline-block', marginBottom: 8 }}>
{s.errors.length} error(s)
</div>
<ul style={{ margin: 0, paddingLeft: 18 }}>
{s.errors.map((e, i) => (
<li key={i} className="small">
{e}
</li>
))}
</ul>
</div>
)}
</>
)}
</Modal>
);
}