Implement ClientSchedule state tracking class
All checks were successful
/ build (push) Successful in 2m16s
/ deploy (push) Successful in 16s

Write the logic of keeping track of location modifications and applying
updates from the server into the ClientSchedule class.  This should
serve as the foundation for replacing the prototype in-component update
logic which have turned into an unmaintainable spagetti.
This commit is contained in:
Hornwitser 2025-06-12 21:45:34 +02:00
parent aa52a6c651
commit e100555304
5 changed files with 1005 additions and 1 deletions

View file

@ -8,7 +8,7 @@ export const entityLivingSchema = z.object({
updatedAt: z.string(),
deleted: z.optional(z.literal(false)),
});
export type EnityLiving = z.infer<typeof entityLivingSchema>;
export type EntityLiving = z.infer<typeof entityLivingSchema>;
export const entityToombstoneSchema = z.object({
id: idSchema,
@ -20,6 +20,9 @@ export type EntityToombstone = z.infer<typeof entityToombstoneSchema>;
export const entitySchema = z.discriminatedUnion("deleted", [entityLivingSchema, entityToombstoneSchema]);
export type Entity = z.infer<typeof entitySchema>;
export type Living<T extends Entity> = Extract<T, { deleted?: false }>;
export type Tombstone<T extends Entity> = Extract<T, { deleted: true }>;
export function defineEntity<T extends {}>(fields: T) {
return z.discriminatedUnion("deleted", [z.extend(entityLivingSchema, fields), entityToombstoneSchema]);
}