import { assertEndpointId, fetchSessionizeView } from './client.ts'
import { projectEvent } from './project.ts'
import type { EndpointInput, EventSummary, SessionizeAllResult } from './types.ts'
/**
* Load a joined Sessionize event: rooms, categories, sessions, and speakers.
*
* @example
* import getEvent from 'kody:@kody/sessionize/get-event'
* const event = await getEvent({ endpointId: 'jl4ktls0' })
* // => { sessionCount: 11, speakerCount: 10, rooms: [...], sessions: [...] }
*/
export default async function getEvent(
input: EndpointInput,
): Promise<EventSummary> {
const endpointId = assertEndpointId(input.endpointId)
const data = await fetchSessionizeView<SessionizeAllResult>({
endpointId,
view: 'All',
})
return projectEvent(endpointId, data)
}