import type { components } from '$lib/generated/api';

type TimelineEntryDTO = components['schemas']['TimelineEntryDTO'];
type TimelineYearDTO = components['schemas']['TimelineYearDTO'];
type TimelineDTO = components['schemas']['TimelineDTO'];

/**
 * Builds a `TimelineEntryDTO` mirroring the real wire shape (no `year`,
 * `description`, or `snippet` fields). Defaults to a dated DAY-precision letter;
 * override `kind`/`derived`/`type`/`derivedType` etc. for events.
 */
export function makeEntry(overrides: Partial<TimelineEntryDTO> = {}): TimelineEntryDTO {
	return {
		kind: 'LETTER',
		precision: 'DAY',
		derived: false,
		senderName: 'Karl Raddatz',
		receiverName: 'Elfriede Raddatz',
		eventDate: '1915-06-15',
		title: 'Brief aus dem Feld',
		documentId: '11111111-1111-1111-1111-111111111111',
		...overrides
	};
}

export function makeYear(year: number, entries: TimelineEntryDTO[]): TimelineYearDTO {
	return { year, entries };
}

export function makeTimelineDTO(
	opts: { years?: TimelineYearDTO[]; undated?: TimelineEntryDTO[] } = {}
): TimelineDTO {
	return { years: opts.years ?? [], undated: opts.undated ?? [] };
}
