Refactor base types for entities and tombstones

Rename the base Entity type to ApiEntity, and the base EntityToombstone
to ApiTombstone to better reflect the reality that its only used in the
API interface and that the client and server types uses its own base if
any.

Remove EntityLiving and pull EntityTombstone out of of the base entity
type so that the types based on ApiEntity are always living entities and
if it's possible for it to contain tombstone this will be explicitly
told with the type including a union with ApiTombstone.

Refactor the types of the ClientEntity and ClientMap to better reflect
the types of the entities it stores and converts to/from.
This commit is contained in:
Hornwitser 2025-06-24 15:19:11 +02:00
parent e3ff872b5c
commit 985b8e0950
13 changed files with 107 additions and 102 deletions

View file

@ -1,6 +1,6 @@
import { readSchedule, type ServerUser, writeSchedule } from '~/server/database';
import { broadcastEvent } from '~/server/streams';
import type { ApiSchedule } from '~/shared/types/api';
import type { ApiSchedule, ApiTombstone } from '~/shared/types/api';
export async function updateScheduleInterestedCounts(users: ServerUser[]) {
const eventCounts = new Map<number, number>();
@ -69,7 +69,7 @@ export function canSeeCrew(userType: string | undefined) {
}
/** Filters out crew visible only parts of schedule */
export function filterSchedule(schedule: ApiSchedule): ApiSchedule {
export function filterSchedule(schedule: ApiSchedule | ApiTombstone): ApiSchedule | ApiTombstone {
if (schedule.deleted) {
return schedule;
}