feat: sync GridSmart agendas and use event-relative demo time
Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage.
This commit is contained in:
1 parent
40f24cf5f7
commit
c0fbf495dc
27 files changed
+1215
-60
No files matched your search
@@ -0,0 +1,19 @@
|
||||
export function normalizeSessionizeSource(value: string): string | null {
|
||||
let source = value.trim();
|
||||
if (!source) return null;
|
||||
if (source.startsWith('<')) {
|
||||
const document = new DOMParser().parseFromString(source, 'text/html');
|
||||
const scripts = document.querySelectorAll('script[src]');
|
||||
if (scripts.length !== 1) throw new Error('Paste one Sessionize script tag or URL');
|
||||
source = scripts[0].getAttribute('src') || '';
|
||||
}
|
||||
let url: URL;
|
||||
try { url = new URL(source); } catch { throw new Error('Enter a valid Sessionize URL or script tag'); }
|
||||
if (url.protocol !== 'https:' || url.hostname !== 'sessionize.com' || url.port
|
||||
|| url.username || url.password || !/^\/api\/v2\/[a-z0-9]+\/view\/(All|GridSmart)$/i.test(url.pathname)) {
|
||||
throw new Error('Use a Sessionize HTTPS All or GridSmart endpoint');
|
||||
}
|
||||
url.search = '';
|
||||
url.hash = '';
|
||||
return url.href;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import type { Event, PretixOptions, PretixSyncResult, SyncResult } from '../lib/types';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { Empty, Modal, Spinner, Toggle } from '../components/ui';
|
||||
import { normalizeSessionizeSource } from '../lib/sessionizeSource';
|
||||
|
||||
export function Events() {
|
||||
const { push } = useToast();
|
||||
@@ -286,6 +287,7 @@ function EventModal({
|
||||
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 [endpointError, setEndpointError] = useState<string | null>(null);
|
||||
const [pretixApiKey, setPretixApiKey] = useState(event?.pretix_api_key ?? '');
|
||||
const [pretixOrganizer, setPretixOrganizer] = useState(event?.pretix_organizer ?? '');
|
||||
const [pretixEventSlug, setPretixEventSlug] = useState(event?.pretix_event_slug ?? '');
|
||||
@@ -328,6 +330,14 @@ function EventModal({
|
||||
|
||||
async function save() {
|
||||
if (!name.trim() || !startDate || !endDate) return;
|
||||
let source: string | null;
|
||||
try {
|
||||
source = normalizeSessionizeSource(endpoint);
|
||||
setEndpointError(null);
|
||||
} catch (error) {
|
||||
setEndpointError(error instanceof Error ? error.message : 'Invalid Sessionize source');
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
try {
|
||||
await upsertEvent(event?.id ?? null, {
|
||||
@@ -335,7 +345,7 @@ function EventModal({
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
location: location.trim() || null,
|
||||
sessionize_endpoint: endpoint.trim() || null,
|
||||
sessionize_endpoint: source,
|
||||
pretix_organizer: pretixOrganizer.trim() || null,
|
||||
pretix_event_slug: pretixEventSlug.trim() || null,
|
||||
pretix_api_key: pretixApiKey.trim() || null,
|
||||
@@ -391,16 +401,20 @@ function EventModal({
|
||||
{endpoint.trim() ? <span className="pill green">configured</span> : <span className="pill">not set</span>}
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Sessionize endpoint</label>
|
||||
<input
|
||||
<label htmlFor="sessionize-source">Sessionize endpoint</label>
|
||||
<textarea
|
||||
id="sessionize-source"
|
||||
className="input"
|
||||
rows={3}
|
||||
value={endpoint}
|
||||
onChange={(e) => setEndpoint(e.target.value)}
|
||||
placeholder="https://sessionize.com/api/v2/<id>/view/All"
|
||||
onChange={(e) => { setEndpoint(e.target.value); setEndpointError(null); }}
|
||||
aria-invalid={!!endpointError}
|
||||
aria-describedby={endpointError ? 'sessionize-source-error' : undefined}
|
||||
placeholder="https://sessionize.com/api/v2/<id>/view/GridSmart"
|
||||
/>
|
||||
{endpointError && <div id="sessionize-source-error" role="alert" className="error">{endpointError}</div>}
|
||||
<div className="muted small" style={{ marginTop: 4 }}>
|
||||
The Sessionize API URL (e.g. <code>…/api/v2/<id>/view/All</code>). Used by the
|
||||
“Run sync” button. You can also import the .xlsx export in the Interfaces menu.
|
||||
All / GridSmart URL or Sessionize script tag. Active events sync automatically every 15 minutes.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { Session, Slot } from './types';
|
||||
|
||||
type AgendaBlock = { slot: Slot; sessions: Session[] };
|
||||
|
||||
export function mergeAgendaPlaceholders(slots: AgendaBlock[]): AgendaBlock[] {
|
||||
const blocks = slots.map(block => ({ slot: block.slot, sessions: [...block.sessions] }));
|
||||
const merged = new Set<number>();
|
||||
for (const block of blocks) {
|
||||
if (block.slot.type !== 'service_session') continue;
|
||||
const target = blocks.find(candidate => candidate.slot.type === 'session'
|
||||
&& candidate.slot.slot_date === block.slot.slot_date
|
||||
&& candidate.slot.start_time === block.slot.start_time
|
||||
&& candidate.slot.end_time === block.slot.end_time);
|
||||
if (!target) continue;
|
||||
const placeholders = block.sessions.filter(session => session.slot_type === 'service_session'
|
||||
&& session.title.trim().toLowerCase() === 'placeholder');
|
||||
if (!placeholders.length) continue;
|
||||
target.sessions.push(...placeholders);
|
||||
const transferred = new Set(placeholders.map(session => session.id));
|
||||
block.sessions = block.sessions.filter(session => !transferred.has(session.id));
|
||||
if (!block.sessions.length) merged.add(block.slot.id);
|
||||
}
|
||||
return blocks.filter(block => !merged.has(block.slot.id));
|
||||
}
|
||||
@@ -83,7 +83,11 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[
|
||||
});
|
||||
}
|
||||
}
|
||||
return [...map.values()].sort((a, b) => a.slot.id - b.slot.id);
|
||||
return [...map.values()].sort((first, second) =>
|
||||
first.slot.slot_date.localeCompare(second.slot.slot_date)
|
||||
|| first.slot.start_time.localeCompare(second.slot.start_time)
|
||||
|| first.slot.end_time.localeCompare(second.slot.end_time)
|
||||
|| first.slot.id - second.slot.id);
|
||||
}
|
||||
|
||||
/** Submit (or update) the current user's event-level feedback. */
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import type { Slot } from './types';
|
||||
|
||||
/** The event day (from the seed). All slot times are on this date. */
|
||||
export const EVENT_DATE = '2026-02-20';
|
||||
|
||||
/** Simulated "now" used for the demo (10:20 on event day → Slot 2 is live,
|
||||
* Slot 3 is next). Matches the mockup's "Good morning" greeting. */
|
||||
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
|
||||
export function demoNow(eventDate: string): Date {
|
||||
return new Date(`${eventDate}T10:20:00`);
|
||||
}
|
||||
|
||||
export type SlotStatus = 'done' | 'now' | 'next';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getActiveEvent, getAgenda, groupAgenda } from './api';
|
||||
import { DEFAULT_NOW } from './time';
|
||||
import { demoNow } from './time';
|
||||
import type { Event, Session, Slot } from './types';
|
||||
|
||||
export interface EventData {
|
||||
@@ -53,7 +53,7 @@ export function useEvent(): EventData {
|
||||
// The event's `use_realtime_clock` flag decides the clock: the real system
|
||||
// time, or the simulated mid-event clock (so the demo always looks live).
|
||||
const clockMode: 'simulated' | 'realtime' = event?.use_realtime_clock ? 'realtime' : 'simulated';
|
||||
const now = clockMode === 'realtime' ? new Date() : DEFAULT_NOW;
|
||||
const now = clockMode === 'simulated' && event ? demoNow(event.start_date) : new Date();
|
||||
|
||||
return {
|
||||
event,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { mergeAgendaPlaceholders } from '../lib/agendaBlocks';
|
||||
import {
|
||||
clearPreference,
|
||||
getMyCheckins,
|
||||
@@ -48,6 +49,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
|
||||
const matchesFilter = (s: Session) =>
|
||||
(!levelFilter || s.level === levelFilter) && (!areaFilter || s.area === areaFilter);
|
||||
const displayBlocks = mergeAgendaPlaceholders(slots);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
@@ -159,7 +161,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
<div className="h1">Agenda</div>
|
||||
<div className="muted small">{event.name}</div>
|
||||
</div>
|
||||
<span className="pill violet">{slots.length} slots</span>
|
||||
<span className="pill violet">{displayBlocks.length} slots</span>
|
||||
</div>
|
||||
<div className="muted small" style={{ marginTop: -4 }}>
|
||||
Pick <b>one session per slot</b> — you can change until the slot starts.
|
||||
@@ -209,14 +211,12 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{slots.map(({ slot, sessions }) => {
|
||||
{displayBlocks.map(({ slot, sessions }) => {
|
||||
const status = slotStatus(slot, now);
|
||||
const isServiceSlot = slot.type === 'service_session';
|
||||
// Apply the level/area filter to non-service sessions only (service
|
||||
// sessions have no level/area and are always shown).
|
||||
const visibleSessions = isServiceSlot
|
||||
? sessions
|
||||
: sessions.filter(matchesFilter);
|
||||
const visibleSessions = sessions.filter(session => session.slot_type === 'service_session' || matchesFilter(session));
|
||||
// Skip the slot if it's a talk slot and all its sessions are filtered out.
|
||||
if (!isServiceSlot && visibleSessions.length === 0) return null;
|
||||
return (
|
||||
@@ -235,7 +235,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
{visibleSessions.map((s) => {
|
||||
const picked = pickFor(slot.id) === s.id;
|
||||
const isMySession = mySpeakerSessions.includes(s.id);
|
||||
const isService = slot.type === 'service_session';
|
||||
const isService = s.slot_type === 'service_session';
|
||||
return (
|
||||
<button key={s.id} className={`sess ${picked ? 'picked' : ''}`} onClick={() => setSelected(s)}>
|
||||
<div className="grow">
|
||||
|
||||
Generated
+286
@@ -8,6 +8,7 @@
|
||||
"name": "convivo-sidecar",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"cheerio": "1.0.0",
|
||||
"pdfkit": "^0.15.0",
|
||||
"xlsx": "^0.18.5"
|
||||
}
|
||||
@@ -81,6 +82,12 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/brotli": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/brotli/-/brotli-1.3.3.tgz",
|
||||
@@ -159,6 +166,48 @@
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/cheerio": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0.tgz",
|
||||
"integrity": "sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cheerio-select": "^2.1.0",
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.1.0",
|
||||
"encoding-sniffer": "^0.2.0",
|
||||
"htmlparser2": "^9.1.0",
|
||||
"parse5": "^7.1.2",
|
||||
"parse5-htmlparser2-tree-adapter": "^7.0.0",
|
||||
"parse5-parser-stream": "^7.1.2",
|
||||
"undici": "^6.19.5",
|
||||
"whatwg-mimetype": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/cheerio?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cheerio-select": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz",
|
||||
"integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-select": "^5.1.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/clone": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||
@@ -196,6 +245,34 @@
|
||||
"deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
|
||||
"integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"nth-check": "^2.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/css-what": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz",
|
||||
"integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/deep-equal": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz",
|
||||
@@ -268,6 +345,61 @@
|
||||
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"entities": "^4.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domelementtype": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
|
||||
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/domhandler": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
|
||||
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
|
||||
"integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
@@ -282,6 +414,31 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/encoding-sniffer": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",
|
||||
"integrity": "sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iconv-lite": "^0.6.3",
|
||||
"whatwg-encoding": "^3.1.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/encoding-sniffer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
@@ -503,6 +660,37 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz",
|
||||
"integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==",
|
||||
"funding": [
|
||||
"https://github.com/fb55/htmlparser2?sponsor=1",
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.1.0",
|
||||
"entities": "^4.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/internal-slot": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",
|
||||
@@ -784,6 +972,18 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/nth-check": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
|
||||
"integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/nth-check?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
@@ -847,6 +1047,55 @@
|
||||
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
|
||||
"license": "(MIT AND Zlib)"
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
|
||||
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"entities": "^6.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5-htmlparser2-tree-adapter": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz",
|
||||
"integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domhandler": "^5.0.3",
|
||||
"parse5": "^7.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5-parser-stream": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz",
|
||||
"integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"parse5": "^7.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5/node_modules/entities": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz",
|
||||
"integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/pdfkit": {
|
||||
"version": "0.15.2",
|
||||
"resolved": "https://registry.npmjs.org/pdfkit/-/pdfkit-0.15.2.tgz",
|
||||
@@ -920,6 +1169,12 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/set-function-length": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
|
||||
@@ -1061,6 +1316,15 @@
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "6.29.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz",
|
||||
"integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
}
|
||||
},
|
||||
"node_modules/unicode-properties": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/unicode-properties/-/unicode-properties-1.4.1.tgz",
|
||||
@@ -1087,6 +1351,28 @@
|
||||
"integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/whatwg-encoding": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",
|
||||
"integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
|
||||
"deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iconv-lite": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-mimetype": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
|
||||
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/which-boxed-primitive": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz",
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
"main": "src/server.js",
|
||||
"scripts": {
|
||||
"start": "node src/server.js",
|
||||
"test": "node --test tests/transform-excel.test.js"
|
||||
"test": "node --test tests/*.test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"cheerio": "1.0.0",
|
||||
"pdfkit": "^0.15.0",
|
||||
"xlsx": "^0.18.5"
|
||||
}
|
||||
|
||||
+25
-15
@@ -42,6 +42,8 @@
|
||||
const http = require('http');
|
||||
const XLSX = require('xlsx');
|
||||
const { transformExcel } = require('./transform-excel');
|
||||
const { readSessionizeSource } = require('./sessionize-source');
|
||||
const { createSessionizePoller } = require('./sessionize-poller');
|
||||
const PDFDocument = require('pdfkit');
|
||||
|
||||
const SUPABASE_URL = (process.env.SUPABASE_URL || 'http://supabase_kong_Convivo:8000').replace(/\/$/, '');
|
||||
@@ -52,6 +54,9 @@ const SESSIONIZE_API_KEY = process.env.SESSIONIZE_API_KEY || '';
|
||||
const PRETIX_API_KEY = process.env.PRETIX_API_KEY || '';
|
||||
const PRETIX_BASE = (process.env.PRETIX_BASE || 'https://pretix.eu/api/v1').replace(/\/$/, '');
|
||||
const PRETIX_SYNC_INTERVAL_MS = parseInt(process.env.PRETIX_SYNC_INTERVAL_MS || '60000', 10);
|
||||
const configuredSessionizeInterval = Number(process.env.SESSIONIZE_SYNC_INTERVAL_MS || 900000);
|
||||
const SESSIONIZE_SYNC_INTERVAL_MS = configuredSessionizeInterval === 0 ? 0
|
||||
: Number.isFinite(configuredSessionizeInterval) ? Math.max(60000, configuredSessionizeInterval) : 900000;
|
||||
const PORT = parseInt(process.env.PORT || '3002', 10);
|
||||
|
||||
// In-memory last-run state (the sidecar is otherwise stateless).
|
||||
@@ -305,21 +310,11 @@ async function runSync(eventId) {
|
||||
throw new Error(`event "${event.name}" has no sessionize_endpoint set`);
|
||||
}
|
||||
|
||||
// 2. Fetch the Sessionize data. The public /view/ endpoint needs no key;
|
||||
// if a key is configured we send it (required for /api/ endpoints).
|
||||
const szUrl = event.sessionize_endpoint.trim();
|
||||
log('run: fetching Sessionize', { szUrl, hasKey: Boolean(SESSIONIZE_API_KEY) });
|
||||
const szHeaders = {};
|
||||
if (SESSIONIZE_API_KEY) szHeaders['X-Sessionize-API-Key'] = SESSIONIZE_API_KEY;
|
||||
const szRes = await fetch(szUrl, { headers: szHeaders });
|
||||
if (!szRes.ok) {
|
||||
const t = await szRes.text();
|
||||
throw new Error(`Sessionize ${szRes.status}: ${t.slice(0, 200)}`);
|
||||
}
|
||||
const szData = await szRes.json();
|
||||
|
||||
// 3. Transform.
|
||||
const { payload, skippedSpeakers } = transform(szData);
|
||||
const source = await readSessionizeSource(event.sessionize_endpoint, { apiKey: SESSIONIZE_API_KEY });
|
||||
const { payload, skippedSpeakers } = source.payload
|
||||
? { payload: source.payload, skippedSpeakers: [] }
|
||||
: transform(source.data);
|
||||
if (!payload.sessions.length) throw new Error('Sessionize contains no scheduled sessions; existing agenda retained');
|
||||
log('run: transformed', {
|
||||
speakers: payload.speakers.length,
|
||||
sessions: payload.sessions.length,
|
||||
@@ -331,6 +326,7 @@ async function runSync(eventId) {
|
||||
method: 'POST',
|
||||
body: { p_event_id: event.id, p_payload: payload },
|
||||
});
|
||||
if (summary.errors?.length) throw new Error(`Sessionize import reported ${summary.errors.length} error(s)`);
|
||||
|
||||
const finishedAt = new Date().toISOString();
|
||||
const result = {
|
||||
@@ -339,6 +335,7 @@ async function runSync(eventId) {
|
||||
started_at: startedAt,
|
||||
finished_at: finishedAt,
|
||||
status: 'success',
|
||||
source_format: source.format,
|
||||
summary,
|
||||
skipped_speakers: skippedSpeakers,
|
||||
};
|
||||
@@ -810,6 +807,13 @@ async function handleExport(body) {
|
||||
};
|
||||
}
|
||||
|
||||
const pollSessionize = createSessionizePoller({
|
||||
listEvents: () => supabaseFetch('/rest/v1/events?is_active=eq.true&sessionize_endpoint=not.is.null&select=id'),
|
||||
syncEvent: runSync,
|
||||
isBusy: () => running,
|
||||
onError: (error, eventId) => log('sessionize poll error', { eventId, error: error.message }),
|
||||
});
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url, `http://${req.headers.host || 'localhost'}`);
|
||||
const path = url.pathname;
|
||||
@@ -822,6 +826,7 @@ const server = http.createServer(async (req, res) => {
|
||||
ok: true,
|
||||
running,
|
||||
lastRun,
|
||||
sessionizeIntervalMs: SESSIONIZE_SYNC_INTERVAL_MS,
|
||||
pretixRunning,
|
||||
lastPretixRun,
|
||||
pretixIntervalMs: PRETIX_SYNC_INTERVAL_MS,
|
||||
@@ -870,6 +875,11 @@ const server = http.createServer(async (req, res) => {
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
if (SESSIONIZE_SYNC_INTERVAL_MS > 0) {
|
||||
log('sessionize auto-sync scheduled', { intervalMs: SESSIONIZE_SYNC_INTERVAL_MS });
|
||||
setInterval(pollSessionize, SESSIONIZE_SYNC_INTERVAL_MS);
|
||||
void pollSessionize();
|
||||
}
|
||||
log('sidecar listening', {
|
||||
port: PORT,
|
||||
supabase: SUPABASE_URL,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
function createSessionizePoller({ listEvents, syncEvent, isBusy, onError }) {
|
||||
let polling = false;
|
||||
return async function pollSessionize() {
|
||||
if (polling || isBusy()) return;
|
||||
polling = true;
|
||||
try {
|
||||
const events = await listEvents();
|
||||
for (const event of events) {
|
||||
if (isBusy()) break;
|
||||
try { await syncEvent(event.id); }
|
||||
catch (error) { onError(error, event.id); }
|
||||
}
|
||||
} catch (error) {
|
||||
onError(error);
|
||||
} finally {
|
||||
polling = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { createSessionizePoller };
|
||||
@@ -0,0 +1,85 @@
|
||||
const { load } = require('cheerio');
|
||||
|
||||
function normalizeSessionizeSource(value) {
|
||||
let source = String(value || '').trim();
|
||||
if (source.startsWith('<')) {
|
||||
const document = load(source);
|
||||
const scripts = document('script[src]');
|
||||
if (scripts.length !== 1) throw new Error('Paste one Sessionize script tag or URL');
|
||||
source = scripts.attr('src');
|
||||
}
|
||||
let url;
|
||||
try { url = new URL(source); } catch { throw new Error('Enter a valid Sessionize URL or script tag'); }
|
||||
if (url.protocol !== 'https:' || url.hostname !== 'sessionize.com' || url.port
|
||||
|| url.username || url.password || !/^\/api\/v2\/[a-z0-9]+\/view\/(All|GridSmart)$/i.test(url.pathname)) {
|
||||
throw new Error('Use a Sessionize HTTPS All or GridSmart endpoint');
|
||||
}
|
||||
url.search = '';
|
||||
url.hash = '';
|
||||
return url.href;
|
||||
}
|
||||
|
||||
function parseGridSmart(html, offsetMinutes) {
|
||||
if (!Number.isInteger(offsetMinutes) || offsetMinutes < -720 || offsetMinutes > 840) {
|
||||
throw new Error('Sessionize event timezone is missing or invalid');
|
||||
}
|
||||
const document = load(html);
|
||||
const sessions = new Map();
|
||||
document('.sz-session[data-sessionid]').each((index, element) => {
|
||||
const card = document(element);
|
||||
const id = card.attr('data-sessionid');
|
||||
const title = card.find('.sz-session__title').text().trim();
|
||||
const timing = card.find('.sz-session__time[data-sztz]').attr('data-sztz')?.split('|');
|
||||
const start = new Date(timing?.[2]);
|
||||
const end = new Date(timing?.[3]);
|
||||
if (!id || !title || !Number.isFinite(start.getTime()) || !Number.isFinite(end.getTime()) || end <= start) {
|
||||
throw new Error('GridSmart contains a session with incomplete identity or timing');
|
||||
}
|
||||
const localStart = new Date(start.getTime() + offsetMinutes * 60000).toISOString();
|
||||
const localEnd = new Date(end.getTime() + offsetMinutes * 60000).toISOString();
|
||||
if (localStart.slice(0, 10) !== localEnd.slice(0, 10)) throw new Error('Overnight sessions are not supported');
|
||||
const session = {
|
||||
external_id: id, title, description: null,
|
||||
room: card.find('.sz-session__room').text().trim() || null,
|
||||
date: localStart.slice(0, 10), start_time: localStart.slice(11, 19), end_time: localEnd.slice(11, 19),
|
||||
is_service_session: card.hasClass('sz-session--service') || card.hasClass('sz-session--plenum'),
|
||||
speakers: [], level: null, area: null,
|
||||
};
|
||||
if (sessions.has(id) && JSON.stringify(sessions.get(id)) !== JSON.stringify(session)) {
|
||||
throw new Error('GridSmart contains conflicting copies of a session');
|
||||
}
|
||||
sessions.set(id, session);
|
||||
});
|
||||
if (!sessions.size) throw new Error('GridSmart contains no scheduled sessions');
|
||||
return { speakers: [], sessions: [...sessions.values()] };
|
||||
}
|
||||
|
||||
async function readSessionizeSource(value, { fetchImpl = fetch, apiKey = '' } = {}) {
|
||||
const source = normalizeSessionizeSource(value);
|
||||
const headers = apiKey ? { 'X-Sessionize-API-Key': apiKey } : {};
|
||||
async function request(url) {
|
||||
const response = await fetchImpl(url, { headers, redirect: 'error', signal: AbortSignal.timeout(30000) });
|
||||
if (!response.ok) throw new Error(`Sessionize HTTP ${response.status}`);
|
||||
const text = await response.text();
|
||||
if (text.length > 5_000_000) throw new Error('Sessionize response exceeds size limit');
|
||||
return text;
|
||||
}
|
||||
const body = await request(source);
|
||||
try {
|
||||
const data = JSON.parse(body);
|
||||
if (!Array.isArray(data.sessions)) throw new Error('Sessionize JSON must contain sessions');
|
||||
return { format: 'json', data };
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) throw error;
|
||||
}
|
||||
const grid = new URL(source);
|
||||
grid.pathname = grid.pathname.replace(/\/(All|GridSmart)$/i, '/GridSmart');
|
||||
const loader = /\/GridSmart$/i.test(new URL(source).pathname) ? body : await request(grid.href);
|
||||
const zone = loader.match(/sessionize\.eventTimezone\s*=\s*['"]UTC([+-])(\d{2})(?::?(\d{2}))?['"]/);
|
||||
if (!zone) throw new Error('Sessionize embed does not expose an event timezone');
|
||||
const offset = (Number(zone[2]) * 60 + Number(zone[3] || 0)) * (zone[1] === '-' ? -1 : 1);
|
||||
grid.searchParams.set('under', 'True');
|
||||
return { format: 'gridsmart', payload: parseGridSmart(await request(grid.href), offset) };
|
||||
}
|
||||
|
||||
module.exports = { normalizeSessionizeSource, parseGridSmart, readSessionizeSource };
|
||||
@@ -0,0 +1,32 @@
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { createSessionizePoller } = require('../src/sessionize-poller');
|
||||
|
||||
test('polls events sequentially and isolates upstream failures', async () => {
|
||||
const calls = [];
|
||||
const failures = [];
|
||||
const poll = createSessionizePoller({ listEvents: async () => [{ id: 'first' }, { id: 'second' }],
|
||||
isBusy: () => false, syncEvent: async id => { calls.push(id); if (id === 'first') throw new Error('unavailable'); },
|
||||
onError: (error, id) => failures.push(id) });
|
||||
await poll();
|
||||
assert.deepEqual(calls, ['first', 'second']);
|
||||
assert.deepEqual(failures, ['first']);
|
||||
});
|
||||
test('does not overlap manual imports or another polling pass', async () => {
|
||||
let finish;
|
||||
let reads = 0;
|
||||
let busy = true;
|
||||
const pending = new Promise(resolve => { finish = resolve; });
|
||||
const poll = createSessionizePoller({ listEvents: async () => { reads++; await pending; return []; },
|
||||
isBusy: () => busy, syncEvent: async () => {}, onError: () => {} });
|
||||
await poll();
|
||||
assert.equal(reads, 0);
|
||||
busy = false;
|
||||
const first = poll();
|
||||
await poll();
|
||||
assert.equal(reads, 1);
|
||||
finish();
|
||||
await first;
|
||||
await poll();
|
||||
assert.equal(reads, 2);
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { normalizeSessionizeSource, parseGridSmart, readSessionizeSource } = require('../src/sessionize-source');
|
||||
const url = 'https://sessionize.com/api/v2/z0s5f2j2/view/GridSmart';
|
||||
const card = (id, title, classes = '') => `<div class="sz-session ${classes}" data-sessionid="${id}">
|
||||
<div class="sz-session__room">Main Stage</div>
|
||||
<div class="sz-session__time" data-sztz="TimeWithDuration|en-US|2026-10-23T06:30:00.0000000Z|2026-10-23T07:00:00.0000000Z"></div>
|
||||
<h3 class="sz-session__title">${title}</h3></div>`;
|
||||
|
||||
test('normalizes URL and script tag without executing code', () => {
|
||||
assert.equal(normalizeSessionizeSource(url), url);
|
||||
assert.equal(normalizeSessionizeSource(`<script type="text/javascript" src='${url}'></script>`), url);
|
||||
for (const input of ['https://example.org/a', 'http://sessionize.com/api/v2/test/view/All',
|
||||
'https://sessionize.com@localhost/api/v2/test/view/All', '<script>alert(1)</script>',
|
||||
'https://sessionize.com:4430/api/v2/test/view/All']) assert.throws(() => normalizeSessionizeSource(input));
|
||||
});
|
||||
test('extracts service identity, entities, room, local time and deduplicates cards', () => {
|
||||
const html = card('service-id', 'Arrival & Coffee', 'sz-session--service') + card('service-id', 'Arrival & Coffee', 'sz-session--service') + card('talk-id', 'Talk');
|
||||
const result = parseGridSmart(html, 120);
|
||||
assert.equal(result.sessions.length, 2);
|
||||
assert.deepEqual(result.sessions[0], { external_id: 'service-id', title: 'Arrival & Coffee', description: null,
|
||||
room: 'Main Stage', date: '2026-10-23', start_time: '08:30:00', end_time: '09:00:00',
|
||||
is_service_session: true, speakers: [], level: null, area: null });
|
||||
assert.equal(result.sessions[1].is_service_session, false);
|
||||
});
|
||||
test('rejects empty, malformed and conflicting schedules', () => {
|
||||
assert.throws(() => parseGridSmart('', 120));
|
||||
assert.throws(() => parseGridSmart(card('id', 'Talk').replace('2026-10-23T06:30:00.0000000Z', 'bad'), 120));
|
||||
assert.throws(() => parseGridSmart(card('id', 'Talk') + card('id', 'Different'), 120));
|
||||
assert.throws(() => parseGridSmart(card('id', 'Talk')));
|
||||
});
|
||||
test('reads loader and HTML without executing embed JavaScript', async () => {
|
||||
const calls = [];
|
||||
const result = await readSessionizeSource(`<script src="${url}"></script>`, { fetchImpl: async source => {
|
||||
calls.push(source);
|
||||
return { ok: true, text: async () => source.includes('under=True') ? card('id', 'Lunch', 'sz-session--plenum') : "sessionize.eventTimezone = 'UTC+02';" };
|
||||
} });
|
||||
assert.equal(result.format, 'gridsmart');
|
||||
assert.equal(result.payload.sessions[0].is_service_session, true);
|
||||
assert.deepEqual(calls, [url, `${url}?under=True`]);
|
||||
});
|
||||
test('retains JSON API compatibility and fails on upstream errors', async () => {
|
||||
const result = await readSessionizeSource(url.replace('GridSmart', 'All'), { fetchImpl: async () => ({ ok: true, text: async () => '{"sessions":[]}' }) });
|
||||
assert.equal(result.format, 'json');
|
||||
await assert.rejects(readSessionizeSource(url, { fetchImpl: async () => ({ ok: false, status: 503 }) }), /503/);
|
||||
});
|
||||
Reference in new issue
Block a user