Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/sessionize

src/get-event.ts

22 lines · 776 B · TypeScript
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)
}